QProg#

Purpose#

Solves the quadratic programming problem.

Format#

{ x, u1, u2, u3, u4, u5 } = QProg(start, q, r, a, b, c, d, bnds)#
Parameters:
  • start (Kx1 vector) – start values.

  • q (KxK matrix) – symmetric model matrix.

  • r (Kx1 vector) – model constant vector.

  • a (MxK matrix) – equality constraint coefficient matrix, or scalar 0, no equality constraints.

  • b (Mx1 vector) – equality constraint constant vector, or scalar 0, will be expanded to Mx1 vector of zeros.

  • c (NxK matrix) – inequality constraint coefficient matrix, or scalar 0, no inequality constraints.

  • d (Nx1 vector) – inequality constraint constant vector, or scalar 0, will be expanded to Nx1 vector of zeros.

  • bnds (Kx2 matrix) – bounds on x, the first column contains the lower bounds on x, and the second column the upper bounds. If scalar 0, the bounds for all elements will default to ±1e200.

Returns:
  • x (Kx1 vector) – coefficients at the minimum of the function.

  • u1 (Mx1 vector) – Lagrangian coefficients of equality constraints.

  • u2 (Nx1 vector) – Lagrangian coefficients of inequality constraints.

  • u3 (Kx1 vector) – Lagrangian coefficients of lower bounds.

  • u4 (Kx1 vector) – Lagrangian coefficients of upper bounds.

  • ret (scalar) –

    return code.

    0

    termination

    1

    iterations exceeded

    2

    accuracy is insufficient to maintain decreasing function values

    3

    matrices not conformable

    < 0

    constraints inconsistent

Global Input#

_qprog_maxit:

(scalar), maximum number of iterations. Default = 1000.

Remarks#

QProg() solves the standard quadratic programming problem:

\[min\; \frac{1}{2} x'Qx - x'R\]

subject to constraints,

\[\begin{split}Ax = B\\ Cx \geq D\end{split}\]

and bounds,

\[x_{low} ≤ x ≤ x_{up}\]

Examples#

// Minimize 0.5*x'Q*x - x'R subject to x >= 0
Q = { 2 0, 0 2 };
R = { 1, 1 };

start = { 0.5, 0.5 };

// No equality or inequality constraints
A = 0;
b = 0;
C = 0;
d = 0;

// Bounds: x >= 0
bnds = (0 ~ 1e200) | (0 ~ 1e200);

{ x, u1, u2, u3, u4, ret } = QProg(start, Q, R, A, b, C, d, bnds);

print "Solution:";
print x;
print "Return code:" ret;

Source#

qprog.src