Main Content

Quadratic programming

Solver for quadratic objective functions with linear constraints.

quadprog finds a minimum for a problem specified by

$$\underset{x}{\mathrm{min}}\frac{1}{2}{x}^{T}Hx+{f}^{T}x\text{suchthat}\{\begin{array}{c}A\cdot x\le b,\\ Aeq\cdot x=beq,\\ lb\le x\le ub.\end{array}$$

*H*, *A*, and *Aeq* are matrices,
and *f*, *b*, *beq*,
*lb*, *ub*, and *x* are
vectors.

You can pass *f*, *lb*, and *ub* as
vectors or matrices; see Matrix Arguments.

**Note**

`quadprog`

applies only to the solver-based approach. For a discussion
of the two optimization approaches, see First Choose Problem-Based or Solver-Based Approach.

solves the preceding problem subject to the additional restrictions
`x`

= quadprog(`H`

,`f`

,`A`

,`b`

,`Aeq`

,`beq`

,`lb`

,`ub`

)`lb `

≤` x `

≤` ub`

.
The inputs `lb`

and `ub`

are vectors of doubles,
and the restrictions hold for each `x`

component. If no equalities
exist, set `Aeq = []`

and
`beq = []`

.

**Note**

If the specified input bounds for a problem are inconsistent, the output
`x`

is `x0`

and the output
`fval`

is `[]`

.

`quadprog`

resets components of `x0`

that violate the bounds
`lb `

≤` x `

≤` ub`

to the interior of the box defined by the bounds.
`quadprog`

does not change components that respect
the bounds.

returns the minimum for `x`

= quadprog(`problem`

)`problem`

, a structure described in
`problem`

. Create the
`problem`

structure using dot notation or the `struct`

function. Alternatively, create a `problem`

structure from an `OptimizationProblem`

object by using `prob2struct`

.

The **Optimize** Live Editor task provides a visual interface for `quadprog`

.

[1] Coleman, T. F., and Y. Li. “A Reflective Newton
Method for Minimizing a Quadratic Function Subject to Bounds on Some of the
Variables.” *SIAM Journal on Optimization*. Vol. 6, Number
4, 1996, pp. 1040–1058.

[2] Gill, P. E., W. Murray, and M. H. Wright.
*Practical Optimization.* London: Academic Press,
1981.

[3] Gould, N., and P. L. Toint.
“Preprocessing for quadratic programming.” *Mathematical
Programming.* Series B, Vol. 100, 2004, pp. 95–132.

`linprog`

| `lsqlin`

| Optimize | `optimoptions`

| `prob2struct`