Hybrid MPC

83
05 - (C) 2017 A. Bemporad - “Model Predictive Control” course 1 Hybrid Systems: Model Predictive Control Alberto Bemporad - “Model Predictive Control” course - Academic year 2016/17

Transcript of Hybrid MPC

Page 1: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 1

Hybrid Systems: Model Predictive Control

Alberto Bemporad - “Model Predictive Control” course - Academic year 2016/17

Page 2: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

MPC of hybrid systems

Useahybriddynamicalmodeloftheprocesstopredictitsfutureevolutionandchoosethe“best”controlaction

processmodel-basedoptimizer

reference outputcontrolinput

measurements

r(t) u(t) y(t)

8><

>:

xk+1 = Axk +B1uk +B2k +B3zk +B5yk = Cxk +D1uk +D2k +D3zk +D5

E2k + E3zk E4xk + E1uk + E5

2

Page 3: Hybrid MPC

wheretheequilibriumconditionisobtainedbysolvingthefollowingmixed-integerfeasibilityproblem

•Attimetsolvethefinite-horizonoptimalcontrolproblemw.r.t. U ,

2

64u0...

uN1

3

75

minu0,...,uN1

N1X

k=0kyk rk2Q + kuk urk2R

+kk rk2 + kzk zrk2 + kxk xrk2

subject to MLD equations

x0 = x(t)

xN = xr

kvk2Q , v0Qv

8><

>:

xr = Axr +B1ur +B2r +B3zrr = Cxr +D1ur +D2r +D3zr

E2r + E3zr E4xr + E1ur + E5

Q,R 0, > 0

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 3

HybridModelPredictiveControlMPC for hybrid systems

•Applyonlyu(t)=u0*(discardtheremainingoptimalinputs)•Attimet+1:getnewmeasurements,repeatoptimization

(xr, ur, r, zr)

notation:

Page 4: Hybrid MPC

min

N1X

k=0

y0kQyk + u0kRuk

s.t.

8<

:

xk+1 = Axk +B1uk +B2k +B3zk +B5yk = Cxk +D1uk +D2k +D3zk +D5

E2k + E3zk E4xk + E1uk + E5

min

1

20H + x

0(t)F +1

2x0(t)Y x(t)

s.t. G W + Sx(t)

= [u0, . . . , uN1, 0, . . . , N1, z0, . . . , zN1]

u Rmc 0,1mb

0,1rbz Rrc

R(mc+rc)N 0,1(mb+rb)N

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 4

MIQPFormulationofMPCMIQP formulation of MPC

MixedIntegerQuadraticProgram(MIQP)

(Bemporad,Morari,1999)

•Optimizationvector:

vectorξhasbothrealandbinaryvalues

Page 5: Hybrid MPC

8Q,R 0, 8 > 0

limt!1

y(t) = r

limt!1

u(t) = ur

limt!1

x(t) = xr

limt!1

(t) = r

limt!1

z(t) = zr

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 5

Closed-loopConvergenceClosed-loop convergence

Proof:EasilyfollowsfromstandardLyapunovarguments(Bemporad,Morari1999)

TheoremLetbetheequilibriumvaluescorrespondingtosetpointr.Assumex(0)issuchthattheMPCproblemisfeasibleattimet=0.

Thentheclosed-loophybridMPCloopconvergesasymptotically

andallconstraintsarefulfilledateachtimet≥0.

(xr, ur, r, zr)

(Lazar,Heemels,Weiland,Bemporad,2006)

Lyapunovasymptoticstabilityandexponentialstabilitycanbeguaranteedbychoosingaproperterminalcostandconstraintset

Page 6: Hybrid MPC

• Byconstructionisfeasible@t+1,asitsatisfiesallMLDconstraintsandterminalconstraint

• SinceR,Q>0,,andallothervariablesconverge.

• ismonotonicallydecreasingand≥0,so

• Thecostofis

• Letbetheoptimalsequence@t

V (x(t)) 9 limt!1

V (x(t)) , V1

V (x(t)) ky(t) rk2Q ku urk2R

k(t) rk2 + kz(t) zrk2 + kx(t) xrk2

V (x(t+1))

k(t) rk2, kz(t) zrk2, kx(t) xrk2 ! 0ky(t) rk2Q, ku(t) urk2R

limt!1

y(t) = r, limt!1

u(t) = ur

t = [ut0, . . . , utN1,

t0, . . . ,

tN1, z

t0, . . . , z

tN1]

t+1

t+1 = [ut1, . . . , u

tN1, ur,

t1, . . . ,

tN1, r, z

t1, . . . , z

tN1, zr]

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 6

Convergence proof

Globaloptimumisnotneededtoproveconvergence!

Mainidea:UsevaluefunctionV*(x(t))asaLyapunovfunction

• Henceand

Page 7: Hybrid MPC

min

N1X

k=0

kQykk1 + kRukk1

s.t.

8<

:

xk+1 = Axk +B1uk +B2k +B3zk +B5yk = Cxk +D1uk +D2k +D3zk +D5

E2k + E3zk E4xk + E1uk + E5

minx, s.t. x, x

minx

|x|

yk ±Qiyk i = 1, . . . ,my k = 0, . . . , N 1uk ±Riuk i = 1, . . . ,mu k = 0, . . . , N 1

yk kQykk1uk kRukk1

Q 2 Rmyny

R 2 Rmunu

= [y0, . . . , yN1,

u0, . . . ,

uN1, u0, . . . , uN1, 0, . . . , N1, z0, . . . , zN1]

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 7

MIQPFormulationofMPCMILP formulation of MPC(Bemporad,Borrelli,Morari,2000)

MixedIntegerLinearProgram(MILP)

•Optimizationvector:

•Introduceslackvariables:

min

N1X

k=0

yk + uk

s.t. G W + Sx(t)

vectorξ hasbothrealandbinaryvalues

Page 8: Hybrid MPC

3

3

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 8

HybridMPC-ExampleHybrid MPC example

open-loopsimulation

PWAsystem:

constraints:

gotodemo/demos/hybrid/bm99sim.m

α

Page 9: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 9

HybridMPC-ExampleHybrid MPC example

/demos/hybrid/bm99.hys

/* 2x2 PWA system - Example from the paper A. Bemporad and M. Morari, ``Control of systems integrating logic, dynamics, and constraints,'' Automatica, vol. 35, no. 3, pp. 407-427, 1999. (C) 2003 by A. Bemporad, 2003 */

SYSTEM pwa INTERFACE STATE REAL x1 [-10,10]; REAL x2 [-10,10];

INPUT REAL u [-1.1,1.1];

OUTPUT REAL y;

PARAMETER REAL alpha = 1.0472; /* 60 deg in radiants */ REAL C = cos(alpha); REAL S = sin(alpha);

IMPLEMENTATION AUX REAL z1,z2; BOOL sign; AD sign = x1<=0;

DA z1 = IF sign THEN 0.8*(C*x1+S*x2) ELSE 0.8*(C*x1-S*x2) ; z2 = IF sign THEN 0.8*(-S*x1+C*x2) ELSE 0.8*(S*x1+C*x2) ; CONTINUOUS x1 = z1; x2 = z2+u;

OUTPUT y = x2;

HYSDELmodel

Page 10: Hybrid MPC

min2X

k=1|yk r(t)|

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 10

HybridMPC-ExampleHybrid MPC example

closed-loop:

performanceindex:

zeta

state

output ref

output & ref

input

delta

Hybrid MLD SystemHybrid Controller

2

2

2

2

2

2

Page 11: Hybrid MPC

min2X

k=0kx2k r(t)k1

s.t.

