MPT 2.0


MPT2 (alias MPT version 2.0) is the next major relase of the Multi-Parameteric Toolbox after version 1.4.4 back in August 2004. Since then, development has been focused on improvements in numerical robustness, runtime efficiency of implemented algorithms, user interface and support of a broader class of solvers. Brand new algorithm for optimal control of PWA systems based on dynamical programming with PWA cost-to-go has been added as well, along with tools which aim at reducing complexity of resulting explicit solutions. Explicit controllers can be now exported to a standalone C-code, or compiled to executable form using the Real Time Workshop.

New major features

Export of controllers to C-code

MPT 2.0 allows to export explicit controllers to a standalone C-code which can then be linked together with your application. To export a controller, call
  >> mpt_exportc(ctrl)
Have a look at mpt/examples/ccode/mpt_example.c on how to include the controller into your application. Alternatively, executable code can be also obtained using the Real Time Workshop from a Simulink model which includes one or multiple instances of the MPT Controller block.

Improved Simulink interface

MPT 2.0 offers a comfortable Simulink library which allows to embed explicit and on-line MPC controllers directly into your models. In addition, it provides blocks for simulation of linear and hybrid systems with constraints and for assesment if a point belongs to certain polytope.

MPT Simulink Library screenshot


To access the library, run the following command on the command prompt:
  >> mpt_sim
To get a flavour of how to connect the blocks, have a look at one of the following demos:
  >> ballandplatesim
  >> turbocardemo
  >> twotanksdemo
The Two-Tanks Simulink model screenshot


It is possible to directly compile any Simulink diagram which contains one or more instances of the MPT Controller block using the Real Time Workshop to deploy the controllers to your target applications.

Verification of hybrid systems

Verification answers the following question:
Do states of a dynamical system (whose inputs either belong to some set of admissible inputs, or whose inputs are driven by an explicit control law) enter some set of "unsafe" states in a given number of steps?.

The verification algorithm implemented in MPT 2.0 is based on the reachability computation procedure and can be called in two ways.

The first approach can be used to verify if a dynamical system can enter some given set of "unsafe" states if the system inputs are assumed to belong to some set of admissible inputs, i.e. u(k) \in U:
  >> canreach = mpt_verify(sysStruct, X0, Xf, N, U)
where sysStruct is a model of a linear or hybrid system, X0 denotes set of initial states, Xf describes set of "unsafe" states, N is the number of steps over which verification should be performed and U is a set of admissible inputs. If the target set Xf can be reached within of N steps, the function will return true, otherwise false will be returned.

It is also possible to verify if a dynamical system can enter a set of "unsafe" states if system inputs are driven by some explicit control law:
  >> canreach = mpt_verify(ctrl, X0, Xf, N)
where ctrl is an explicit controller computed by MPT and the rest of arguments has the same meaning as in the example above.

The verification procedure can be used in practive for instance to verify safety and liveness properties of explicit control laws.

Improved Lyapunov analysis

MPT 2.0 brings a common interface to calculate large variety of Lyapunov function. The following types of Lyapunov functions include: To calculate a Lyapunov function for a given explicit controller, this simple command can be used:
  >> ctrl_lyap = mpt_lyapunov(ctrl, lyaptype)
Here ctrl is a variable which describes an explicit controller and lyaptype is a string parameter which chooses which type of Lyapunov function to compute.

Graphical user interface

MPT now features a rich Graphical User Interface (GUI) for modeling of constrained linear and hybrid systems, controller computation and post-analysis. You can see it live in action in our flash live demos section, or watch some screenshots. Type
  >> mpt_studio
on the command line to start the GUI.

Computation of on-line MPC controllers

MPT can now also design on-line MPC controllers in addition to explicit control laws. Just define your dynamical system and properties of the optimization problem and call
  >> controller = mpt_control(sysStruct, probStruct, 'on-line')
to compute an on-line controller. The controller can then be used for simulations in exactly the same way as explicit controllers are. For instance, you can plug an on-line controller directly into the new MPT Simulink interface and perform simulations there in the usual manner.

Intuitive modeling of hybrid systems

MPT can now design controllers for hybrid systems generated from HYSDEL models. HYSDEL (HYbrid Systems DEscription Language) is a language for easy modeling of hybrid systems described by interconnections of linear dynamic systems, automata, if-then-else and propositional logic rules. To transform a HYSDEL model into a model suitable for MPT, simply call:
  >> sysStruct = mpt_sys('myhysdelfile')
where myhysdelfile is the name of the file which contains your model.


