Model Predictive Control of Hybrid Systems Alberto Bemporad

advertisement
Model Predictive Control
of Hybrid Systems
Model Predictive Control
of Hybrid Systems
Controller
Alberto Bemporad
Reference
r(t)
Dip. di Ingegneria dell’Informazione
Università degli Studi di Siena
•
•
Università degli Studi di Siena
Facoltà di Ingegneria
Receding Horizon Philosophy
– minimize |y à r| + ú|u|
Input
u(t)
Output
y(t)
Measurements
bemporad@dii.unisi.it
http://www.dii.unisi.it/~bemporad
http://www.dii.unisi.it/~bemporad
• At time t :
Solve an optimal
control problem over a
finite future horizon p :
Hybrid System
•
MODEL: a model of the plant is needed to predict the future
behavior of the plant
PREDICTIVE: optimization is based on the predicted future
evolution of the plant
CONTROL: control complex constrained multivariable plants
Receding Horizon - Example
r(t)
Predicted outputs
Manipulated
Inputs
t t+1
MPC is like playing chess !
u(t+k)
t+p
– subject to constraints
u min ô u ô u max
y min ô y ô y max
t+1 t+2
t+p+1
• Only apply the first optimal move u ã (t)
• Get new measurements, and repeat the optimization
at time t +1
Advantage of on-line optimization: FEEDBACK!
1
MPC for Hybrid Systems
past
Closed-Loop Stability
future
Model
Predictive (MPC)
Control
Predicted
outputs y(t+k|t)
Manipulated
Inputs u(t+k)
t t+1
t+T
• At time t solve with respect to
the finite-horizon open-loop, optimal control problem:
(Bemporad, Morari 1999)
• Apply only u(t) =uã(t) (discard the remaining optimal inputs)
Proof: Easily follows from standard Lyapunov arguments
• Repeat the whole optimization at time t+1
Stability Proof
Hybrid MPC - Example
Switching System:
"
x(t + 1) = 0.8
Lyapunov function
cos ë(t) à sinë(t)
sinë(t)
cos ë(t)
#
ô õ
x(t) + 0 u(t)
1
y(t) = [ 0 1 ] x(t)

ù


if [1 0]x(t) õ 0
3
ë(t) =
ù

 à if [1 0]x(t) < 0
3
Constraint:
Open loop:
Closed loop:
y(t), r(t)
u(t)
à 1 ô u (t) ô 1
time t
time t
Note: Global optimum not needed for convergence !
2
MIQP Formulation of MPC
(Bemporad, Morari, 1999)
Optimal Control of Hybrid Systems:
Computational Aspects
Mixed Integer Quadratic Program (MIQP)
(Bemporad, Borrelli, Morari, 2000)
Mixed-Integer Program Solvers
• Mixed-Integer Programming is NP-hard
Phase transitions have been found in
computationally hard problems.
• Introduce slack variables:
ïxk
ïuk
• Set
õ kQy(t + k|t)k∞
õ kRu(t + k)k∞
ø,[ïx1 ,
. . .,
ïxN , ïu1 ,
y
min |x|
ïxk
ïxk
ïuk
ïuk
BUT
min ï
s.t. ï õ x
ïõ àx
[Qy(t + k|t)]i
õ
õ à [Qy(t + k|t)]i
õ [Ru(t + k))]i
õ à [Ru(t + k))]i
i = 1, . . ., p,
i = 1, . . ., p,
i = 1, . . ., m,
i = 1, . . ., m,
4000
50 var
40 var
20 var
3000
2000
1000
0
2
3
4
5
6
7
8
Ratio of Constraints to Variables
(Monasson et al., Nature, 1999)
k = 1, . . ., T à 1
k = 1, . . ., T à 1
k = 0, . . ., T à 1
k = 0, . . ., T à 1
• General purpose Branch & Bound/Branch & Cut solvers available
for MILP and MIQP (CPLEX, Xpress-MP, BARON, GLPK, ...)
More solvers and benchmarks: http://plato.la.asu.edu/bench.html
• No need to reach global optimum (see proof of the theorem),
although performance deteriorates
. . ., ïTà1 , U, î, z]
min J(ø, x (t)) =
Mixed Integer Linear Program
(MILP)
Cost of Computation
MILP Formulation of MPC
ø
Tà1
X
ï xi + ïui
k=0
s.t.Gø ô W + Sx (t)
Good for large sampling times (e.g., 1 h) / expensive hardware …
… but not for fast sampling (e.g. 10 ms) / cheap hardware !
3
On-Line vs. Off-Line Optimization
min J(U, x(t)),
U
Tà1
P
kQy(t + k + 1|t)k∞ + kRu(t + k)k∞
k=0

 MLD model
