10.02.2015 Views

Explicit MPC: Basics, Fast Implementations, Advantages and ...

Explicit MPC: Basics, Fast Implementations, Advantages and ...

Explicit MPC: Basics, Fast Implementations, Advantages and ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>Explicit</strong> <strong>MPC</strong>:<br />

<strong>Basics</strong>, <strong>Fast</strong> <strong>Implementations</strong>, <br />

<strong>Advantages</strong> <strong>and</strong> Limitations<br />

Alberto Bemporad<br />

http://cse.lab.imtlucca.it/~bemporad<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013 1


Outline<br />

• Formulation of linear <strong>MPC</strong> design framework<br />

• Multiparametric quadratic programming (explicit <strong>MPC</strong>)<br />

• An automotive control example<br />

• <strong>Fast</strong> circuit implementations<br />

• Final conclusions (explicit vs implicit <strong>MPC</strong>)<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

2


Finite-­‐time optimal control of linear systems<br />

linear model<br />

<br />

xk+1 = Ax k + Bu k<br />

performance index<br />

y k = Cx k<br />

z =<br />

min x u 0 ,...,u N−1<br />

N Px N +<br />

N−1 <br />

k=0<br />

x k Qx k + u k Ru k<br />

min<br />

2 z Hz + x 0 F z + 1 2 x 0 Yx 0<br />

s.t. Gz ≤ W + Sx 0<br />

z<br />

1<br />

H 0<br />

⎡<br />

⎢<br />

⎣<br />

⎤<br />

u 0<br />

u 1<br />

⎥<br />

. ⎦<br />

u N−1<br />

constraints <br />

<br />

umin ≤ u k ≤ u max<br />

y min ≤ Cx k ≤ y max<br />

(convex) Quadratic Program (QP)<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

3


Linear <strong>MPC</strong> algorithm<br />

@ each sampling step t:<br />

past<br />

future<br />

y k<br />

r(t)<br />

predicted outputs<br />

u k<br />

manipulated<br />

inputs<br />

t t+k t+N<br />

•Measure (or estimate) the current state x(t) <br />

feedback !<br />

• Get the solution z * ={u 0<br />

*,...,u N-1 * } of the QP<br />

min z<br />

s.t.<br />

1<br />

2<br />

z Hz + x (t)F z<br />

Gz ≤ W + Sx(t)<br />

• Apply only u(t)= u 0<br />

*, discard remaining optimal inputs u 1<br />

*,...,u N-1 *<br />

Routinely used in process control, now spreading in automotive/aerospace<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013 4


Requirements for embedded <strong>MPC</strong><br />

1. Speed: fast enough to provide a solution within <br />

short sampling intervals (such as 10-­‐100 ms)<br />

2.Require simple/cheap hardware (microcontroller, <br />

microprocessor, FPGA) <strong>and</strong> little memory to store <br />

problem data <strong>and</strong> code<br />

3.Code simple enough to be verifiable/certifiable<br />

4.Worst-­‐case execution time must be (tightly) estimated for <br />

embedding <strong>MPC</strong> in a real-­‐time platform<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

5


Computing the <strong>MPC</strong> comm<strong>and</strong> action<br />

Algorithms for solving QP on-­‐line given x(t):<br />

min z<br />

1<br />

2<br />

z Hz + x (t)F z<br />

• active set (AS) methods<br />

• interior point (IP) methods<br />

• gradient projection (GP) methods <br />

• conjugate gradient (CG) methods<br />

• alternating direction method of multipliers (ADMM)<br />

s.t. Gz ≤ W + Sx(t)<br />

Quadratic Program (QP)<br />

(the control law u=u(x) is implicitly defined by the QP solver) <br />

Alternative: solve the QP off-­‐line for all x(t) to find the control law <br />

u=u(x) explicitly via multiparametric programming <br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

6


Offline multiparametric QP algorithm<br />

Fix a point x 0 2 X in the parameter space<br />

solve QP to find<br />

z ∗ (x 0 ), λ ∗ (x 0 )<br />

identify active constraints at<br />

form matrices <br />

active constraints:<br />

˜G, ˜W , ˜S<br />

z ∗ (x 0 )<br />

by collecting<br />

