Nonlinear MPC hard constraints

28 次查看(过去 30 天)
Tristan
Tristan 2024-11-25,16:57
编辑: Ashok 2024-11-27,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.

回答(1 个)

Ashok
Ashok 2024-11-26,12:00
编辑:Ashok 2024-11-26,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 个评论
Tristan
Tristan 2024-11-26,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 2024-11-27,3:36
编辑:Ashok 2024-11-27,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.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Model Predictive Control Toolbox 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by