# How can I constrain the output variables using an MPC controller?

8 views (last 30 days)
Robert Allen on 6 Feb 2017
Answered: Hannes Daepp on 13 Feb 2017
My system is a point mass controlled by 3 (force) inputs and has 6 (3 position and 3 velocity) outputs. I would like to limit the three velocity inputs to be no larger than abs(6), thereby limiting the velocity of the point mass to the norm of the velocity outputs.
I am using an MPC block to track a reference trajectory. I have tried specifying the limits in the controller by navigating to the tuning tab in the MPC designer and specifying limits to y(4:6), but the constraints are ignored. I have tried to constrain the output variables in a script directly:
mpcobj.OV(4).Min = -6;
mpcobj.OV(4).Max = 6;
mpcobj.OV(5).Min = -6;
mpcobj.OV(5).Max = 6;
mpcobj.OV(6).Min = -6;
mpcobj.OV(6).Max = 6;
Constraints are ignored. I have also tried setting them with the setconstraint() function:
E = [0 0 0;
0 0 0;
0 0 0;
0 0 0;
0 0 0;
0 0 0]
F = [0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 0 0 0 0;
0 0 0 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1]
G = [0; 0; 0; 6; 6; 6]
V = [0;0;0;0;0;0]
setconstraint(mpcobj,E,F,G,V)
this method attempts to control the system for a few seconds then the manipulated variables saturate and the system becomes unstable.

Hannes Daepp on 13 Feb 2017
Since your constraints are not being satisfied, it is likely that you need to set the bound softness in the Quadratic Programming (QP) problem. By default, all the outputput (OV) constraints are soft, i.e., MinECR = 1 and MaxECR = 1, as detailed in the documentation.
The violation of soft constraints competes with tracking performance in the objective function. In general, hard output constraints are not recommended, due to the danger of having an infeasible QP problem at run time.
You might also find the following page, which provides a more detailed overview of hard and soft constraints, to be useful: https://www.mathworks.com/help/mpc/ug/specifying-constraints.html#buj077i