Main Content

ActiveSet

Options object for active-set QP solver used within an mpc object

Since R2024a

    Description

    Use the ActiveSet object to set options for the active-set QP solver used within an mpc object. To set options for mpcActiveSetSolver, use mpcActiveSetOptions instead.

    Creation

    Creating an mpc object automatically creates an ActiveSet object set to default options. If the Optimizer.Solver property of the mpc object is set to 'active-set' (the default solver option), the ActiveSet object is assigned to the Optimizer.SolverOption property of the mpc object. You can access the object and its properties using dot notation.

    Properties

    expand all

    Maximum number of iterations allowed during the computation of the QP solution, specified as one of the following:

    • 'default' — The MPC controller automatically computes the maximum number of QP solver iterations as 4(nc+nv), where:

      • nc is the total number of constraints across the prediction horizon.

      • nv is the total number of optimization variables across the control horizon.

      The default MaxIterations value has a lower bound of 120.

    • Positive integer — The QP solver stops after the specified number of iterations. If the solver fails to converge in the final iteration, the controller:

      • Freezes the controller movement if UseSuboptimalSolution is false.

      • Applies the suboptimal solution reached after the final iteration if UseSuboptimalSolution is true.

    Note

    The default MaxIterations value can be very large for some controller configurations, such as those with large prediction and control horizons. When simulating such controllers, if the QP solver cannot find a feasible solution, the simulation can appear to stop responding, since the solver continues searching for a solution until the number of iterations reaches MaxIterations.

    Example: mpcobj.Optimizer.SolverOptions.MaxIterations = 2000

    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.

    Example: mpcobj.Optimizer.SolverOptions.ConstraintTolerance = 1e-5

    Option indicating whether to warm start each QP solver iteration by passing in a list of active inequalities from the previous iteration, specified as a logical value. Inequalities are active when their equal portion is true. If the solver fails to find a solution using the warm start procedure, then the cold start procedure is used. For more information, see QP Solvers. For more general information on warm start procedures, see Warm Start Best Practices (Optimization Toolbox) and Warm Start quadprog (Optimization Toolbox).

    Example: mpcobj.Optimizer.SolverOptions.UseWarmStart = true

    Object Functions

    Examples

    collapse all

    Create an mpc object.

    plant = ss(0.8,0.5,0.25,0,0.1); 
    mpcobj=mpc(plant);
    -->"PredictionHorizon" is empty. Assuming default 10.
    -->"ControlHorizon" is empty. Assuming default 2.
    -->"Weights.ManipulatedVariables" is empty. Assuming default 0.00000.
    -->"Weights.ManipulatedVariablesRate" is empty. Assuming default 0.10000.
    -->"Weights.OutputVariables" is empty. Assuming default 1.00000.
    

    Display the fields of the Optimizer property.

    mpcobj.Optimizer
    ans = struct with fields:
             OptimizationType: 'QP'
                       Solver: 'active-set'
                SolverOptions: [1x1 mpc.solver.options.qp.ActiveSet]
                 MinOutputECR: 0
        UseSuboptimalSolution: 0
                 CustomSolver: 0
          CustomSolverCodeGen: 0
    
    

    Display the properties of the SolverOptions object.

    mpcobj.Optimizer.SolverOptions
    ans = 
      ActiveSet with properties:
    
              MaxIterations: 'default'
        ConstraintTolerance: 1.0000e-06
               UseWarmStart: 1
    
    

    Modify the ConstraintTolerance property.

    mpcobj.Optimizer.SolverOptions.ConstraintTolerance = 1e-5;

    Extract the object.

    asopts = mpcobj.Optimizer.SolverOptions;

    Modify the UseWarmStart property.

    asopts.UseWarmStart = false;

    Reassign the object to the SolverOptions field of the Optimizer property of mpcobj.

    mpcobj.Optimizer.SolverOptions = asopts;

    Display the fields of the Optimizer property again.

    mpcobj.Optimizer.SolverOptions
    ans = 
      ActiveSet with properties:
    
              MaxIterations: 'default'
        ConstraintTolerance: 1.0000e-05
               UseWarmStart: 0
    
    

    Version History

    Introduced in R2024a