˜Gz ∗ (x 0 ) − ˜W − ˜Sx 0 =0<br />

(Bemporad, Morari, Dua, Pistikopoulos, 2002)<br />

min z<br />

s.t.<br />

1<br />

2<br />

z Hz + x F z<br />

Gz ≤ W + Sx<br />

KKT <br />

optimality<br />

conditions:<br />

(1) Hz + Fx+ G λ = 0 (2) ˜Gz − ˜W − ˜Sx =0<br />

(3) λ i (G i z − W i − S i x) = 0 (4) Ĝz ≤ Ŵ + Ŝx<br />

(5) ˜λ i ≥ 0, ˆλ i =0<br />

From (1) : <br />

z = −H −1 (Fx+ ˜G ˜λ)<br />

From (2) : <br />

z(x) =H −1 ˜G ( ˜GH −1 ˜G ) −1 ( ˜W +(˜S + ˜GH −1 F )x) − Fx <br />

In some neighborhood of x 0 , λ <strong>and</strong> z are explicit affine functions of x<br />

(Zafiriou, 1990)<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

7


Multiparametric QP algorithm<br />

• Impose primal <strong>and</strong> dual feasibility:<br />

Ĝz(x) ≤ Ŵ + Ŝx<br />

˜λ(x) ≥ 0<br />

from (4)<br />

from (5)<br />

CR 0<br />

linear inequalities in x !<br />

x-­‐space<br />

• Remove redundant constraints (this requires solving LP’s):<br />

critical region CR 0<br />

• x<br />

0<br />

X<br />

• CR 0 is the set of all <strong>and</strong> only parameters x for which <br />

combination of active constraints at the optimizer<br />

is the optimal <br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

8


Multiparametric QP solvers<br />

Method #1: Split <strong>and</strong> proceed iteratively <br />

(Bemporad, Morari, Dua, Pistikopoulos, 2002)<br />

Method #2: Split <strong>and</strong> proceed iteratively <br />

(Tøndel, Johansen, Bemporad, 2003)<br />

x-­‐space<br />

R 2<br />

R • x 1 0<br />

CR 0<br />

R 3<br />

CR 1<br />

R N R 4<br />

X<br />

add constraint #i<br />

CR 0<br />

CR 0<br />

CR 0<br />

Ĝ i z(x) ≤ Ŵ i + Ŝ i x<br />

˜λ j (x) ≥ 0<br />

remove constraint #j <br />

Method #3: exploit the facet-­‐to-­‐facet property<br />

(Spjøtvold, Kerrigan, Jones, Tøndel, Johansen, 2006) (Spjøtvold, 2008)<br />

Step out ² outside each facet, solve QP, get new region, iterate. (Baotic, 2002)<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

9


Properties of multiparametric QP<br />

z ∗ : X ∗ → R s<br />

(Bemporad, Morari, Dua, Pistikopoulos, 2002)<br />

z ∗ (x) =argmin z<br />

s.t.<br />

1<br />

2<br />

x Hz + x F z<br />

Gz ≤ W + Sx<br />

continuous,<br />

piecewise affine <br />

V ∗ (x) = 1 2 x Yx+min z<br />

s.t.<br />

1<br />

2<br />

x Hz + x F z<br />

Gz ≤ W + Sx<br />

convex, continuous, <br />

piecewise quadratic, <br />

C 1 (if no degeneracy)<br />

Corollary: The linear <strong>MPC</strong> controller is a continuous piecewise affine <br />

function of the state<br />

z ∗ =<br />

⎡<br />

⎢<br />

⎣<br />

u ∗ 0<br />

u ∗ 1<br />

.<br />

u ∗ N−1<br />

⎤<br />

⎥<br />

⎦<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

10


Applicability of explicit <strong>MPC</strong> approach<br />

• Consider the following general <strong>MPC</strong> formulation<br />

min z<br />

N−1 <br />

k=0<br />

1<br />