(x1k 25, k = 1,2MLD model

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 11

Hybrid MPC – Temperature control

>>[XX,UU,DD,ZZ,TT]=sim(C,S,r,x0,Tstop);

>>C=hybcon(S,Q,N,limits,refs);

>>refs.x=2; % just weight state #2>>Q.x=1; % unit weight on state #2>>Q.rho=Inf; % hard constraints>>Q.norm=Inf; % infinity norms>>N=2; % prediction horizon>>limits.xmin=[25;-Inf];

>> C

Hybrid controller based on MLD model S <heatcoolmodel.hys> [Inf-norm]

2 state measurement(s) 0 output reference(s) 0 input reference(s) 1 state reference(s) 0 reference(s) on auxiliary continuous z-variables 20 optimization variable(s) (8 continuous, 12 binary) 46 mixed-integer linear inequalitiessampling time = 0.5, MILP solver = 'glpk' Type "struct(C)" for more details.>>

Page 12: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 12

Hybrid MPC – Temperature control

Page 13: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 13

Mixed-IntegerProgramSolversMixed-Integer Program (MIP) solvers

BUT

•Generalpurposebranch&bound/branch&cutsolversavailableforMILP

andMIQP(CPLEX,GLPK,Xpress-MP,CBC,Gurobi,...)

•Noneedtoreachglobaloptimum(seeproofofthetheorem),althoughperformancedeteriorates

http://plato.la.asu.edu/bench.htmlMoresolversandbenchmarks:

•Mixed-IntegerProgrammingisNP-complete

Page 14: Hybrid MPC

•QPalgorithmbasedonNNLSisextendedheretohandle- equalityconstraints- bilateralconstraints- warm-starts

minz

V (z) , 1

2z0Qz + c0z

s.t. ` Az u

Gz = g

Aiz 2 ¯i, ui, i = 1, . . . , q

Q = Q0 0

¯i Aiz ui

¯i = 0, ui = 1, Ai = [0 . . .0 1 0 . . .0]

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Branch & Bound for MIQP (Using NNLS solver for QP)•WeconsideraMIQPproblemofthefollowingform

14

•Binaryconstraintsonzareaspecialcase:

sotosolveMIQPrelaxations()veryefficiently

(Bemporad,NMPC,2015)

Page 15: Hybrid MPC

Aiz 2 ¯i, ui8i = 1, . . . , q

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Branch & Bound for MIQP (Using NNLS solver for QP)

15

•Branchandboundscheme:

QP0

minz

V (z) , 1

2z0Qz + c0z

s.t. ` Az u

Gz = g

¯ Az u

QPinfeasible

?

no yesMIQPinfeasible

integerfeasible

?

MIQPsolutionfound

startbranching...

(lucky case)(lucky case)

(typical case)

yes

no

QP relaxation

Page 16: Hybrid MPC

minz

V (z) , 1

2z0Qz + c0z

s.t. ` Az u

Gz = g

Aiz = ¯i¯j Ajz uj, j 6= i min

zV (z) , 1

2z0Qz + c0z

s.t. ` Az u

Gz = g

Aiz = ui¯j Ajz uj, j 6= i

Aiz¯i+ui

2 ¯i ui

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Branch & Bound for MIQP (Using NNLS solver for QP)

16

•Branching:pickupindexisuchthatisclosestto

QP0

minz

V (z) , 1

2z0Qz + c0z

s.t. ` Az u

Gz = g

¯ Az u

QP1 QP2

•SolvetwonewQPproblems:

x

WarmstartfromprevioussolutionofQP0heavilyexploitedinsolvingQP1,QP2!

Page 17: Hybrid MPC

updateupperbound

onMIQPsolution

V0 V

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Branch & Bound for MIQP (Using NNLS solver for QP)

17

QP0

QP1 QP2

QPinfeasible

?

no

yes

integerfeasible

?

keepbranching...

no

stopbranchingonsubtree

yes

Page 18: Hybrid MPC

upperbound

onMIQPisavailable

V0 V

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Branch & Bound for MIQP (Using NNLS solver for QP)

18

QP0

QP1 QP2

optimum>=V0 ?

keepbranching...

no

yes

stopbranching!(addingfurtherequality

constraintscanonlyincreasetheoptimalcost)

Page 19: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Branch & Bound for MIQP (Using NNLS solver for QP)

19

• LowerboundVonoptimalsolutionofQPrelaxationareimmediatelyavailableduringtheiterationsoftheQPalgorithm(dualcost)

This saves a lot of QP active set iterations !

•Whennofurtherbranchingispossible,eithertheMIQPproblemisrecognizedinfeasibleortheoptimalsolutionhasbeenfound

V V0stopsolvingQPrelaxation(andfurtherbranching)if

Page 20: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

MIQP via NNLS: Numerical results

20

QPalgorithmincompiledEmbeddedMATLABcode,B&BininterpretedMATLABcode.CPUtimemeasuredonthisMac

(NNLSLDL in the table) of

MP`d`P`

MPu duPuN f

M 0

P`M 0

PuN 0

d0`P`

d0uPu

f 0

recursively as described in (Bemporad, 2015b) when the

dimension of vectorh

y`yu

iis smaller or equal than n, and,

for improved numerical robustness, QR factorization incase more than n elements must be optimized in Prob-lem (4). As an alternative, we purely updated the QRfactorization of the same matrix (NNLSQR in the table)recursively as described in (Lawson and Hanson, 1974,Chap. 24, Method 1).

n m q NNLSLDL NNLSQR GUROBI CPLEX10 5 2 2.3 1.2 1.4 8.010 100 2 5.7 3.3 6.1 31.450 25 5 4.2 6.1 14.1 30.150 200 10 68.8 104.4 114.6 294.1

100 50 2 4.6 10.2 37.2 69.2100 200 15 137.5 365.7 259.8 547.8150 100 5 15.6 49.2 157.2 260.1150 300 20 1174.4 3970.4 1296.1 2123.9

Table 1. Worst-case CPU time (ms) on randomMIQP problems over 20 instances for each

combination of n, m, q.

It is apparent that on such a set of random MIQPproblems, Algorithm 2 performs comparably well withrespect to the commercial solvers GUROBI and CPLEX,especially when the number q of binary constraints is smallcompared to n and m, probably due to the pure B&Bnature of Algorithm 2.

The results shown in Table 2 are obtained, under the sameconditions, on purely binary quadratic programs (n = q,m = 5n). When turning the presolver on, in GUROBI andCPLEX the results remain rather similar.

n m q NNLSLDL NNLSQR GUROBI CPLEX2 10 2 5.1 4.0 0.7 8.44 20 4 8.9 4.3 4.5 16.78 40 8 19.2 18.0 37.1 14.7

12 60 12 59.7 57.8 82.3 47.920 100 20 483.5 457.7 566.8 99.625 250 25 110.4 93.3 1054.4 169.430 150 30 1645.4 1415.8 2156.2 184.5

Table 2. Worst-case CPU time (ms) for randombinary QP problems with n variables and 5mconstraints, over 20 instances for each value of

n and the corresponding m, q.

5.2 Hybrid MPC problem

In order to test Algorithm 2 in a hybrid MPC problem (2)–(3), we consider the hybrid control problem describedin (Bemporad and Morari, 1999, Example 5.1) with allzero weights except a unit weight on the output of thesystem (these are the settings of the demo bm99sim.m inthe Hybrid Toolbox for MATLAB (Bemporad, 2003)) anda prediction horizon T between 2 and 10.

The regularization term 104I was added on the resultingHessian matrix Q to make the resulting MIQP’s positivedefinite. This induces a small di↵erence in the input and

N NNLSLDL NNLSQR GUROBI CPLEX2 2.2 2.3 1.2 3.03 3.4 3.9 2.0 6.54 5.0 6.5 2.6 8.15 7.6 9.8 3.7 9.06 12.3 17.7 4.3 11.07 20.5 30.5 5.8 13.18 28.9 47.1 7.3 17.39 38.8 62.5 9.5 18.9

10 55.4 98.2 10.9 22.4

Table 3. Hybrid MPC problem: CPU time(ms) per sampling step for di↵erent prediction

horizons N

output trajectories, however the norm of the di↵erencebetween the entire trajectories smaller than 0.001. Wecompare Algorithm 2 with preconditioning (16) againstGUROBI and CPLEX with presolvers enabled. The resultsare reported in Table 3. For T = 10, the MIQP problemhas n = 40, q = 10 (i.e., 30 continuous variables and10 binary variables) and m = 160 linear inequalities.We observed that disabling presolvers in GUROBI andCPLEX sometimes speeds up sometimes slows down thesolver.

6. CONCLUSIONS

In this paper we have proposed a new MIQP solver basedon B&B that is tailored to embedded hybrid MPC appli-cations. The approach extends an active set method re-cently developed by the author to solve QP relaxations asnonnegative least-squares problems. While the presentedapproach was shown e↵ective in simulations compared toreference commercial solvers, current research is devotedto combine hybrid models and MIQP solution methods forreaching even higher degrees of e↵ectiveness.

REFERENCES

Axehill, D. and Hansson, A. (2006). A mixed integer dualquadratic programming algorithm tailored for MPC. InProc. 45th IEEE Conference on Decision and Control,5693–5698. San Diego, CA, USA.

Bemporad, A. (2003). Hybrid Toolbox – User’sGuide. http://cse.lab.imtlucca.it/~bemporad/hybrid/toolbox.

Bemporad, A. (2015a). A multiparametric quadraticprogramming algorithm with polyhedral computationsbased on nonnegative least squares. IEEE Trans. Auto-matic Control. In press.

Bemporad, A. (2015b). A quadratic programming algo-rithm based on nonnegative least squares with appli-cations to embedded model predictive control. IEEETrans. Automatic Control. Conditionally accepted forpublication.

Bemporad, A. and Morari, M. (1999). Control of systemsintegrating logic, dynamics, and constraints. Automat-ica, 35(3), 407–427.

Bertsekas, D. (2009). Convex Optimization Theory.Athena Scientific.

Bierlaire, M., Toint, P., and Tuyttens, D. (1991). Oniterative algorithms for linear ls problems with boundconstraints. Linear Algebra and Its Applications, 143,111–143.

n=#variables,m=#inequalityconstraints,noequalities,q=#binaryconstraints

•Worst-caseCPUtimeonrandomMIQPproblems:

NNLSLDL=recursiveLDLfactorizationusedtosolveleast-squareproblemsinQPsolverNNLSQR=recursiveQRfactorizationusedinstead(numericallymorerobust)

(Bemporad,NMPC2015)

Page 21: Hybrid MPC

n = 40, m = 160, q = 10

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Numerical results

21

•Worst-caseCPUtime(ms)onrandompurelybinaryQPproblems:

(NNLSLDL in the table) of

MP`d`P`

MPu duPuN f

M 0

P`M 0

PuN 0

d0`P`

d0uPu

f 0

recursively as described in (Bemporad, 2015b) when the

dimension of vectorh

y`yu

iis smaller or equal than n, and,

for improved numerical robustness, QR factorization incase more than n elements must be optimized in Prob-lem (4). As an alternative, we purely updated the QRfactorization of the same matrix (NNLSQR in the table)recursively as described in (Lawson and Hanson, 1974,Chap. 24, Method 1).

n m q NNLSLDL NNLSQR GUROBI CPLEX10 5 2 2.3 1.2 1.4 8.010 100 2 5.7 3.3 6.1 31.450 25 5 4.2 6.1 14.1 30.150 200 10 68.8 104.4 114.6 294.1

100 50 2 4.6 10.2 37.2 69.2100 200 15 137.5 365.7 259.8 547.8150 100 5 15.6 49.2 157.2 260.1150 300 20 1174.4 3970.4 1296.1 2123.9

Table 1. Worst-case CPU time (ms) on randomMIQP problems over 20 instances for each

combination of n, m, q.

It is apparent that on such a set of random MIQPproblems, Algorithm 2 performs comparably well withrespect to the commercial solvers GUROBI and CPLEX,especially when the number q of binary constraints is smallcompared to n and m, probably due to the pure B&Bnature of Algorithm 2.

The results shown in Table 2 are obtained, under the sameconditions, on purely binary quadratic programs (n = q,m = 5n). When turning the presolver on, in GUROBI andCPLEX the results remain rather similar.

n m q NNLSLDL NNLSQR GUROBI CPLEX2 10 2 5.1 4.0 0.7 8.44 20 4 8.9 4.3 4.5 16.78 40 8 19.2 18.0 37.1 14.7

12 60 12 59.7 57.8 82.3 47.920 100 20 483.5 457.7 566.8 99.625 250 25 110.4 93.3 1054.4 169.430 150 30 1645.4 1415.8 2156.2 184.5

Table 2. Worst-case CPU time (ms) for randombinary QP problems with n variables and 5mconstraints, over 20 instances for each value of

n and the corresponding m, q.

5.2 Hybrid MPC problem

In order to test Algorithm 2 in a hybrid MPC problem (2)–(3), we consider the hybrid control problem describedin (Bemporad and Morari, 1999, Example 5.1) with allzero weights except a unit weight on the output of thesystem (these are the settings of the demo bm99sim.m inthe Hybrid Toolbox for MATLAB (Bemporad, 2003)) anda prediction horizon T between 2 and 10.

The regularization term 104I was added on the resultingHessian matrix Q to make the resulting MIQP’s positivedefinite. This induces a small di↵erence in the input and

N NNLSLDL NNLSQR GUROBI CPLEX2 2.2 2.3 1.2 3.03 3.4 3.9 2.0 6.54 5.0 6.5 2.6 8.15 7.6 9.8 3.7 9.06 12.3 17.7 4.3 11.07 20.5 30.5 5.8 13.18 28.9 47.1 7.3 17.39 38.8 62.5 9.5 18.9

10 55.4 98.2 10.9 22.4

Table 3. Hybrid MPC problem: CPU time(ms) per sampling step for di↵erent prediction

horizons N

output trajectories, however the norm of the di↵erencebetween the entire trajectories smaller than 0.001. Wecompare Algorithm 2 with preconditioning (16) againstGUROBI and CPLEX with presolvers enabled. The resultsare reported in Table 3. For T = 10, the MIQP problemhas n = 40, q = 10 (i.e., 30 continuous variables and10 binary variables) and m = 160 linear inequalities.We observed that disabling presolvers in GUROBI andCPLEX sometimes speeds up sometimes slows down thesolver.

6. CONCLUSIONS

In this paper we have proposed a new MIQP solver basedon B&B that is tailored to embedded hybrid MPC appli-cations. The approach extends an active set method re-cently developed by the author to solve QP relaxations asnonnegative least-squares problems. While the presentedapproach was shown e↵ective in simulations compared toreference commercial solvers, current research is devotedto combine hybrid models and MIQP solution methods forreaching even higher degrees of e↵ectiveness.

REFERENCES

Axehill, D. and Hansson, A. (2006). A mixed integer dualquadratic programming algorithm tailored for MPC. InProc. 45th IEEE Conference on Decision and Control,5693–5698. San Diego, CA, USA.

Bemporad, A. (2003). Hybrid Toolbox – User’sGuide. http://cse.lab.imtlucca.it/~bemporad/hybrid/toolbox.

Bemporad, A. (2015a). A multiparametric quadraticprogramming algorithm with polyhedral computationsbased on nonnegative least squares. IEEE Trans. Auto-matic Control. In press.

Bemporad, A. (2015b). A quadratic programming algo-rithm based on nonnegative least squares with appli-cations to embedded model predictive control. IEEETrans. Automatic Control. Conditionally accepted forpublication.

Bemporad, A. and Morari, M. (1999). Control of systemsintegrating logic, dynamics, and constraints. Automat-ica, 35(3), 407–427.

Bertsekas, D. (2009). Convex Optimization Theory.Athena Scientific.

Bierlaire, M., Toint, P., and Tuyttens, D. (1991). Oniterative algorithms for linear ls problems with boundconstraints. Linear Algebra and Its Applications, 143,111–143.

•Worst-caseCPUtime(ms)onahybridMPCproblem (Bemporad,Morari,1999)

(NNLSLDL in the table) of

MP`d`P`

MPu duPuN f

M 0

P`M 0

PuN 0

d0`P`

d0uPu

f 0

recursively as described in (Bemporad, 2015b) when the

dimension of vectorh

y`yu

iis smaller or equal than n, and,

for improved numerical robustness, QR factorization incase more than n elements must be optimized in Prob-lem (4). As an alternative, we purely updated the QRfactorization of the same matrix (NNLSQR in the table)recursively as described in (Lawson and Hanson, 1974,Chap. 24, Method 1).

n m q NNLSLDL NNLSQR GUROBI CPLEX10 5 2 2.3 1.2 1.4 8.010 100 2 5.7 3.3 6.1 31.450 25 5 4.2 6.1 14.1 30.150 200 10 68.8 104.4 114.6 294.1

100 50 2 4.6 10.2 37.2 69.2100 200 15 137.5 365.7 259.8 547.8150 100 5 15.6 49.2 157.2 260.1150 300 20 1174.4 3970.4 1296.1 2123.9

Table 1. Worst-case CPU time (ms) on randomMIQP problems over 20 instances for each

combination of n, m, q.

It is apparent that on such a set of random MIQPproblems, Algorithm 2 performs comparably well withrespect to the commercial solvers GUROBI and CPLEX,especially when the number q of binary constraints is smallcompared to n and m, probably due to the pure B&Bnature of Algorithm 2.

The results shown in Table 2 are obtained, under the sameconditions, on purely binary quadratic programs (n = q,m = 5n). When turning the presolver on, in GUROBI andCPLEX the results remain rather similar.

n m q NNLSLDL NNLSQR GUROBI CPLEX2 10 2 5.1 4.0 0.7 8.44 20 4 8.9 4.3 4.5 16.78 40 8 19.2 18.0 37.1 14.7

12 60 12 59.7 57.8 82.3 47.920 100 20 483.5 457.7 566.8 99.625 250 25 110.4 93.3 1054.4 169.430 150 30 1645.4 1415.8 2156.2 184.5

Table 2. Worst-case CPU time (ms) for randombinary QP problems with n variables and 5mconstraints, over 20 instances for each value of

n and the corresponding m, q.

5.2 Hybrid MPC problem

In order to test Algorithm 2 in a hybrid MPC problem (2)–(3), we consider the hybrid control problem describedin (Bemporad and Morari, 1999, Example 5.1) with allzero weights except a unit weight on the output of thesystem (these are the settings of the demo bm99sim.m inthe Hybrid Toolbox for MATLAB (Bemporad, 2003)) anda prediction horizon T between 2 and 10.

The regularization term 104I was added on the resultingHessian matrix Q to make the resulting MIQP’s positivedefinite. This induces a small di↵erence in the input and

N NNLSLDL NNLSQR GUROBI CPLEX2 2.2 2.3 1.2 3.03 3.4 3.9 2.0 6.54 5.0 6.5 2.6 8.15 7.6 9.8 3.7 9.06 12.3 17.7 4.3 11.07 20.5 30.5 5.8 13.18 28.9 47.1 7.3 17.39 38.8 62.5 9.5 18.9

10 55.4 98.2 10.9 22.4

Table 3. Hybrid MPC problem: CPU time(ms) per sampling step for di↵erent prediction

horizons N

output trajectories, however the norm of the di↵erencebetween the entire trajectories smaller than 0.001. Wecompare Algorithm 2 with preconditioning (16) againstGUROBI and CPLEX with presolvers enabled. The resultsare reported in Table 3. For T = 10, the MIQP problemhas n = 40, q = 10 (i.e., 30 continuous variables and10 binary variables) and m = 160 linear inequalities.We observed that disabling presolvers in GUROBI andCPLEX sometimes speeds up sometimes slows down thesolver.

6. CONCLUSIONS

In this paper we have proposed a new MIQP solver basedon B&B that is tailored to embedded hybrid MPC appli-cations. The approach extends an active set method re-cently developed by the author to solve QP relaxations asnonnegative least-squares problems. While the presentedapproach was shown e↵ective in simulations compared toreference commercial solvers, current research is devotedto combine hybrid models and MIQP solution methods forreaching even higher degrees of e↵ectiveness.

REFERENCES

Axehill, D. and Hansson, A. (2006). A mixed integer dualquadratic programming algorithm tailored for MPC. InProc. 45th IEEE Conference on Decision and Control,5693–5698. San Diego, CA, USA.

Bemporad, A. (2003). Hybrid Toolbox – User’sGuide. http://cse.lab.imtlucca.it/~bemporad/hybrid/toolbox.

Bemporad, A. (2015a). A multiparametric quadraticprogramming algorithm with polyhedral computationsbased on nonnegative least squares. IEEE Trans. Auto-matic Control. In press.

Bemporad, A. (2015b). A quadratic programming algo-rithm based on nonnegative least squares with appli-cations to embedded model predictive control. IEEETrans. Automatic Control. Conditionally accepted forpublication.

Bemporad, A. and Morari, M. (1999). Control of systemsintegrating logic, dynamics, and constraints. Automat-ica, 35(3), 407–427.

Bertsekas, D. (2009). Convex Optimization Theory.Athena Scientific.

Bierlaire, M., Toint, P., and Tuyttens, D. (1991). Oniterative algorithms for linear ls problems with boundconstraints. Linear Algebra and Its Applications, 143,111–143.

N=predictionhorizon

MIQPregularizedtomakeQstrictly>0(-->solutiondifferenceisnegligible)

Page 22: Hybrid MPC

minz

V (z) , 1

2z0Qz + c0z

s.t. ` Az u

Aeqz = beq

Aiz 2 ¯i, ui, i = 1, . . . , p

¯i Aiz ui

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Fast gradient projection for MIQP•MIQPproblem

22

•Usebranch&bound,relaxbinaryconstraintsto

special case:binary constraints zi∊0,1

constraint is relaxed

constraint is fixed

constraint is ignored

(Naik,Bemporad,2016)

Aiz ui ! yik+1 = maxnyik + sik,0

o

Aiz = ui ! yik+1 = yik + sik

Aiz = ¯i ! yk+1i = 0

•OnlyprojectionchangesfromoneQPrelaxationtoanother:

yi≥0

yi≷0

yi=0

Page 23: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Fast gradient projection for MIQP

•Numericalresults(timeinms):

23

First we consider the hybrid vehicle example describedin (Takapoui et al., 2016), that consists of the combinationof a battery, an electric motor/generator, and an engine.For a given power demand P

dest at time t = 0, . . . , T 1,

the objective is to plan the battery power P battt and engine

power P engt for the time interval t = 0, . . . , T1, such that

Pbattt + P

engt P

dest . Let Et be the energy of the battery

at time t, Et+1 = Et Pbattt , where is the sample time.

The hybrid vehicle control problem is

min (ET Emax)2 +

T1X

t=0

f(P engt , zt) + (zt zt1)+

s.t. Et+1 = Et Pbattt

Pbattt + P

engt P

dest

zt 2 0, 1, t = 0, . . . , T 1

where Pbattt , P

engt , zt (engine on/o↵) and Et are the

optimization variables. The term (zt zt1)+ penalizesthe engine going from the o↵ to the on state. By choosingT = 72 steps, the resulting MIQP problem has n = 862optimization variables, p = 72 binary variables, m = 503inequality constraints, q = 575 equality constraints.

The solver GUROBI (Gurobi Optimization, Inc., 2014)computes the optimal cost V

= 135.9 in 21.05 s withdefault options. The cost calculated by the ADMM-basedheuristic approach of Takapoui et al. (2016), denotedas miqpADMM, is 138.1 1 and is obtained in 0.40 s forpreconditioning + 3.55 s for solving the problem.

The performance of Algorithm 1+4+2 implemented ininterpreted MATLAB code, denoted as miqpGPAD-H, isreported in Table 1 for di↵erent values of the feasibil-ity tolerance A and optimality tolerance V . Whenevercondition (9) is satisfied at a given iteration k, ratherthan restarting the values of k we just assign wk yk,weq,k k in Step (5) for that iteration. We also intro-duce the regularization term 103

I in the cost function tomake the primal Hessian matrix Q positive definite. Thetolerance value used in Algorithm 2 is I = 1e 2.

V , A Cost Precond., Solving Constr. violation

1e-2, 1e-2 131.5 1.19, 3.81 s 3.62e-1

1e-2, 1e-3 135.9 1.12, 8.62 s 8.09e-3

1e-3, 1e-3 135.9 1.07, 8.67 s 7.98e-3

1e-3, 1e-4 136.0 1.14, 13.37 s 2.59e-3

1e-4, 1e-3 136.1 1.10, 15.87 s 1.08e-3

Table 1. Performance comparison with di↵er-ent values of V , A for miqpGPAD-H

Figure 1 shows the trajectories obtained with miqpGPAD-

H for V = 1e2, A = 1e3 and compare them with theones obtained by GUROBI and miqpADMM. It is apparentthat the proposed heuristic approach is computationallyfaster and very simple to implement in an embeddedcontrol platform, and keeps the quality of the solution overa sucient level for the practical application at hand.

Next, we test the B&B method miqpGPAD on randomlygenerated MIQP problems with n variables, m inequality1 https://github.com/cvxgrp/miqp_admm/tree/master/matlab/vehicle.m

0 10 20 30 40 50 60 70

Pen

gt

0

20

40

0 10 20 30 40 50 60 70

Pbatt

t

-2

0

2

0 10 20 30 40 50 60 70

Et

0

0.5

1

t0 10 20 30 40 50 60 70

z t

0

0.5

1

miqpADMM

GUROBI

miqpGPAD

Fig. 1. Engine power, battery power, battery energy, andengine on/o↵ signals versus time.(V = 1e 2, A =1e 3 case for miqpGPAD), cost=135.9

constraints, p binary constraints, q equality constraints,condition number = 10 of the primal Hessian Q

2 .Algorithm 3 is implemented in interpreted MATLAB codeand Algorithms 1, 2, 4 are implemented in EmbeddedMATLAB and complied. The tolerance values used in

n m p q miqpGPAD GUROBI

10 100 2 2 15.6 6.56

50 25 5 3 3.44 8.74

50 150 10 5 63.22 46.25

100 50 2 5 6.22 26.24

100 200 15 5 164.06 188.42

150 100 5 5 31.26 88.13

150 200 20 5 258.80 274.06

200 50 15 6 35.08 144.38

Table 2. Average CPU time (ms) on randomMIQP problems over 50 instances for each

combination of n, m, p, q.

Algorithm 1 are V , A = 1e 5, in Algorithm 2 I =1e 2. The CPU time reported for solving feasible MIQPproblems, averaged over 50 executions is listed in Table 2.The results show that the proposed scheme performs wellas compared to the commercial GUROBI solver, but hasthe advantage of a very simple coding, therefore making itvery suitable for embedded control applications.

6. CONCLUSION

In this paper we have presented an exact and a heuristicapproach to solve MIQPs based on accelerated gradientprojection methods applied on the dual QP relaxations. Inspite of their simplicity of code, the proposed approaches2

The entries of matrix A are generated from the normal distribution

N (0, 0.0025), `, u from the uniform distribution U(0, 100), c from

N (0, 1); matrix Q = UV 0, where U, V are orthogonal matrices

generated by QR decomposition of random n n matrices, and

is diagonal with nonzero entries having logarithms equally spaced

between ± log()/4 (Bierlaire et al., 1991).

•SamedualQPmatrices,preconditioningonlycomputedatrootnode

•Warm-startexploited,dualcostusedtostopQPrelaxationsearlier

•CriterionbasedonFarkaslemmatodetectQPinfeasibility

(Naik,Bemporad,2016)

Page 24: Hybrid MPC

min 12x

0Qx+ q0xs.t. ` Ax u

Aix 2 `i, ui, i 2 I

quantization

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Heuristic ADMM method for (Suboptimal) MIQP(Takapoui,Moehle,Boyd,Bemporad,ACC’16)

24

•MIQPproblem:

• ADMMiterations:

• Iterationsconvergetoa(local)solution

xk+1 = (Q+ ATA)1(AT (yk zk) + q)

zk+1 = minmaxAxk+1 + yk, `, u

zk+1i =

8<

:`i if zk+1

i < `i+ui2

ui if zk+1i `i+ui

2 , i 2 I

yk+1 = yk +Axk+1 zk+1

(Naik,Bemporad,2016)• Similarideaalsoapplicabletofastgradientmethods

Page 25: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

ADMM method for MIQP(Takapoui,Moehle,Boyd,Bemporad,ACC’16)

25

• Example:parallelHybridElectricVehiclecontrolproblem

0 10 20 30 40 50 60 700

100

200

0 10 20 30 40 50 60 70-20

0

20

0 10 20 30 40 50 60 700

10

20

30

0 10 20 30 40 50 60 700

0.5

1

t

PEng

tP

batt

tE

tzt

0 10 20 30 40 50 60 700

100

200

0 10 20 30 40 50 60 70-20

0

20

0 10 20 30 40 50 60 700

10

20

30

0 10 20 30 40 50 60 700

0.5

1

t

PEng

tP

batt

tE

tzt

Fig. 1: Engine power, battery power, battery energy, and engine on/off signals versus time. Left: the globalsolution. Right: the solution found using ADMM (Algorithm 1).

L1

L2

R

+−utVdc

C1

C2

Fig. 2: Converter circuit model.

Figure 1, we see that qualitatively, the optimal trajectoryand the trajectory generated by ADMM are very similar.

C. Power converter control

We consider control of the switched-mode powerconverter shown in Figure 2. The circuit dynamics are

ξt+1 = Gξt +Hut, t = 0, 1, . . . , T − 1,

where ξt = (i1,t, v1,t, i2,t, v2,t) is the system state atepoch t, consisting of all inductor currents and capacitorvoltages, and ut ∈ −1, 0, 1 is the control input. Thedynamics matrices G ∈ R4×4 and H ∈ R4×1 areobtained by discretizing the dynamics of the circuit inFigure 2.

We would like to control the switch configurations sothat v2 tracks a desired sinusoidal waveform. This canbe done by solving

minimize!T

t=0(v2,t − vdes)2 + λ|ut − ut−1|subject to ξt+1 = Gξt +Hut

ξ0 = ξTu0 = uT

ut ∈ −1, 0, 1,

(6)

where λ ≥ 0 is a tradeoff parameter between output volt-age regulation and switching frequency. The variablesare ξt for t = 0, . . . , T and ut for t = 0, . . . , T − 1.

Note that if we take λ = 0, and take the inputvoltage ut to be unconstrained (i.e., allow ut to take anyvalues in R), (6) can be solved as a convex quadraticminimization problem, with solution ξlst . Returning to

our original problem, we can penalize deviation fromthis ideal waveform by including a regularization termµ∥ξ − ξlst ∥

2 to (6), where µ > 0 is a positive weightingparameter. We solved this regularized version of (6), withL1 = 10 µH, C1 = 1 µF, L2 = 10 µH, C2 = 10 µF,R = 1Ω, Vdc = 10V, T = 100 (with a discretizationinterval of 0.5 µs), λ = 1.5V2, and µ = 0.1. Werun algorithm 1 with ρ = 2.7 and 500 iterations forthree different initializations. An approximate solution isfound via our heuristic in less than 2 seconds, whereasit takes MOSEK more than 4 hours to find the globalsolution. Figure 3 compares the approximate solutionderived by the heuristic with the global solution.

D. Signal decoding

We consider maximum-likelihood decoding of a mes-sage passed through a linear multiple-input and multiple-output (MIMO) channel. In particular, we have

y = Hx+ v,

where y ∈ Rp is the message received, H ∈ Rp×n isthe channel matrix, x ∈ Rn is the message sent, and theelements of the noise vector v ∈ Rp are independent,identically distributed Gaussian random variables. Wefurther assume that the elements of x belong to the signalconstellation −3,−1, 1, 3. The maximum likelihoodestimate of x is given by the solution to the problem

minimize ∥Hx− y∥2

subject to xi ∈ − 3,−1, 1, 3, i = 1, . . . , n,(7)

where x ∈ Rn is the variable.We generate 1000 random problem instances with

H ∈ R2000×400 chosen from a standard normal distri-bution. The uncorrupted signal x is chosen uniformlyrandomly and the additive noise is Gaussian such thatthe signal to noise ratio (SNR) is 8 dB. For sucha problem in embedded application, branch-and-bound

6

CONFIDENTIAL. Limited circulation. For review only.

Preprint submitted to 2016 American Control Conference.

Received September 27, 2015.

0 10 20 30 40 50 60 700

100

200

0 10 20 30 40 50 60 70-20

0

20

0 10 20 30 40 50 60 700

10

20

30

0 10 20 30 40 50 60 700

0.5

1

t

PEng

tP

batt

tE

tzt

0 10 20 30 40 50 60 700

100

200

0 10 20 30 40 50 60 70-20

0

20

0 10 20 30 40 50 60 700

10

20

30

0 10 20 30 40 50 60 700

0.5

1

t

PEng

tP

batt

tE

tzt

Fig. 1: Engine power, battery power, battery energy, and engine on/off signals versus time. Left: the globalsolution. Right: the solution found using ADMM (Algorithm 1).

L1

L2

R

+−utVdc

C1

C2

Fig. 2: Converter circuit model.

Figure 1, we see that qualitatively, the optimal trajectoryand the trajectory generated by ADMM are very similar.

C. Power converter control

We consider control of the switched-mode powerconverter shown in Figure 2. The circuit dynamics are

ξt+1 = Gξt +Hut, t = 0, 1, . . . , T − 1,

where ξt = (i1,t, v1,t, i2,t, v2,t) is the system state atepoch t, consisting of all inductor currents and capacitorvoltages, and ut ∈ −1, 0, 1 is the control input. Thedynamics matrices G ∈ R4×4 and H ∈ R4×1 areobtained by discretizing the dynamics of the circuit inFigure 2.

We would like to control the switch configurations sothat v2 tracks a desired sinusoidal waveform. This canbe done by solving

minimize!T

t=0(v2,t − vdes)2 + λ|ut − ut−1|subject to ξt+1 = Gξt +Hut

ξ0 = ξTu0 = uT

ut ∈ −1, 0, 1,

(6)

where λ ≥ 0 is a tradeoff parameter between output volt-age regulation and switching frequency. The variablesare ξt for t = 0, . . . , T and ut for t = 0, . . . , T − 1.

Note that if we take λ = 0, and take the inputvoltage ut to be unconstrained (i.e., allow ut to take anyvalues in R), (6) can be solved as a convex quadraticminimization problem, with solution ξlst . Returning to

our original problem, we can penalize deviation fromthis ideal waveform by including a regularization termµ∥ξ − ξlst ∥

2 to (6), where µ > 0 is a positive weightingparameter. We solved this regularized version of (6), withL1 = 10 µH, C1 = 1 µF, L2 = 10 µH, C2 = 10 µF,R = 1Ω, Vdc = 10V, T = 100 (with a discretizationinterval of 0.5 µs), λ = 1.5V2, and µ = 0.1. Werun algorithm 1 with ρ = 2.7 and 500 iterations forthree different initializations. An approximate solution isfound via our heuristic in less than 2 seconds, whereasit takes MOSEK more than 4 hours to find the globalsolution. Figure 3 compares the approximate solutionderived by the heuristic with the global solution.

D. Signal decoding

We consider maximum-likelihood decoding of a mes-sage passed through a linear multiple-input and multiple-output (MIMO) channel. In particular, we have

y = Hx+ v,

where y ∈ Rp is the message received, H ∈ Rp×n isthe channel matrix, x ∈ Rn is the message sent, and theelements of the noise vector v ∈ Rp are independent,identically distributed Gaussian random variables. Wefurther assume that the elements of x belong to the signalconstellation −3,−1, 1, 3. The maximum likelihoodestimate of x is given by the solution to the problem

minimize ∥Hx− y∥2

subject to xi ∈ − 3,−1, 1, 3, i = 1, . . . , n,(7)

where x ∈ Rn is the variable.We generate 1000 random problem instances with

H ∈ R2000×400 chosen from a standard normal distri-bution. The uncorrupted signal x is chosen uniformlyrandomly and the additive noise is Gaussian such thatthe signal to noise ratio (SNR) is 8 dB. For sucha problem in embedded application, branch-and-bound

6

CONFIDENTIAL. Limited circulation. For review only.

Preprint submitted to 2016 American Control Conference.

Received September 27, 2015.

optimalsolution ADMMsolution

energy stored in battery

engine on/off

engine power

electrical power

Page 26: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

ADMM method for (Suboptimal) MIQP(Takapoui,Moehle,Boyd,Bemporad,ACC’16)

26

• Example:powerconvertercontrol

optimalsolution ADMMsolution

output voltagev2

input voltage sign ut

0 10 20 30 40 50 60 700

100

200

0 10 20 30 40 50 60 70-20

0

20

0 10 20 30 40 50 60 700

10

20

30

0 10 20 30 40 50 60 700

0.5

1

t

PEng

tP

batt

tE

tzt

0 10 20 30 40 50 60 700

100

200

0 10 20 30 40 50 60 70-20

0

20

0 10 20 30 40 50 60 700

10

20

30

0 10 20 30 40 50 60 700

0.5

1

t

PEng

tP

batt

tE

tzt

Fig. 1: Engine power, battery power, battery energy, and engine on/off signals versus time. Left: the globalsolution. Right: the solution found using ADMM (Algorithm 1).

L1

L2

R

+−utVdc

C1

C2

Fig. 2: Converter circuit model.

Figure 1, we see that qualitatively, the optimal trajectoryand the trajectory generated by ADMM are very similar.

C. Power converter control

We consider control of the switched-mode powerconverter shown in Figure 2. The circuit dynamics are

ξt+1 = Gξt +Hut, t = 0, 1, . . . , T − 1,

where ξt = (i1,t, v1,t, i2,t, v2,t) is the system state atepoch t, consisting of all inductor currents and capacitorvoltages, and ut ∈ −1, 0, 1 is the control input. Thedynamics matrices G ∈ R4×4 and H ∈ R4×1 areobtained by discretizing the dynamics of the circuit inFigure 2.

We would like to control the switch configurations sothat v2 tracks a desired sinusoidal waveform. This canbe done by solving

minimize!T

t=0(v2,t − vdes)2 + λ|ut − ut−1|subject to ξt+1 = Gξt +Hut

ξ0 = ξTu0 = uT

ut ∈ −1, 0, 1,

(6)

where λ ≥ 0 is a tradeoff parameter between output volt-age regulation and switching frequency. The variablesare ξt for t = 0, . . . , T and ut for t = 0, . . . , T − 1.

Note that if we take λ = 0, and take the inputvoltage ut to be unconstrained (i.e., allow ut to take anyvalues in R), (6) can be solved as a convex quadraticminimization problem, with solution ξlst . Returning to

our original problem, we can penalize deviation fromthis ideal waveform by including a regularization termµ∥ξ − ξlst ∥

2 to (6), where µ > 0 is a positive weightingparameter. We solved this regularized version of (6), withL1 = 10 µH, C1 = 1 µF, L2 = 10 µH, C2 = 10 µF,R = 1Ω, Vdc = 10V, T = 100 (with a discretizationinterval of 0.5 µs), λ = 1.5V2, and µ = 0.1. Werun algorithm 1 with ρ = 2.7 and 500 iterations forthree different initializations. An approximate solution isfound via our heuristic in less than 2 seconds, whereasit takes MOSEK more than 4 hours to find the globalsolution. Figure 3 compares the approximate solutionderived by the heuristic with the global solution.

D. Signal decoding

We consider maximum-likelihood decoding of a mes-sage passed through a linear multiple-input and multiple-output (MIMO) channel. In particular, we have

y = Hx+ v,

where y ∈ Rp is the message received, H ∈ Rp×n isthe channel matrix, x ∈ Rn is the message sent, and theelements of the noise vector v ∈ Rp are independent,identically distributed Gaussian random variables. Wefurther assume that the elements of x belong to the signalconstellation −3,−1, 1, 3. The maximum likelihoodestimate of x is given by the solution to the problem

minimize ∥Hx− y∥2

subject to xi ∈ − 3,−1, 1, 3, i = 1, . . . , n,(7)

where x ∈ Rn is the variable.We generate 1000 random problem instances with

H ∈ R2000×400 chosen from a standard normal distri-bution. The uncorrupted signal x is chosen uniformlyrandomly and the additive noise is Gaussian such thatthe signal to noise ratio (SNR) is 8 dB. For sucha problem in embedded application, branch-and-bound

6

CONFIDENTIAL. Limited circulation. For review only.

Preprint submitted to 2016 American Control Conference.

Received September 27, 2015.

0 10 20 30 40 50 60 700

100

200

0 10 20 30 40 50 60 70-20

0

20

0 10 20 30 40 50 60 700

10

20

30

0 10 20 30 40 50 60 700

0.5

1

t

PEng

tP

batt

tE

tzt

0 10 20 30 40 50 60 700

100

200

0 10 20 30 40 50 60 70-20

0

20

0 10 20 30 40 50 60 700

10

20

30

0 10 20 30 40 50 60 700

0.5

1

t

PEng

tP

batt

tE

tzt

Fig. 1: Engine power, battery power, battery energy, and engine on/off signals versus time. Left: the globalsolution. Right: the solution found using ADMM (Algorithm 1).

L1

L2

R

+−utVdc

C1

C2

Fig. 2: Converter circuit model.

Figure 1, we see that qualitatively, the optimal trajectoryand the trajectory generated by ADMM are very similar.

C. Power converter control

We consider control of the switched-mode powerconverter shown in Figure 2. The circuit dynamics are

ξt+1 = Gξt +Hut, t = 0, 1, . . . , T − 1,

where ξt = (i1,t, v1,t, i2,t, v2,t) is the system state atepoch t, consisting of all inductor currents and capacitorvoltages, and ut ∈ −1, 0, 1 is the control input. Thedynamics matrices G ∈ R4×4 and H ∈ R4×1 areobtained by discretizing the dynamics of the circuit inFigure 2.

We would like to control the switch configurations sothat v2 tracks a desired sinusoidal waveform. This canbe done by solving

minimize!T

t=0(v2,t − vdes)2 + λ|ut − ut−1|subject to ξt+1 = Gξt +Hut

ξ0 = ξTu0 = uT

ut ∈ −1, 0, 1,

(6)

where λ ≥ 0 is a tradeoff parameter between output volt-age regulation and switching frequency. The variablesare ξt for t = 0, . . . , T and ut for t = 0, . . . , T − 1.

Note that if we take λ = 0, and take the inputvoltage ut to be unconstrained (i.e., allow ut to take anyvalues in R), (6) can be solved as a convex quadraticminimization problem, with solution ξlst . Returning to

our original problem, we can penalize deviation fromthis ideal waveform by including a regularization termµ∥ξ − ξlst ∥

2 to (6), where µ > 0 is a positive weightingparameter. We solved this regularized version of (6), withL1 = 10 µH, C1 = 1 µF, L2 = 10 µH, C2 = 10 µF,R = 1Ω, Vdc = 10V, T = 100 (with a discretizationinterval of 0.5 µs), λ = 1.5V2, and µ = 0.1. Werun algorithm 1 with ρ = 2.7 and 500 iterations forthree different initializations. An approximate solution isfound via our heuristic in less than 2 seconds, whereasit takes MOSEK more than 4 hours to find the globalsolution. Figure 3 compares the approximate solutionderived by the heuristic with the global solution.

D. Signal decoding

We consider maximum-likelihood decoding of a mes-sage passed through a linear multiple-input and multiple-output (MIMO) channel. In particular, we have

y = Hx+ v,

where y ∈ Rp is the message received, H ∈ Rp×n isthe channel matrix, x ∈ Rn is the message sent, and theelements of the noise vector v ∈ Rp are independent,identically distributed Gaussian random variables. Wefurther assume that the elements of x belong to the signalconstellation −3,−1, 1, 3. The maximum likelihoodestimate of x is given by the solution to the problem

minimize ∥Hx− y∥2

subject to xi ∈ − 3,−1, 1, 3, i = 1, . . . , n,(7)

where x ∈ Rn is the variable.We generate 1000 random problem instances with

H ∈ R2000×400 chosen from a standard normal distri-bution. The uncorrupted signal x is chosen uniformlyrandomly and the additive noise is Gaussian such thatthe signal to noise ratio (SNR) is 8 dB. For sucha problem in embedded application, branch-and-bound

6

CONFIDENTIAL. Limited circulation. For review only.

Preprint submitted to 2016 American Control Conference.

Received September 27, 2015.

0 10 20 30 40 50 60 70 80 90 100−1

−0.5

0

0.5

1

0 10 20 30 40 50 60 70 80 90 100−1

−0.5

0

0.5

1

t

ut

v2,t

0 10 20 30 40 50 60 70 80 90 100-1

-0.5

0

0.5

1

0 10 20 30 40 50 60 70 80 90 100-1

-0.5

0

0.5

1

ut

v2,t

Fig. 3: The switch configuration and the output voltage. Left: the global solution. Right: the solution usingADMM (Algorithm 1).

methods are not desirable due to their worst-case timecomplexity. We run the heuristic with only one initial-ization, with 10 iterations to find xadmm. The averageruntime for each problem (including preprocessing) is 80milliseconds, which is substantially faster than branch-and-bound based methods. We compare the performanceof the points xadmm with the points found by relax-and-round technique xrlx. In Figure 4 we have plotted thehistogram of the difference between the objective valuesevaluated at xadmm and xrlx. Depicted in Figure 4, we seethat in 95% of the cases, the bit error rate (BER) usingour heuristic was at least as good as the bit error rateusing relax and round.

IV. CONCLUSIONS

In this paper, we introduced an effective heuristicfor finding approximate solutions to convex quadraticminimization problems over the intersection of affine andnonconvex sets. Our heuristic is significantly faster thanbranch-and-bound algorithms and has shown effective ina variety of embedded problems including hybrid vehiclecontrol, power converter control, and signal decoding.

REFERENCES

[AB07] T. Achterberg and T. Berthold. Improving the FeasibilityPump. Discrete Optimization, 4(1):77–86, 2007.

[ApS15] MOSEK ApS. TheMOSEKoptimization toolbox for MAT-LAB manual. Version 7.1 (Revision 28), 2015.

[Bec14] A. Beck. Introduction to Nonlinear Optimization: Theory,Algorithms, and Applications with MATLAB, volume 19.SIAM, 2014.

[Bem15] A. Bemporad. Solving mixed-integer quadratic programsvia nonnegative least squares. Submitted for publication,2015.

[BFL07] L. Bertacco, M. Fischetti, and A. Lodi. A feasibility pumpheuristic for general mixed-integer problems. DiscreteOptimization, 4(1):63–76, 2007.

[BM99] A. Bemporad and M. Morari. Control of systems in-tegrating logic, dynamics, and constraints. Automatica,35(3):407–427, 1999.

[Bol13] D. Boley. Local linear convergence of the alternatingdirection method of multipliers on quadratic or linearprograms. SIAM Journal on Optimization, 23(4):2183–2207, 2013.

[BPC+11] S. Boyd, N. Parikh, E. Chu, B. Peleato, and J. Eckstein.Distributed optimization and statistical learning via thealternating direction method of multipliers. Foundationsand Trends in Machine Learning, 3(1):1–122, 2011.

[Bra10] A. M. Bradley. Algorithms for the Equilibration ofMatrices and their Application to Limited-Memory Quasi-Newton Methods. PhD thesis, Stanford University, 2010.

[BV04] S. Boyd and L. Vandenberghe. Convex Optimization.Cambridge University Press, 2004.

[CA06] M. Carrion and J. M. Arroyo. A computationally efficientmixed-integer linear formulation for the thermal unit com-mitment problem. IEEE Transactions on Power Systems,21(3):1371–1378, 2006.

[CCH89] V. Chvatal, W. Cook, and M. Hartmann. On cutting-planeproofs in combinatorial optimization. Linear Algebra andits Applications, 114:455–499, 1989.

[Cha12] R. Chartrand. Nonconvex splitting for regularized low-rank + sparse decomposition. IEEE Transactions on SignalProcessing, 60(11):5810–5819, 2012.

[CPDB13] E. Chu, N. Parikh, A. Domahidi, and S. Boyd. Codegeneration for embedded second-order cone programming.In Proceedings of the 2013 European Control Conference,pages 1547–1552, 2013.

[CPL09] IBM ILOG CPLEX. User’s manual for CPLEX. Interna-tional Business Machines Corporation, 46(53):157, 2009.

[CPM10] J. P. S. Catalao, H. M. I. Pousinho, and V. M. F. Mendes.Scheduling of head-dependent cascaded hydro systems:Mixed-integer quadratic programming approach. EnergyConversion and Management, 51(3):524–530, 2010.

[CW13] R. Chartrand and B. Wohlberg. A nonconvex ADMMalgorithm for group sparsity with sparse groups. In Pro-ceedings of IEEE International Conference on Acoustics,Speech and Signal Processing (ICASSP), pages 6009–6013. IEEE, 2013.

[DBEY13] N. Derbinsky, J. Bento, V. Elser, and J. S. Yedidia. Animproved three-weight message-passing algorithm. arXivpreprint arXiv:1305.1961, 2013.

[DCB13] A. Domahidi, E. Chu, and S. Boyd. ECOS: An SOCPsolver for embedded systems. In Proceedings of the 12thEuropean Control Conference, pages 3071–3076. IEEE,2013.

[DY12] W. Deng and W. Yin. On the global and linear conver-gence of the generalized alternating direction method of

7

CONFIDENTIAL. Limited circulation. For review only.

Preprint submitted to 2016 American Control Conference.

Received September 27, 2015.

0 10 20 30 40 50 60 70 80 90 100−1

−0.5

0

0.5

1

0 10 20 30 40 50 60 70 80 90 100−1

−0.5

0

0.5

1

t

ut

v2,t

0 10 20 30 40 50 60 70 80 90 100-1

-0.5

0

0.5

1

0 10 20 30 40 50 60 70 80 90 100-1

-0.5

0

0.5

1

ut

v2,t

Fig. 3: The switch configuration and the output voltage. Left: the global solution. Right: the solution usingADMM (Algorithm 1).

methods are not desirable due to their worst-case timecomplexity. We run the heuristic with only one initial-ization, with 10 iterations to find xadmm. The averageruntime for each problem (including preprocessing) is 80milliseconds, which is substantially faster than branch-and-bound based methods. We compare the performanceof the points xadmm with the points found by relax-and-round technique xrlx. In Figure 4 we have plotted thehistogram of the difference between the objective valuesevaluated at xadmm and xrlx. Depicted in Figure 4, we seethat in 95% of the cases, the bit error rate (BER) usingour heuristic was at least as good as the bit error rateusing relax and round.

IV. CONCLUSIONS

In this paper, we introduced an effective heuristicfor finding approximate solutions to convex quadraticminimization problems over the intersection of affine andnonconvex sets. Our heuristic is significantly faster thanbranch-and-bound algorithms and has shown effective ina variety of embedded problems including hybrid vehiclecontrol, power converter control, and signal decoding.

REFERENCES

[AB07] T. Achterberg and T. Berthold. Improving the FeasibilityPump. Discrete Optimization, 4(1):77–86, 2007.

[ApS15] MOSEK ApS. TheMOSEKoptimization toolbox for MAT-LAB manual. Version 7.1 (Revision 28), 2015.

[Bec14] A. Beck. Introduction to Nonlinear Optimization: Theory,Algorithms, and Applications with MATLAB, volume 19.SIAM, 2014.

[Bem15] A. Bemporad. Solving mixed-integer quadratic programsvia nonnegative least squares. Submitted for publication,2015.

[BFL07] L. Bertacco, M. Fischetti, and A. Lodi. A feasibility pumpheuristic for general mixed-integer problems. DiscreteOptimization, 4(1):63–76, 2007.

[BM99] A. Bemporad and M. Morari. Control of systems in-tegrating logic, dynamics, and constraints. Automatica,35(3):407–427, 1999.

[Bol13] D. Boley. Local linear convergence of the alternatingdirection method of multipliers on quadratic or linearprograms. SIAM Journal on Optimization, 23(4):2183–2207, 2013.

[BPC+11] S. Boyd, N. Parikh, E. Chu, B. Peleato, and J. Eckstein.Distributed optimization and statistical learning via thealternating direction method of multipliers. Foundationsand Trends in Machine Learning, 3(1):1–122, 2011.

[Bra10] A. M. Bradley. Algorithms for the Equilibration ofMatrices and their Application to Limited-Memory Quasi-Newton Methods. PhD thesis, Stanford University, 2010.

[BV04] S. Boyd and L. Vandenberghe. Convex Optimization.Cambridge University Press, 2004.

[CA06] M. Carrion and J. M. Arroyo. A computationally efficientmixed-integer linear formulation for the thermal unit com-mitment problem. IEEE Transactions on Power Systems,21(3):1371–1378, 2006.

[CCH89] V. Chvatal, W. Cook, and M. Hartmann. On cutting-planeproofs in combinatorial optimization. Linear Algebra andits Applications, 114:455–499, 1989.

[Cha12] R. Chartrand. Nonconvex splitting for regularized low-rank + sparse decomposition. IEEE Transactions on SignalProcessing, 60(11):5810–5819, 2012.

[CPDB13] E. Chu, N. Parikh, A. Domahidi, and S. Boyd. Codegeneration for embedded second-order cone programming.In Proceedings of the 2013 European Control Conference,pages 1547–1552, 2013.

[CPL09] IBM ILOG CPLEX. User’s manual for CPLEX. Interna-tional Business Machines Corporation, 46(53):157, 2009.

[CPM10] J. P. S. Catalao, H. M. I. Pousinho, and V. M. F. Mendes.Scheduling of head-dependent cascaded hydro systems:Mixed-integer quadratic programming approach. EnergyConversion and Management, 51(3):524–530, 2010.

[CW13] R. Chartrand and B. Wohlberg. A nonconvex ADMMalgorithm for group sparsity with sparse groups. In Pro-ceedings of IEEE International Conference on Acoustics,Speech and Signal Processing (ICASSP), pages 6009–6013. IEEE, 2013.

[DBEY13] N. Derbinsky, J. Bento, V. Elser, and J. S. Yedidia. Animproved three-weight message-passing algorithm. arXivpreprint arXiv:1305.1961, 2013.

[DCB13] A. Domahidi, E. Chu, and S. Boyd. ECOS: An SOCPsolver for embedded systems. In Proceedings of the 12thEuropean Control Conference, pages 3071–3076. IEEE,2013.

[DY12] W. Deng and W. Yin. On the global and linear conver-gence of the generalized alternating direction method of

7

CONFIDENTIAL. Limited circulation. For review only.

Preprint submitted to 2016 American Control Conference.

Received September 27, 2015.

Page 27: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 27

A simple example in supply chain managementmanufacturerA

manufacturerB

manufacturerC

inventory1

inventory2

retailer1

Page 28: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 28

System variables

xij(k)=amountofjholdininventoryiattime k(i=1,2,j=1,2)

•continuousstates:

yj(k)=amountofjsoldattimek(j=1,2)

•continuousoutputs:

uij(k)=amountofjtakenfrominventoryiattimek (i=1,2,j=1,2)

•continuousinputs:

UXij(k)=1ifmanufacturerXproducesandsendjtoinventoryiattimek•binaryinputs:

Page 29: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 29

Constraints•Maxcapacityofinventoryi:0≤∑ jxij(k)≤ xMi

•Maxtransportationfrominventories:0≤ uij(k)≤uM

•Aproductcanonlybesenttooneinventory:

UA11(k) andUA21(k)cannotbeboth=1UB11(k)andUB21(k)cannotbeboth=1UB12(k)andUB22(k)cannotbeboth=1UC12(k) andUC22(k)cannotbeboth=1

[UB11(k)orUB21(k)=1],[UB12(k)orUB22(k)=1]cannotbebothtrue

•Amanufacturercanonlyproduceonetypeofproductatonetime:

Numericalvalues:xM1=10,xM2=10

Page 30: Hybrid MPC

(y1 = u11 + u21y2 = u12 + u22

8><

>:

x11(k +1) = x11(k) + PA1UA11(k) + PB1UB11(k) u11(k)x12(k +1) = x12(k) + PB2UB12(k) + PC2UC12(k) u12(k)x21(k +1) = x21(k) + PA1UA21(k) + PB1UB21(k) u21(k)x22(k +1) = x22(k) + PB2UB22(k) + PC2UC22(k) u22(k)

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 30

Dynamics

•Levelofinventories:

Numericalvalues:PA1=4,PB1=6,PB2=7,PC2=3

•Retailer:

PA1,PB1,PB2,PC2=amountofproductoftype1(2)producedbyA(B, C)inonetimeinterval

Page 31: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 31

Hybrid dynamical modelSYSTEM supply_chainINTERFACE STATE REAL x11 [0,10]; REAL x12 [0,10]; REAL x21 [0,10]; REAL x22 [0,10]; INPUT REAL u11 [0,10]; REAL u12 [0,10]; REAL u21 [0,10]; REAL u22 [0,10]; BOOL UA11,UA21,UB11,UB12,UB21,UB22,UC12,UC22;

OUTPUT REAL y1,y2;

PARAMETER REAL PA1,PB1,PB2,PC2,xM1,xM2;IMPLEMENTATION

AUX REAL zA11, zB11, zB12, zC12, zA21, zB21, zB22, zC22;

DA zA11 = IF UA11 THEN PA1 ELSE 0; zB11 = IF UB11 THEN PB1 ELSE 0; zB12 = IF UB12 THEN PB2 ELSE 0; zC12 = IF UC12 THEN PC2 ELSE 0; zA21 = IF UA21 THEN PA1 ELSE 0; zB21 = IF UB21 THEN PB1 ELSE 0; zB22 = IF UB22 THEN PB2 ELSE 0; zC22 = IF UC22 THEN PC2 ELSE 0;

CONTINUOUS x11 = x11 + zA11 + zB11 - u11; x12 = x12 + zB12 + zC12 - u12; x21 = x21 + zA21 + zB21 - u21; x22 = x22 + zB22 + zC22 - u22;

OUTPUT y1 = u11 + u21; y2 = u12 + u22;

MUST ~(UA11 & UA21); ~(UC12 & UC22); ~((UB11 | UB21) & (UB12 | UB22)); ~(UB11 & UB21); ~(UB12 & UB22); x11+x12 <= xM1; x11+x12 >=0; x21+x22 <= xM2; x21+x22 >=0;

/demos/hybrid/supply_chain.m

Page 32: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 32

Objectives

•Meetcustomerdemandasmuchaspossible:

•Minimizetransportationcosts

•Fulfillallconstraints

y1¼r1,y2¼r2

Page 33: Hybrid MPC

minN1X

k=0

10(|y1,k r1(t)|+ |y2,k r2(t)|+

4(|u11,k|+ |u12,k|)+

2(|u21,k|+ |u22,k|)+

1(|UA11,k|+ |UA21,k|)+

4(|UB11,k|+ |UB12,k|+ UB21,k|+ |UB22,k|)+

10(|UC12,k|+ |UC22,k|)

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 33

Performance specs

cost from C to inventories

penalty on demand tracking error

cost for shippingfrom inv.#1 to market

cost for shippingfrom inv.#2 to market

cost from A to inventories

cost from B to inventories

Page 34: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 34

Simulation setup

>>C=hybcon(S,Q,N,limits,refs);

>>refs.y=[1 2]; % weights output2 #1,#2>>Q.y=diag([10 10]); % output weights…>>Q.norm=Inf; % infinity norms>>N=2; % optimization horizon>>limits.umin=umin; % constraints>>limits.umax=umax;>>limits.xmin=xmin; % xij(k)>=0>>limits.xmax=xmax; % xij(k)<=xMi (redundant)

>> C

Hybrid controller based on MLD model S <supply_chain.hys> [Inf-norm]

4 state measurement(s) 2 output reference(s) 12 input reference(s) 0 state reference(s) 0 reference(s) on auxiliary continuous z-variables 44 optimization variable(s) (28 continuous, 16 binary)176 mixed-integer linear inequalitiessampling time = 1, MILP solver = 'glpk' Type "struct(C)" for more details.

>>

Page 35: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 35

Simulation results

>>[XX,UU,DD,ZZ,TT]=sim(C,S,r,x0,Tstop);

>>x0=[0;0;0;0]; % Initial condition>>r.y=[6+2*sin((0:Tstop-1)'/5) % Reference trajectories 5+3*cos((0:Tstop-1)'/3)];

CPUtime:¼13mspertimestepusingGLPK(9msusingCPLEX)onthismachine

Page 36: Hybrid MPC

•Goal:swingthependulumup

•Non-convexinputconstraint

•Nonlineardynamicalmodel

l2M = Mgl sin + u

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Hybrid MPC of an inverted pendulum

36

θ

l

u

u 2 [max,min] [ 0 [ [min, max]

Page 37: Hybrid MPC

•Approximatesin(θ)asthepiecewiselinearfunction

sin s ,

8><

>:

↵ if 2

↵ if || 2

↵ + if 2

↵ =24

3

=24

2

−5 0 5−1.5

−1

−0.5

0

0.5

1

1.5

min↵

Z 2

0

(↵ sin())2d

=

2

1

2cos sin 2↵ sin +

1

3↵23 + 2↵ cos

2

0=

1

243↵2 2↵+

4

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Inverted pendulum: nonlinearity

37

•Getoptimalvaluesforαandγbyminimizingfiterror

• Zeroingthederivativewithrespecttoαgives

•Requirings=0forθ=πgives

π

Page 38: Hybrid MPC

•Set,with

• Introducetheeventvariables

[3 = 1] $ [ 2]

[4 = 1] $ [ 2]

s3 =

(2↵ if 3 = 10 otherwise

s4 =

(2↵ + if 4 = 10 otherwise

[4 = 1] ! [3 = 0]

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Inverted pendulum: nonlinearity

38

−5 0 5−1.5

−1

−0.5

0

0.5

1

1.5

π/2-π/2

s = ↵ + s3 + s4

alongwiththelogicconstraint

Page 39: Hybrid MPC

•Astheinputuhasnoeffectonthedynamicsfor,ifuispenalizedintheMPCcostfunctionthenumericalsolverwillnotchoosevaluesinthatrange

andletbethetorqueactingonthependulum,with

A =

(u if min u min0 otherwise

u A

u 2 [max, max]

u 2 [min, min]

u 2 [max,min] [ 0 [ [min, max]

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Inverted pendulum: non-convex constraint

39

•Tomodeltheconstraintweintroducetheauxiliaryvariable

Page 40: Hybrid MPC

[1 = 1] $ [u min]

[2 = 1] $ [u min]

A =

(u if [1 = 1] ^ [2 = 1]0 otherwise

[1 = 0] ! [2 = 1]

minmin

1 = 12 = 12 = 0

1 = 0

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Inverted pendulum: non-convex constraint

40

• Introduceneweventvariables

andset

alongwiththelogicconstraint

u

sothatiszeroinforu A u 2 [min, min]

Page 41: Hybrid MPC

d

dt

"x1x2

#

= Ac

"x1x2

#

+Bc

"s3 + s4u A

#

y =h1 0

ix

Ac ,"

0 1gl↵

l2M

#

, Bc ,"0 0gl

1l2M

#

x ,h

i, y ,

"x1(k +1)x2(k +1)

#

= A

"x1(k)x2(k)

#

+B

"s3(k) + s4(k)u(k) A(k)

#

y(k) =h1 0

ix(k)

A , eTsAc, B ,Z Ts

0etAcBcdt

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Inverted pendulum: dynamics

41

•Transformintolinearmodel

•DiscretizeintimewithsampletimeTs=50 ms

Page 42: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Inverted pendulum: HYSDEL model

42

/* Hybrid model of a pendulum (C) 2012 by A. Bemporad, April 2012 */

SYSTEM hyb_pendulum INTERFACE STATE REAL th [-2*pi,2*pi]; REAL thdot [-20,20]; INPUT REAL u [-11,11]; OUTPUT REAL y; PARAMETER REAL tau_min,alpha,gamma; REAL a11,a12,a21,a22,b11,b12,b21,b22;

IMPLEMENTATION AUX REAL tauA,s3,s4; BOOL d1,d2,d3,d4; AD d1 = u<=tau_min; d2 = u>=-tau_min; d3 = th <= -0.5*pi; d4 = th >= 0.5*pi;

DA tauA = IF d1 & d2 THEN u ELSE 0; s3 = IF d3 THEN -2*alpha*th-gamma ELSE 0; s4 = IF d4 THEN -2*alpha*th+gamma ELSE 0; CONTINUOUS th = a11*th+a12*thdot+b11*(s3+s4)+b12*(u-tauA); thdot = a21*th+a22*thdot+b21*(s3+s4)+b22*(u-tauA);

OUTPUT y = th; MUST d4->~d3; ~d1->d2;

gotodemo/demos/hybrid/pendulum_init.m

>>S=mld('pendulum',Ts);

Page 43: Hybrid MPC

(0) = 2, (0) = 0

u(t) =

(2 Nm if 0 t 10 s0 otherwise

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Inverted pendulum: model validation

43

•Open-loopsimulationfrominitialcondition

0 5 10 15 20−3.5

−3

−2.5

−2

−1.5

• Inputtorqueexcitation

>>u0=2;>>U=[2*ones(200,1);zeros(200,1)];>>x0=[-pi/2;0];

>>[X,T,D,Z,Y]=sim(S,x0,U);

hybrid model (nominal)

nonlinear model

Page 44: Hybrid MPC

4X

k=0|yk r(t))|+ |0.01uk|

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Inverted pendulum: MPC design

44

•MPCcostfunction

>>C=hybcon(S,Q,N,limits,refs);

>>refs.y=1;>>refs.u=1;>>Q.y=1; >>Q.y=0.01;>>Q.rho=Inf; >>Q.norm=Inf; >>N=5;

>>limits.umin=-10;>>limits.umax=10;•MPCconstraints u 2 [max, max]

>> C

Hybrid controller based on MLD model S <pendulum.hys> [Inf-norm]

2 state measurement(s) 1 output reference(s) 1 input reference(s) 0 state reference(s) 0 reference(s) on auxiliary continuous z-variables 55 optimization variable(s) (30 continuous, 25 binary)155 mixed-integer linear inequalitiessampling time = 0.05, MILP solver = 'gurobi' Type "struct(C)" for more details.>>

Page 45: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Inverted pendulum: Closed-loop results

45

•Nonlinearsimulation

•Nominalsimulation >>[X,U,D,Z,T,Y]=sim(C,S,r,x0,4);

0 1 2 3 4

0

1

2

3

θ

0 1 2 3 4−10

0

10

input torque

0 1 2 3 4

0

1

2

3

θ

0 1 2 3 4−10

0

10

input torque

CPUtime:51mspertimestep(GLPK)22mspertimestep(CPLEX)25ms(GUROBI)onthismachine

Page 46: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 46

Explicit Hybrid MPC

Page 47: Hybrid MPC

min J(, x(t)) =N1X

k=0

kQykk1 + kRukk1

subject to

8><

>:

xk+1 = Axk +B1uk +B2k +B3zk +B5yk = Cxk +D1uk +D2k +D3zk +D5

E2k + E3zk E4xk + E1uk + E5x0 = x(t)

minN1X

k=0yk + uk

s.t. G W + Sx(t)

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 47

Explicit hybrid MPC (MLD formulation)

•On-lineoptimization:solvetheproblemforagivenstatex(t)

multi-parametricMixedIntegerLinearProgram(mp-MILP)

Mixed-IntegerLinearProgram(MILP)

•Off-lineoptimization:solvetheMILPinadvanceforallx(t)

Page 48: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 48

Multiparametric MILP

u(x) =

F1x + g1 if H1x K1

... ...

FMx + gM if HMx KM

minc,d

f cc + f dd

s.t. Gcc + Gdd W + Sx

•Theorem:Themultiparametricsolutionispiecewiseaffine(butpossiblydiscontinuous)

(Dua,Pistikopoulos,1999)•mp-MILPcanbesolved(byalternatingMILPsandmp-LPs)

•TheMPCcontrollerispiecewiseaffineinx=x(t) x-space

1

2

3

M4

5 6

(moregenerally,theMPCcontrollerisaPWAfunctionofx andofthereferencesignals)

Page 49: Hybrid MPC

min J(, x(t)) =N1X

k=0

kQykk1 + kRukk1

subject to

8><

>:

xk+1 = Ai(k)xk +Bi(k)uk + fi(k)yk = Ci(k)xk +Di(k)uk + gi(k)

i(k) such that Hi(k)xk +Wi(k)uk Ki(k)x0 = x(t)

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 49

Alternative: use PWA formulation

u(x) =

F1x + g1 if H1x K1

... ...

FMx + gM if HMx KM

•TheMPCcontrollerispiecewiseaffineinx=x(t) x-space

1

2

3

M4

5 6

(moregenerally,theMPCcontrollerisaPWAfunctionofx andofthereferencesignals)

Page 50: Hybrid MPC

1-Usebackwards(=DP)reachabilityanalysisforenumeratingallfeasiblemodesequencesI=i(0),i(1),…,i(N)

2-ForeachfixedsequenceI,solvetheexplicitfinite-timeoptimalcontrolproblemforthecorrespondinglineartime-varyingsystem(mpQPormpLP)

3a-Case1/1-norm:Comparevaluefunctionsandsplitregions

3b-Casequadraticcosts:thepartitionmaynotbefullypolyhedralbetterkeepoverlappingpolyhedraandcompareon-linequadraticcostfunctions(whenoverlapsaredetected)

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

Alternative: use PWA formulation

UseacombinationofDP(dynamicprogramming)andmpLP

(Borrelli,Baotic,Bemporad,Morari,Automatica,2005)

(Mayne,ECC2001)

Method#1

Method#2 (Bemporad,HybridToolbox,2003)(Alessio,Bemporad,ADHS2006)

(1-norm,1-norm),ormpQP(quadraticforms)

(Mayne,Rakovic,2002)

(Fuchs,Axehill,Morari,2015)Comparisonofquadraticcostscanbeavoidedbyliftingtheparameterspace

Page 51: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 51

Hybrid control examples (revisited)

Page 52: Hybrid MPC

10 x(t) 10

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 52

Hybrid control example

Openloopbehavior:

PWAsystem:

Constraints:

Closedloop:

HybTbx:/demos/hybrid/bm99sim.m

Objective: min2X

k=1|yk r(t)|

α

Page 53: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 53

Explicit PWA controller

(CPUtime=1.51s,thismachine)

HybTbx:/demos/hybrid/bm99sim.m

Sectionwith r=0

x1

x2

PWAlaw´MPClaw!

Page 54: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 54

HybridcontrolexampleHybrid control exampleClosedloop:

Page 55: Hybrid MPC

min 10kxNk1 +N1X

k=010kxkk1 + kukk1

s.t.

(1 uk 1, k = 0, . . . , N 1

10 xk 10, k = 1, . . . , N

Q =

h10 00 10

i

R = 1

!

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 55

Explicit PWA regulator

PredictionhorizonN=1

HybTbx:/demos/hybrid/bm99benchmark.m

MPCproblem:

PredictionhorizonN=2 PredictionhorizonN=3

Page 56: Hybrid MPC

min2X

k=0kx2k r(t)k1

s.t.

(x1k 25, k = 1,2hybrid model

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 56

Explicit MPC – Temperature control

>>E=expcon(C,range,options);

>> E

Explicit controller (based on hybrid controller C) 3 parameter(s) 1 input(s) 12 partition(s)sampling time = 0.5 The controller is for hybrid systems (tracking)This is a state-feedback controller. Type "struct(E)" for more details.>>

Sectioninthe(T1,T2)-spaceforTref=30

384numberstostoreinmemory

Page 57: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 57

Explicit MPC – Temperature control

generatedC-code

utils/expcon.h

Page 58: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 58

Implementation aspects of hybrid MPC

•Alternatives: (1)solveMIPon-line (2)evaluateaPWAfunction

•Smallproblems(shorthorizonN=1,2,oneortwoinputs):explicitPWAcontrollawpreferable

-timetoevaluatethecontrollawisshorterthanMIP

-controlcodeissimpler(nocomplexsolvermustbeincludedinthecontrolsoftware!)

-moreinsightincontroller’sbehavior

•Medium/largeproblems(longerhorizon,manyinputsandbinaryvariables):MIPpreferable

Page 59: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 59

Moving Horizon EstimationFault Detection & Isolation

Page 60: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 60

State estimation / fault detection

•Solution:UseMovingHorizonEstimationforMLDsystems(≈dualofMPC)

(Bemporad,Mignone,Morari,ACC1999)

•Inputdisturbances•Outputdisturbances

•Problem:givenpastoutputmeasurementsandinputs,estimatethecurrentstatesandfaults

MHEoptimization=MIQPConvergencecanbeguaranteed (Ferrari-T.,Mignone,Morari,2002)

AugmenttheMLDmodelwith:

Faultdetection: augmentMLDwithunknownbinarydisturbances

t-T t+1-T t-1 t+1-1

minx(tT |t)

TX

k=1ky(t k|t) y(t k)k22 + . . .Ateachtimet

solvetheproblem:andgetestimate

Page 61: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 61

•:valveV1blockedfor

Example: three tank system

•:leakintank1for

COSYBenchmarkproblem,ESF

hv = 0.3 m

Page 62: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 62

Example: Three Tank System

COSYBenchmarkproblem,ESF

•Addlogicconstraint

•:valveV1blockedfor

•:leakintank1for

hv = 0.3 m

Page 63: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 63

A Few Hybrid MPC Tricks …

Page 64: Hybrid MPC

xv(t+1) = xv(t)

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 64

Measured disturbances

•Augmentthehybridpredictionmodelwithaconstantstate

•Disturbancev(t)canbemeasuredattimet

INTERFACE STATE REAL x [-1e3, 1e3]; REAL xv [-1e3, 1e3]; ... IMPLEMENTATION CONTINUOUS x = A*x + B*u + Bv*xv xv= xv; ...

•InHYSDEL:

/demos/hybrid/hyb_meas_dist.m

Note:sametrickappliestolinearMPC

Page 65: Hybrid MPC

minU

N1X

k=0

kWy(yk+1 r(t))k2 + kWuukk2

[uk , uk uk1], u1 = u(t 1)

subj. to hybrid dynamicsumin uk umax, k = 0, . . . , N 1ymin yk ymax, k = 1, . . . , Numin uk umax, k = 0, . . . , N 1

min

J(, x(t)) = 12

0H + [x0(t) r

0(t) u0(t 1)]F

s.t. G W + S

2

4x(t)r(t)

u(t 1)

3

5

=

2

664

u0

0z0...

uN1

N1zN1

3

775

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 65

Hybrid MPC - Tracking

Mixed-IntegerQuadraticProgram

(MIQP)

•Optimizationproblem:

•Optimalcontrolproblem(quadraticperformanceindex):

Note:sametrickasinlinearMPC

Page 66: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 66

Integral action in hybrid MPC•Augmentthehybridpredictionmodelwithintegratorsofoutputerrorsasadditionalstates:

Ts=samplingtime

INTERFACE STATE REAL x [-100,100]; ... REAL epsilon [-1e3, 1e3]; REAL r [0, 100]; OUTPUT REAL y; ... IMPLEMENTATION CONTINUOUS epsilon=epsilon+Ts*(r-(c*x)); r=r; ... OUTPUT y=c*x;

•InHYSDEL:

•Treatr(k)asameasureddisturbance(=additionalconstantstate)

•Addweighton²(k)incostfunctiontomake²(k)→0

/demos/hybrid/hyb_integral_action.m

Note:sametrickappliestolinearMPC

Page 67: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 67

Time-Varying constraintsProblem:changeupper(and/orlower)boundsonline

3.On-lineimplementation:feedthestatebacktothecontroller

Note:sametrickappliestolinearMPC

1.Addaconstantstateandanewoutputinthepredictionmodel:

2.Addoutputconstraint

/demos/linear/varbounds.m

outp

utinpu

tAlternative(inHYSDEL): MUST u <= xu; (noneedtoaddextraoutput)

Page 68: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 68

Reference/disturbance previewMeasureddisturbancev(t)isknownMstepsinadvance

initialcondition

Previewofreferencer(t):similar.

producesv=v(t),v(t+1),…,v(t+M-1),v(t+M-1),…

Note:sametrickappliestolinearMPC

Page 69: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 69

Delays – Method 1•Hybridmodelw/delays:

•Mapdelaystopolesinz=0:

•ApplyMPCtotheextendedMLDsystem

Note:sametrickasinlinearMPC

•ExtendthestatespaceoftheMLDmodel:

Page 70: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 70

Delays – Method 2•Delay-freeMLDmodel:

•DesignMPCfordelay-freemodel:

•Computethepredictedstate:

•ComputeMPCaction: Forbetterclosed-loopperformancethemodelusedforpredictingthefuturehybridstatex(t+τ)maybemoreaccuratethanMLDmodel!

whereareobtainedfromMLDineq.(orHYSDELmodel)

Page 71: Hybrid MPC

NX

i=1i = m

NX

i=1i m

NX

i=1i m

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 71

Choice constraints

1 + 2 + 3 1

1 + 2 + 3 2

1 + 2 + 3 = 1

Sometimes,onehastomakeoneormorechoicesamongacertainsetofalternatives.Examples:

=chooseatmost2itemsoutof3

chooseatmostmitemsoutofN

chooseexactlymitemsoutofN

“Exclusiveor”constraint:

=makenecessarilyone(andonlyone)choice

=makeatmostonechoice

chooseatleastmitemsoutofN

Page 72: Hybrid MPC

2 0,1n

6=

F = i : i = 0T = i : i = 1

X

i2Ti

X

i2Fi 1+

nX

i=1i

nX

i=1(2i 1)i 1+

nX

i=1i

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course

“no-good” Constraints•Givenabinaryvector,wewanttoimposetheconstraint

72

• ThismaybeusefulforexampletoextractdifferentsolutionsfromanMIPthathasmultipleoptima

• The“no-good”conditioncanbeexpressedequivalentlyas

or

Page 73: Hybrid MPC

•When∞-normsareused,onecandothesametrick:

(betterway:iftheMILPproblemconstructorcanbeaccessed,avoidintroducingzuandjustremovetheconstraint²u(k)≥–[R]iu(k)usedtominimize|Ru(k)|,withconstraint²u(k)≥0)

8>>>><

>>>>:

min (. . .) +N1X

k=0z2k

s.t. zk ukzk 0

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 73

Asymmetric weights•Sayyouwanttoweightavariableu(k)onlyifu(k)≥0

INTERFACE INPUT REAL u [-100,100]; REAL z [-1, 1e3]; ... IMPLEMENTATION MUST z >= u; z >= 0;

•InHYSDEL:

• Onewayistointroduceabinaryvariable[±=1]↔[u≥0],acontinuousvariablez=uif±=1,z=0otherwise,andweightz

•Bettersolution:avoid±andset:

Note:sametrickappliestolinearMPC

8>>>><

>>>>:

min (. . .) +N1X

k=0|zk|

s.t. zk ukzk 0

Page 74: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 74

General remarks about MIP modeling

Thecomplexityofsolvingamixed-integerprogramlargelydependsonthenumberofinteger(binary)variablesinvolvedintheproblem

Bethriftywithbinaryvariables!

Hence,whencreatingahybridmodelonehasto

Modelingisanart(aunifyinggeneraltheorydoesnotexist)

Generallyspeaking:

Addinglogicalconstraintsusuallyhelps...

Page 75: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 75

Verification of Safety Properties (Reachability Analysis)

Page 76: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 76

Hybrid verification problem

binarydisturbances

hybridprocess

continuousdisturbances

binarystates

continuousstates

verificationalgorithmsafetyquery

setofpossibleinitialstates

setofpossibledisturbances

answer

alwayssafe!

counter-example

Page 77: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 77

Verification algorithm #1

•Alternativesolutions:•Exploitthespecialstructureoftheproblemandusepolyhedralcomputation.

•Useabstractions(LPs)+SATsolvers

• QUERY:IsthetargetsetXfreachableafterNstepsfromsomeinitialstatex02 X0forsomeinputprofileu 2 U?

• Computation:Solvethemixed-integerlinearprogram(MILP)

(Torrisi,2003)

(Giorgetti,Pappas,Bemporad,2005)

withrespecttou(0),δ(0),z(0),…,u(N-1), δ(N-1),z(N-1),x(0)

Page 78: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 78

Verification example #1

•MLDmodel:roomtemperaturesystem

••N=10(timehorizon)

(setofunsafestates)

(setofinitialstates)

(setofpossibleinputs)

>>[flag,x0,U]=reach(S,N,Xf,X0,umin,umax);

Page 79: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 79

Verification example #1

Page 80: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 80

Verification algorithm #2

• QUERY:IsthetargetsetXfreachablewithinNstepsfromsomeinitialstatex02 X0forsomeinputprofileu 2 U?

-SolveMILPfeasibilitytest

• IDEA:AugmenttheMLDsystemtoregistertheentranceofthetarget(unsafe)setXf=x:Afx·bf:

-Addanewvariableδf(k),where[δf(k)=1]![x(k+1)2 Xf]

-Addtheconstraint(x2Xfforatleastonek)

big-M

Page 81: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 81

Verification example #3•States/inputs:

•Events:

•Switcheddynamics:

•Automaton:

Query:StartingfromX0,isitpossiblethatx(k)∈Xfatsomek≤N,undertherestrictionthatx3(k)+x2(k)≤0,δ1(k)|δ2(k)|x5(k)istrue,and~x4(k)|x5(k)isalsotrue∀k≤N?

gotodemo/demos/hybrid/reachtest.m

Page 82: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 82

Verification example #3

•N=5

(setofpossibleinputs)

>>[flag,x0,U,xf,X,T,D,Z,Y,reachtime]=reach(S,[1 N],Xf,X0);

(setofinitialstates)

(setofunsafestates)

(timehorizon)

Page 83: Hybrid MPC

05 -(C)2017A.Bemporad-“ModelPredictiveControl”course 83

Verification example #3

ThesetXfisreachedbyx(k)attimesk=2,3,4