-
Notifications
You must be signed in to change notification settings - Fork 2
Home
MPTplus is an open-source extension of MATLAB-based Multi-Parametric Toolbox (MPT) introducing various novel methods and features. MPTplus is expected to be merged into the next release of MPT.
Questions and comments should be addressed to: Juraj Holaza and Juraj Oravec
Disclaimer: The MPTplus is distributed under MIT License.
MPTplus is going to be presented at the 24th International Conference on Process Control.
BibTex entry for use in Latex with: TBA
MATLAB R2022a or later. MPTplus is not a stand-alone toolbox, as it extends the MPT toolbox. As the consequence, MPTplus depends on MPT and its dependencies.
We strongly recommend installing MPTplus using a tbxManager by typing:
tbxmanager install mptplus
Otherwise, download the latest release of the MPTplus package, unpack the package in the target directory, and set and save the corresponding path in MATLAB.
To update MPTplus call:
tbxmanager update mptplus
If you wish to uninstall MPTplus call:
tbxmanager uninstall mptplus
MPTplus is going to be presented at the 24th International Conference on Process Control.
BibTex entry for use in Latex with: TBA
MPTplus enables the rigid Tube MPC design according to: Mayne et al., Automatica (2005): Robust model predictive control of constrained linear systems with bounded disturbances
Example on how to construct and evaluate Tube MPC controller:
%% TUBE MPC DESIGN
% LTI system
model = ULTISystem('A', [1, 1; 0, 1], 'B', [0.5; 1], 'E', [1, 0; 0, 1]);
model.u.min = [-1];
model.u.max = [ 1];
model.x.min = [-5; -5];
model.x.max = [ 5; 5];
model.d.min = [-0.1; -0.1];
model.d.max = [ 0.1; 0.1];
% Penalty functions
model.x.penalty = QuadFunction(diag([1, 1]));
model.u.penalty = QuadFunction(diag([0.01]));
% Terminal set
model.x.with('terminalSet');
model.x.terminalSet = model.LQRSet;
% Terminal penalty
model.x.with('terminalPenalty');
model.x.terminalPenalty = model.LQRPenalty;
% Prediction horizon
N = 2;
% Enable construction of the explicit controller
option = {'eMPC',1};
% TMPC controller construction
[iMPC,eMPC,sol] = TMPCController(model,N,option)
% TMPC evaluation
x0 = [-5; 2]; % Initial condition
u_implicit = iMPC.optimizer(x0) % Implicit MPC evaluation
u_explicit = eMPC.evaluate(x0) % Explicit MPC evaluation
[u, feasible, openloop] = eMPC.evaluate(x0) % Enriched output
Warning: prevent using the function evaluate()
on the implicit Tube MPC controller as it leads to incorrect output in the current version of MPTplus, yet. Use optimizer
instead.
Note: the current version of MPTplus always displays for explicit Tube MPC controller confusing information on the prediction horizon N=1, although the controller is constructed correctly for any value of N.
For the given uncertain LTI model
and prediction horizon N
, enable/disable (potentially time-consuming) construction of the explicit Tube MPC controller by:
% Enable construction of the explicit controller
option = {'eMPC',1};
% TMPC controller construction
[iMPC,eMPC] = TMPCController(model,N,option)
% TMPC evaluation
x0 = [-5; 2]; % Initial condition
u = eMPC.evaluate(x0) % Explicit MPC evaluation
To disable construction of the explicit controller run:
% Disable construction of the explicit controller
option = {'eMPC',0};
% TMPC controller construction
[iMPC,eMPC] = TMPCController(model,N,option)
% TMPC evaluation
x0 = [-5; 2]; % Initial condition
u = iMPC.optimizer(x0) % Implicit MPC evaluation
Warning: do not use toExplicit()
function to transform an implicit Tube MPC controller into the corresponding explicit controller. Use: option = {'eMPC',1}; [iMPC,eMPC] = TMPCController(model,N,option)
instead.
For the given uncertain LTI model
and prediction horizon N
, get (approximated) minimum robust positive invariant set (the tube), sets of the conservative state and input constraints, and plot them (if applicable):
% TMPC controller construction
[iMPC,eMPC,sol] = TMPCController(model,N);
% Tube
Tube = sol.Tube
figure, Tube.plot()
% State constraints
Xconservative = sol.Xc
figure, Xconservative.plot()
% Input constraints
Uconservative = sol.Uc
figure, Uconservative.plot()
For the given uncertain LTI model
and prediction horizon N
, get the internal feedback (discrete-time LQ-optimal) controller, corresponding terminal penalty (Lyapunov) matrix, and the associated terminal set, and plot them (if applicable):
% TMPC controller construction
[iMPC,eMPC,sol] = TMPCController(model,N)
% K: u(0) = u_opt + K*( x(0) - x_opt )
K = sol.K
% Terminal penalty: P > 0
P = model.x.terminalPenalty.weight
% Terminal set: X_N
X_N = model.x.terminalSet
figure, X_N.plot()
For given feedback control law: u(0) = u_opt + K*( x(0) - x_opt ) , switch between returning the compact control input u(0) and the vector of the particular variables u_opt and x_opt using the option solType
- {0/1}
.
For the given uncertain LTI model
and prediction horizon N
, evaluate the vector of the particular variables u_opt and x_opt:
% Setup for expanded control input
option = {'empc',1, 'solType',0}
% TMPC controller construction
[iMPC,eMPC] = TMPCController(model,N,option)
% TMPC evaluation of compact control input
x0 = [-5; 2]; % Initial condition
ux_implicit = iMPC.optimizer(x0) % Implicit MPC evaluation
ux_explicit = eMPC.evaluate(x0) % Explicit MPC evaluation
Evaluation of the compact control input u(0):
% Setup for compact control input
option = {'empc',1, 'solType',1}
% TMPC controller construction
[iMPC,eMPC] = TMPCController(model,N,option)
% TMPC evaluation of compact control input
x0 = [-5; 2]; % Initial condition
u_implicit = iMPC.optimizer(x0) % Implicit MPC evaluation
u_explicit = eMPC.evaluate(x0) % Explicit MPC evaluation
How to plot the partition, PWA feedback law, and PWQ cost function of the explicit Tube MPC controller
For the given uncertain LTI model
and prediction horizon N
, plot, if applicable, the partition (explicit solution map/domain of the optimization problem), PWA feedback law, and PWQ cost function of the explicit Tube MPC controller run:
% Define to compute also the explicit MPC
option = {'eMPC',1, 'solType',1}; % for compact control input
% option = {'eMPC',1, 'solType',0}; % enable for expanded control input
% TMPC controller construction
[iMPC,eMPC,sol] = TMPCController(model,N,option)
figure, eMPC.partition.plot()
figure, eMPC.feedback.fplot()
figure, eMPC.cost.fplot()
Note, the returned outputs partition
, feedback
differ in the case of the compact (u) and in the case of the expanded vector of the control inputs (u_opt,x_opt) based on the value of option solType
- {0/1}
Warning: the PWQ cost function is always computed (and plotted) subject to the original decision variables of the optimization problem (i.e., the expanded control inputs: u_opt, x_opt) regardless of the setting of the parameter solType
.
The constructed explicit Tube MPC controller can be reduced without optimality loss using the Optimal region merging (ORM) method and the Separation-based method. For the given uncertain LTI model
and prediction horizon N
, apply the Optimal region merging method running:
% Setup for explicit compact control input
option = {'empc',1, 'solType',1}
% TMPC controller construction
[iMPC,eMPC] = TMPCController(model,N,option)
% Complexity reduction by Optimal region merging method
eMPCsimple = eMPC.simplify('orm')
% Number of critical regions
Nr_original = eMPC.nr
Nr_reduced = eMPCsimple.nr
The separation-based method targets to reduce the complexity by removing all critical regions that lead to saturated control laws. Next, a separation filter is constructed to identify optimal control actions above the removed critical regions. For the given uncertain LTI model
and prediction horizon N
, apply the Separation-based method by running:
% Setup for explicit compact control input
option = {'empc',1, 'solType',1}
% TMPC controller construction
[iMPC,eMPC] = TMPCController(model,N,option)
% Complexity reduction using a Separation-based method
eMPCsimple = eMPC.simplify('separation')
% Number of critical regions
Nr_original = eMPC.nr
Nr_reduced = eMPCsimple.nr
Note: you need to have installed MPT extension package LowCom to run function simplify
.
For the given uncertain LTI model
and prediction horizon N
, adopt the advanced settings of the tube construction using the parameters:
Tube_tol
- allowed tolerance for the convergence (default = 1e-4
),
Tube_MaxIter
- maximal number of iterations (default = 1e3
) by running:
% Setup for advanced configuration of the Tube construction
option = {'empc',1, 'Tube_tol',1e-3, 'Tube_MaxIter', 100}
% TMPC controller construction
[iMPC,eMPC,sol] = TMPCController(model,N,option)
Tube = sol.Tube
figure, Tube.plot()
- Introduced the Rigid Tube MPC design.
- Non-Applicable
- Do not use
toExplicit()
function to transform an implicit Tube MPC controller into the corresponding explicit controller. Use:option = {'eMPC',1}; [iMPC,eMPC] = TMPCController(model,N,option)
instead. - Prevent using the function
evaluate()
on the implicit Tube MPC controller as it leads to incorrect output in the current version of MPTplus, yet. Useoptimizer
instead. - The current version of MPTplus always displays for explicit Tube MPC controller confusing information on the prediction horizon N=1, although the controller is constructed correctly for any value of N.
- The PWQ cost function is always computed (and plotted) subject to the original decision variables of the optimization problem (i.e., the expanded control inputs: u_opt, x_opt) regardless of the setting of the parameter
solType
.