subj. to
x(t|t) = x(t)

x(t + T|t) = 0
Explicit Form of
Model Predictive Control
• On-line optimization: given x(t), solve the problem at each time step t
Mixed-Integer Linear Program (MILP)
via Multiparametric Programming
• Off-line optimization: solve the MILP for all x(t)
min J(ø, x (t)), f 0 ø
ø
s.t.Gø ô W + F x (t)
multi-parametric Mixed Integer Linear Program (mp-MILP)
Linear MPC
Example of Multiparametric Solution
Multiparametric LP ( ø ∈ R2 )
40
• Linear Model:
CR{1,2,3}
CR{1,4}
60
CR{1,3}
20
• Constraints:
CR{2,3}
x2 0
- 20
• Optimal control problem (quadratic performance index):
- 40
- 60
- 60
- 40
- 20
0
20
40
60
x1
4
Linear MPC
Multiparametric Quadratic Programming
(Bemporad et al., 2002)
• Substitution:
• Optimization problem:
(quadratic)
(linear)
Convex QUADRATIC PROGRAM (QP)
• Objective: solve the QP for all
• Assumption:
Linearity of the Solution
x0∈ X
solve QP to find
(always satisfied if QP
problem originates from
optimal control problem)
Determining a Critical Region
• Impose primal and dual feasibility:
identify active constraints at
linear inequalities in x !
form matrices
by collecting
active constraints
KKT
optimality
conditions:
From (1) :
From (2) :
In some neighborhood of x0, λ and U are explicit
affine functions of x !
• Remove redundant constraints
• x0
critical region CR0
CR0
CR0 = {Ax ô B}
x-space
X
à,W
à ,S
à
• CR0 is the set of all and only parameters x for which G
is the optimal combination of active constraints at the optimizer
5
Multiparametric QP
R2
x-space
RN
R2
CR0 = {Ax ô B}
R3
•x0
CR0
R1
Multiparametric QP
Ri = {x ∈ X : Aix > Bi, Ajz ô Bj, ∀j < i}
R4
{CR0 , R1 , . . ., RN}
Theorem:
is a partition of X ò Rn
X
X ← Ri
Mp-QP – More efficient method
(Tøndel, Johansen, Bemporad, 2003)
x2
R4
{CR0 , R1 , . . ., RN}
Theorem:
is a partition of X ò Rn
Note: while CR0 is characterizing a set of active constraints, Ri is not
X
X
Keep track of the CR already
explored, don’t split CRs
Mp-QP Properties
x2
CR
CR
Ri = {x ∈ X : Aix > Bi, Ajz ô Bj, ∀j < i}
X
Ri
The recursive algorithm terminates after a finite
number of steps, because the number of combinations
of active constraints is finite
x2
RN
x-space
Proceed iteratively: for each region
repeat the whole procedure with
•x0
CR0
R1
CR0 = {Ax ô B}
R3
CR
continuous,
piecewise affine
x1
x1
x1
The active set of a neighboring region is found by using
the active set of the current region + knowledge of the
type of hyperplane we are crossing:
⇒ The corresponding constraint is added to the
active set
convex, continuous,
piecewise quadratic,
C1 (if no degeneracy)
Corollary: The linear MPC controller is a continuous
piecewise affine function of the state
⇒ The corresponding constraint is withdrawn from
the active set
6
Complexity Reduction
2.5
2.5
CR1
CR2
CR3
CR4
CR5
CR6
CR7
CR8
CR9
2
1.5
1
• System: y(t) =
CR1
CR2
CR3
CR4
CR5
CR6
CR7
2
1.5
1
s2
ô
x(t + 1) = 1
0
u(t)
sampling + ZOH
Ts=1 s
1
0.5
õ
ô õ
1 x(t) + 0 u(t)
1
1
0 ] x(t)
y(t) = [ 1
0.5
0
• Constraints: à 1 ô u(t) ô 1
0
-0.5
-0.5
-1
-1
-1.5
• Control objective: minimize
-1.5
-2
-2.5
-2.5
Double Integrator Example
P∞
t=0
1 2
y 0 (t)y(t) + 100
u (t)
-2
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
2.5
-2.5
-2.5
-2
-1.5
-1
-0.5
0
0.5
1
1.5
2
u t+k = KLQ x(t + k|t) ∀k õ N u
2.5
• Optimization problem: for Nu=2
(cost function is
normalized by
max λ(H))
Regions where the first component of the solution is the same
can be joined (when their union is convex). (Bemporad, Fukuda, Torrisi,
Computational Geometry, 2001)
mp-QP solution
Complexity
Nu=5
Nu=4
Nu=3
Nu=2
CPU time
40
20
0
0
# Regions
Nu=6
5
10
15
20
15
20
300
200
100
0
0
5
10
# free moves
7
Complexity
• Worst- case complexity analysis:
M,
Pq
Nr ô
( q ) = 2q
`=0 `
PMà1
k=0
k!qk
Extensions
• Tracking of reference r(t) : îu(t) = F(x(t), u(t à 1), r(t))
combinations of active constraints
upper-
bound to the number of regions
• Numerical Tests:
• Rejection of measured
disturbance v(t) :
îu(t) = F(x(t), u(t à 1), v(t))
• Soft constraints:
u(t) = F(x(t))
Number of regions in the state-space
partition
y min à ï ô y(t + k|t) ô y max + ï
• Variable constraints:
u min(t) ô u(t + k) ô u max(t)
y min(t) ô y(t + k|t) ô y max(t)
Computation time (s)
[Matlab 5.3, Pentium II 300MHz]
• Linear norms:
ClosedClosed-Loop MPC and Hybrid Systems
u(t) = F(x(t), u min(t), . . ., y max(t))
min J(U, x(t)),
U
Pp
k=0
kQy(t + k|t)k ∞ + kRu(t + k)k ∞
(Bemporad, Borrelli, Morari, IEEE TAC, 2002)
MPC Regulation of a Ball on a Plate
Task:
•
Tune an MPC
controller by
simulation, using the
MPC Simulink
Toolbox
•
Get the explicit
solution of the MPC
controller.
•
Validate the controller
on experiments.
DHA
Motivation:
Use hybrid techniques to analyze closed-loop MPC systems !
(Bemporad, Heemels, De Schutter IEEE TAC, 2002)
8
Ball&Plate Experiment
General Philosophy: (1) MPC Design
• Step 1: Tune the MPC controller (in simulation)
y
x
γ
δ
α'
β'
α
β
•
Specifications:
Angle:
-17 deg … +17deg
Plate:
-30 cm …+30 cm
Input Voltage: -10 V… +10 V
Computer: PENTIUM166
Sampling Time:30 ms
•
Model:
LTI 14 states
Constraints on inputs and states
E.g: MPC Toolbox for Matlab
(Bemporad, Morari, Ricker, 2003)
MPC Tuning
General Philosophy: (2) Implementation
• Step 2: Solve mp
MPC
QP and implement Explicit
Sampling time:
Prediction horizon:
Free control moves:
Ts = 30 ms
p = 50
m=2
m
Output constraint horizon:
1 (soft constraint)
Input constraint horizon:
1 (hard constraint)
Weight on position error:
5
Weight on input voltage changes:
E.g: Real-
y
u
p
1
T
ime Workshop + xPC Toolbox
9
Explicit MPC Solution
MPC Regulation of a Ball on a Plate
x: 22 Regions, y: 23 Regions
Controller:
Design Steps:
x-MPC: sections at αx=0, αx=0, ux=0, rx=18, rα=0
o
•
Tune an MPC
controller by
simulation, using
the MPC Simulink
Toolbox .
•
Get the explicit
solution of the
16
1
6
6
1
16
MPC controller.
9 Validate the
controller on
experiments.
Region 1:
LQR Controller (near Equilibrium)
Region 6:
Saturation at -10
Region 16: Saturation at +10
Comments on Explicit MPC
MILP Formulation of MPC
(Bemporad, Borrelli, Morari, 2000)
• Multiparametric Quadratic Programs (mp-QP) can be solved efficiently
• Model Predictive Control (MPC) can be solved off-line via mp-QP
• Introduce slack variables:
min |x |
• Explicit solution of MPC controller u = f(x) is Piecewise Affine
ïxk
ïuk
õ kQy(t + k|t)k∞
õ kRu(t + k)k∞
x
Eliminate heavy on-line computation for MPC
x
ïxk
ïxk
ïuk
ïuk
min ï
s.t. ï õ x
ïõ àx
õ [Qy(t + k|t)]i
õ à [Qy(t + k|t)]i
õ [Ru(t + k))]i
õ à [Ru(t + k))]i
i = 1, . . ., p,
i = 1, . . ., p,
i = 1, . . ., m,
i = 1, . . ., m,
k = 1, . . ., T à 1
k = 1, . . ., T à 1
k = 0, . . ., T à 1
k = 0, . . ., T à 1
u
• Set ø , [ ï1 , . . . , ï N y, ï1 , . . . , ïTà 1 , U, î, z ]
min J(ø, x (t)) =
Make MPC suitable for fast/small/cheap processes
Mixed Integer Linear Program
(MILP)
ø
Tà1
X
ï xi + ïui
k=0
s.t.Gø ô W + Sx (t)
10
Multiparametric MILP
Solutions via Dynamic Programming
(Borrelli, Bemporad, Baotic, Morari, 2003)
(Mayne, ECC 2001)
min
ø={ø c ,ød}
f 0øc + d0ød
s.t. Gøc + Eød ô W + Fx
ø c ∈ Rn
ø d ∈ {0, 1} m
• mp-MILP can be solved (by alternating MILPs and mp-LPs)
(Dua, Pistikopoulos, 1999)
• Theorem: The multiparametric solution
ø ã (x) is piecewise affine
• Explicit solutions to finite
- time optimal control
problems for PWA systems can be obtained using a
combination of
• Dynamic Programming
• Multiparametric Linear (1
- norm, ∞
norm), or
or Quadratic (squared 2
- norm) programming
• Corollary: The MPC controller is piecewise affine in x
Note: in the 2-norm case,
the partition may not be polyhedral
Hybrid Control - Example
Switching System:
"
x(t + 1) = 0.8
Hybrid Control Example
(Revisited)
#
cos ë(t) à sin ë(t)
sin ë(t)
cos ë(t)
ô õ
x(t) + 0 u(t)
1
y(t) = [ 0 1 ] x(t)

