Constraints violation in MPC design

I am building a mpc on MATLAB/Simulink. I applied some equality and inequality constraints to the controller (states and unputs); however, there are inequality state constraints that are violated. What might be the reason behind that?

 Risposta accettata

The more constraints you are adding, the smaller the solutions space, the harder it gets for the solver to find a solution. If your constraints are too restrictive, you may be asking the controller to solve an infeasible optimization problem. You can easily check if that's the case by making sure that your constraints are soft. And always make sure to check the exit flag status to see if the controller was actually able to solve the problem or not.

15 Commenti

Thank Emmanouil for your response
ans =
Simulink.SimulationOutput:
tout: [653x1 double]
SimulationMetadata: [1x1 Simulink.SimulationMetadata]
ErrorMessage: [0x0 char]
Above is the message generated once the simulation is finished. However, there are some states constraints that are still violated. It does not show any errors; thus, the controller was able to solve the problem, right?
If constraints are violated you are not going to see any errors in the simulation. You need to add a scope to display the optimization status of the MPC block. See qp.status on this doc page for more details.
I am using nonlinear mpc, so I checked nlp.status. My issue involves one constraint. When it is inactive, the nlp status is a postive integer and the state value does not increase beyond the limit. However, when the constraint is active, nlp status has a negative value from the start, and the constraint is violated. I don't understand why is this happening.
As I mentioned, this particular constraint seems to be very restrictive and the optimization problem cannot be solved while satisfying it. You need to make the constraint soft or modify it accordingly
If it is the state constraint which is being violated (as mentioned in the question), is it still possible to soften the constraint? as in the documentation it is written that the state constraints are always hard?
In order to soften the constraints, I used the 'MaxECR' property of one manipulated variable. This value should in turn influence the slack variable 'e' passed to the cost function. I used a small value for 'MaxECR = 0.1'. However, the value of the MV at some instances is twice the value of the upper bound. How does 'MaxECR' influence the slack variable? Also, how can I declare a slack variable for the states, since it does not have 'MaxECR' property?
Here is an example that shows how to apply soft constraints with multi-stage nonlinear MPC. This uses a data-driven model but the idea is the same. Also, since multi-stage MPC does not care whether constraints are on states vs outputs, it's more flexible.
Hi Emmanouil,
In the first image, there is no constraint violations and the 'nlp.status' shows a positive integer. No problem here.
In the second image, there is constraint violations; however, the nlp.status is still a positive integer. No constraints softening are applied in this case.
Do you know what could be the reason why the solver may not detect any constraint violations? Thank you in advance.
Interesting. I would need more details to investigate. Are you using multi-stage MPC? For example, some bound constraints are by default soft (see here)
Sure, just tell me what would you like to know. And to answer your question, I am using nonlinear MPC 'nlmpc'. The states constraints are always hard, and they are the ones being violated. Beside, a slack variable is introduced, and its value was zero through out the simulation time.
The following additional information might help. The dynamical model of the plant I am simulating is derived from graph-based modeling and it is given by
The difference between image 1 and 2 is that capacitance matrix 'C' is lower in image 2 than image 1. Thus, it exhibits faster dynamics.
My feeling is that the constraints are not set up properly in the code, so it would be good to see how you created the nlmpc object, how you set up the constraints and what your cost function looks like
I have uploaded the files you need to check. You can find them here.
@Osamah Ali Mohammed Saad Thanks for uploading your files! I took a look through them and simulated the controller on my end, and I'm not seeing any constraint violation. State 3 (SOC) is the only state with constraints in the code you provided, it looks like all the others are commented out. State 3 stays within its hard constraints ([0.1, 1]) during the entire simulation.
All the constraints on the MVs appear to be satisfied as well, except for some very small violations of the RateMin constraint on MV 3 (mass flow), which is a soft constraint.
Could you elaborate on what constraint violations you are seeing on your end?
Thank you Jordan for your response. A custom inequalities constraints file is used to apply softened state constraints. These constraints are violated, but the slack variable value remains unchanged (0 = unused). However, when I reduce the sampling time, the solver is able to detect the constraints violation and uses the slack variable accordingly.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by