You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# Add quadratic objective support for convex QP problems
6
+
7
+
Added support for quadratic programming (QP) problems, allowing optimization of quadratic objectives of the form `minimize c^T x + 0.5 x^T Q x`. The quadratic matrix Q can be specified in either dense or sparse format, and must be positive semidefinite for convexity. This enhancement enables solving portfolio optimization, least squares, and other convex QP problems. Note that mixed-integer quadratic programming (MIQP) is not supported - only continuous variables are allowed with quadratic objectives.
.min(1,"At least one objective coefficient is required")
29
-
.describe(
30
-
"Linear coefficients for each variable. The length of this array defines the number of variables in the problem. All other arrays (constraint matrix rows, variable bounds, types, and names) must match this length.",
sparse.shape[0]===sparse.shape[1]&&// Must be square
66
+
sparse.rows.length===sparse.cols.length&&// Array lengths match
67
+
sparse.rows.length===sparse.values.length&&// Array lengths match
68
+
sparse.rows.every((r)=>r<sparse.shape[0])&&// Row indices in bounds
69
+
sparse.cols.every((c)=>c<sparse.shape[1])
70
+
);// Col indices in bounds
71
+
}
72
+
},"Quadratic matrix must be square with valid dimensions");
73
+
74
+
exportconstObjectiveSchema=z
75
+
.object({
76
+
linear: z
77
+
.array(z.number())
78
+
.optional()
79
+
.describe(
80
+
"Linear coefficients for each variable (c in: minimize c^T x + 0.5 x^T Q x). If not provided but quadratic is present, defaults to zeros. The length defines the number of variables when quadratic is not present.",
0 commit comments