ù


if [1 0]x(t) õ 0
3
ë(t) =
ù

 à if [1 0]x(t) < 0
3
Closed loop:
y(t), r(t)
u(t)
Constraint: à 1 ô u (t) ô 1
Open loop:
time t
time t
11
Hybrid MPC - Example
• MLD system
• mp
-
State x (t)
2 variables
Input u(t)
1 variables
Aux. binary vector δ(t)
1 variables
Aux. continuous vector z(t)
4 variables
mp-MILP Solution
Prediction Horizon T=2
M
ILP optimization problem
P
minn 1o J(v10, x(t)), 1k=0 kQ1(v(k) à ue)k∞ + kQ2(î(k|t) à îe)k∞ + kQ3(z(k|t) à ze)k∞ + kQ4(x(k|t) à xe)k∞
v
0
subject to constraints
to be solved in the region
à5
à5
ô x1 ô
ô x2 ô
5
5
• Computational complexity of mp
-
M
ILP
Linear constraints
Continuous variables
Binary variables
Parameters
Time to solve mp-MILP
Number of regions
PWA law
84
20
2
2
3 min
7
ñ MPC law
Linear constraints
Continuous variables
Binary variables
Parameters
Time to solve mp-MILP
Number of regions
84
20
2
2
3 min
7
mp-MILP Solution
X2
Hybrid Control Example:
Traction Control System
X2
X1
Prediction Horizon T=3
X1
Prediction Horizon T=4
12
Simple Traction Model
Vehicle Traction Control
• Mechanical system
Improve driver’s ability to control a vehicle
under adverse external conditions (wet or icy roads)
ò
ó
üt
1
üc à beωe à
gr
Je
üt
vç v =
mv rt
ωç e =
• Manifold/fueling dynamics
üc = biüd(t à üf)
• Tire torque τt is a function of
slip ∆ω and road surface
Model
nonlinear, uncertain,
constraints
adhesion coefficient µ
Controller
suitable for real-time
implementation
∆ω =
Hybrid Model
Tire Force Characteristics
Nonlinear tire torque τt =f(∆ω , µ)
Torque
Longitudinal Force
PWA Approximation
(PWL Toolbox, Julian, 1999)
Slip Target
Zone
Maximum
Braking
Slip
Maximum
Cornering
Maximum
Acceleration
Steer Angle
Tire Slip
Longitudinal
Force
Lateral
Force
Torque
ra
µ
Tire Forces
te
La
Wheel slip
∆ω
MLD hybrid framework + optimization-based control strategy
ce
or
lF
ωe vv
à
gr rt
Mixed-Logical
µ
Slip
HYSDEL
(Hybrid Systems
Description Language)
Dynamical (MLD)
Hybrid Model
(discrete time)
13
MLD Model
Performance and Constraints
• Control objective:
min
PN
k=0
subj. to.
State x(t)
9 variables
Input u(t)
1 variable
Aux. Binary vars δ(t)
3 variables
Aux. Continuous vars z(t)
4 variables
|∆ω(k|t) à ∆ωdes|
MLD Dynamics
• Constraints:
• Limits on the engine torque: à 20Nm ô ü d ô 176Nm
• Logic Constraint:
• Hysteresis
The MLD matrices are automatically
generated in Matlab format by HYSDEL
Experimental Apparatus
Experimental Apparatus
14
Experiment
Hybrid Control Example:
Cruise Control System
• >500 regions
• 20ms sampling time
• Pentium 266Mhz +
Labview
Hybrid Control Problem
Renault Clio 1.9 DTI RXE
Hybrid Model
• Vehicle dynamics
mẍ = F e à F b à ìxç
xç
= vehicle speed
Fe =
traction force
Fb =
brake force
discretized with sampling time
T s = 0.5 s
• Transmission kinematics
GOAL:
command gear ratio, gas pedal,
and brakes to track a desired
speed and minimize consumption
ω=
Rg(i)
xç
ks
Fe =
Rg(i)
M
ks
ω
= engine speed
M=
i
engine torque
= gear
15
Hybrid Model
• Engine torque
Hybrid Model
• Gear selection: for each gear #i,
+
à Cà
e (ω) ô M ô Ce (ω)
define a binary input
gi ∈ {0, 1}
C+
e (ω)
• Max engine torque
• Gear selection (traction force):
Fe =
180
Rg( i)
M
ks
depends on gear #i
define auxiliary continuous variables:
160
http://www.renault.fr
Piecewise-linearization:
120
(PWL Toolbox, Julián, 1999)
100
requires: 4 binary aux variables
4 continuous aux variables
• Min engine torque
IF gi = 1 THEN F ei =
140
Rg(i)
M
ks
ELSE 0
F e = F eR + F e1 + F e2 + F e3 + F e4 + F e5
80
60
1000
2000
3000
4000
Cà
e (ω) = ë1 + ì 1 ω
• Gear selection (engine/vehicle speed):
ω=
Rg( i)
xç
ks
similarly, also requires 6 auxiliary continuous variables
Hysdel Model
Hybrid Model
• MLD model
x(t + 1) = Ax(t) + B1 u(t) + B2 î(t) + B3 z(t)
y(t) = Cx(t) + D1 u(t) + D2 î(t) + D3 z(t)
E 2 î(t) + E 3 z(t) ô E 4 x(t) + E 1 u(t) + E 5
x, v
• 2 continuous inputs: M, F b
• 6 binary inputs: gR, g1 , g2 , g3 , g4 , g5
• 1 continuous output:v
• 2 continuous states:
• 16 auxiliary continuous vars:
• 4 auxiliary binary vars:
(vehicle position and speed)
(engine torque, brake force)
(gears)
(vehicle speed)
(6 traction force, 6 engine speed,
4 PWL max engine torque)
(PWL max engine torque breakpoints)
• 96 mixed-integer inequalities
http://control.ethz.ch/~hybrid/hysdel
16
Hybrid Controller
Hybrid Controller
• Max-speed controller
• Max-speed controller
Velocity (km/h)
Gear
200
max J(u t, x(t)),v(t + 1|t)
ut
ú
MLD model
subj. to
x(t|t) = x(t)
Fraction of Max Torque (Nm)
1
1
150
4
0.5
0.5
250
100
3
50
2
0
1
Linear constraints
Continuous variables
Binary variables
Parameters
Time to solve mp-MILP
(Sun Ultra 10)
Number of regions
v(t)
0
0
200
MILP optimization problem
Brakes (Nm)
5
-0.5
-0.5
150
0
50
100
0
50
100
-1
0
50
-1
100
0
50
100
100
96
18
10
1
Road Slope (deg)
Engine speed (rpm)
1
50
Engine Torque (Nm)
6000
Power (kW)
200
60
5000
50
0.5
0
150
4000
x (t)
45 s
11
0
40
3000
( x (t ) is irrelevant)
100
30
2000
20
-0.5
50
1000
-1
0
50
Time (s)
Hybrid Controller
100
10
0
0
100
0
0
50
Time (s)
0
100
0
50
Time (s)
100
Hybrid Controller
• Tracking controller
min J(u t, x (t)),|v(t + 1|t) à vd(t)| + ú|ω|
• Tracking controller
min J(u t, x(t)),|v(t + 1|t) à vd (t)| + ú|ω|
ut
ú
MLD model
subj. to
x(t|t) = x (t)
50
Time (s)
Velocity (km/h), Desired velocity (km/h)
120
ut
Gear
Fraction of Max Torque (Nm)
5
Brakes (Nm)
10000
1
100
8000
4
0.5
80
6000
60
250
3
0
4000
40
2
200
0
MILP optimization problem
Linear constraints
Continuous variables
Binary variables
Parameters
Time to solve mp-MILP
(Sun Ultra 10)
Number of regions
98
19
10
2
27 m
49
vd(t)
150
0
100
200
1
0
100
200
2000
-1
0
100
200
0
0
100
200
ú = 0.001
100
6
50
00
-0.5
20
40
80
120
v(t)
160
200
6000
5000
2
4000
0
3000
-2
2000
-4
1000
-6
0
100
Time (s)
Engine Torque (Nm)
Engine speed (rpm)
Road Slope (deg)
4
200
0
0
Power (kW)
200
100
100
50
0
100
Time (s)
200
0
-100
-50
-200
-100
0
100
Time (s)
200
0
100
200
Time (s)
17
Hybrid Controller
Hybrid Controller
• Smoother tracking controller
• Smoother tracking controller
Velocity (km/h), Desired velocity (km/h)
120
min J(u t, x(t)),| v(t + 1 |t) à vd (t)| + ú| ω|
ut

 |v(t + 1|t) à v(t)| < T samax
subj. to
MLD model

x(t|t) = x(t)
Gear
Fraction of Max Torque (Nm)
5
100
8000
4
0.5
80
6000
60
3
0
2
-0.5
20
Linear constraints
Continuous variables
Binary variables
Parameters
Time to solve mp-MILP
(Sun Ultra 10)
Number of regions
100
19
10
2
200
28 m
54
0
0
150
vd(t)
6
100
50
00
4000
40
250
MILP optimization problem
Brakes (Nm)
10000
1
40
80
120
v(t)
160
200
100
200
1
0
100
200
2000
-1
0
6000
4
5000
2
4000
0
3000
-2
2000
200
-6
0
0
100
200
Power (kW)
200
100
100
50
0
0
-50
-100
-4
0
Engine Torque (Nm)
Engine speed (rpm)
Road Slope (deg)
100
1000
100
Time (s)
200
0
-200
0
100
Time (s)
200
0
100
Time (s)
200
-100
0
100
200
Time (s)
18
Download