MPCController
Purpose
MPC controller with on-line optimization
Syntax
ctrl = MPCController(model)
ctrl = MPCController(model, horizon)
Description
ctrl = MPCController(model) constructs an MPC
optimization problem by using the object model as the
prediction model.
The basic optimization problem takes the following form:

where
is the prediction horizon,
,
,
are the state, input, and output predictions,
respectively,
denotes the terminal cost,
is the stage cost,
represents the state-update equation, and
is
the output equation.
The terminal cost is given by
, where
is the weighting matrix and
is the type of the
norm (if
, then
, see
"help Function" for more information). The type
of the norm as well as the weighting matrix are specified by the
terminalPenalty property of the state signal (see
"help SystemSignal/filter_terminalPenalty").
The stage cost is represented by
, where
are weighting matrices and
represent types
of the norms. Properties of the state penalization are taken from
model.x.penalty (see "help
SystemSignal/filter_penalty"). Similarly, properties of input
and output penalizations are extracted from
model.u.penalty and model.y.penalty,
respectively. Note that different norms/weights can be assigned to
various signals. Hence you can have a quadratic penalization of
the state, but use a 1-norm penalty on the inputs.
If a certain signal (state, input, and/or output) has the
reference filter enabled (see "help
SystemSignal/filter_reference"), the terminal and stage costs
become
and
. If some
signal does not have the reference property enabled, we
assume a zero reference instead.
By default, min/max bounds on state, input, and output variables
are added to the MPC setup. The bounds stored in
model.x.min, model.x.max, model.u.min,
model.u.max, model.y.min, and
model.y.max are used. Note that other types of
constraints can be added. These include polyhedral constraints
(see "help SystemSignal/filter_setConstraint"), soft
constraints (see "help SystemSignal/filter_softMax" and
"help SystemSignal/filter_softMin"), or move blocking (see
"help SystemSignal/filter_block").
The basic way to create an MPC controller is to call
controller = MPCController(system)
where system represents the dynamical system to be used
for predictions (can be an
instance of the LTISystem, PWASystem, or
MLDSystem classes). Then you can further fine-tune the
prediction model by adding constraints and/or modifying
penalties. This can be done by accessing the model
property of the controller object:
controller.model.x.min = [-5; -5]
You can also specify the prediction horizon directly from the
command line:
controller.N = 3
Once the controller is fully specified, you can use the
evaluate method to obtain the optimal sequence of inputs,
(see "help MPCController/evaluate"), or compute the
explicit form of the controller by calling the toExplicit
method (see "help MPCController/toExplicit").
Input Arguments
model |
Any MPT3 system (LTISystem, PWASystem,
MLDSystem)
Class: AbstractSystem
|
N |
Prediction horizon
Class: Double
|
Output Arguments
controller |
Instance of the MPCController class. |
Example(s)
Example
1
Create a 1D LTI system
sys = LTISystem('A', 0.9, 'B', 1)
LTISystem with 1 state, 1 input, 0 outputs
Construct the MPC controllerctrl = MPCController(sys)
MPC controller (no prediction horizon defined)
Add constraints
ctrl.model.x.min = -1; ctrl.model.x.max = 1;
ctrl.model.u.min = -1; ctrl.model.u.max = 1;
Add penalties (we use squared two-norm with unity
weights here)
ctrl.model.x.penalty = QuadFunction(1);
ctrl.model.u.penalty = QuadFunction(1);
Specify the prediction horizonctrl.N = 4;
Compute the optimal control action for the initial state x0=0.5
x0 = 0.5;
u = ctrl.evaluate(x0)
u =
-0.268049612898345
We can also ask for the full open-loop predictions:
[u, feasible, openloop] = ctrl.evaluate(x0)
u =
-0.268049612898345
feasible =
1
openloop =
cost: 0.370622325804255
U: [-0.268049612898345 -0.0956658064407663 -0.0306402938778255 -3.46944695195361e-18]
X: [0.5 0.181950387101655 0.0680895419507233 0.0306402938778255 0.0275762644900429]
Y: [0x4 double]
Convert the controller to an explicit formexpctrl = ctrl.toExplicit()
mpt_plcp: 1 regions
Explicit MPC controller (horizon: 4, regions: 1)
See Also
empccontroller
© 2003-2013 Michal Kvasnica: STU Bratislava, michal.kvasnica@stuba.sk