Create default option set for
mpcInteriorPointSolver
creates a structure of default options for options
= mpcInteriorPointOptionsmpcInteriorPointSolver
, which solves a quadratic programming (QP)
problem using an interior-point algorithm.
opt = mpcInteriorPointOptions;
Create default option set.
opt = mpcInteriorPointOptions;
Specify the maximum number of iterations allowed during computation.
opt.MaxIterations = 100;
Specify a constraint tolerance for verifying that the optimal solution satisfies the inequality constraints.
opt.ConstraintTolerance = 1.0e-4;
opt = mpcInteriorPointOptions('single');
type
— Solver input argument data type'double'
(default) | 'single'
Solver input argument data type, specified as either
'double'
or 'single'
. This data
type is used for both simulation and code generation. All real options in
the option set are specified using this data type, and all real input
arguments to mpcInteriorPointSolver
must match this
type.
options
— Option set for mpcInteriorPointSolver
Option set for mpcInteriorPointSolver
, returned as a
structure with the following fields.
Field | Description | Default |
---|---|---|
DataType | Input argument data type, specified as either
'double' or
'single' . This data type is used for
both simulation and code generation, and all real input
arguments to the solver function must match this
type. | 'double' |
MaxIterations | Maximum number of iterations allowed when computing the QP solution, specified as a positive integer. | 50 |
ConstraintTolerance | Tolerance used to verify that equality and inequality
constraints are satisfied by the optimal solution, specified
as a positive scalar. A larger
ConstraintTolerance value allows for
larger constraint violations. | 1e-6 |
OptimalityTolerance | Termination tolerance for first-order optimality (KKT dual residual), specified as a positive scalar. Increasing this value relaxes the condition for the optimality check. | 1e-6 |
ComplementarityTolerance | Termination tolerance for first-order optimality (KKT average complementarity residual), specified as a positive scalar. Increasing this value improves robustness, while decreasing this value increases accuracy. | 1e-8 |
StepTolerance | Termination tolerance for decision variables, specified as a positive scalar. | 1e-8 |
IntegrityChecks | Indicator of whether integrity checks are performed on
the solver function input data, specified as a logical
value. If IntegrityChecks is
true , then integrity checks are
performed and diagnostic messages are displayed. Use
false for code generation
only. | true |
Usage notes and limitations:
You can use mpInteriorPointSolver
as a
general-purpose QP solver that supports code generation. To specify
solver options, use mpcInteriorPointOptions
. Create
the function myCode
that uses
mpInteriorPointSolver
and
mpcInteriorPointOptions
.
function [out1,out2] = myCode(in1,in2) %#codegen ... options = mpcInteriorPointOptions; [x,exitflag] = mpcInteriorPointSolver(H,f,A,b,Aeq,Beq,x0,options); ...
Generate C code with MATLAB® Coder™.
func = 'myCode'; cfg = coder.config('mex'); % or 'lib', 'dll' codegen('-config',cfg,func,'-o',func);
For code generation, use the same precision for all real inputs,
including options. Configure the precision as
'double'
or 'single'
using
mpcInteriorPointOptions
.
You have a modified version of this example. Do you want to open this example with your edits?