Nonlinear MPC hard constraints

19 visualizzazioni (ultimi 30 giorni)
Tristan
Tristan il 25 Nov 2024
Modificato: Ashok il 27 Nov 2024

Is there a way to make custom inequality constraint functions in the nonlinear mpc functions to be a hard constraint and not a slacked constraint? I have been trying to design a nonlinear mpc that needs a custom constraint but it seems by default this is slacked, and it would be highly infeasible if it was strictly enforced.

Risposte (1)

Ashok
Ashok il 26 Nov 2024
Modificato: Ashok il 26 Nov 2024
Hey @Tristan,
In the Model Predictive Control Toolbox, the default implementation of MPC uses slack variables to handle constraints. Setting these slack variables to zero converts the constraints into hard constraints. The constraint violation penalty weight indicates the weightage given to the slack variable in a minimization problem, as detailed here:
Raising this weight to a high value makes the constraints stricter.
Here's how it can be done:
  • If using the standard cost function and the propertynlmpc.Optimization.ReplaceStandardCostis set tofalse, increasing thenlmpc.Weights.ECRvalue raises the weight on the slack variables. More details are available here:
  • When specifying a custom cost function for a nonlinear MPC controller, it's possible to replace or augment the standard quadratic MPC cost function. By default, anlmpccontroller replaces the standard cost function with the custom one, treating all constraints as hard constraints.
  • To combine standard and custom costs, setnlmpc.Optimization.ReplaceStandardCostto false, similar to the first scenario, allowing adjustments to thenlmpc.Weights.ECR property.
The attached file example_R2024b.m contains a simple example with a custom cost function andnlmpc.Optimization.ReplaceStandardCostset totrue, treating the constraint as a hard constraint.
The plot of the states shows that state x remains within 5, even when the reference/desired state is 10.
For more detailed information, check out these pages:
I believe this will assist you!
  2 Commenti
Tristan
Tristan il 26 Nov 2024
Your example seems to be for a custom cost function. Can you detail the analagous steps for custom inequality constraint function?
Ashok
Ashok il 27 Nov 2024
Modificato: Ashok il 27 Nov 2024
The attached example specifies a custom cost function named 'customCostFcn' along with a custom inequality constraint funtion named 'customConstraintFcn'. They are added to the nlmpc object, 'nlobj' by the following lines in the attached code.

Accedi per commentare.

Categorie

Scopri di più su Model Predictive Control Toolbox in Help Center e File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by