You are on page 1of 40
ECETES0 We znang ECE7850 Lecture 9 Model Predictive Control: Computational Aspects + Model Predictive Control for Constrained Linear Systems - Online Solution to Linear MPC ~ Multiparametric Programming — Explicit Linear MPC - Examples + MPC for Discrete Time Hybrid Systems — Discrete Time Hybrid System Models: General Modeling Framework, Piecewise Affine System, Mixed Logical Dynamical System ~ Online Solution to Hybrid MPC — Explicit Hybrid MPC. — Hybrid MPC Examples ECETES0 We znang Linear MPC Problem > Up = [uea, Yi] + At time #: solve the following N’-horizon optimal control prdblem: Us) © Iplany) + ENS! minty I(x(t), Uo) = Silex) + E pro Lrg. up) subj. to: 2j41 = Aap + Buy, k = 0, dt Arty S by, Aut S by, k Ayty < by, a =2(t) Pr(e(O): — Vw(w(8)) = (ty constroin’ + Polyhedral state/control constraints: Ajay < b,, Autix < bay Aya < by * Cost functions Jy((t),u): 2-norm, 1-norm, oo-norm = 2norm: ehQrry + ofa (ef Qr,+ufRup) Re , x0 , OF% Ae An = Loo-norm: ||Qyrx|lp + 28g (Qxellp + || Ruelly)s ul = 1,0, Q,Q;. R are full column rank matrices Nally = ) rlP fora + frat” — Recall: |la:||, = © |a,| and |||]. = max; |i] a aces LUnear MPC Problem 2 ECETES0 Batch Formulation of Linear MPC + Vector form of prediction model over N horizon: x(t) I 0 0 a B o-- off “ ] i f= a(t)+}| AB i al : : : baal ry AN ANB uv} x = su 3 v k ka it HES) — SBE eR, Ace Met SA BY in J ieee + 2-norm cost function becomes: Jo(:r(0)), Up) =|A7QAUU ! RU, wey 8 i; “aXtl) - QS diag{Q,...,Q,Q/}.Q=0 = : ee BYR 0 Mu ‘oe Mel % QA) \ Batch Formulation of Lineat MPC. We znang (2) ECETES0 We znang + Substituting the expression of V+: x Eee : Jy (a(t), Uo) = (S*x(t) + S"Up)"Q(S* x(t) + S"Up) + Uy" RUp = Uy" ((S")! QS" + RYU o + 207 (HS)? QS"Uy + 27 (((S")" QS" x(t) Se eo eee 0? (t)FUy + x7 (t)¥ x(t) where Gp, wo, Ey,.1(#) are known matrices/vectors at time i. Be Rite StU) [a Batch Forman of near MPC > E ; ) Wo s Snehidg 4 ECETES0 We znang * Py(:(t)) bolls down to a quadratic programming (QP) problem: H FTI UG FY || a(t) (3) ming, Jy(x(t),U a(t) Vula(t)) = Uf. 20] subj. to Gop < wy + Enx(t) — QP with affine constraints is a special class of convex programs, which can be solved very efficiently — Optimization variable is Uy; all parameters are known and constant; ) is the measured state at each time t, which is also known before solving the QP. — MATLAB quadratic programming function: quadprog Batch Formulation of Lineat MPC. x ECETES0 We znang Explicit Linear MPC + Online solution: given .r(t) at each time ¢ compute a control action uj by solving the QP (3) * Offline solution (Explicit MPC): pre-compute the control law Uj(=) for all possible state location «r(t) = =. The online implementation of the controller only involves evaluating the law at a given state wu) = Uj(a(t)) + Simplest case: no state and control constraint =Uj(«(t)) = —H-' FT x(t) + With polyhedral state and control constraints, explicit solution can be obtained through mul- tiparametrix programming xc Linear MPC : ECETES0 We znang + Multiparametric programming problem: mc min, J(,2) « subj.to. Ge Dae Hach, Ftd, Mh nt chan + There exists-a minimizer function v*(:r) that is affine in each partition Veeutd be were fe) = ee > FE Wash, fie + 1h Hash + J*(x) is convex ope |S ety xc Linear MPC 8 eceves0 Wei zmang + Multiparametric Quadratic Programming (mp-QP): = F(x) = min,{v Hv ; subj. to Gu < w+ Sr}; — v(x) = argmin,{v" Hv : subj. to Gu < w+ Se} - Theorem 2 (mp-LP): There exists a polyhedral partition of K such that + J*(x) is continuous, convex, and piecewise quadratic The ge +a Hh prtitin 1 Te= ; + v'() is continuous and piecewise affine vom af Fu%t ty Th partite 4. ' xc Linear MPC ° ECETES0 We znang + Explicit MPC using multiparameteric programming: = 2 norm case: Uj (:r(t)) = argining, {Uf HUp + x(t)" PUp : GoUp < wy + Syx(t)} « can be transformed to standard mp-QP problem with v = Uy + H-'FT x(t). * = explicit MPC law is of the form: Fic) +f if Aya(t) < hy Up (ate) = (8) Fuctt) + fr if Hya(t) < har * can be solved efficiently using Multi-Parametric Toolbox xc Linear MPC 10 ECETES0 Wo zrang — (cc-norm) case: Uj}(«(t)) = argminy, { Jy((t), Up) : Golly < wo + Sye(t)}, where Iua(t)s Un) ="S'NQaaic + WRuulic)s tre Sapir (2) AO terminal test is * Note: min,{[x| : h(c) < 0} min, fe: € > xe > x, h(x) < 0} pet ince min || ma & bet con be eal male * as 7 ME | 6h hixyeo \ £2", Cx V ktxigo « introduce slack variables: (3 a or eres > (Qe, i=1...50 2 [Qzello _, Jk 2 —1Qex), n ef ||Rupljoc ef > [Ruy], sitet bar > [Rul i= 1,...,m —~— Liner vnofualites wrk. £8) 6 j and Ue, Me Expt Linear MPC ecereso we znang + The problem reduces to an optimization problem of the following form: Nat min = tet subj.to Gé afi] 0 v= The target set or initial set S is given as {-s sf > (Xpre,Xpreandx] = pre_function(sysStruct, xX) ; >> [Rsets, Vsets] = mpt_reachSets(sysStruct, x0, U0, N); [Examples forLinear MPC “ ECETES0 We znang ane nr) ase — Left: maximal control invariant set C* can be obtained after 28 iterations (a = >> [Cinf, iterations, Piter] = mpt_maxCtrlset (sysStruct) ;-D Computes c ~ Right: maximal positive invariant set O* for o = 1 >> [Oinf,tstar,fd,isemptypoly] = mpt_infset (A,X, tmax) ; Examples for Linear MPC 18 ecereso we znang + Example 2 Persistent feasibility problem Consider the double integrator system 1 ‘. a(t) +|°] we (40) 0 1 at+y=| with Jj(2y) th Pry, Ure tu) = 22 Qee + ul Ruy, P= 2; = R?, subject to the input constraints —0.5 < ulk) $0.5,k =0,. (11) and the state constraints (12) Examples for Linear MPC 16 ECETES0 — % is not control invariant; ~ state in X) \ O” are not persistently feasible as shown in the right figure. We znang 1 >> ctrl = apt_control (sysStruct , probStruct); 2 >> invCtrl = mpt_invariantSet (ctrl); 2 >> [X,U, cost, trajectory]=mpt_plotTrajectory(ctrl); [Examples forLinear MPC v ECETES0 We znang — Choose «V; as control invariant set (obtained through LQR) - MPC problem is persistently feasible. + >> [K,P,E] = dlgr(sysStruct .A, sysStruct .B, probStruct .Q, probStruct.R) ; 2 >> [Oinf,tstar,fd,isemptypoly] = mpt_infset (sysStruct.A-sysStruct .B4K,X, vmax 3 >> ctrl = mpt_control(sysStruct , probStruct) ; Examples for Linear MPC 1% ECETES0 We znang + Example 3 Receding Horizon Control of Constrained Linear Systems: Consider the double integrator system (10) with the input constraints —1> probStruct..Tconstraint = 0; Examples for Linear MPC 2% ECETES0 ~ Case 4: p inf, N =5, Vy = X, i.e, no terminal state constraints, Evoton of sates We znang voit of ututs 0 Hw ww Somping instances ‘Sonping instances Evouton cf cnt moves ‘etre dance al Ey ’ z go 5 + The size of feasible regions is independent of norm (Case 3 and Case 4). + Comparing feasible regions 1): case 4 = case 3 > case 2 > case 1 Examples for Linear MPC 2 EcETES0 Wo zrang Hybrid System Models + Piecewise affine (PWA) systems a-space a(t +1) = AMa(t) + But) + flO y(t) = oie () bene) + gi ~ state: U4) eR" cnimuors — control: u(t) € R" = output: y(t) © R” — mode: i(t) € £4 {1,...M} Uv Hybrid System Models 2% ECETES0 Wo zrang + Discrete hybrid automaton (DHA) ~ connection of a finite state machine (FSM) and a switched affine system (SAS), through a mode selector (MS) and an event generator (EG). Hybrid System Models ~ eceves0 — Switched Affine System (SAS) r(t+1) = AMa,(t) + BOu(t) + fo elt) = CMa, (t) + DO u(t) + gi +1 ER", u ER", yee RY, i(t) eL* {1,... 5} ~ Event Generator (EG) Event generated by function of state and control input: Meme Ras oedd.niy) VR XR > fh} Ll ifWe.+ Jue+ K' <0 Ai (ae, te) = 0 if Hx, + Su+ Ki >0 where 4,(t) € {0,1}". Hybrid System Models We znang (13) (14) (15) a ecereso we znang ~ Finite State Machine (FSM): binary state of the finite state machine evolves according to a Boolean state update function: BEE Boston -finctim — saqpose {; is beoleey * x6} vecbn x(t +1) = filei(t), w(t), de(t)) & - My, 2, LHe) ult) = ale 1), u(t), 6.(0)) & Rep Ny, P; where x, € {0, 1}" is the binary state, u; € {0,1} is the exojohous Tee input, 6. (t) is v Conjunctive ortmel ~forin CONF) the endogenous binary input coming from the EG ~ Mode Selector (MS) a(t) = fuglai(t), u(t).6.(0)) (17) v Boolean —furc ten a where i(t) {0,1}, 7 = [los s] Hybrid System Models = ECETES0 We znang — DHA Trajectories 1.(0) (0) the state .r(1) of the system evolves according to: c(t) Me ny t Rr x {0,1}, and inputs | 7) For a given initial condition [ eR x {0,1}", 5,(t) = (elt), welt), t) ) = Fuslai(t), w(t), 0.(6)) yet) = Ca (t) + D'Ou(t) +g (t) = gilar(t), u(t), de(2)) re(t+1) = A'Ox,(t) + BOug a(t +1) = filet), u(t), 6(0)) (18) te po Hybrid System Models 2 ECETES0 We znang + Proposition: Any logic formula involving Boolean variables and linear combinations of con- tinuous variables can be translated into a set of (mixed-integer linear (in)equalities = e.g: XV XP=TRUE + 6,45) >1,61,8 € {0,1} oui ALE a 4 — FSM and Mode selector: any logic statement f(.X) = TRUE can be written! Sien, 6: + Sien,(1—6)) > 1, M2 ¥ppte bound os: ht : 1 lowte bal of hil) t « (1-6) 21174 € =| [; (Vier, Xi Vien, >X:) Nj, Py C(,--n} ae Wee tie Shes) ¢0 ~ Event generator: [6(t) <1) [Hxt) <)> Jy SF 7 es : te 8D AS ag) mi s wh. “sd ng ~ Switched affine system: Ty géc0 7 (m—M)b+2 lewpsmt if (6 =I thenz =ale+blut fi (m — My)5 — 2 < —af x — bfu— fo Etats» else z= aha+blut fo (m, — My)(1—-6) +2 Safe+bfut fh (my — M,)(1— 6) — 2 < ala — bu fr Hybrid System Models ECETES0 We znang + All DHA blocks can be translated into (mixed)integer linear equalities and inequalities + This leads to the so-called Mixed Logical Dynamical (MLD) System a(t +1) = Ax(t) + Byu(t) + By6(t) + Bya(t) + Bs u(t) = Cx(t) + Diu(t) + D2d(t) + Dsz(t) + Ds (19) Ey6(t) + Bya(t) < Eyult) + Bxe(t) + Bs re RM x {0,1)", we RM x 40,17", y © R% x {0,1}, 6 {0, 1p", 2 eR’ Theorem 3 MLD and PWA are Equivalent in the sense that given a MLD (resp. PWA), one can always find a corresponding PWA (resp. MLD) model which produces the same output under the same initial state and control inputs. + For MPC problems, MLD is better suited for online optimization while PWA is more appro- priate for explicit MPC. Hybrid System Models a ECETES0 We znang + HYSDEL Modeling Language: A modeling language describing DHA models SYSTEM sample { INTERFACE { STATE { x REAL xx [-10, 10]; } meur¢ ~~ REAL ur (22, 21; + et IMPLEMENTATION {« AUX Le addition variables REAL 21, 22, 23; BOOL de, af, dl, a2, a3; } re(t) + uc(t)—1, if SAS: 2%(t) = 2 2re(t), if 2, if ga: f &(t) =[e(t) 20) AD {€ At.0 Continuous to ditcrete) p(t) = [are(t) + uel 1 > 0 de = xr >= 0; : df = xr + ur - 1 >= 0; PEt ‘sil = “ Sueno rce & “af; MS: a(t) =4 2 i 5 aa-ctaer see lide ° a : 3 it [563] = 101. pace dete Ei Satins zi = {IF di THEN xr + ur - 1 }; z2 = {IF d2 THEN 2 * xr }; 23 = {IF (“de & df) THEN 2}; } CONTINUOUS { xr = zi + 22+ 23; } a Hybrid System Models se ECETES0 We znang MPC of Hybrid Systems ln + 2-norm case: , me sain, H(e(t), Ua) = AhQLY + ENG} (2 Qe + uf Ru) on subj. to. MLD (19) which can be reduced to TPE + a(t)TY a(t) fe ETHE + 2x( oy subj.to GE < W + Sr(t) where € (0t0, 065 tuy ay boy 5x vaya}. This is Mixed Integer Quadratic Pro- gramming (MIQP) problem. [MPC of Hybrid Systems 38 ECETES0 We znang + oc-norm case: a I(e(t), Uo) = ERGY (Qe loo + [Retell oo) (22) subj. to. MLD (19) — introduce slack variables: > [Qu G2 [Qn _, Je > Ql > [Rusllo ~ Jet > (Ru 6 2 — [Ru — The problem reduces to an optimization problem of the following form: NST ery en min Sef +e | u E +e (23) where € = {ef,.2 5651s sees Woy oy Uys Ops 0+ ON 20) ENP Linear ~ This is Mixed Integer Quadratic Programming (MILP) problem. [MPC of Hybrid Systems Py ECETES0 We znang + Problems (21) and (23) can be solved online using MIQP and MILP solvers. + Explicit MPC solutions can also be computed offline using multiparametric MIQP (mp-MIQP) meeparamene and multiparametric MILP (mp-MILP). + Explicit Hybrid MPC: The hybrid MPC controller is piecewise affine Fa(t)+g: — if2(t) € partition 1 Up (a(t) = 43 Fyrx(t)+ gar if x(t) € partition M In the 2-norm case, the partition may not be polyhedral he 2-norm case, the partition may not be polyhedra N IME to he inkepor yorable [MPC of Hybrid Systems 6 ecereso we znang + Example 4 Example for Hybrid MPC Consider the following PWA system cos.a(t) —sina(t) sina(t) cosa(t) yt) =[0 1] u(t) _ fi #[1 o]e@) 20 no =| = if {1 o]a() <0 s0-+1)=0s| a+ {°] ute U1] subject to the input and state constraints -5 5 k=0, (24) 5 5 Jsxs| -1< u(k) <1,k =0, (25) [MPC of Hybrid Systems 36 ECETES0 — Case 1: p , Ky = R’, i.e, no terminal state constraints, We znang vou of ets ad eal Sonpingivonces —”Sapinpinstnces Evourencteorvemores atv namics oa| =] | en #7 oa Bo aa a of MW} as 7 Bette eee ° Somping stances ‘Sonoing mstncee ~ The feasible region .%) is divided into 44 polytope regions. >>probStruct norm = 2 >>probStruct .N = 3; >>probStruct.Tconstraint = 0; >>ctrl= mpt_control(sysStruct, probStruct) ; >>plot (ctrl Pa) ; >>simplot (ctrl , x0, WSteps) ; [MPC of Hybrid Systems st ECETES0 wo me — Case 2: p = inf, A’ = |—0.01, 0.01] x (0.01, 0.01), ) i i ed SEE eeee ater eee eee |_eeund oe favre 1] oa a a oe Teese ~ The feasible region 4% is divided into 84 polytope regions. >>probStruct.Tconstraint = 2; >>X_f=polytope (Leye (2) ;~eye(2)], [0.01}0.0150.0150.01]); >>probStruct.Tset=X_f; >>ctrl= mpt_control(sysStruct, probStruct) ; [MPC of Hybrid Systems 38 ECETES0 ~ Case 3: p We znang Eoin fututs ‘oe mm wd Sang mabe Sania nore ect oe Re ts 2 Ml ‘, B — The feasible region %, is divided into 92 polytope regions. } >>ctrl= mpt_control(sysStruct, probStruct) ; 2 >oplot (ctrl. Pn); 3 >>simplot (ctrl ,x0,NSteps) ; [MPC of Hybrid Systems We znang ECETES0 Value function over 92 regions ve 1 >>mpt_plotJ (ctrl); 2 >>mpt_plotU (ctr); 3 >>[aQi,dLi,dC1, feasible, drho]=mpt_getPWOLyapFet (ctrl); piecewise quadratic Lyapunov function heompute a [MPC of Hybrid Systems

You might also like