# mpcInteriorPointSolver

Solve a quadratic programming problem using an interior-point algorithm

## Description

Using mpcInteriorPointSolver, you can solve a quadratic programming (QP) problem using a primal-dual interior-point algorithm with a Mehrotra predictor-corrector. This function provides access to the built-in Model Predictive Control Toolbox™ interior-point QP solver.

Using an interior-point solver can provide superior performance for large-scale optimization problems, such as MPC applications that enforce constraints over large prediction and control horizons.

This solver is useful for:

• Advanced MPC applications that are beyond the scope of Model Predictive Control Toolbox software.

• Custom QP applications, including applications that require code generation.

Alternatively, you can also access the built-in active-set QP solver using mpcActiveSetSolver.

example

[x,exitflag] = mpcInteriorPointSolver(H,f,A,b,Aeq,beq,x0,options) finds an optimal solution x to a quadratic programming problem by minimizing the objective function

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

subject to inequality constraints $Ax\le b$ and equality constraints ${A}_{eq}x={b}_{eq}$. exitflag indicates the validity of x.

[x,exitflag,feasible,lambda] = mpcInteriorPointSolver(H,f,A,b,Aeq,beq,x0,options) also returns a logical flag feasible that indicates the feasibility of the solution and the Lagrange multipliers lambda for the solution.

## Examples

collapse all

Find the values of x that minimize

$f\left(x\right)=0.5{x}_{1}^{2}+{x}_{2}^{2}-{x}_{1}{x}_{2}-2{x}_{1}-6{x}_{2},$

subject to the constraints

$\begin{array}{l}{x}_{1}\ge 0\\ {x}_{2}\ge 0\\ {x}_{1}+{x}_{2}\le 2\\ -{x}_{1}+2{x}_{2}\le 2\\ 2{x}_{1}+{x}_{2}\le 3.\end{array}$

Specify the Hessian matrix and linear multiplier vector for the objective function.

H = [1 -1; -1 2];
f = [-2; -6];

Specify the inequality constraint parameters.

A = [-1 0; 0 -1; 1 1; -1 2; 2 1];
b = [0; 0; 2; 2; 3];

Define Aeq and beq to indicate that there are no equality constraints.

n = length(f);
Aeq = zeros(0,n);
beq = zeros(0,1);

As a best practice, verify that H is positive definite using the chol function.

[~,p] = chol(H);

If p = 0, then H is positive definite.

p
p = 0

Create a default option set for mpcInteriorPointSolver.

opt = mpcInteriorPointOptions;

To cold start the solver, specify an initial guess of zeros for the elements of x.

x0 = zeros(n,1);

Solve the QP problem.

[x,exitflag] = mpcInteriorPointSolver(H,f,A,b,Aeq,beq,x0,opt);

Examine the solution x.

x
x = 2×1

0.6667
1.3333

## Input Arguments

collapse all

Hessian matrix, specified as an n-by-n matrix, where n > 0 is the number of optimization variables.

The interior-point QP algorithm requires that the Hessian matrix be positive definite. To determine whether H is positive definite, use the chol function.

[~,p] = chol(H);

If p = 0, then H is positive definite. Otherwise, p is a positive integer.

Multiplier of the objective function linear term, specified as a column vector of length n, where n is the number of optimization variables.

Linear inequality constraint coefficients, specified as an m-by-n matrix, where n is the number of optimization variables and m is the number of inequality constraints.

If your problem has no inequality constraints, use zeros(0,n).

Right-hand side of inequality constraints, specified as a column vector of length m, where m is the number of inequality constraints.

If your problem has no inequality constraints, use zeros(0,1).

Linear equality constraint coefficients, specified as a q-by-n matrix, where n is the number of optimization variables and q <= n is the number of equality constraints. Equality constraints must be linearly independent with rank(Aeq) = q.

If your problem has no equality constraints, use zeros(0,n).

Right-hand side of equality constraints, specified as a column vector of length q, where q is the number of equality constraints.

If your problem has no equality constraints, use zeros(0,1).

Initial guess for the solution, where the equal portion of the inequality is true, specified as a column vector of length n, where n is the number of optimization variables. For a cold start, specify the initial guess as zeros(n,1).

Option set for mpcInteriorPointSolver, specified as a structure created using mpcInteriorPointOptions.

## Output Arguments

collapse all

Optimal solution to the QP problem, returned as a column vector of length n, where n is the number of optimization variables. mpcInteriorPointSolver always returns a value for x. To determine whether the solution is optimal or feasible, check exitflag and feasible.

Solution validity indicator, returned as an integer according to the following table.

ValueDescription
> 0x is optimal. exitflag represents the number of iterations performed during optimization.
0The maximum number of iterations was reached before the solver could find an optimal solution. Solution x is feasible only if feasible is true.
-1The problem appears to be infeasible; that is, the constraint $Ax\le b$ cannot be satisfied.

Solution feasibility, returned as a logical scalar. When exitflag is 0, the solver reached the maximum number of iterations without finding an optimal solution. This suboptimal solution, returned in x, is feasible only if feasible is true.

Lagrange multipliers, returned as a structure with the following fields.

FieldDescription
ineqlinMultipliers of the inequality constraints, returned as a vector of length n. When the solution is optimal, the elements of ineqlin are nonnegative.
eqlinMultipliers of the equality constraints, returned as a vector of length q. There are no sign restrictions in the optimal solution.

## Tips

• To determine whether H is positive definite, use the chol function.

[~,p] = chol(H);

If p = 0, then H is positive definite. Otherwise, p is a positive integer.

• mpcInteriorPointSolver provides access to the interior-point 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, see Solve Custom MPC Quadratic Programming Problem and Generate Code. This example uses mpcActiveSetSolver, however, the workflow applies to mpcInteriorPointSolver as well.

## Algorithms

mpcInteriorPointSolver solves the QP problem using an interior-point method. For more information, see QP Solvers.

## Extended Capabilities

### GPU Code GenerationGenerate CUDA® code for NVIDIA® GPUs using GPU Coder™.

| | (Optimization Toolbox)

### Topics

Introduced in R2020a