Main /

FAQ

Main.FAQ History

Hide minor edits - Show changes to output

Added lines 114-124:

!!! How do I recompile the LCP mex solver?

First, make sure you have a working mex compiler. Then run the following commands:
(:source lang=MATLAB -getcode:) [@
cwd = pwd;
cd(fileparts(which('lcp')))
lcp_compile;
cd(cwd)
@]
Afterwards, re-initialize MPT by running @@mpt_init@@ and all should work fine.
Changed lines 98-99 from:
!!! How do I extract data of the explicit cost function {$ J = x^T H_i x + F_i x + g_i$} if {$ A_i x \le b_i $}
to:
!!! 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 $}
Deleted lines 113-114:

Note that you can access the optimizer of an explicit MPC controller via @@explicit_controller.optimizer@@.
Added lines 90-109:
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@@.

[[#extract-cost]]
!!! How do I extract data of the explicit cost function {$ J = 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:
(:source lang=MATLAB -getcode:) [@
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;
April 25, 2014, at 01:59 PM by 129.132.52.158 -
Added lines 21-36:

!!! 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
(:source lang=MATLAB -getcode:) [@
mptopt('lpsolver', 'LCP', 'qpsolver', 'LCP')
@]
In this example we set CDD as default LP solver and QUADPROG as default QP solver
(:source lang=MATLAB -getcode:) [@
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:
(:source lang=MATLAB -getcode:) [@
options = mptopt;
options.solvers_list
@]
Resetting to default values is achieved by calling @@mpt_init@@ script.
April 25, 2014, at 01:41 PM by 129.132.52.158 -
Added line 20:
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.
April 25, 2014, at 01:34 PM by 129.132.52.158 -
Changed lines 17-19 from:
* %newwin% [[http://www.gurobi.com | GUROBI optimizer]] %
* %newwin% [[http://www-01.ibm.com/software/commerce/optimization/cplex-optimizer/ | IBM CPLEX optimizer]] %
* %newwin% [[http://www.nag.com/numeric/MB/start.asp | NAG toolbox for Matlab]] %
to:
* %newwin% [[http://www.gurobi.com | GUROBI optimizer]] %%
* %newwin% [[http://www-01.ibm.com/software/commerce/optimization/cplex-optimizer/ | IBM CPLEX optimizer]] %%
* %newwin% [[http://www.nag.com/numeric/MB/start.asp | NAG toolbox for Matlab]] %%
April 25, 2014, at 01:33 PM by 129.132.52.158 -
Added lines 14-19:

!!! 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:
* %newwin% [[http://www.gurobi.com | GUROBI optimizer]] %
* %newwin% [[http://www-01.ibm.com/software/commerce/optimization/cplex-optimizer/ | IBM CPLEX optimizer]] %
* %newwin% [[http://www.nag.com/numeric/MB/start.asp | NAG toolbox for Matlab]] %
Changed line 57 from:
to:
[[#extract-optimizer]]
Changed lines 58-60 from:
!!! How do I extract data of the explicit feedback law @@u = Fi*x+gi@@?

We will assume that your explicit controller is stored in the @@expctrl@@ variable.
Then:
to:
!!! 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:
Changed lines 63-65 from:
for i = 1:expctrl.optimizer.Num
F
{i} = expctrl.optimizer.Set(i).Functions('primal').F;
g
{i} = expctrl.optimizer.Set(i).Functions('primal').g;
to:
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
;
Changed lines 70-72 from:
@]
to:
@]

Note that you can access the optimizer of an explicit MPC controller via @@explicit_controller.optimizer@@.
August 06, 2013, at 07:43 PM by Michal Kvasnica -
Changed lines 21-22 from:
It should due to the [[BackwardsCompatibility|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.
to:
It should thanks to the [[BackwardsCompatibility|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.
Changed lines 25-26 from:
* The syntax is the same, i.e., @@P = Polyhedron(H, K)@@ 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.convexHull()@@ to perform redundancy elimination.
to:
* 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.
July 26, 2013, at 07:46 PM by Michal Kvasnica -
Changed lines 63-65 from:
for i = 1:expctrl.feedback.Num
F{i} = expctrl.feedback.Set(i).Functions('primal').F;
g{i} = expctrl.feedback.Set(i).Functions('primal').g;
to:
for i = 1:expctrl.optimizer.Num
F{i} = expctrl.optimizer.Set(i).Functions('primal').F;
g{i} = expctrl.optimizer.Set(i).Functions('primal').g;
July 26, 2013, at 07:45 PM by Michal Kvasnica -
Changed lines 64-65 from:
F{i} = expctrl.feedback.Set(i).Func{1}.F;
g{i} = expctrl.feedback.Set(i).Func{1}.g;
to:
F{i} = expctrl.feedback.Set(i).Functions('primal').F;
g{i} = expctrl.feedback.Set(i).Functions('primal').g;
May 23, 2013, at 08:21 PM by Michal Kvasnica -
Added lines 1-67:
!!! What are the main reasons why I should upgrade to MPT3?

# New geometric library, which supports unbounded and lower-dimensional polyhedra, among other things.
# Novel parametric optimization solver with improved numerical reliability.
# 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.

!!! Can I load objects saved in MPT2?

Yes. MPT3 contains a [[BackwardsCompatibility|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 due to the [[BackwardsCompatibility|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 the same, i.e., @@P = Polyhedron(H, K)@@ 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.convexHull()@@ 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?

(:source lang=MATLAB -getcode:) [@
expctrl.partition.plot()
@]

!!! How do I plot the explicit feedback law?

(:source lang=MATLAB -getcode:) [@
expctrl.feedback.fplot()
@]

!!! How do I plot the optimal cost function?

(:source lang=MATLAB -getcode:) [@
expctrl.cost.fplot()
@]

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


!!! How do I extract data of the explicit feedback law @@u = Fi*x+gi@@?

We will assume that your explicit controller is stored in the @@expctrl@@ variable. Then:
(:source lang=MATLAB -getcode:) [@
F = {}; g = {};
for i = 1:expctrl.feedback.Num
F{i} = expctrl.feedback.Set(i).Func{1}.F;
g{i} = expctrl.feedback.Set(i).Func{1}.g;
end
@]