Create default option set for mpcActiveSetSolver
creates a
structure of default options for options
= mpcActiveSetOptionsmpcActiveSetSolver
, which solves a quadratic programming (QP)
problem using an active-set algorithm.
opt = mpcActiveSetOptions;
Create default option set.
opt = mpcActiveSetOptions;
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 = mpcActiveSetOptions('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 mpcActiveSetSolver
must match this
type.
options
— Option set for mpcActiveSetSolver
Option set for mpcActiveSetSolver
, 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. | 200 |
ConstraintTolerance | Tolerance used to verify that inequality constraints are
satisfied by the optimal solution, specified as a positive
scalar. A larger ConstraintTolerance
value allows for larger constraint violations. | 1e-6 |
UseHessianAsInput | Indicator of whether the first input argument to
If your application requires
repetitive calls of
| true |
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 mpcActiveSetSolver
as a
general-purpose QP solver that supports code generation. To specify
solver options, use mpcActiveSetOptions
. Create the
function myCode
that uses
mpcActiveSetSolver
and
mpcActiveSetOptions
.
function [out1,out2] = myCode(in1,in2) %#codegen ... options = mpcActiveSetOptions; [x,status] = mpcActiveSetSolver(Linv,f,A,b,Aeq,Beq,iA0,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
mpcActiveSetOptions
.
You have a modified version of this example. Do you want to open this example with your edits?