25.2 Quadratic Programming

Octave can also solve Quadratic Programming problems, this is

min 0.5 x'*H*x + x'*q

subject to

A*x = b
     lb <= x <= ub
     A_lb <= A_in*x <= A_ub
: [x, obj, info, lambda] = qp (x0, H)
: [x, obj, info, lambda] = qp (x0, H, q)
: [x, obj, info, lambda] = qp (x0, H, q, A, b)
: [x, obj, info, lambda] = qp (x0, H, q, A, b, lb, ub)
: [x, obj, info, lambda] = qp (x0, H, q, A, b, lb, ub, A_lb, A_in, A_ub)
: [x, obj, info, lambda] = qp (…, options)

Solve a quadratic program (QP).

Solve the quadratic program defined by

min 0.5 x'*H*x + x'*q
 x

subject to

A*x = b
lb <= x <= ub
A_lb <= A_in*x <= A_ub

using a null-space active-set method.

Any bound (A, b, lb, ub, A_in, A_lb, A_ub) may be set to the empty matrix ([]) if not present. The constraints A and A_in are matrices with each row representing a single constraint. The other bounds are scalars or vectors depending on the number of constraints. The algorithm is faster if the initial guess is feasible.

options is a structure specifying additional parameters which control the algorithm. Currently, qp recognizes these options: "MaxIter", "TolX".

"MaxIter" proscribes the maximum number of algorithm iterations before optimization is halted. The default value is 200. The value must be a positive integer.

"TolX" specifies the termination tolerance for the unknown variables x. The default is sqrt (eps) or approximately 1e-8.

On return, x is the location of the minimum and fval contains the value of the objective function at x.

info

Structure containing run-time information about the algorithm. The following fields are defined:

solveiter

The number of iterations required to find the solution.

info

An integer indicating the status of the solution.

0

The problem is feasible and convex. Global solution found.

1

The problem is not convex. Local solution found.

2

The problem is not convex and unbounded.

3

Maximum number of iterations reached.

6

The problem is infeasible.

See also: sqp.

: x = pqpnonneg (c, d)
: x = pqpnonneg (c, d, x0)
: x = pqpnonneg (c, d, x0, options)
: [x, minval] = pqpnonneg (…)
: [x, minval, exitflag] = pqpnonneg (…)
: [x, minval, exitflag, output] = pqpnonneg (…)
: [x, minval, exitflag, output, lambda] = pqpnonneg (…)

Minimize 1/2*x'*c*x + d'*x subject to x >= 0.

c and d must be real matrices, and c must be symmetric and positive definite.

x0 is an optional initial guess for the solution x.

options is an options structure to change the behavior of the algorithm (see optimset). pqpnonneg recognizes one option: "MaxIter".

Outputs:

x

The solution matrix

minval

The minimum attained model value, 1/2*xmin'*c*xmin + d'*xmin

exitflag

An indicator of convergence. 0 indicates that the iteration count was exceeded, and therefore convergence was not reached; >0 indicates that the algorithm converged. (The algorithm is stable and will converge given enough iterations.)

output

A structure with two fields:

  • "algorithm": The algorithm used ("nnls")
  • "iterations": The number of iterations taken.
lambda

Undocumented output

See also: lsqnonneg, qp, optimset.

© 1996–2020 John W. Eaton
Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions.
https://octave.org/doc/v6.3.0/Quadratic-Programming.html