Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Solve a quadratic programming problem using the KWIK algorithm

```
[x,status]
= mpcqpsolver(Linv,f,A,b,Aeq,beq,iA0,options)
```

```
[x,status,iA,lambda]
= mpcqpsolver(Linv,f,A,b,Aeq,beq,iA0,options)
```

`[`

finds an optimal solution, `x`

,`status`

]
= mpcqpsolver(`Linv`

,`f`

,`A`

,`b`

,`Aeq`

,`beq`

,`iA0`

,`options`

)`x`

, to a quadratic programming
problem by minimizing the objective function:

$$J=\frac{1}{2}{x}^{\u22ba}Hx+{f}^{\u22ba}x$$

subject to inequality constraints $$Ax\ge b$$, and equality constraints $${A}_{eq}x={b}_{eq}$$. `status`

indicates the validity of
`x`

.

The KWIK algorithm requires that the Hessian matrix,

*H*, be positive definite. When calculating`Linv`

, use:`[L, p] = chol(H,'lower');`

If

*p*= 0, then*H*is positive definite. Otherwise,*p*is a positive integer.`mpcqpsolver`

provides access to the QP solver used by Model Predictive Control Toolbox™ software. Use this command to solve QP problems in your own custom MPC applications. For an example of a custom MPC application using`mpcqpsolver`

, see Solve Custom MPC Quadratic Programming Problem and Generate Code.

`mpcqpsolver`

solves the QP problem using an active-set method, the
KWIK algorithm, based on [1]. For more information, see QP Solver.

The KWIK algorithm defines inequality constraints as $$Ax\ge b$$ rather than $$Ax\le b$$, as in the `quadprog`

command.

[1] Schmid, C., and L. T. Biegler. "Quadratic programming methods
for reduced Hessian SQP." *Computers & Chemical Engineering*.
Vol. 18, No. 9, 1994, pp. 817–832.