Nonlinear MPC hard constraints

25 views (last 30 days)
Tristan
Tristan on 25 Nov 2024 at 16:57
Edited: Ashok on 27 Nov 2024 at 3:36

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.

Answers (1)

Ashok
Ashok on 26 Nov 2024 at 12:00
Edited: Ashok on 26 Nov 2024 at 12:12
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 Comments
Tristan
Tristan on 26 Nov 2024 at 15:54
Your example seems to be for a custom cost function. Can you detail the analagous steps for custom inequality constraint function?
Ashok
Ashok on 27 Nov 2024 at 3:36
Edited: Ashok on 27 Nov 2024 at 3:36
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.

Sign in to comment.

Categories

Find more on Model Predictive Control Toolbox in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!