Options set for mpcmove
options = mpcmoveopt
options = mpcmoveopt creates an mpcmoveopt object, with default values for its properties. Use this object with mpcmove to allow run-time adjustment of the weights and constraints of the Model Predictive Controller, an mpc object, that is operating.
Options for the mpcmove command with the following fields:
Use an mpcmoveopt object to vary an MV upper bound during a simulation employing mpcmove. The upper bound decreases step-wise from 2 to 1 when elapsed time exceeds 4 seconds. Also, setting OnlyComputeCost = 1 causes the Info object returned by mpcmove to contain the cost only.
Define an mpcmoveopt object and initialize some of its fields.
OPTobj = mpcmoveopt; OPTobj.OnlyComputeCost = true; OPTobj.MVMin = -2;
Define a plant model and a model predictive controller object.
ts = 2; Plant = ss(0.8, 0.5, 0.25, 0, ts); MPCobj = mpc(Plant, ts); MPCobj.MV(1).Min = -2; MPCobj.MV(1).Max = 2;
Perform mpcmove simulation.
x = mpcstate(MPCobj); r = 1; v = ; t = [0:ts:10]; N = length(t); y = zeros(N,1); u = zeros(N,1); for i = 1:N y(i) = 0.25*x.Plant; % Use the MPCMOVEOPT object to modify the MV upper bound in % real time. if t(i) <= 4 OPTobj.MVMax = 2; else OPTobj.MVMax = 1; end [u(i), Info] = mpcmove(MPCobj, x, y(i), r, v, OPTobj); end
Analyze the results.
[ts, us] = stairs(t, u); plot(ts, us,'b-', t, y,'r--') legend('Reference','Output');
When you use mpcmove, an mpcmoveopt object is optional. As an alternative, you can modify the weight, constraint definitions, or both before calling mpcmove. This approach is usually less computationally efficient, but it avoids potential conflicts with constraint definitions when mixed bounded and unbounded variables are present.
The number of manipulated variables (nu) and output variables (ny) for the mpcmoveopt object must match that of the corresponding mpc object.
If any weight property in options is set to  (default), mpcmove uses the corresponding weight specified in the mpc object.
In general, constraint specifications of options must be consistent with those of the corresponding mpc object.
If all of the four constraint properties of options are set to  (default), mpcmove uses the existing constraints specified for the corresponding mpc object. The result will be the same as if there are no run-time constraint changes.
Constraints set to  are treated as unbounded signals. The corresponding constraint settings for the mpc object must also be unbounded.
Constraints not set to  are treated as bounded signals. The corresponding constraint settings for the mpc object must also be bounded.
These requirements make the Model Predictive Controller object behave consistently with the corresponding MPC Controller block in Simulink®
A conflict may arise when you have a mixture of bounded and unbounded variables for one or more constraint properties of options. It may be resolved by defining compatible constraints for the mpc object and corresponding mpcmoveopt object.
For example, suppose ny = 2, and your mpc object defines a maximum for the first output variable but the second has no upper bound. If,
options.OutputMax = , then mpcmove interprets this as an attempt to remove the upper bound on the first output.
options.OutputMax is not , then, because all entries must be finite, mpcmove interprets this as an attempt to impose a new upper bound on the second output.
To avoid this conflict, modify your mpc object to have a large but finite upper bound on the second output. It can then be paired with options, containing finite OutputMax values, without conflict.