Main Content

mpcInteriorPointSolver

Solve a quadratic programming problem using an interior-point algorithm

Since R2020a

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.

[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=12xHx+fx

subject to inequality constraints Axb and equality constraints Aeqx=beq. exitflag indicates the validity of x.

example

[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(x)=0.5x12+x22-x1x2-2x1-6x2,

subject to the constraints

x10x20x1+x22-x1+2x222x1+x23.

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 an InteriorPoint options object, which you can create 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 Axb 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, based on [1]. For more information, see QP Solvers.

References

[1] Nocedal, Jorge, and Stephen J. Wright. Numerical Optimization. New York, NY: Springer New York, 2006. https://doi.org/10.1007/978-0-387-40065-5.

Extended Capabilities

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2020a