I am having contraint violation problems using nlmpcmove.
10 views (last 30 days)
Show older comments
Hey there,
I am having issues with the optimization in my nonlinear MPC. In my nlmpc-Object I have set all hard constraints from -Inf to Inf (States & Output Variables), except for my ManipulatedVariables. After some time steps of nlmpcmove I start getting exit flags of -2 and the Optimization shows problems with my contraints:
Optimization stopped because the relative changes in all elements of x are
less than options.StepTolerance = 1.000000e-06, but the relative maximum constraint
violation, 2.795604e-02, exceeds options.ConstraintTolerance = 1.000000e-06.
After trying a lot of different settings and tolerances in the SolverOptions, I could not eliminate the problem. My Model.StateFcn, Model.OutputFcn and Optimization.CustomCostFcn always showed expected behavior. I have double-checked all the scaling for my variables.
I have tried changing the constraints of my ManipulatedVariables to different ranges and have even completely removed them. Nevertheless the optimization still shows exeeding constraint violations. Are there further constraints in the nlmpc-Object I have overlooked? I have also tried to give different initial MVs. I have run out of ideas what else I could try.
Thanks for your help already!
Cheers,
Jonathan
PS: I am happy to provide further code or information, if helpful.
1 Comment
Emmanouil Tzorakoleftherakis
on 10 Feb 2023
I was initially going to suggest that the optimization problem is actually infeasible (this is not uncommon when you have hard constraints), in which case making the MV bounds soft would likely resolve the issue. But then you mentioned that you were getting the same error even when you removed the mv bounds? If you can share a reproduction example, it would be easier to make recommendations.
Answers (1)
Karanjot
on 30 Jan 2024
It seems like you have already tried various approaches to address the constraint violation issue in your nonlinear MPC. However, there might be a few additional constraints in the nlmpc object that you may have overlooked. Here are a few suggestions to investigate further:
- Check for soft constraints: In addition to hard constraints, the nlmpc object also supports soft constraints. Soft constraints allow the optimizer to violate the constraints within certain limits, which can help in cases where strict adherence to constraints is not possible. Check if there are any soft constraints defined in your nlmpc object and adjust their limits if necessary.
- Verify constraint scaling: Ensure that the scaling of your constraints is appropriate. If the constraints are not scaled properly, it can lead to unexpected behavior during optimization. Double-check the scaling factors for your constraints and make sure they are consistent with the scaling of your variables.
- Investigate constraint functions: The constraint violation message suggests that the relative maximum constraint violation exceeds the ConstraintTolerance value. This indicates that there might be an issue with one or more of your constraint functions. Review the constraint functions defined in your nlmpc object's Model property (e.g., Model.StateFcn, Model.OutputFcn, etc.) and verify their correctness. Ensure that the constraints are formulated correctly and that they are being evaluated as expected.
If none of these suggestions resolve the constraint violation issue, it might be helpful to provide more specific details about your optimization problem, including the code snippets related to the nlmpc object setup and the constraint functions.
0 Comments
See Also
Categories
Find more on Nonlinear MPC Design 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!