Main /

FAQ

What are the main reasons why I should upgrade to MPT3?

  1. New geometric library, which supports unbounded and lower-dimensional polyhedra, among other things.
  2. Novel parametric optimization solver with improved numerical reliability.
  3. Reworked user interface which gives greater control over specifying MPC problems.

How can I help?

Use MPT3 and report bugs. We will be grateful for your feedback and will do our best to address your concerns and/or answer questions.

Why is MPT3 slower than MPT2?

MPT2 was tuned for speed, which resulted in an incredibly messy code that was difficult to maintain and extend. Our goal for MPT3 was to have a code base which is sustainable in the long term, and hence contains a minimum of speed-hacks. We definitely plan to make MPT3 faster in the future.

How can I make MPT3 run faster?

One option to improve the speed of MPT3 is to employ external commercial solvers to solve the low-level optimization problems. In MPT3 we provide interfaces and support the following external optimization solvers:

If the external solver is available on the Matlab path, MPT3 will detect it automatically using the initialization script mpt_init. The new solver will be assigned a higher priority and can be then used for computations.

How can I control which solver is used in low-level optimization problems?

When calling the initialization script mpt_init, MPT3 searches for available solvers on the Matlab path and assigns them priorities according to our performance results on various tests cases. If you want to give preference to a different solver, one can use mptopt class to handle the global MPT3 options. For instance, selecting LCP solver as default LP and QP solver is achieved by

mptopt('lpsolver', 'LCP', 'qpsolver', 'LCP')

In this example we set CDD as default LP solver and QUADPROG as default QP solver

mptopt('lpsolver', 'CDD', 'qpsolver', 'QUADPROG')

When selecting the solver, one has to choose from the list of solvers that are available on the Matlab path. The list of available solvers is stored in mptopt class:

options = mptopt;
options.solvers_list

Resetting to default values is achieved by calling mpt_init script.

Can I load objects saved in MPT2?

Yes. MPT3 contains a thin compatibility layer which will convert polytope and mptctrl objects of MPT2 to the new format.

I have a custom algorithm built around the MPT2's polytope object. Will my code work?

It should thanks to the thin compatibility layer. If you experience problems, just let us know. However, you should start rewriting your algorithms in terms of the more powerful Polyhedron object.

What should I know about the new Polyhedron class, which replaces polytope from MPT2?

  • The syntax is P = Polyhedron(A, b) to construct a polyhedron using a H-representation, and P = Polyhedron(V) to construct it from vertices.
  • Redundant constraints are not removed by default. Use P.minHRep() to perform redundancy elimination.
  • The Polyhedron object can also represent lower-dimensional polyhedra. To determine whether a polyhedron is empty (i.e., there is no point x \in P), use the P.isEmptySet() method. To determine whether a polyhedron is fully dimensional, use P.isFullDim().

What is the equivalent of mpt_control(sysStruct, probStruct) in MPT3?

Use the MPCController class, see MigrationFromMPT2 and UI.Control.

mpt_import complains that minimum-time setups cannot be automatically imported. How do I construct an explicit minimum-time controller in MPT3?

Use ctrl = EMinTimeController(model) to construct explicit minimum-time controllers.

How do I plot regions of an explicit controller?

expctrl.partition.plot()

How do I plot the explicit feedback law?

expctrl.feedback.fplot()

How do I plot the optimal cost function?

expctrl.cost.fplot()

p. (Notice that the correct method is fplot, not plot!)

How do I extract data of the explicit optimizer {$ u = F_i x + g_i$} if {$ A_i x \le b_i $}

We will assume that your explicit optimizer is stored in the optimizer variable, which is an instance of the PolyUnion class. Then:

F = {}; g = {};
A = {}; b = {};
for i = 1:optimizer.Num
        F{i} = optimizer.Set(i).Functions('primal').F;
        g{i} = optimizer.Set(i).Functions('primal').g;
        A{i} = optimizer.Set(i).A;
        b{i} = optimizer.Set(i).b;
end

Note that you can access the optimizer of an explicit MPC controller via explicit_controller.optimizer.

How do I extract data of the explicit cost function {$ J(x) = x^T H_i x + F_i x + g_i$} if {$ A_i x \le b_i $}

We will assume that your explicit optimizer is stored in the optimizer variable, which is an instance of the PolyUnion class (for explicit MPC controllers the optimizer is available in controller.optimizer). Then:

H = {}; F = {}; g = {};
A = {}; b = {};
for i = 1:optimizer.Num
        if isa(optimizer.Set(i).Functions('obj'), 'QuadFunction')
                H{i} = optimizer.Set(i).Functions('obj').H;
        end
        F{i} = optimizer.Set(i).Functions('obj').F;
        g{i} = optimizer.Set(i).Functions('obj').g;
        A{i} = optimizer.Set(i).A;
        b{i} = optimizer.Set(i).b;
end

How do I recompile the LCP mex solver?

First, make sure you have a working mex compiler. Then run the following commands:

cwd = pwd;
cd(fileparts(which('lcp')))
lcp_compile;
cd(cwd)

Afterwards, re-initialize MPT by running mpt_init and all should work fine.