Dynamical models can also be imported from state-space objects (ss), transfer function objects (tf), system identification toolbox objects (idss) and MPC toolbox objects (mpc). To convert a model from one of these objects, call
  >> sysStruct = mpt_sys(myvar)
where myvar is a variabled of one of the above mentioned types.

Complexity reduction

Complexity of explicit solutions was always an important issue. There are two levels of complexity involved in multi-parametric solutions to optimal control problems:
  1. Runtime complexity
  2. Complexity of the resulting solution in terms of the number of regions
Runtime complexity is important during the computation of the solution, while the second level is vital for on-line implementation of explicit controllers in real life. Clearly, the higher the number of regions the longer it takes to identify a proper control law and also the more memory is needed to store all necessary regions along with the associated control laws. Therefore there is a clear need of simple controllers in terms of number of regions. Although this can be achived by applying one of the low-complexity schemes MPT offers, these controllers do not guarantee optimal performance.
If the controller is required to provide optimal control action, complexity can only be reduced by post-processing. MPT2 now allows to achieve this goal by simplifying the resulting controller while maintaining the same performance the original controller gives. This is achived by merging regions which have the same control law into larger chunks. Two levels of simplifications can be used:
Optimal merging gives least number of regions one could possible get, while greedy merging is based on a randomized procedure which checks which regions can be merged. Differences between these two methods are in runtime and complexity of the simplified solutions. The greedy merging algorithm is much faster but optimal merging gives the least number of regions one can possibly get. So the choice is up to you. Give the function a try by calling
  >> simple_controller = mpt_simplify(controller)
Consult help mpt_simplify for how to switch from greedy merging (which is used by default) to optimal merging.

Efficiency of algorithms

Big progress has been achieved in improving runtime efficiency of (almost all) algorihtms provided by MPT. First, a brand new technique for computing solutions to Constrained Finite-Time Optimal Control (CFTOC) problems for Piecewise-Affine (PWA) systems is now available. This algorithm, developed by Miroslav Baric et al., is based on a Dynamic Programming approach with Piecewise-Affine cost-to-go expressions. As can be seen from the table below, this algorithm is faster by a factor of 2-20 (depending on the problem) than the original implementation of the CFTOC algorithm. Secondly, the complete MPT code has been massively optimized for runtime speed, which gives the new version an additional edge over the old release.

Problem setup Runtime MPT 1.4.4 Runtime MPT 2.0 Improvement
Problem 1 468.0 secs180.0 secs 260 %
Problem 2 402.1 secs226.0 secs 178 %
Problem 3 1817.0 secs154.7 secs 1175 %
Problem 4 22.7 secs9.8 secs 232 %

Problem 1 Finite time solution for a 2D PWA system (opt_sincos; probStruct.N=11)
Problem 2 Minimum-time solution for a 3D PWA system (pwa3d; probStruct.subopt_lev=1)
Problem 3 Finite time solution for a 3D PWA system (pwa3d; probStruct.subopt_lev=0; probStruct.norm=1; probStruct.N=4)
Problem 4 Finite-time solution for a 2D LTI system (Double_Integrator; probStruct.norm=1; probStruct.N=7)

Computation of reachable sets

N-step reachable sets, i.e. sets of states which are reachable from a given set of intitial conditions in N steps, can now be computed using mpt_reachSets. Sets can be calculated either for a dynamical system whose inputs are assumed to belong to some bounded set U0 using
  >> sets = mpt_reachSets(sysStruct, X0, U0, N)

or for an explicit controller

  >> sets = mpt_reachSets(ctrl, X0, N)

In the latter case, the system inputs are assumed to be driven by an explicit controller ctrl. For more information discuss help mpt_reachSets.

Improved numerical robustness

It is a known fact that different solvers tend to give slightly different solutions in some tricky cases. MPT2 therefore introduces extensive error checking while solving certain linear and quadratic programs in order to avoid any problems resulting from a buggy behavior of external solvers. If a problem is detected, the given LP (QP) will be automatically solved again with a different solver in order to get a feasible solution. Our tests have shown that this rescue procedure often helps to obtain a solution in cases where the old release failed.

Support for many solvers

MPT2 comes with an extended support for LP, QP, MILP and MIQP solvers. Besides the already supported solvers (CPLEX, NAG, CDD, GLPK, QSopt), we have added support for XPRESS, MOSEK, OOQP, CLP and bintprog. Depending on the problem you are solving, fastest and most reliable solvers will be choosen automatically. If one solver fails to give a proper solution due to numerical problems, another available solver will be tried automatically as described in the numerical robustness section.

Other improvements