2 (y k − r(t + k) S(y k − r(t + k))+ 1 2 ∆u k T ∆u k<br />

+(u k − u r (t + k)) V (u k − u r (t + k)) + ρ 2<br />

subj. to x k+1 = Ax k + Bu k + B v v(t + k), k =0,...,N − 1<br />

y k = Cx k + Du k + D v v(t + k), k =0,...,N − 1<br />

u min (t + k) ≤ u k ≤ u max (t + k), k =0,...,N − 1<br />

∆u min (t + k) ≤ ∆u k ≤ ∆u max (t + k), k =0,...,N − 1<br />

y min (t + k) − V min ≤ y k ≤ y max (t + k) + V max , k =1,...,N<br />

• Everything marked in red can be time-­‐varying in explicit <strong>MPC</strong><br />

• Not applicable to time-­‐varying problems (weights <strong>and</strong>/or system matrices)<br />

• Can be extended to hybrid systems (continuity of control law may be lost)<br />

(Bemporad, Borrelli, Morari, 2001) (Mayne, Rakovic, 2002) (Mayne, ECC 2001)<br />

(Borrelli, Baotic, Bemporad, Morari, 2005) (Alessio, Bemporad, 2006)<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

11


Hybrid Toolbox for MATLAB<br />

Features:<br />

• <strong>Explicit</strong> <strong>MPC</strong> control (via multi-­‐parametric programming)<br />

<strong>and</strong> C-­‐code generation<br />

(Bemporad, 2003-­‐2013)<br />

Supported by<br />

• Hybrid models: design, simulation, verification<br />

5000+ download requests<br />

since October 2004<br />

http://cse.lab.imtlucca.it/~bemporad/hybrid/toolbox/<br />

Other good tools: Multiparametric Toolbox (see next talk !)<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

12


<strong>Explicit</strong> <strong>MPC</strong> for idle speed control<br />

(Di Cairano, Yanakiev, Bemporad, Kolmanovsky, Hrovat, 2011)<br />

• Ford pickup truck, V8 4.6L gasoline engine<br />

• Process:<br />

-­‐ 1 output (engine speed) to regulate<br />

-­‐ 2 inputs (airflow, spark advance)<br />

-­‐ input delays<br />

• Objectives <strong>and</strong> specs:<br />

-­‐ regulate engine speed at constant rpm<br />

-­‐ saturation limits on airflow <strong>and</strong> spark<br />

-­‐ lower bound on engine speed (≥450 rpm)<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

13


<strong>Explicit</strong> <strong>MPC</strong> for idle speed -­‐ Experiments<br />

(Di Cairano, Yanakiev, Bemporad, Kolmanovsky, Hrovat, 2011)<br />

• Sampling time = 30 ms<br />

• <strong>Explicit</strong> <strong>MPC</strong> implemented in dSPACE <br />

MicroAutoBox rapid prototyping unit<br />

Load torque (power steering)<br />

• Observer tuning as much important<br />

as tuning of <strong>MPC</strong> weights !<br />

peak reduced by 50%<br />

convergence 10s faster<br />

explicit <strong>MPC</strong><br />

baseline controller (linear)<br />

set-­‐point<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

14


Hardware (ASIC) implementation of explicit <strong>MPC</strong><br />

http://www.mobydic-project.eu/<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

15


continuous functions that are affine over each simplex constitutes an N v -dim<br />

PWA approximation of <strong>MPC</strong> over simplices<br />

P W AS[S] ⊂ PWA[S] ∩ C 0 [S] [19]. Therefore, it is possible to define diffe<br />

• Approximate<br />

independent<br />

a <br />

functions<br />

given linear<br />

belonging<br />

<strong>MPC</strong> controller<br />

to P W<br />

by<br />

AS<br />

using canonical PWA functions <br />

p [S]. By choosing some (arbitrary<br />

over simplicial partitions (PWAS)<br />

(Bemporad, Oliveri, Poggi, Storace , 2011)<br />

these bases, we can regard them as an N v -length vector, say φ(x). Then a sca<br />

is defined as a linear combination of the basis functions as follows<br />

û(x) =<br />

N v<br />

k=1<br />

w k φ k (x) =w φ(x)<br />

Vector w =[w 1 ... w Nv ] determines û uniquely for each given x ∈ S.<br />

approximate <strong>MPC</strong> law<br />

(Julian, Desages, Agamennoni, 1999)<br />

Weights wk optimized off-­‐line <br />

to best approximate a given <strong>MPC</strong> law<br />

September 29, 2010<br />

http://www.mobydic-project.eu/<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

16


PWA approximation of <strong>MPC</strong> over simplices<br />

• Extremely cheap: PWAS functions can be directly implemented <br />

on FPGA, or ASIC (Application Specific Integrated Circuits)<br />

• Extremely fast computations (10-­‐100 nanoseconds)<br />

Computation time [s] Control M p Latency Computation (A - B) time [ns] [s] M Latency online time<br />

fit criterion<br />

(A - B) [ns]<br />

12 0.18187 170 -12 31<br />

0.1818 to compute 170 - 31 <strong>MPC</strong><br />

36 L 2 0.046131 238 -36 45<br />

0.0461 238 - 45<br />

Architecture A: (Xilinx Spartan 3 FPGA)<br />

170 0.022963 272 -170 46 mainly 0.0229 serial 272 - 46<br />

11 0.16797 170 -11 31<br />

0.1679 170 - 31<br />

34 L ∞ Architecture B: MIMO system dynamics<br />

0.046131 238 -34 45<br />

0.0461 238 - 45<br />

fully parallel<br />

1.2 1<br />

160 0.022763 272 -160 46<br />

0.0227 x k+1 = 272 - 46x k +<br />

# partitions<br />

per dimension<br />

Exact explicit <strong>MPC</strong>: 52 regions <br />

383 ns (avg) -­‐ 486 ns (max)<br />

y k =<br />

0 1.1<br />

1 1<br />

x<br />

1 0 k<br />

<br />

0 1<br />

u<br />

1 1 k<br />

subject to saturation on u <strong>and</strong> y<br />

• Closed-­‐loop stability results are available<br />

(Bemporad, Oliveri, Poggi, Storace , 2011)<br />

(Rubagotti, Barcelli, Bemporad, 2012)<br />

✖Curse of dimensionality (with respect to to state dimension)<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

17


Complexity of multiparametric solutions<br />

•The number of regions depends on the number of <br />

possible combinations of active constraints<br />

•Weak dependence on the number of states <strong>and</strong> references<br />

•<strong>Explicit</strong> <strong>MPC</strong> gets less attractive when number of regions grows,<br />

too much memory required, too much time to locate state x(t)<br />

•<strong>Fast</strong> <strong>and</strong> simple on-­‐line QP may be preferable otherwise<br />

<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013 18


<strong>Fast</strong> gradient projection for (dual) QP<br />

• Solve dual QP using fast gradient projection<br />

(Nesterov, 1983)<br />

• Main on-­‐line operations involve only <br />

simple linear algebra<br />

• Using Riccati-­‐like iterations, complexity <br />

per iteration is O(N) [N = prediction horizon]<br />

(Patrinos, Bemporad, IEEE TAC, 2013)<br />

• Tight bounds on maximum number of iterations<br />

• Similar approaches exist<br />

(Richter, Morari, Jones, 2009/2011/2012)<br />

(Giselsson, 2012)<br />

• Dual gradient projection methods for QP work very well in fixed-­‐point !<br />

(Patrinos, Guiggiani, Bemporad, ECC 2013)<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

19


Conclusions<br />

<strong>Explicit</strong> or implicit <br />

CPU time / throughput<br />

worst-­‐case exec estimates<br />

numerical arithmetics<br />

off-­‐line computations<br />

solution quality (feas/opt)<br />

data memory<br />

control code<br />

<strong>Explicit</strong><br />

<strong>MPC</strong><br />

Implicit (=on-­‐line QP)<br />

active <br />

set<br />

interior <br />

point<br />

gradient<br />

projection<br />

problem size small medium large medium<br />

•<strong>Explicit</strong> typically limited 6÷8 free control moves <strong>and</strong> 8÷12 parameters <br />

(states+references)<br />

•Embedded QP methods are preferable otherwise<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

20


Conclusions<br />

Research on QP solution methods started ~60 years ago ...<br />

(Beale, 1955)<br />

... still more research on QP can have an impact in real applications !<br />

A. Bemporad <strong>Explicit</strong> <strong>MPC</strong> -­‐ ECC’13 -­‐ Zurich, July 17, 2013<br />

21

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!