Main Content

Tune Weights

A model predictive controller design usually requires some tuning of the cost function weights. This topic provides tuning tips. SeeOptimization Problemfor details on the cost function equations.

Initial Tuning

  • Before tuning the cost function weights, specify scale factors for each plant input and output variable. Hold these scale factors constant as you tune the controller. SeeSpecify Scale Factorsfor more information.

  • During tuning, use thesensitivityandreviewcommands to obtain diagnostic feedback. Thesensitivitycommand is intended to help with cost function weight selection.

  • Change a weight by setting the appropriate controller property, as follows:

    To change this weight Set this controller property Array size
    OV reference tracking (wy) Weights.OV p-by-ny
    MV reference tracking (wu) Weights.MV p-by-nu
    MV increment suppression (wΔu) Weights.MVRate p-by-nu

Here, MV is a plant manipulated variable, andnuis the number of MVs. OV is a plant output variable, andnyis the number of OVs. Finally,pis the number of steps in the prediction horizon.

If a weight array containsn<prows, the controller duplicates the last row to obtain a full array ofprows. The default (n= 1) minimizes the number of parameters to be tuned, and is therefore recommended. SeeSetting Time-Varying Weights and Constraints with MPC Designerfor an alternative.

Tips for Setting OV Weights

  • Considering thenyOVs, suppose thatnycmust be held at or near a reference value (setpoint). If theith OV is not in this group, setWeights.OV(:,i)= 0.

  • Ifnunyc, it is usually possible to achieve zero OV tracking error at steady state, if at leastnycMVs are not constrained. The defaultWeights.OV = ones(1,ny)is a good starting point in this case.

    Ifnu>nyc, however, you have excess degrees of freedom. Unless you take preventive measures, therefore, the MVs may drift even when the OVs are near their reference values.

    • The most common preventive measure is to define reference values (targets) for the number of excess MVs you have,nunyc。这样的目标可以代表经济或中欧ically desirable steady-state values.

    • An alternative measure is to setw∆u> 0 for at leastnu– nycMVs to discourage the controller from changing them.

  • Ifnu<nyc, you do not have enough degrees of freedom to keep all required OVs at a setpoint. In this case, consider prioritizing reference tracking. To do so, setWeights.OV(:,i) > 0to specify the priority for theith OV. Rough guidelines for this are as follows:

    • 0.05 — Low priority: Large tracking error acceptable

    • 0.2 — Below-average priority

    • 1 — Average priority – the default. Use this value ifnyc= 1.

    • 5 — Above average priority

    • 20 — High priority: Small tracking error desired

Tips for Setting MV Weights

By default,Weights.MV = zeros(1,nu)。If some MVs have targets, the corresponding MV reference tracking weights must be nonzero. Otherwise, the targets are ignored. If the number of MV targets is less than (nunyc), try using the same weight for each. A suggested value is 0.2, the same as below-average OV tracking. This value allows the MVs to move away from their targets temporarily to improve OV tracking.

Otherwise, the MV and OV reference tracking goals are likely to conflict. Prioritize by setting theWeights.MV(:,i)values in a manner similar to that suggested forWeights.OV(see above). Typical practice sets the average MV tracking priority lower than the average OV tracking priority (e.g., 0.2 < 1).

If theith MV does not have a target, setWeights.MV(:,i)= 0 (the default).

Tips for Setting MV Rate Weights

  • By default,Weights.MVRate = 0.1*ones(1,nu)。The reasons for this default include:

    • If the plant is open-loop stable, large increments are unnecessary and probably undesirable. For example, when model predictions are imperfect, as is always the case in practice, more conservative increments usually provide more robust controller performance, but poorer reference tracking.

    • These values force the QP Hessian matrix to be positive-definite, such that the QP has a unique solution if no constraints are active.

    To encourage the controller to use even smaller increments for theith MV, increase theWeights.MVRate(:,i)value.

  • If the plant is open-loop unstable, you might need to decrease the averageWeight.MVRatevalue to allow sufficiently rapid response to upsets.

Tips for Setting ECR Weights

SeeConstraint Softeningfor tips regarding theWeights.ECRproperty.

Testing and Refinement

To focus on tuning individual cost function weights, perform closed-loop simulation tests under the following conditions:

  • No constraints.

  • No prediction error. The controller prediction model should be identical to the plant model. Both theMPC Designerapp and thesimfunction provide the option to simulate under these conditions.

使用参考和测量disturba的变化nce signals (if any) to force a dynamic response. Based on the results of each test, consider changing the magnitudes of selected weights.

One suggested approach is to use constantWeights.OV(:,i) = 1to signify “average OV tracking priority,” and adjust all other weights to be relative to this value. Use thesensitivitycommand for guidance. Use thereviewcommand to check for typical tuning issues, such as lack of closed-loop stability.

SeeAdjust Disturbance and Noise Modelsfor tests focusing on the disturbance rejection ability of the controller.

Robustness

Once you have weights that work well under the above conditions, check for sensitivity to prediction error. There are several ways to do so:

  • If you have a nonlinear plant model of your system, such as a Simulink®model, simulate the closed-loop performance at operating points other than that for which the LTI prediction model applies.

  • Alternatively, run closed-loop simulations in which the LTI model representing the plant differs (such as in structure or parameter values) from that used at the MPC prediction model. Both theMPC Designerapp and thesimfunction provide the option to simulate under these conditions. For an example, seeTest MPC Controller Robustness using MPC Designer

If controller performance seems to degrade significantly in comparison to tests with no prediction error, for an open-loop stable plant, consider making the controller less aggressive.

InMPC Designer, on theTuningtab, you can do so using theClosed-Loop Performanceslider.

Moving towards more robust control decreases OV/MV weights and increases MV Rate weights, which leads to relaxed control of outputs and more conservative control moves.

At the command line, you can make the following changes to decrease controller aggressiveness:

  • Increase allWeight.MVRatevalues by a multiplicative factor of order 2.

  • Decrease allWeight.OVandWeight.MVvalues by dividing by the same factor.

After adjusting the weights, reevaluate performance both with and without prediction error.

  • If both are now acceptable, stop tuning the weights.

  • If there is improvement but still too much degradation with model error, increase the controller robustness further.

  • If the change does not noticeably improve performance, restore the original weights and focus on state estimator tuning (seeAdjust Disturbance and Noise Models).

Finally, if tuning changes do not provide adequate robustness, consider one of the following options:

Related Topics