SlideShare a Scribd company logo
C21 Model Predictive Control
Mark Cannon
4 lectures
Hilary Term 2023
Department of Engineering Science
eng.ox.ac.uk/control
0 - 1
Lecture 1
Introduction
1 - 2
Organisation
B 4 lectures – Tuesday & Thursday weeks 5 & 6
in person at 14:00 in LR2
or pre-recorded on Canvas
B Examples class – Thursday week 7
in person at 12:00, 14:00, 15:00 in LR6
1 - 3
Course outline
1. Introduction to predictive control
2. Prediction and optimization
3. Closed loop properties
4. Disturbances and integral action
5. Robust tube MPC
1 - 4
Books
B J.M. Maciejowski, Predictive control with constraints. Prentice Hall, 2002
Recommended reading: Chapters 1–3, 6 & 8
B J.B. Rawlings and D.Q. Mayne, Model Predictive Control: Theory and Design. Nob Hill
Publishing, 2009
B B. Kouvaritakis and M. Cannon, Model Predictive Control: Classical, Robust and Stochastic,
Springer 2015
Recommended reading: Chapters 1, 2 & 3
1 - 5
Motivating example: switching control
How does a thermostat regulate room temperature?

tĞĚŶĞƐĚĂLJ͕ϮϵƉƌŝůϮϬϮϬ ϭϰ͗ϬϬ
Closed loop control system:
 PUFEQGXVHP
dŚĞƌŵŽĚŝĂŐƌĂŵƐ
tĞĚŶĞƐĚĂLJ͕ϮϵƉƌŝůϮϬϮϬ ϭϰ͗ϬϬ
1 - 6
Motivating example: switching control
System model:
C
dT
dt
= q − qL
qL = βT
q = αu
u =
(
U if on
0 if off
Switching controller:
 PUFEQGXVHP
dŚĞƌŵŽƐǁŝƚĐŚŝŶŐƉůŽƚƐ
tĞĚŶĞƐĚĂLJ͕ϮϵƉƌŝůϮϬϮϬ ϭϱ͗ϯϰ
? Single controller parameter: hysteresis band δ
? Accurate models aren’t needed to regulate T to [T0
− δ, T0
+ δ]
1 - 7
Motivating example: switching control
System model:
C
dT
dt
= q − qL
qL = βT
q = αu
u =
(
U if on
0 if off
Closed loop response:
T(t) = Tss + (T(0) − Tss)e−t/τ
Tss =
(
αU/β if on
0 if off
τ =
C
β
? Single controller parameter: hysteresis band δ
? Accurate models aren’t needed to regulate T to [T0
− δ, T0
+ δ]
1 - 7
Motivating example: switching control
System model:
C
dT
dt
= q − qL
qL = βT
q = αu
u =
(
U if on
0 if off
Closed loop response:
? Single controller parameter: hysteresis band δ
? Accurate models aren’t needed to regulate T to [T0
− δ, T0
+ δ]
1 - 7
Motivating example: proportional control (P)
System model:
C
dT
dt
= q − qL
qL = βT
q = αu
u = K(T0
− T)
Closed loop response:
T(t) = Tss + (T(0) − Tss)e−t/τ
Tss =
αK
αK + β
T0
τ =
C
αK + β
? Controller parameter: gain K
? Tss → T0
and τ → 0 as K → ∞ independent of parameters C, α, β
1 - 8
Motivating example: proportional control (P)
Controller: u = K(T0
− T)
Effect of increasing gain (ideal case), K1  K2  K3:
 PUFEQGXVHP
WƌŽƉŽƌƚŝŽŶĂůƉůŽƚƐ
tĞĚŶĞƐĚĂLJ͕ϮϵƉƌŝůϮϬϮϬ ϭϳ͗ϯϭ
High gain K is often de-stabilizing because of:
? nonlinearity, e.g. actuator saturation: u = min
n
ū, max

K(T0
− T), 0
o
? additional dynamics, e.g. sensor and actuator time-delay or lag
1 - 9
Motivating example: proportional control (P)
Controller: u = K(T0
− T)
Actual effect of increasing gain:
High gain K is often de-stabilizing because of:
? nonlinearity, e.g. actuator saturation: u = min
n
ū, max

K(T0
− T), 0
o
? additional dynamics, e.g. sensor and actuator time-delay or lag
1 - 9
Motivating example: proportional + integral control (PI)
Control signal proportional to tracking error and integral of tracking error:
u = K(T0
− T) +
K
Ti
Z t
(T0
− T) dt
? If closed loop system is stable
then T0
− T(t) → 0 as t → ∞, i.e. no steady state error
(assuming T0
= constant)
? Controller has no knowledge of model parameters
but increasing gain (K/Ti) generally degrades transient performance
(overshoot and oscillations)
? Two controller parameters K, Ti to be tuned/optimized
1 - 10
Motivating example: PID control
Include the rate of change of tracking error:
u = K(T0
− T) +
K
Ti
Z t
(T0
− T) dt + KTd
d
dt
(T0
− T)
? The derivative term provides anticipation of future error (“feedforward”)
? Three PID gains K, Ti, Td need tuning, either using a system model or heuristic rules
(e.g. Ziegler-Nichols)
? PID tuning is difficult with nonlinear dynamics and constraints
? Not obvious how to configure feedback loops for MIMO problems
1 - 11
Controller optimization
Can we optimize controller parameters for a given performance criterion?
e.g. mean square error: min
K,Ti,Td
Z ∞
0
E{(T0
− T)2
+ ρu2
} dt
KWWSVXQLR[IRUGQH[XVPVKDUHSRLQWFRPSHUVRQDOHQJVBR[BDFBXNBODRXWV'RFDVS[VRXUFHGRF ^FFHIDHEFGI` DFWLRQ«
? Optimization of linear controller gains (e.g. K, Ti, Td) is generally nonconvex
? It’s more common to optimize over control signals (e.g. LQG control)
min
u
Z ∞
0
E{(T0
− T)2
+ ρ u2
} dt
Unconstrained linear system =⇒ solution is linear state feedback
but no closed-form solution in almost all other cases
1 - 12
Model predictive control
MPC optimizes predicted performance numerically over future control and state trajectories
KWWSVXQLR[IRUGQH[XVPVKDUHSRLQWFRPSHUVRQDOHQJVBR[BDFBXNBODRXWV'RFDVS[VRXUFHGRF ^FFHIDHEFGI` DFWLRQ«
? The optimization is generally easier than optimizing feedback gains
(e.g. convex for linear systems with linear state and input constraints)
? Single-shot solution is an open loop control signal
MPC updates it by repeating the optimization periodically online
? This results in a feedback controller,
providing robustness to model and measurement uncertainty
and compensating for using finite numbers of optimization variables
1 - 13
Model predictive control
1 Prediction using a dynamic model  constraints
2 Online optimization
3 Receding horizon implementation
1. Prediction
? Plant model: xk+1 = f(xk, uk)
? Simulate forward in time (over a prediction horizon of N steps)
predicted
input
sequence
uk =





u0|k
u1|k
.
.
.
uN−1|k





predicted
state
sequence
xk =





x0|k
x1|k
.
.
.
xN|k





Notation: (ui|k, xi|k) = predicted i steps ahead | evaluated at time k
x0|k = xk
1 - 14
Overview of MPC
2. Optimization
? Performance cost: J(xk, uk) =
N
X
i=0
`i(xi|k, ui|k)
`i(x, u): stage cost
? Optimize numerically to determine the optimal input sequence:
u∗
k = arg min
uk
J(xk, uk)
= u∗
0|k(xk), . . . , u∗
N−1|k(xk)

3. Implementation
? Use first element of u∗
k =⇒ MPC law: uk = u∗
0|k(xk)
? Repeat optimization at each sampling instant k = 0, 1, . . .
1 - 15
Overview of MPC
time
prediction horizon
time
past predicted
u
x
k k + N
1 - 16
Overview of MPC
time
prediction horizon at time
prediction horizon at time
time
u
x
k
k + 1
k k + N
k + 1 k + N + 1
1 - 16
Example
Plant model: xk+1 =

1.1 2
0 0.95

xk +

0
0.0787

uk
yk =

−1 1

xk
Cost:
N−1
X
i=0
(y2
i|k + u2
i|k) + y2
N|k
Prediction horizon: N = 3
Predicted input and state sequences: uk =


u0|k
u1|k
u2|k

, xk =




x0|k
x1|k
x2|k
x3|k




1 - 17
Example
0 1 2 3 4 5 6 7 8 9 10
input
-4
-2
0
2
4
6
sample
0 1 2 3 4 5 6 7 8 9 10
output
-1
-0.5
0
0.5
1
1 - 18
Example
0 1 2 3 4 5 6 7 8 9 10
input
-4
-2
0
2
4
6
sample
0 1 2 3 4 5 6 7 8 9 10
output
-1
-0.5
0
0.5
1
1 - 18
Example
0 1 2 3 4 5 6 7 8 9 10
input
-4
-2
0
2
4
6
sample
0 1 2 3 4 5 6 7 8 9 10
output
-1
-0.5
0
0.5
1
1 - 18
Example
0 1 2 3 4 5 6 7 8 9 10
input
-4
-2
0
2
4
6
sample
0 1 2 3 4 5 6 7 8 9 10
output
-1
-0.5
0
0.5
1
1 - 18
Example
0 1 2 3 4 5 6 7 8 9 10
input
-4
-2
0
2
4
6
predicted at k=0
closed loop
sample
0 1 2 3 4 5 6 7 8 9 10
output
-1
-0.5
0
0.5
1
1 - 18
Model predictive control
Advantages
B Flexible plant model
– multivariable
– linear or nonlinear
– deterministic, stochastic or fuzzy
B Handles constraints on control inputs and states
– actuator limits
– safety, environmental and economic constraints
B Approximately optimal control
Disadvantages
B Requires online optimization
– quadratic programming (QP) problem for linear-quadratic problems
– high computational requirement for nonlinear systems
1 - 19
MPC development
Control strategy reinvented several times
LQG optimal control 1950’s
industrial process control 1980’s
constrained nonlinear MPC 1990’s
robust MPC 2000’s
stochastic MPC 2010’s
Current research challenges:
– high sample rates, long prediction horizons, uncertain  nonlinear models
– embedded optimization  sparse solvers
– adaptive and stochastic MPC
1 - 20
Prediction model
Linear plant model: xk+1 = Axk + Buk
B Predicted xk depends linearly on uk [details in Lecture 2]
B Therefore LQ cost is quadratic in uk u
k Huk + 2f
uk + g(xk)
and constraints are linear Acuk ≤ b(xk)
B Online optimization:
min
u
u
Hu + 2f
u s.t. Acu ≤ bc
This is a convex Quadratic Program (QP),
which is reliably and efficiently solvable
1 - 21
Prediction model
Nonlinear plant model: xk+1 = f(xk, uk)
B Predicted xk depends nonlinearly on uk
B In general the cost is nonconvex in uk: J(xk, uk)
and the constraints are nonconvex: gc(xk, uk) ≤ 0
B Online optimization:
min
u
J(xk, u) s.t. gc(xk, u) ≤ 0
– may be nonconvex
– may have local minima
– may not be solvable efficiently or reliably
1 - 22
Prediction model
Discrete time prediction model
B Predictions optimized periodically at t = 0, T, 2T, . . .
B Usually T = Ts = sampling interval of model
B But T = nTs for any integer n ≥ 1 is possible, (e.g. if Ts  time needed
for online optimization)
1 - 23
Prediction model
Continuous time prediction model
B Predicted u(t) need not be piecewise constant,
e.g. continuous, piecewise linear u(t)
or u(t) = polynomial in t (piecewise quadratic, cubic etc)
B Continuous time prediction models can be solved online
B This course: discrete-time model and T = Ts assumed
1 - 24
Constraints
Classify state and input constraints as either hard or soft
B Hard constraints must be satisfied at all times,
if this is not possible, then the problem is infeasible
B Soft constraints can be violated to avoid infeasibility
B Strategies for handling soft constraints:
? impose (hard) constraints on the probability of violating each soft constraint
? or remove active constraints until the problem becomes feasible
1 - 25
Constraints
Typical methods for handling input constraints:
(a) Saturate the unconstrained control law
(ignore constraints in controller design)
(b) De-tune the unconstrained control law
by increasing the penalty on u in the performance objective
(c) Use an anti-windup strategy to limit the state of a dynamic controller
(typically the integral term of a PI or PID controller)
(d) Use MPC with inequality-constrained optimization
1 - 26
Example: input constraints
(a) Effects of controller saturation, u ≤ uk ≤ u
unconstrained LQ optimal control: u0
(x) = Klqx
saturated: u = max

min{u0
, u}, u
Input constraints:
u ≤ u ≤ u
u = −1, u = 1
Controller saturation causes
? poor performance
? possible instability
0 5 10 15 20 25 30 35 40
−2
0
2
4
6
8
u
0 5 10 15 20 25 30 35 40
−4
−2
0
2
4
6
y
sample
saturated lqr
unconstrained lqr
1 - 27
Example: input constraints
(b) Effects of de-tuning the unconstrained optimal control law:
Klq = optimal gain for LQ cost
∞
X
k=0
y2
k + ρ u2
k

Increase ρ until u = Klqx satisfies constraints (locally)
Example
10−2
≤ ρ ≤ 103
⇓
settling time increased
from 6 to 40
? yk → 0 slowly
? stability can be ensured
0 10 20 30 40 50 60
−2
0
2
4
6
y
sample
0 10 20 30 40 50 60
−2
0
2
4
6
8
u
lqr, R=1000
lqr, R=0.01
1 - 28
Example: input constraints
(c) Effects of Anti-windup:
Anti-windup attempts to avoid instability while control input saturated
Many possible approaches, e.g. anti-windup PI controller:
u = max

min{(Ke + v), u}, u
Tiv̇ + v = u
⇓
u ≤ u ≤ u =⇒ u = K

e +
1
Ti
Z t
e dt

u = u or u =⇒ v(t) → u or u exponentially
Heuristic strategy may not prevent instability
1 - 29
Example: input constraints
(d) Comparison with optimal constrained LQ control (MPC)
Example
MPC vs saturated LQ
(both using the same cost):
? settling time reduced to 20 by
MPC
? stability is guaranteed with
MPC
0 5 10 15 20 25 30 35 40
−1
0
1
2
3
u
0 5 10 15 20 25 30 35 40
−4
−2
0
2
4
6
y
sample
mpc, N=16
saturated lqr
1 - 30
Summary
B Predict performance using plant model
e.g. linear or nonlinear, discrete or continuous time
B Optimize future (open loop) control sequence
computationally much easier than optimizing over feedback laws
B Implement first sample, then repeat optimization
provides feedback to reduce effect of uncertainty
B Comparison of common methods of handling constraints:
saturation, de-tuning, anti-windup, MPC
1 - 31
Lecture 2
Prediction and optimization
2 - 1
Prediction and optimization
Input and state predictions
Unconstrained finite horizon optimal control
Infinite prediction horizons and connection with LQ optimal control
Incorporating constraints
Quadratic programming
2 - 2
Review of MPC strategy
At each sampling instant:
1 Use a model to predict system behaviour over a finite future horizon
2 Compute a control sequence by solving an online optimization problem
3 Apply the first element of optimal control sequence as control input
Advantages
? flexible plant model
? constraints taken into account
? optimal performance
Disadvantage
? online otimization required
2 - 3
Prediction equations
Linear time-invariant model: xk+1 = Axk + Buk
assume xk is measured at time k
Predictions: uk =



u0|k
.
.
.
uN−1|k


, xk =



x0|k
.
.
.
xN|k



Quadratic cost: J(xk, uk) =
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
(kxk2
Q = x
Qx, kuk2
R = u
Ru
P = terminal weighting matrix )
2 - 4
Prediction equations
Linear time-invariant model: xi+1|k = Axi|k + Bui|k
assume xk is measured at time k
x0|k = xk
x1|k = Axk + Bu0|k
.
.
.
xN|k = AN
xk + AN−1
Bu0|k + AN−2
Bu1|k + · · · + BuN−1|k
⇓
xk = Mxk + Cuk,
M =







I
A
A2
.
.
.
AN







, C =







0 0 · · · 0
B
AB B
.
.
.
.
.
.
...
AN−1
B AN−2
B · · · B







2 - 4
Prediction equations
Predicted cost:
Jk =
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
= x
k Q xk + u
k R uk

Q = diag{Q, . . . , Q, P}
R = diag{R, . . . , R, R}
⇓
Jk = u
k Huk + 2x
k F
uk + x
k Gxk
where
H = C
Q C + R ← u × u terms
F = C
Q M ← u × x terms
G = M
Q M ← x × x terms
time-invariant model =⇒ H, F, G can be computed offline
2 - 5
Prediction equations
Predicted cost:
Jk =
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
= x
k Q xk + u
k R uk

Q = diag{Q, . . . , Q, P}
R = diag{R, . . . , R, R}
⇓
Jk = u
k Huk + 2x
k F
uk + x
k Gxk
where
H = C
Q C + R ← u × u terms
F = C
Q M ← u × x terms
G = M
Q M ← x × x terms
time-invariant model =⇒ H, F, G can be computed offline
2 - 5
Prediction equations – example
Plant model: xk+1 = Axk + Buk, yk = Cxk
A =

1.1 2
0 0.95

, B =

0
0.079

, C =

−1 1

Prediction horizon N = 4: C =











0 0 0 0
0 0 0 0
0 0 0 0
0.079 0 0 0
0.157 0 0 0
0.075 0.079 0 0
0.323 0.157 0 0
0.071 0.075 0.079 0
0.497 0.323 0.157 0
0.068 0.071 0.075 0.079











Cost matrices Q = C
C, R = 0.01, and P = Q:
H =


0.271 0.122 0.016 −0.034
? 0.086 0.014 −0.020
? ? 0.023 −0.007
? ? ? 0.016

 F =


0.977 4.925
0.383 2.174
0.016 0.219
−0.115 −0.618


G =
h
7.589 22.78
? 103.7
i
2 - 6
Prediction equations: LTV model
Linear time-varying model: xk+1 = Akxk + Bkuk
assume xk is measured at time k
Predictions: x0|k = xk
x1|k = Akxk + Bku0|k
x2|k = Ak+1Akxk + Ak+1Bku0|k + Bk+1u1|k
.
.
.
xi|k =
0
Y
j=i−1
Ak+jxk + Ci(k)uk, i = 0, . . . , N
Ci(k) =
 1
Y
j=i−1
Ak+jBk
2
Y
j=i−1
Ak+jBk+1 · · · Bk+i−1 0 · · · 0
#
?
Q0
j=i−1 Ak+j = Ak+i−1 · · · Ak for i ≥ 1 and
Q0
j=i−1 Ak+j = 0 for i = 0
? H(k), F(k), G(k) depend on k and must be computed online
2 - 7
Unconstrained optimization
Minimize cost: u∗
= arg min
u
J, J = u
Hu + 2x
F
u + x
Gx
differentiate w.r.t. u: ∇uJ = 2Hu + 2Fx = 0
⇓
u = −H−1
Fx
= u∗
if H is positive definite i.e. if H  0
Here H = C
Q C + R  0 if:

R  0  Q, P  0 or
R  0  Q, P  0  C is full-rank
m
(A, B) controllable
Receding horizon controller is linear state feedback:
uk = −

I 0 · · · 0

H−1
Fxk
is the closed loop response optimal? is it even stable?
2 - 8
Unconstrained optimization
Minimize cost: u∗
= arg min
u
J, J = u
Hu + 2x
F
u + x
Gx
differentiate w.r.t. u: ∇uJ = 2Hu + 2Fx = 0
⇓
u = −H−1
Fx
= u∗
if H is positive definite i.e. if H  0
Here H = C
Q C + R  0 if:

R  0  Q, P  0 or
R  0  Q, P  0  C is full-rank
m
(A, B) controllable
Receding horizon controller is linear state feedback:
uk = −

I 0 · · · 0

H−1
Fxk
is the closed loop response optimal? is it even stable?
2 - 8
Example
Model: A, B, C as before, cost: Jk =
N−1
X
i=0
y2
i|k + 0.01u2
i|k

+ y2
N|k
I For N = 4: u∗
k = −H−1
Fxk =



−4.36 −18.7
1.64 1.24
1.41 3.00
0.59 1.83


xk
uk =

−4.36 −18.7

xk
I For general N: uk = L(N)xk
N = 4 N = 3 N = 2 N = 1
L(N)

−4.36 −18.69
 
−3.80 −16.98
 
1.22 −3.95
 
5.35 5.10

λ A + BL(N)

0.29 ± 0.17j 0.36 ± 0.22j 1.36, 0.38 2.15, 0.30
stable stable unstable unstable
2 - 9
Example
Horizon: N = 4, x0 = (0.5, −0.5)
0 2 4 6 8 10
−2
0
2
4
6
8
u
0 2 4 6 8 10
−1
−0.5
0
0.5
1
sample, k
y
closed−loop
predicted
2 - 10
Example
Horizon: N = 3, x0 = (0.5, −0.5)
0 2 4 6 8 10
−5
0
5
10
u
0 2 4 6 8 10
−1
−0.5
0
0.5
1
sample, k
y
closed−loop
predicted
2 - 10
Example
Horizon: N = 2, x0 = (0.5, −0.5)
0 2 4 6 8 10
−10
−5
0
5
u
0 2 4 6 8 10
−5
0
5
10
15
sample, k
y
closed−loop
predicted
2 - 10
Example
Horizon: N = 2, x0 = (0.5, −0.5)
0 2 4 6 8 10
−80
−60
−40
−20
0
20
u
0 2 4 6 8 10
−5
0
5
10
15
sample, k
y
closed−loop
predicted
Observation: predicted and closed loop responses are different for small N
2 - 10
Receding horizon control
Why is this example unstable for N ≤ 2?
System is non-minimum phase
⇓
impulse response changes sign
⇓
hence short horizon causes instability
N  3
C21 Model Predictive Control 2 - 12
Unconstrained optimization: example
• Unstable for
short horizon closed-loop
instability
impulse response changes sign
non-minimum phase
System is
• Solution:
use infinite cost horizon
but retain finite number of d.o.f. in predictions
N =
Solution:
? use an infinite horizon cost
? but keep a finite number of optimization variables in predictions
2 - 11
Dual mode predictions
An infinite prediction horizon is possible with dual mode predictions:
ui|k =

optimization variables i = 0, . . . , N − 1, mode 1
Kxi|k i = N, N + 1, . . . mode 2
mode 1
optimized explicitly
mode 2
feedback law: u = Kx
Feedback gain K: stabilizing and determined offline
e.g. unconstrained LQ optimal for
P∞
i=0(kxik2
Q + kuik2
R)
2 - 12
Infinite horizon cost
If the predicted input sequence is
{u0|k, . . . , uN−1|k, KxN|k, KΦxN|k, . . .}
then
∞
X
i=0
kxi|kk2
Q + kui|kk2
R) =
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R) + kxN|kk2
P
where
P − (A + BK)
P(A + BK) = Q + K
RK
Lyapunov matrix equation (discrete time)
? If Q + K
RK  0, then the solution P is unique and P  0
? Matlab: P = dlyap(Phi’,RHS);
Phi = A+B*K; RHS = Q+K’*R*K;
? P is the steady state Riccati equation solution if K is LQ optimal
2 - 13
Infinite horizon cost
If the predicted input sequence is
{u0|k, . . . , uN−1|k, KxN|k, KΦxN|k, . . .}
then
∞
X
i=0
kxi|kk2
Q + kui|kk2
R) =
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R) + kxN|kk2
P
where
P − (A + BK)
P(A + BK) = Q + K
RK
Lyapunov matrix equation (discrete time)
? If Q + K
RK  0, then the solution P is unique and P  0
? Matlab: P = dlyap(Phi’,RHS);
Phi = A+B*K; RHS = Q+K’*R*K;
? P is the steady state Riccati equation solution if K is LQ optimal
2 - 13
Infinite horizon cost
Proof that the predicted cost over the mode 2 horizon is kxN|kk2
P :
Let J∞
(x) =
∞
X
i=0
kxik2
Q + kuik2
R

, with ui = Kxi, xi+1 = Φxi ∀i
x0 = x
– then J∞
(x) =
∞
X
i=0
x
Φi
QΦi
x + x
K
Φi
RKΦi
x

= x
 ∞
X
i=0
(Φi
)
(Q + K
RK)Φi
| {z }
=P

x = kxk2
P
– but Φ
PΦ =
∞
X
i=1
(Φi
)
(Q + K
RK)Φi
= P − (Q + K
RK)
so P − Φ
PΦ = Q + K
RK
2 - 14
Connection with LQ optimal control
Let J(xk, uk) =
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
P − (A + BK)
P(A + BK) = Q + K
RK, K = LQ optimal
Then the solution of the unconstrained optimization satisfies
u∗
0|k = Kxk where u∗
k = arg min
u
J(xk, u) = (u∗
0|k, . . . , u∗
N−1|k)
since
{u0|k, u1,k, . . .} is optimal iff

uk = {u0|k, . . . , uN−1|k} is optimal
and {uN|k, uN+1|k, . . .} is optimal
2 - 15
Connection with LQ optimal control – example
I Model parameters (A, B, C) as before
LQ optimal gain for Q = C
C, R = 0.01: K =

−4.36 −18.74

Lyapunov equation solution: P =

3.92 4.83
13.86

I Cost matrices for N = 4:
H =




1.44 0.98 0.59 0.26
? 0.72 0.44 0.20
? ? 0.30 0.14
? ? ? 0.096



 F =




3.67 23.9
2.37 16.2
1.36 9.50
0.556 4.18



 G =

13.8 66.7
? 413

I Predictive control law: uk = −

1 0 0 0

H−1
Fxk
=

−4.35 −18.74

xk
2 - 16
Connection with LQ optimal control – example
I Response for N = 4, x0 = (0.5, −0.5)
0 2 4 6 8 10
u
-2
0
2
4
6
8
sample, k
0 2 4 6 8 10
y
-1
-0.5
0
0.5
closed loop
predicted
Infinite horizon cost
no constraints

=⇒ identical predicted and closed loop responses
2 - 17
Dual mode predictions
Pre-stabilize predictions to provide better numerical stability:
B Control inputs
mode 1 ui|k = Kxi|k + ci|k, i = 0, 1, . . . , N − 1
mode 2 ui|k = Kxi|k, i = N, N + 1, . . .
B States
mode 1 xi+1|k = Φxi|k + Bci|k, i = 0, 1, . . . , N − 1
mode 2 xi+1|k = Φxi|k, i = N, N + 1, . . .
where (c0|k, . . . , cN−1|k) are optimization variables
2 - 18
Dual mode predictions
Pre-stabilize predictions to provide better numerical stability:
B Vectorized form: xk = Mxk + Cck
xk :=



x0|k
.
.
.
xN|k


 , ck :=



c0|k
.
.
.
cN−1|k



M =







I
Φ
Φ2
.
.
.
ΦN







, C =







0 0 · · · 0
B
ΦB B
.
.
.
.
.
.
...
ΦN−1
B ΦN−2
B · · · B







B Cost: J xk, (u0|k, . . . , uN−1|k)

= J (xk, ck)
2 - 18
Input and state constraints
Infinite horizon unconstrained MPC = LQ optimal control
but MPC can also handle constraints
Consider constraints applied to mode 1 predictions:
? input constraints: u ≤ ui|k ≤ u, i = 0, . . . , N − 1
⇐⇒

I
−I

uk ≤

u
−u

where
u =

u
· · · u

u =

u
· · · u

? state constraints: x ≤ xi|k ≤ x, i = 1, . . . , N
⇐⇒

Ci
−Ci

uk ≤

x
−x

+

−Ai
Ai

xk, i = 1, . . . , N
2 - 19
Input and state constraints
Constraints on mode 1 predictions can be expressed
Acuk ≤ bc + Bcxk
where Ac, Bc, bc can be computed offline since model is time-invariant
The online optimization is a quadratic program (QP):
minimize
u
u
Hu + 2x
k F
u
subject to Acu ≤ bc + Bcxk
which is a convex optimization problem with a unique solution if
H = C
QC + R is positive definite
2 - 20
QP solvers: (a) Active set
Consider the QP: u∗
= arg min
u
u
Hu + 2f
u
subject to Au ≤ b
and let (Ai, bi) = ith row/element of (A, b)
B Individual constraints are active or inactive
active inactive
Aiu∗
= bi, ∀i ∈ I Aiu∗
≤ bi, ∀i 6∈ I
bi affects solution bi does not affect solution
B Equality constraint problem: u∗
= arg min
u
u
Hu + 2f
u
subject to Aiu = bi, ∀i ∈ I
B Solve QP by searching for I
? one equality constraint problem solved at each iteration
? optimality conditions (KKT conditions) identify solution
2 - 21
QP solvers: (a) Active set
Consider the QP: u∗
= arg min
u
u
Hu + 2f
u
subject to Au ≤ b
and let (Ai, bi) = ith row/element of (A, b)
B Individual constraints are active or inactive
active inactive
Aiu∗
= bi, ∀i ∈ I Aiu∗
≤ bi, ∀i 6∈ I
bi affects solution bi does not affect solution
B Equality constraint problem: u∗
= arg min
u
u
Hu + 2f
u
subject to Aiu = bi, ∀i ∈ I
B Solve QP by searching for I
? one equality constraint problem solved at each iteration
? optimality conditions (KKT conditions) identify solution
2 - 21
Active constraints – example
−3 −2 −1 0 1 2
−2.5
−2
−1.5
−1
−0.5
0
0.5
1
1.5
2
2.5
u1
u
2
u∗
i =
4
i = 5
i
=
3
i = 2
i = 1
A QP problem with 5 inequality constraints
active set at solution: I = {2}
2 - 22
Active constraints – example
−3 −2 −1 0 1 2
−2.5
−2
−1.5
−1
−0.5
0
0.5
1
1.5
2
2.5
u1
u
2
u∗
i = 2
An equivalent equality constraint problem
2 - 22
QP solvers: (a) Active set
B Computation:
O(N3
n3
u) additions/multiplications per iteration (conservative estimate)
upper bound on number of iterations is exponential in problem size
B At each iteration choose trial active set using: cost gradient
constraint sensitivities
⇓
number of iterations needed is often small in practice
B In MPC u∗
k = u∗
(xk) and Ik = I(xk)
hence initialize solver at time k using the solution computed at k − 1
2 - 23
QP solvers: (b) Interior point
B Solve an unconstrained problem at each iteration:
u(µ) = min
u
µ u
Hu + 2f
u

+ φ(u)
where
φ(u) = barrier function (φ → ∞ at constraints)
u → u∗
as µ → ∞
Increase µ until φ(u∗
)  1/ ( = user-defined tolerance)
B # arithmetic operations per iteration is constant, e.g. O(N3
n3
u)
# iterations for given  is polynomial in problem size
⇓
Computational advantages for large-scale problems
e.g. # variables  102
, # constraints  103
B No general method for initializing at solution estimate
2 - 24
QP solvers: (b) Interior point
B Solve an unconstrained problem at each iteration:
u(µ) = min
u
µ u
Hu + 2f
u

+ φ(u)
where
φ(u) = barrier function (φ → ∞ at constraints)
u → u∗
as µ → ∞
Increase µ until φ(u∗
)  1/ ( = user-defined tolerance)
B # arithmetic operations per iteration is constant, e.g. O(N3
n3
u)
# iterations for given  is polynomial in problem size
⇓
Computational advantages for large-scale problems
e.g. # variables  102
, # constraints  103
B No general method for initializing at solution estimate
2 - 24
Interior point method – example
−0.5 0 0.5 1 1.5 2 2.5 3 3.5
0
1
2
3
4
5
6
7
8
9
10
u
u(0.5)
u(1)
u(2)
φ(u)
A
A
K
u
Hu + 2f
u
6
u(µ) → u∗
= 1 as µ → ∞
but minu µ u
Hu + 2f
u

+ φ(u) becomes ill-conditioned as µ → ∞
2 - 25
QP solvers: (c) Multiparametric
Let u∗
(x) = arg min
u
u
Hu + 2x
F
u
subject to Au ≤ b + Bx
then:
? u∗
is a continous function of x
? u∗
(x) = Kjx + kj for all x in a polytopic set Xj
B In principle each Kj, kj and Xj can be determined offline
B Large number of sets Xj (combinatorial in problem size)
so online determination of j such that xk ∈ Xj is difficult
2 - 26
Multiparametric QP – example
−8 −6 −4 −2 0 2 4 6 8
−1.5
−1
−0.5
0
0.5
1
1.5
x1
x
2
Model: (A, B, C) as before,
cost: Q = C
C, R = 1, horizon: N = 10
constraints: −1 ≤ u ≤ 1, −1 ≤ x/8 ≤ 1
2 - 27
Summary
B Predicted control inputs: uk =



u0|k
.
.
.
uN−1|k



and states: xk =



x1|k
.
.
.
xN|k


 = Mxk + Cuk
B Predicted cost: J(xk, uk) =
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
= u
k Huk + 2x
k F
uk + x
k Gxk
B Online optimization subject to linear state and input constraints is a QP:
minimize
u
u
Hu + 2x
k F
u
subject to Acu ≤ bc + Bcxk
2 - 28
Lecture 3
Closed loop properties of MPC
3 - 1
Closed loop properties of MPC
Review: infinite horizon cost
Infinite horizon predictive control with constraints
Closed loop stability
Constraint-checking horizon
Connection with constrained optimal control
3 - 2
Review: infinite horizon cost
Short prediction horizons cause poor performance and instability, so
? use an infinite horizon cost: J(xk, uk) =
∞
X
i=0
kxi|kk2
Q + kui|kk2
R

? keep optimization finite-dimensional by using dual mode predictions:
ui|k =

optimization variables i = 0, . . . , N − 1, mode 1
Kxi|k i = N, N + 1, . . . mode 2
mode 1: uk =



u0|k
.
.
.
uN−1|k


 uk optimized online
mode 2: ui|k = Kxi|k K chosen offline
3 - 3
Review: infinite horizon cost
B Cost for mode 2:
∞
X
i=N
kxi|kk2
Q + kui|kk2
R

= kxN|kk2
P
P is the solution of the Lyapunov equation
P − (A + BK)
P(A + BK) = Q + K
RK
B Infinite horizon cost:
J(xk, uk) =
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
= u
k Huk + 2x
k F
uk + x
k Gxk
3 - 4
Review: MPC online optimization
B Unconstrained optimization: ∇uJ(x, u∗
) = 2Hu∗
+ 2Fx = 0, so
u∗
(x) = −H−1
Fx
=⇒ linear controller: uk = KMPCxk
KMPC = LQ-optimal if K = LQ-optimal (in mode 2)
B Constrained optimization:
u∗
(x) = arg min
u
u
Hu + 2x
F
u
subject to Acu ≤ bc + Bcx
=⇒ nonlinear controller: uk = KMPC(xk)
3 - 5
Constrained MPC – example
B Plant model: xk+1 = Axk + Buk, yk = Cxk
A =

1.1 2
0 0.95

, B =

0
0.0787

, C =

−1 1

Constraints: −1 ≤ uk ≤ 1
B MPC optimization (constraints applied only to mode 1 predictions):
minimize
u
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
subject to − 1 ≤ ui|k ≤ 1, i = 0, . . . , N − 1
Q = C
C, R = 0.01, N = 2
. . . performance? stability?
3 - 6
Constrained MPC – example
Closed loop response for x0 = (0.8, −0.8)
0 20 40 60 80 100
−1
−0.5
0
0.5
1
u
0 20 40 60 80 100
−200
−150
−100
−50
0
50
sample, k
y
unstable
3 - 7
Constrained MPC – example
Closed loop response for x0 = (0.5, −0.5)
0 20 40 60 80 100
−1
−0.5
0
0.5
1
u
0 20 40 60 80 100
−2
0
2
4
6
sample, k
y
stable, but . . .
3 - 8
Constrained MPC – example
Optimal predicted cost x0 = (0.5, −0.5)
0 20 40 60 80 100
0
10
20
30
40
50
60
70
80
90
sample, k
Predicted
cost
J(k)
. . . increasing Jk =⇒ closed loop response does not follow predicted trajectory
3 - 9
Stability analysis
How can we guarantee the closed loop stability of MPC?
(a). Show that a Lyapunov function exists demonstrating stability
(b). Ensure that optimization feasible is at each time k = 0, 1, . . .
B For Lyapunov stability analysis:
? consider first the unconstrained problem
? use predicted cost as a trial Lyapunov function
B Guarantee feasibility of the MPC optimization recursively
by ensuring that feasibility at time k implies feasibility at k + 1
3 - 10
Stability analysis
How can we guarantee the closed loop stability of MPC?
(a). Show that a Lyapunov function exists demonstrating stability
(b). Ensure that optimization feasible is at each time k = 0, 1, . . .
B For Lyapunov stability analysis:
? consider first the unconstrained problem
? use predicted cost as a trial Lyapunov function
B Guarantee feasibility of the MPC optimization recursively
by ensuring that feasibility at time k implies feasibility at k + 1
3 - 10
Discrete time Lyapunov stability
Consider the system xk+1 = f(xk), with f(0) = 0
B Definition: x = 0 is a stable equilibrium point if
maxk kxkk can be made arbitrarily small
by making x0 sufficiently small
B If continuously differentiable V (x) exists with
(i). V (x) is positive definite and
(ii). V (xk+1) − V (xk) ≤ 0
then x = 0 is a stable equilibrium point
3 - 11
Discrete time Lyapunov stability
Consider the system xk+1 = f(xk), with f(0) = 0
B Definition: x = 0 is a stable equilibrium point if
for all R  0 there exists r such that
kx0k  r =⇒ kxkk  R for all k
B If continuously differentiable V (x) exists with
(i). V (x) is positive definite and
(ii). V (xk+1) − V (xk) ≤ 0
then x = 0 is a stable equilibrium point
3 - 11
Discrete time Lyapunov stability
Consider the system xk+1 = f(xk), with f(0) = 0
B Definition: x = 0 is an asymptotically stable equilibrium point if
(i). x = 0 is stable and
(ii). r exists such that kx0k  r =⇒ lim
k→∞
xk = 0
B If continuously differentiable V (x) exists with
(i). V (x) is positive definite and
(ii). V (xk+1) − V (xk)  0 whenever xk 6= 0
then x = 0 is an asymptotically stable equilibrium point
3 - 12
Lyapunov stability
Trial Lyapunov function:
J∗
(xk) = J(xk, u∗
k)
where J(xk, uk) =
∞
X
i=0
kxi|kk2
Q + kui|kk2
R

? J∗
(x) is positive definite if:
(a). R  0 and Q  0, or
(b). R  0 and Q  0 and (A, Q) is observable
since then J∗
(xk) ≥ 0 and J∗
(xk) = 0 if and only if xk = 0
? J∗
(x) is continuously differentiable
. . . from analysis of MPC optimization as a multiparametric QP
3 - 13
Lyapunov stability
Construct a bound on J∗
(xk+1) − J∗
(xk) using the “tail” of the
optimal prediction at time k
u
i
optimal at k
tail at k + 1
0 1 N −1 N
Optimal predicted sequences at time k:
u∗
k =











u∗
0|k
u∗
1|k
.
.
.
u∗
N−1|k
Kx∗
N|k
.
.
.











x∗
k =











x∗
0|k
x∗
1|k
.
.
.
x∗
N|k
Φx∗
N|k
.
.
.











(Φ = A + BK)
optimal at k : J∗
(xk) = J(xk, u∗
k) =
∞
X
i=0
kx∗
i|kk2
Q + ku∗
i|kk2
R

tail at k + 1 : ˜
J(xk+1) = J(xk+1, ũk+1) =
∞
X
i=1
kx∗
i|kk2
Q + ku∗
i|kk2
R

3 - 14
Lyapunov stability
Construct a bound on J∗
(xk+1) − J∗
(xk) using the “tail” of the
optimal prediction at time k
u
i
optimal at k
tail at k + 1
0 1 N −1 N
Tail sequences at time k + 1:
ũk+1 =











u∗
1|k
.
.
.
u∗
N−1|k
Kx∗
N|k
KΦx∗
N|k
.
.
.











x̃k+1 =











x∗
1|k
.
.
.
x∗
N|k
Φx∗
N|k
Φ2
x∗
N|k
.
.
.











(Φ = A + BK)
optimal at k : J∗
(xk) = J(xk, u∗
k) =
∞
X
i=0
kx∗
i|kk2
Q + ku∗
i|kk2
R

tail at k + 1 : ˜
J(xk+1) = J(xk+1, ũk+1) =
∞
X
i=1
kx∗
i|kk2
Q + ku∗
i|kk2
R

3 - 14
Lyapunov stability
Construct a bound on J∗
(xk+1) − J∗
(xk) using the “tail” of the
optimal prediction at time k
u
i
optimal at k
tail at k + 1
0 1 N −1 N
Tail sequences at time k + 1:
ũk+1 =











u∗
1|k
.
.
.
u∗
N−1|k
Kx∗
N|k
KΦx∗
N|k
.
.
.











x̃k+1 =











x∗
1|k
.
.
.
x∗
N|k
Φx∗
N|k
Φ2
x∗
N|k
.
.
.











(Φ = A + BK)
optimal at k : J∗
(xk) = J(xk, u∗
k) =
∞
X
i=0
kx∗
i|kk2
Q + ku∗
i|kk2
R

tail at k + 1 : ˜
J(xk+1) = J(xk+1, ũk+1) =
∞
X
i=1
kx∗
i|kk2
Q + ku∗
i|kk2
R

3 - 14
Lyapunov stability
Construct a bound on J∗
(xk+1) − J∗
(xk) using the “tail” of the
optimal prediction at time k
Predicted cost for the tail:
˜
J(xk+1) = J∗
(xk) − kxkk2
Q − kukk2
R
but ũk+1 is suboptimal at time k + 1, so
J∗
(xk+1) ≤ ˜
J(xk+1)
Therefore
J∗
(xk+1) ≤ J∗
(xk) − kxkk2
Q − kukk2
R
3 - 15
Lyapunov stability
The bound J∗
(xk+1) − J∗
(xk) ≤ −kxkk2
Q − kukk2
R implies:
(i). the closed loop cost cannot exceed the initial predicted cost,
since summing both sides over all k ≥ 0 gives
∞
X
k=0
kxkk2
Q + kukk2
R

≤ J∗
(x0)
(ii). x = 0 is asymptotically stable
? if R  0 and Q  0, this follows from Lyapunov’s direct method
? if R  0, Q  0 and (A, Q) observable, this follows from:
(a). stability of x = 0 ⇐ Lyapunov’s direct method
(b). lim
k→∞
(kxkk2
Q + kukk2
R) = 0 ⇐
P∞
k=0 kxkk2
Q + kukk2
R

 ∞
3 - 16
Stability analysis
How can we guarantee the closed loop stability of MPC?
(a). Show that a Lyapunov function exists demonstrating stability
(b). Ensure that optimization feasible is at each time k = 0, 1, . . .
B For Lyapunov stability analysis:
? consider first the unconstrained problem
? use predicted cost as a trial Lyapunov function
B Guarantee feasibility of the MPC optimization recursively
by ensuring that feasibility at time k =⇒ feasibility at k + 1
3 - 17
Stability analysis
How can we guarantee the closed loop stability of MPC?
(a). Show that a Lyapunov function exists demonstrating stability
(b). Ensure that optimization feasible is at each time k = 0, 1, . . .
B For Lyapunov stability analysis:
? consider first the unconstrained problem
? use predicted cost as a trial Lyapunov function
B Guarantee feasibility of the MPC optimization recursively
by ensuring that feasibility at time k =⇒ feasibility at k + 1
3 - 17
Terminal constraint
The basic idea
terminal set
origin
stabilizing linear controller satisfies constraints



more sophisticated controller needed to satisfy constraints




 ?
@
@
@
@
R
3 - 18
Terminal constraint
Terminal constraint: xN|k ∈ Ω, where Ω = terminal set
xk
x1|k
xN−1|k
xN|k
xN+1|k
safe region
for mode 2
control law
Choose Ω so that:
(a). x ∈ Ω =⇒

u ≤ Kx ≤ u
x ≤ x ≤ x
(b). x ∈ Ω =⇒ (A + BK)x ∈ Ω
then Ω is invariant for the mode 2 dynamics and constraints, so
xN|k ∈ Ω =⇒

u ≤ ui|k ≤ u
x ≤ xi|k ≤ x
for i = N, N + 1, . . .
i.e. constraints are satisfied over
the infinite mode 2 prediction horizon
3 - 19
Stability of constrained MPC
Prototype MPC algorithm
At each time k = 0, 1, . . .
(i). solve u∗
k = arg min
uk
J(xk, uk)
s.t. u ≤ ui|k ≤ u, i = 0, . . . , N − 1
x ≤ xi|k ≤ x, i = 1, . . . , N
xN|k ∈ Ω
(ii). apply uk = u∗
0|k to the system
Asymptotically stabilizes x = 0 with region of attraction FN ,
FN =





x0 : ∃ {u0, . . . , uN−1} such that
u ≤ ui ≤ u, i = 0, . . . , N − 1
x ≤ xi ≤ x, i = 1, . . . , N
xN ∈ Ω





= the set of all feasible initial conditions for N-step horizon
and terminal set Ω
3 - 20
Terminal constraints
Make Ω as large as possible so that the feasible set FN is maximized, i.e.
Ω = X∞ = lim
j→∞
Xj
where
? Xj = initial conditions for which constraints are satisfied for j steps
with u = Kx
=

x :
u ≤ K(A + BK)i
x ≤ u
x ≤ (A + BK)i
x ≤ x
i = 0, . . . , j

? X∞ = Xν for some finite ν if |eig(A + BK)|  1
⇓
x ∈ X∞ if constraints are satisfied on a finite constraint checking horizon
3 - 21
Terminal constraints – Example
Plant model: xk+1 = Axk + Buk, yk = Cxk
A =

1.1 2
0 0.95

B =

0
0.0787

C =

−1 1

input constraints: −1 ≤ uk ≤ 1
mode 2 feedback law: K =

−1.19 −7.88

= KLQ for Q = C
C, R = 1
3 - 22
Terminal constraints – example
Constraints: −1 ≤ u ≤ 1
−5 0 5
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
x1
x
2
X0
Kx = −1

Kx = 1 -
3 - 23
Terminal constraints – example
Constraints: −1 ≤ u ≤ 1
−5 0 5
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
x1
x
2
X1
KΦx = −1

KΦx = 1 -
Kx = −1

Kx = 1 -
3 - 23
Terminal constraints – example
Constraints: −1 ≤ u ≤ 1
−5 0 5
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
x1
x
2
X2
KΦ2
x = −1

KΦ2
x = 1 -
KΦx = −1

KΦx = 1 -
Kx = −1

Kx = 1 -
3 - 23
Terminal constraints – example
Constraints: −1 ≤ u ≤ 1
−5 0 5
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
x1
x
2
X∞
X4 = X5 = · · · = Xj for all j  4 so X4 = X∞
3 - 23
Terminal constraints – example
In this example X∞ is determined in a finite number of steps because
A (A + BK) is strictly stable, and
B (A + BK), K

is observable
A ⇒

shortest distance of hyperplane
K(A + BK)i
x ≤ 1 from origin

=
1
kK(A + BK)ik2
→ ∞ as i → ∞
B ⇒ X∞ is bounded because x0 /
∈ X∞ if x0 is sufficiently large
Here {x : −1 ≤ K(A + BK)i
x ≤ 1} contains X4 for i  4
⇓
X∞ = X4
constraint checking horizon: ν = 4
3 - 24
Terminal constraints – example
In this example X∞ is determined in a finite number of steps because
A (A + BK) is strictly stable, and
B (A + BK), K

is observable
A ⇒

shortest distance of hyperplane
K(A + BK)i
x ≤ 1 from origin

=
1
kK(A + BK)ik2
→ ∞ as i → ∞
B ⇒ X∞ is bounded because x0 /
∈ X∞ if x0 is sufficiently large
Here {x : −1 ≤ K(A + BK)i
x ≤ 1} contains X4 for i  4
⇓
X∞ = X4
constraint checking horizon: ν = 4
3 - 24
Terminal constraints
General case
Let Xj = {x : FΦi
x ≤ 1, i = 0, . . . j} with

Φ strictly stable
(Φ, F) observable
then:
(i). X∞ = Xν for finite ν
(ii). Xν = X∞ iff x ∈ Xν+1 whenever x ∈ Xν
Proof of (ii)
(a). for any j, Xj+1 = Xj ∩

x : FΦj+1
x ≤ 1
so Xj ⊇ Xj+1 ⊇ limj→∞ Xj = X∞
(b). if x ∈ Xν+1 whenever x ∈ Xν , then Φx ∈ Xν whenever x ∈ Xν
but Xν ⊆

x : Fx ≤ 1 and it follows that Xν ⊆ X∞
(a)  (b) ⇒ Xν = X∞
3 - 25
Terminal constraints – constraint checking horizon
Algorithm for computing constraint checking horizon Nc
for input constraints u ≤ u ≤ u:
C4A Model Predictive Control 3 - 28
Terminal constraint set
Algorithm (computation of ) :
umax := max
x
K(A+ BK)N +1
x s.t. u ! K(A+ BK)i
x ! u, i = 0,…N
umin := min
x
K(A+ BK)N +1
x s.t. u ! K(A+ BK)i
x ! u, i = 0,…N
Nc := N
N := 0
umax ! u ?
and
umin  u?
N := N +1
no
yes
2 linear programs
solved at each step
3 - 26
Constrained MPC
Define the terminal set Ω as XNc
MPC algorithm
At each time k = 0, 1, . . .
(i). solve u∗
k = arg min
uk
J(xk, uk)
s.t. u ≤ ui|k ≤ u, i = 0, . . . , N + Nc
x ≤ xi|k ≤ x, i = 1, . . . , N + Nc
(ii). apply uk = u∗
0|k to the system
Note
? predictions for i = N, . . . N + Nc:

xi|k = (A + BK)i−N
xN|k
ui|k = K(A + BK)i−N
xN|k
? xN|k ∈ XNc
implies linear constraints so online optimization is a QP
3 - 27
Closed loop performance
Longer horizon N ensures improved predicted cost J∗
(x0)
and is likely (but not certain) to give better closed-loop performance
Example: Cost vs N for x0 = (−7.5, 0.5)
N 6 7 8 11  11
J∗
(x0) 364.2 357.0 356.3 356.0 356.0
Jcl(x0) 356.0 356.0 356.0 356.0 356.0
Closed loop cost: Jcl(x0) :=
P∞
k=0 kxkk2
Q + kukk2
R

For this initial condition:
MPC with N = 11 is identical to constrained LQ optimal control (N = ∞)!
3 - 28
Closed loop performance – example
Predicted and closed loop inputs for N = 6
0 5 10 15 20 25 30
−1
−0.8
−0.6
−0.4
−0.2
0
0.2
0.4
0.6
0.8
1
time step, k
input,
u
predicted
closed−loop
3 - 29
Closed loop performance – example
Predicted and closed loop states for N = 6
−8 −7 −6 −5 −4 −3 −2 −1 0 1
−0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
x
1
x
2
predicted
closed−loop
Ω
F6
x6|0 -
3 - 29
Closed loop performance – example
Predicted and closed loop states for N = 11
x
1
-8 -7 -6 -5 -4 -3 -2 -1 0 1
x
2
-0.1
0
0.1
0.2
0.3
0.4
0.5
0.6
0.7
0.8
predicted
closed-loop
Ω
F6
x11|0
3 - 29
Choice of mode 1 horizon – performance
B For this x0: N = 11 ⇒ xN|0 lies in the interior of Ω
m
terminal constraint is inactive
⇓
no reduction in cost for N  11
B Constrained LQ optimal performance is always obtained with N ≥ N∞
for some finite N∞ dependent on x0
B N∞ may be large, implying high computational load
but closed loop performance is often close to optimal for N  N∞
(due to receding horizon)
in this example Jcl(x0) ≈ optimal for N ≥ 6
3 - 30
Choice of mode 1 horizon – region of attraction
Increasing N increases the feasible set FN
−10 −8 −6 −4 −2 0 2 4 6 8 10
−1.5
−1
−0.5
0
0.5
1
1.5
x
1
x
2
N = 26
N = 24
N = 20
N = 16
N = 12
N = 8
N = 4
N = 0
Ω
F4

F8

F12

3 - 31
Summary
B Linear MPC ingredients:
? Infinite cost horizon (via terminal cost)
? Terminal constraints (via constraint-checking horizon)
B Constraints are satisfied over an infinite prediction horizon
B Closed-loop system is asymptotically stable
with region of attraction equal to the set of feasible initial conditions
B Ideal optimal performance if mode 1 horizon N is large enough
3 - 32
Lecture 4
Robustness to disturbances
4 - 1
Robustness to disturbances
Review of nominal model predictive control
Setpoint tracking and integral action
Robustness to unknown disturbances
Handling time-varying disturbances
4 - 2
Review
MPC with guaranteed stability – the basic idea
terminal set
origin
stabilizing linear controller satisfies constraints



more sophisticated controller needed to satisfy constraints




 ?
@
@
@
@
R
4 - 3
Review
MPC optimization for linear model xk+1 = Axk + Buk
minimize
uk
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc
x ≤ xi|k ≤ x, i = 1, . . . , N + Nc
where
? ui|k = Kxi|k for i ≥ N, with K = unconstrained LQ optimal
? terminal cost: kxN|kk2
P =
∞
X
i=N
(kxi|kk2
Q + kui|kk2
R), with
P − ΦT
PΦ = Q + KT
RK, Φ = A + BK
? terminal constraints are defined by the constraint checking horizon Nc:
u ≤ KΦi
x ≤ u
x ≤ Φi
x ≤ x

i = 0, . . . , Nc =⇒

u ≤ KΦNc+1
x ≤ u
x ≤ ΦNc+1
x ≤ x
4 - 4
Review
MPC optimization for linear model xk+1 = Axk + Buk
minimize
uk
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc
x ≤ xi|k ≤ x, i = 1, . . . , N + Nc
where
? ui|k = Kxi|k for i ≥ N, with K = unconstrained LQ optimal
? terminal cost: kxN|kk2
P =
∞
X
i=N
(kxi|kk2
Q + kui|kk2
R), with
P − ΦT
PΦ = Q + KT
RK, Φ = A + BK
? terminal constraints are defined by the constraint checking horizon Nc:
u ≤ KΦi
x ≤ u
x ≤ Φi
x ≤ x

i = 0, . . . , Nc =⇒

u ≤ KΦNc+1
x ≤ u
x ≤ ΦNc+1
x ≤ x
4 - 4
Review
MPC optimization for linear model xk+1 = Axk + Buk
minimize
uk
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc
x ≤ xi|k ≤ x, i = 1, . . . , N + Nc
where
? ui|k = Kxi|k for i ≥ N, with K = unconstrained LQ optimal
? terminal cost: kxN|kk2
P =
∞
X
i=N
(kxi|kk2
Q + kui|kk2
R), with
P − ΦT
PΦ = Q + KT
RK, Φ = A + BK
? terminal constraints are defined by the constraint checking horizon Nc:
u ≤ KΦi
x ≤ u
x ≤ Φi
x ≤ x

i = 0, . . . , Nc =⇒

u ≤ KΦNc+1
x ≤ u
x ≤ ΦNc+1
x ≤ x
4 - 4
Review
MPC optimization for nonlinear model xk+1 = f(xk, uk)
minimize
uk
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
subject to u ≤ ui|k ≤ u, i = 0, . . . , N − 1
x ≤ xi|k ≤ x, i = 1, . . . , N − 1
xN|k ∈ Ω
with
? mode 2 feedback: ui|k = κ(xi|k) asymptotically stabilizes x = 0 (locally)
? terminal cost: kxN|kk2
P ≥
∞
X
i=N
(kxi|kk2
Q + kui|kk2
R)
for mode 2 dynamics: xi+1|k = f xi|k, κ(xi|k)

? terminal constraint set Ω: invariant for mode 2 dynamics and constraints
f x, κ(x)

∈ Ω
u ≤ κ(x) ≤ u, x ≤ x ≤ x

for all x ∈ Ω
4 - 5
Review
MPC optimization for nonlinear model xk+1 = f(xk, uk)
minimize
uk
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
subject to u ≤ ui|k ≤ u, i = 0, . . . , N − 1
x ≤ xi|k ≤ x, i = 1, . . . , N − 1
xN|k ∈ Ω
with
? mode 2 feedback: ui|k = κ(xi|k) asymptotically stabilizes x = 0 (locally)
? terminal cost: kxN|kk2
P ≥
∞
X
i=N
(kxi|kk2
Q + kui|kk2
R)
for mode 2 dynamics: xi+1|k = f xi|k, κ(xi|k)

? terminal constraint set Ω: invariant for mode 2 dynamics and constraints
f x, κ(x)

∈ Ω
u ≤ κ(x) ≤ u, x ≤ x ≤ x

for all x ∈ Ω
4 - 5
Review
MPC optimization for nonlinear model xk+1 = f(xk, uk)
minimize
uk
N−1
X
i=0
kxi|kk2
Q + kui|kk2
R

+ kxN|kk2
P
subject to u ≤ ui|k ≤ u, i = 0, . . . , N − 1
x ≤ xi|k ≤ x, i = 1, . . . , N − 1
xN|k ∈ Ω
with
? mode 2 feedback: ui|k = κ(xi|k) asymptotically stabilizes x = 0 (locally)
? terminal cost: kxN|kk2
P ≥
∞
X
i=N
(kxi|kk2
Q + kui|kk2
R)
for mode 2 dynamics: xi+1|k = f xi|k, κ(xi|k)

? terminal constraint set Ω: invariant for mode 2 dynamics and constraints
f x, κ(x)

∈ Ω
u ≤ κ(x) ≤ u, x ≤ x ≤ x

for all x ∈ Ω
4 - 5
Comparison
B Linear MPC
terminal cost ←− exact cost over the mode 2 horizon
terminal constraint set ←− contains all feasible initial conditions
for mode 2
B Nonlinear MPC
terminal cost ←− upper bound on cost over
mode 2 horizon
terminal constraint set ←− invariant set (usually not the largest)
for mode 2 dynamics and constraints
4 - 6
Model uncertainty
4 - 7
Model uncertainty
Uncertain
model,
robust
constraints
Stochastic
model,
probabilistic
constraints
Nominal,
unconstrained
Nominal,
constrained
4 - 7
Model uncertainty
Uncertain
model,
robust
constraints
Stochastic
model,
probabilistic
constraints
Nominal,
unconstrained
LQ-optimal
control
Classical
MPC
Robust
MPC
Stochastic
MPC
4 - 7
Model uncertainty
Common causes of model error and uncertainty:
I Unknown or time-varying model parameters
B unknown loads  inertias, static friction
B unknown d.c. gain
I Random (stochastic) model parameters
B random process noise or sensor noise
I Incomplete measurement of states
B state estimation error
4 - 7
Setpoint tracking
I Output setpoint: y0
y → y0
⇒

x → x0
u → u0
where
x0
= Ax0
+ Bu0
y0
= Cx0
⇓
y0
= C(I − A)−1
Bu0
I Setpoint for (u0
, x0
) is unique iff C(I − A)−1
B is invertible
e.g. if dim(u) = dim(y), then

u0
= C(I − A)−1
B
−1
y0
x0
= (I − A)−1
Bu0
I Tracking problem: yk → y0
subject to

u ≤ uk ≤ u
x ≤ xk ≤ x
is only feasible if u ≤ u0
≤ u and x ≤ x0
≤ x
4 - 8
Setpoint tracking
I Unconstrained tracking problem:
minimize
uδ
k
∞
X
i=0
kxδ
i|kk2
Q + kuδ
i|kk2
R

where xδ
= x − x0
uδ
= u − u0
has optimal solution: uk = Kxδ
k + u0
, K = KLQ
I Constrained tracking problem:
minimize
uδ
k
∞
X
i=0
kxδ
i|kk2
Q + kuδ
i|kk2
R

subject to u ≤ uδ
i|k + u0
≤ u, i = 0, 1, . . .
x ≤ xδ
i|k + x0
≤ x, i = 1, 2, . . .
has optimal solution: uk = uδ∗
0|k + u0
4 - 9
Setpoint tracking
If û0
is used instead of u0
(e.g. if d.c. gain C(I − A)−1
B unknown)
then uk = uδ∗
0|k + û0
implies
uδ
k = uδ∗
0|k + (û0
− u0
)
xδ
k+1 = Axδ
k + Buδ∗
0|k + B (û0
− u0
)
| {z }
constant disturbance
and if uδ∗
0|k → Kxδ
k as k → ∞, then
lim
k→∞
xδ
k = (I − A − BK)−1
B(û0
− u0
) 6= 0
lim
k→∞
yk − y0
= C(I − A − BK)−1
B(û0
− u0
)
| {z }
steady state tracking error
6= 0
4 - 10
Additive disturbances
Convert (constant) setpoint tracking problem into a regulation problem:
x ← xδ
, y ← yδ
, u ← uδ
Consider the effect of additive disturbance w:
xk+1 = Axk + Buk + Dwk,
yk = Cxk
Assume that wk is unknown at time k, but is known to be:
? constant (wk = w for all k) or time-varying
? within a known polytopic set: wk ∈ W for all k
where W = conv{w(1)
, . . . , w(r)
}
or W = {w : Hw ≤ 1}
4 - 11
Additive disturbances
Convert (constant) setpoint tracking problem into a regulation problem:
x ← xδ
, y ← yδ
, u ← uδ
Consider the effect of additive disturbance w:
xk+1 = Axk + Buk + Dwk,
yk = Cxk
Assume that wk is unknown at time k, but is known to be:
? constant (wk = w for all k) or time-varying
? within a known polytopic set: wk ∈ W for all k
where W = conv{w(1)
, . . . , w(r)
}
or W = {w : Hw ≤ 1}
W
w(1)
w(2)
w(3)
w(4)
w(5)
w(6)
4 - 11
Integral action (no constraints)
Introduce integral action to remove steady state error in y
by considering the augmented system:
zk =

xk
vk

, zk+1 =

A 0
C I

zk +

B
0

uk +

D
0

wk
vk = integrator state
vk+1 = vk + yk
? Linear feedback uk = Kxk + KIvk
is stabilizing if eig

A + BK BKI
C I

 1
? If the closed-loop system is (strictly) stable and wk → w = constant
then uk → uss
=⇒ vk → vss
=⇒ yk → 0 even if w 6= 0
but arbitrary KI may destabilize the closed loop system
4 - 12
Integral action (no constraints)
Introduce integral action to remove steady state error in y
by considering the augmented system:
zk =

xk
vk

, zk+1 =

A 0
C I

zk +

B
0

uk +

D
0

wk
vk = integrator state
vk+1 = vk + yk
? Linear feedback uk = Kxk + KIvk
is stabilizing if eig

A + BK BKI
C I

 1
? If the closed-loop system is (strictly) stable and wk → w = constant
then uk → uss
=⇒ vk → vss
=⇒ yk → 0 even if w 6= 0
but arbitrary KI may destabilize the closed loop system
4 - 12
Integral action (no constraints)
Ensure stability by using a modified cost:
minimize
uk
∞
X
i=0
kzi|kk2
Qz
+ kui|kk2
R

Qz =

Q 0
0 QI

 0
with predictions generated by an augmented model
zi+1|k =

A 0
C I

zi|k +

B
0

ui|k, z0|k =

xk
vk

? this is a “nominal” prediction model since wk = 0 is assumed
? unconstrained solution: uk = Kzzk = Kxk + KIvk
? if R  0,

A 0
C I

,

Q 0
0 QI

is observable and wk → w = constant
then uk → uss
=⇒ vk → vss
=⇒ yk → 0
4 - 13
Integral action – example
Plant model:
xk+1 = Axk + Buk + Dw yk = Cxk
A =

1.1 2
0 0.95

B =

0
0.0787

D =

1
0

C =

−1 1

Constraints: none
Cost weighting matrices: Qz =

CT
C 0
0 0.01

, R = 1
Unconstrained LQ optimal feedback gain:
Kz =

−1.625 −9.033 0.069

4 - 14
Integral action – example
+ integrator
no integrator
0 10 20 30 40 50
u
-1
0
1
2
3
4
+ integrator
no integrator
sample k
0 10 20 30 40 50
y
-1
-0.5
0
0.5
1
1.5
Closed loop response for initial condition: x0 = (0.5, −0.5)
no disturbance: w = 0
4 - 15
Integral action – example
+ integrator
no integrator
0 10 20 30 40 50
u
-2
-1
0
1
2
3
4
+ integrator
no integrator
sample k
0 10 20 30 40 50
y
-5
-4
-3
-2
-1
0
Closed loop response for initial condition: x0 = (0.5, −0.5)
constant disturbance: w = 0.75
4 - 16
Constrained MPC
Naive constrained MPC strategy: w = 0 assumed in predictions
minimize
uk
N−1
X
i=0
kzi|kk2
Qz
+ kui|kk2
R

+ kzN|kk2
P
subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc
x ≤ xi|k ≤ x, i = 1, . . . , N + Nc
with: P and Nc determined for mode 2 control law ui|k = Kzzi|k
and initial prediction state: z0|k =

xk
vk

where vk+1 = vk + yk
? If closed loop system is stable
then uk → uss
=⇒ vk → vss
=⇒ yk → 0
? but disturbance wk is ignored in predictions, so

J∗
(zk+1) − J∗
(zk) 6≤ 0
feasibility at time k 6⇒ feasibility at k + 1
therefore no guarantee of stability
4 - 17
Constrained MPC
Naive constrained MPC strategy: w = 0 assumed in predictions
minimize
uk
N−1
X
i=0
kzi|kk2
Qz
+ kui|kk2
R

+ kzN|kk2
P
subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc
x ≤ xi|k ≤ x, i = 1, . . . , N + Nc
with: P and Nc determined for mode 2 control law ui|k = Kzzi|k
and initial prediction state: z0|k =

xk
vk

where vk+1 = vk + yk
? If closed loop system is stable
then uk → uss
=⇒ vk → vss
=⇒ yk → 0
? but disturbance wk is ignored in predictions, so

J∗
(zk+1) − J∗
(zk) 6≤ 0
feasibility at time k 6⇒ feasibility at k + 1
therefore no guarantee of stability
4 - 17
Constrained MPC – example
constraints
violated


*
Closed loop response with initial condition: x0 = (0.5, −0.5)
constraints: −1 ≤ u ≤ 1 disturbance: w = 0.75
4 - 18
Robust constraints
If predictions satisfy constraints

for all prediction times i = 0, 1, . . .
for all disturbances wi ∈ W
then feasibility of constraints at time k ensures feasibility at time k + 1
B Decompose predictions into
nominal predicted state si|k
uncertain predicted state ei|k
where
xi|k = si|k + ei|k

si+1|k = Φsi|k + Bci|k s0|k = xk
ei+1|k = Φei|k + Dwi|k e0|k = 0
B Pre-stabilized predictions:
ui|k = Kxi|k + ci|k and Φ = A + BK
where K = KLQ is the unconstrained LQ optimal gain
4 - 19
Pre-stabilized predictions – example
Scalar system: xk+1 = 2xk + uk + wk, constraint: |xk| ≤ 2
uncertainty: ei|k =
i−1
X
j=0
2j
w = (2i
− 1)w, disturbance: wk = w
|w| ≤ 1
4 - 20
Pre-stabilized predictions – example
Scalar system: xk+1 = 2xk + uk + wk, constraint: |xk| ≤ 2
uncertainty: ei|k =
i−1
X
j=0
2j
w = (2i
− 1)w, disturbance: wk = w
|w| ≤ 1
Robust constraints:
|si|k + ei|k| ≤ 2 for all |w| ≤ 1
m
|si|k| ≤ 2 − max|w|≤1|ei|k|
⇓
|si|k| ≤ 2 − (2i
− 1)
⇓
infeasible for all i  1 sample
0 1 2 3 4 5
-10
-8
-6
-4
-2
0
2
4
6
8
10
upper bound on ei|k
@
@
R
lower bound on ei|k

4 - 20
Pre-stabilized predictions – example
Avoid infeasibility by using pre-stabilized predictions:
ui|k = Kxi|k + ci|k, K = −1.9, ci|k =
(
free i = 0, . . . , N − 1
0 i ≥ N
stable predictions: ei|k =
i−1
X
j=0
0.1j
w = (1 − 0.1i
)w/0.9, |w| ≤ 1
4 - 21
Pre-stabilized predictions – example
Avoid infeasibility by using pre-stabilized predictions:
ui|k = Kxi|k + ci|k, K = −1.9, ci|k =
(
free i = 0, . . . , N − 1
0 i ≥ N
stable predictions: ei|k =
i−1
X
j=0
0.1j
w = (1 − 0.1i
)w/0.9, |w| ≤ 1
Robust constraints:
|si|k + ei|k| ≤ 2 for all |w| ≤ 1
m
|si|k| ≤ 2 − max|w|≤1|ei|k|
⇓
|si|k| ≤ 2 − (1 − 0.1i
)/0.9
| {z }
0 for all i
sample
0 1 2 3 4 5
-5
-4
-3
-2
-1
0
1
2
3
4
5
upper bound on ei|k
?
lower bound on ei|k
6
4 - 21
Pre-stabilized predictions
B Feedback structure of MPC with open loop predictions:
Plant
MPC
Optimization
- -
- x
u
?
w
B Feedback structure of MPC with pre-stabilized predictions:
Stablizing
feedback
Plant
MPC
Optimization
6
g
- - -

- x
u
c
Kx
+ +
?
w
4 - 22
General form of robust constraints
How can we impose (general linear) constraints robustly?
? Pre-stabilized predictions:
xi|k = si|k + ei|k

si+1|k = Φsi|k + Bci|k s0|k = xk
ei+1|k = Φei|k + Dwi|k e0|k = 0
=⇒ ei|k = Dwi−1 + ΦDwi−2 + · · · + Φi−1
Dw0
? General linear constraints: Fxi|k + Gui|k ≤ 1
are equivalent to tightened constraints on nominal predictions:
(F + GK)si|k + Gci|k ≤ 1 − hi
where h0 = 0
hi = max
w0,...,wi−1∈W
(F + GK)ei|k, i = 1, 2, . . .
(i.e. hi = hi−1 + maxw∈W (F + GK)w
requiring one LP for each row of hi)
4 - 23
Tube interpretation
The uncertainty in predictions: ei+1|k = Φei|k + Dwi, wi ∈ W
evolves inside a tube (a sequence of sets): ei|k ∈ Ei|k, where
Ei|k = DW ⊕ ΦDW ⊕ · · · ⊕ Φi−1
DW, i = 1, 2, . . .
Hence we can define:
? a state tube xi|k = si|k + ei|k ∈ Xi|k
Xi|k = {si|k} ⊕ Ei|k, i = 0, 1, . . .
? a control input tube ui|k = Kxi|k + ci|k = Ksi|k + ci|k + Kei|k ∈ Ui|k
Ui|k = {Ksi|k + ci|k} ⊕ KEi|k, i = 0, 1, . . .
and impose constraints robustly for the state and input tubes
(where ⊕ is Minkowski set addition)
4 - 24
Tube interpretation
The uncertainty in predictions: ei+1|k = Φei|k + Dwi, wi ∈ W
evolves inside a tube (a sequence of sets): ei|k ∈ Ei|k, where
Ei|k = DW ⊕ ΦDW ⊕ · · · ⊕ Φi−1
DW, i = 1, 2, . . .
e.g. for constraints Fx ≤ 1 (G = 0)
s0|k
X1|k



s1|k
s2|k
X2|k



s3|k
X3|k



s4|k
X4|k



sample
Fx = 1
?
Xi|k = {si|k} ⊕ Ei|k
4 - 24
Robust MPC
Prototype robust MPC algorithm
Offline: compute Nc and h1, . . . , hNc
. Online at k = 0, 1, . . .:
(i). solve c∗
k = arg min
ck
J(xk, ck)
s.t. (F + GK)si|k + Gci|k ≤ 1 − hi, i = 0, . . . , N + Nc
(ii). apply uk = Kxk + c∗
0|k to the system
? tightened linear constraints are applied to nominal predictions
? Nc is the constraint-checking horizon defined by:
(F + GK)ΦNc+1
s ≤ 1 − hNc+1
for all s satisfying (F + GK)Φi
s ≤ 1 − hi, i = 0, . . . , Nc
? the online optimization is robustly recursively feasible
4 - 25
Robust MPC
Prototype robust MPC algorithm
Offline: compute Nc and h1, . . . , hNc
. Online at k = 0, 1, . . .:
(i). solve c∗
k = arg min
ck
J(xk, ck)
s.t. (F + GK)si|k + Gci|k ≤ 1 − hi, i = 0, . . . , N + Nc
(ii). apply uk = Kxk + c∗
0|k to the system
nominal cost, evaluated assuming wi = 0 for all i:
J(xk, ck) =
∞
X
i=0
ksi|kk2
Q + kKsi|k + ci|kk2
R

= kxkk2
P + kckk2
Wc
(one possible choice)
4 - 25
Convergence of robust MPC with nominal cost
If ui|k = Kxi|k + ci|k for K = KLQ, then:
? the unconstrained solution is ck = 0, so the nominal cost is
J(xk, ck) = kxkk2
P + kckk2
Wc
and Wc is block-diagonal: Wc = diag{Pc, . . . , Pc}
? recursive feasibility ⇒ c̃k+1 = (c∗
1|k, . . . , c∗
N−1|k, 0) feasible at k + 1
? hence kc∗
k+1k2
Wc
≤ kc∗
kk2
Wc
− kc∗
0|kk2
Pc
⇒
∞
X
k=0
kc0|kk2
Pc
≤ kc∗
0k2
Wc
 ∞
⇒ limk→∞ c0|k = 0
? therefore uk → Kxk as k → ∞
xk → the (minimal) robustly invariant set
under unconstrained LQ optimal feedback
4 - 26
Robust MPC with constant disturbance
Assume wk = w = constant for all k
combine: pre-stabilized predictions
augmented state space model
? Predicted state and input sequences:
xi|k =

I 0

(si|k + ei|k)
ui|k = Kz(si|k + ei|k) + ci|k
? Prediction model:
nominal si+1|k = Φsi|k +

B
0

ci|k Φ =

A 0
C I

+

B
0

Kz
uncertain ei|k =
i−1
X
j=0
Φj

D
0

w s0|k =

xk
vk

, e0|k = 0
? Nominal cost:
J(xk, vk, ck) =
∞
X
i=0
ksi|kk2
Qz
+ kKzsi|k + ci|kk2
R

4 - 27
Robust MPC with constant disturbance
Assume wk = w = constant for all k
combine: pre-stabilized predictions
augmented state space model
? robust state constraints:
x ≤ xi|k ≤ x ⇐⇒ x + hi ≤ si|k ≤ x − hi
hi = max
w∈W

I 0
 i−1
X
j=0
Φj

D
0

w
? robust input constraints:
u ≤ ui|k ≤ u ⇐⇒ u + h0
i ≤ Kzsi|k + ci|k ≤ u − h0
i
h0
i = max
w∈W
Kz
i−1
X
j=0
Φj

D
0

w
? Nc and hi, h0
i for i = 1, . . . , Nc can be computed offline
4 - 27
Robust MPC with constant disturbance – example
+ integrator
no integrator
0 10 20 30 40 50
u
-1
-0.5
0
0.5
1 + integrator
no integrator
sample k
0 10 20 30 40 50
y
-6
-5
-4
-3
-2
-1
0
1
Closed loop response with initial condition: x0 = (0.5, −0.5)
constraints: −1 ≤ u ≤ 1 disturbance: w = 0.75
4 - 28
Summary
B Integral action: augment model with integrated output error
include integrated output error in cost
then
(i). closed loop system is stable if w = 0
(ii). steady state error must be zero if response is stable for w 6= 0
B Robust MPC: use pre-stabilized predictions
apply constraints for all possible future uncertainty
then
(i). constraint feasibility is guaranteed at all times if initially feasible
(ii). closed loop system inherits the stability and convergence properties
of unconstrained LQ optimal control (assuming nominal cost)
4 - 29
Overview of the course
1 Introduction and Motivation
Basic MPC strategy; prediction models; input and state constraints; constraint handling:
saturation, anti-windup, predictive control
2 Prediction and optimization
Input/state prediction equations; unconstrained optimization. Infinite horizon cost; dual mode
predictions. Incorporating constraints; quadratic programming.
3 Closed loop properties
Lyapunov analysis based on predicted cost. Recursive feasibility; terminal constraints; the
constraint checking horizon. Constrained LQ-optimal control.
4 Robustness to disturbances
Setpoint tracking; MPC with integral action. Robustness to constant disturbances:
prestabilized predictions and robust feasibility. Handling time-varying disturbances.
4 - 30

More Related Content

PDF
Predictive Control For Linear And Hybrid Systems Draft Draft Francesco Borrelli
PDF
Predictive Control for Linear and Hybrid Systems 1st Edition Francesco Borrelli
PPT
Concepts of predictive control
PDF
Start MPC
PDF
M ODEL P REDICTIVE C ONTROL U SING F PGA
PPTX
Implementation of Model Predictive Controller for a drone
PDF
Multi parametric model predictive control based on laguerre model for permane...
Predictive Control For Linear And Hybrid Systems Draft Draft Francesco Borrelli
Predictive Control for Linear and Hybrid Systems 1st Edition Francesco Borrelli
Concepts of predictive control
Start MPC
M ODEL P REDICTIVE C ONTROL U SING F PGA
Implementation of Model Predictive Controller for a drone
Multi parametric model predictive control based on laguerre model for permane...

Similar to 9-12 MPC mode predictive control system.pdf (20)

PDF
PPT
MPC Bilinear com restrições - MCA 2008
PPTX
Self tuning, Optimal MPC, DMC.pptx
PDF
Real Time Code Generation for Nonlinear Model Predictive Control
PDF
Moving Horizon Model Based Control in the Presence of Feedback Noise
PDF
Performance analysis of a liquid column in a chemical plant by using mpc
PDF
Performance analysis of a liquid column in a chemical plant by using mpc
PPT
MPC Tuning Based On Desired Frequency Domain Closed Loop Response
PDF
UROP MPC Report
PDF
EFFINET - Initial Presentation
PDF
Application of a merit function based interior point method to linear model p...
PDF
Smart Systems for Urban Water Demand Management
PDF
Design of predictive controller for smooth set point tracking for fast dynami...
PDF
Modelling & Control of Drinkable Water Networks
PDF
Explicit model predictive control of fast dynamic system
PDF
Explicit model predictive control of fast dynamic system
PDF
Robust model predictive control for discrete-time fractional-order systems
PDF
Optimal control : Introduction and Overview
PPTX
Control Strategies for Autonomous quadrotors.pptx
PPTX
Constrained state feedback control
MPC Bilinear com restrições - MCA 2008
Self tuning, Optimal MPC, DMC.pptx
Real Time Code Generation for Nonlinear Model Predictive Control
Moving Horizon Model Based Control in the Presence of Feedback Noise
Performance analysis of a liquid column in a chemical plant by using mpc
Performance analysis of a liquid column in a chemical plant by using mpc
MPC Tuning Based On Desired Frequency Domain Closed Loop Response
UROP MPC Report
EFFINET - Initial Presentation
Application of a merit function based interior point method to linear model p...
Smart Systems for Urban Water Demand Management
Design of predictive controller for smooth set point tracking for fast dynami...
Modelling & Control of Drinkable Water Networks
Explicit model predictive control of fast dynamic system
Explicit model predictive control of fast dynamic system
Robust model predictive control for discrete-time fractional-order systems
Optimal control : Introduction and Overview
Control Strategies for Autonomous quadrotors.pptx
Constrained state feedback control
Ad

More from abbas miry (20)

PPTX
Grey_wolf_optimizer Grey_wolf_optimizer.pptx
PDF
L-9 wave EM for electrical students .pdf
PDF
solid state physics-Chapter eight 8-2.pdf
PDF
solid state for physics science -Chapter 8-1.pdf
PDF
Robust Stability and Robust Performance Analysis and Synthesis
PPTX
PSOPPT with example (pso optimization with solved problem) .pptx
PDF
swarm pso and gray wolf Optimization.pdf
PPTX
optimization methods by using matlab.pptx
PPTX
TLEN-5830-Wireless-Systems-Lecture-01.pptx
PPT
UNIT-V-PPT state space of system model .ppt
PPTX
lec_2 - Copy lyponve stability of system .pptx
PPTX
lec_2 for stability of control system .pptx
PPTX
11-Optimization algorithm with swarm.pptx
PPT
Neuron Modeling for Artificial Neural Systems 3
PPT
Neuron Modeling for Artificial Neural Systems
PPTX
Control Signal Flow Graphs lecture notes
PPTX
SFG.pptx
PPTX
bode.pptx
PDF
bode.pdf
PDF
Lec_13.pdf
Grey_wolf_optimizer Grey_wolf_optimizer.pptx
L-9 wave EM for electrical students .pdf
solid state physics-Chapter eight 8-2.pdf
solid state for physics science -Chapter 8-1.pdf
Robust Stability and Robust Performance Analysis and Synthesis
PSOPPT with example (pso optimization with solved problem) .pptx
swarm pso and gray wolf Optimization.pdf
optimization methods by using matlab.pptx
TLEN-5830-Wireless-Systems-Lecture-01.pptx
UNIT-V-PPT state space of system model .ppt
lec_2 - Copy lyponve stability of system .pptx
lec_2 for stability of control system .pptx
11-Optimization algorithm with swarm.pptx
Neuron Modeling for Artificial Neural Systems 3
Neuron Modeling for Artificial Neural Systems
Control Signal Flow Graphs lecture notes
SFG.pptx
bode.pptx
bode.pdf
Lec_13.pdf
Ad

Recently uploaded (20)

PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Sustainable Sites - Green Building Construction
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
bas. eng. economics group 4 presentation 1.pptx
PPT
Project quality management in manufacturing
PPT
Mechanical Engineering MATERIALS Selection
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
Welding lecture in detail for understanding
PPTX
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
PPTX
Lesson 3_Tessellation.pptx finite Mathematics
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PPTX
Construction Project Organization Group 2.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
web development for engineering and engineering
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Sustainable Sites - Green Building Construction
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
bas. eng. economics group 4 presentation 1.pptx
Project quality management in manufacturing
Mechanical Engineering MATERIALS Selection
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
Welding lecture in detail for understanding
KTU 2019 -S7-MCN 401 MODULE 2-VINAY.pptx
Lesson 3_Tessellation.pptx finite Mathematics
Foundation to blockchain - A guide to Blockchain Tech
Model Code of Practice - Construction Work - 21102022 .pdf
Strings in CPP - Strings in C++ are sequences of characters used to store and...
Construction Project Organization Group 2.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
web development for engineering and engineering
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...

9-12 MPC mode predictive control system.pdf

  • 1. C21 Model Predictive Control Mark Cannon 4 lectures Hilary Term 2023 Department of Engineering Science eng.ox.ac.uk/control 0 - 1
  • 3. Organisation B 4 lectures – Tuesday & Thursday weeks 5 & 6 in person at 14:00 in LR2 or pre-recorded on Canvas B Examples class – Thursday week 7 in person at 12:00, 14:00, 15:00 in LR6 1 - 3
  • 4. Course outline 1. Introduction to predictive control 2. Prediction and optimization 3. Closed loop properties 4. Disturbances and integral action 5. Robust tube MPC 1 - 4
  • 5. Books B J.M. Maciejowski, Predictive control with constraints. Prentice Hall, 2002 Recommended reading: Chapters 1–3, 6 & 8 B J.B. Rawlings and D.Q. Mayne, Model Predictive Control: Theory and Design. Nob Hill Publishing, 2009 B B. Kouvaritakis and M. Cannon, Model Predictive Control: Classical, Robust and Stochastic, Springer 2015 Recommended reading: Chapters 1, 2 & 3 1 - 5
  • 6. Motivating example: switching control How does a thermostat regulate room temperature? tĞĚŶĞƐĚĂLJ͕ϮϵƉƌŝůϮϬϮϬ ϭϰ͗ϬϬ Closed loop control system: PUFEQGXVHP dŚĞƌŵŽĚŝĂŐƌĂŵƐ tĞĚŶĞƐĚĂLJ͕ϮϵƉƌŝůϮϬϮϬ ϭϰ͗ϬϬ 1 - 6
  • 7. Motivating example: switching control System model: C dT dt = q − qL qL = βT q = αu u = ( U if on 0 if off Switching controller: PUFEQGXVHP dŚĞƌŵŽƐǁŝƚĐŚŝŶŐƉůŽƚƐ tĞĚŶĞƐĚĂLJ͕ϮϵƉƌŝůϮϬϮϬ ϭϱ͗ϯϰ ? Single controller parameter: hysteresis band δ ? Accurate models aren’t needed to regulate T to [T0 − δ, T0 + δ] 1 - 7
  • 8. Motivating example: switching control System model: C dT dt = q − qL qL = βT q = αu u = ( U if on 0 if off Closed loop response: T(t) = Tss + (T(0) − Tss)e−t/τ Tss = ( αU/β if on 0 if off τ = C β ? Single controller parameter: hysteresis band δ ? Accurate models aren’t needed to regulate T to [T0 − δ, T0 + δ] 1 - 7
  • 9. Motivating example: switching control System model: C dT dt = q − qL qL = βT q = αu u = ( U if on 0 if off Closed loop response: ? Single controller parameter: hysteresis band δ ? Accurate models aren’t needed to regulate T to [T0 − δ, T0 + δ] 1 - 7
  • 10. Motivating example: proportional control (P) System model: C dT dt = q − qL qL = βT q = αu u = K(T0 − T) Closed loop response: T(t) = Tss + (T(0) − Tss)e−t/τ Tss = αK αK + β T0 τ = C αK + β ? Controller parameter: gain K ? Tss → T0 and τ → 0 as K → ∞ independent of parameters C, α, β 1 - 8
  • 11. Motivating example: proportional control (P) Controller: u = K(T0 − T) Effect of increasing gain (ideal case), K1 K2 K3: PUFEQGXVHP WƌŽƉŽƌƚŝŽŶĂůƉůŽƚƐ tĞĚŶĞƐĚĂLJ͕ϮϵƉƌŝůϮϬϮϬ ϭϳ͗ϯϭ High gain K is often de-stabilizing because of: ? nonlinearity, e.g. actuator saturation: u = min n ū, max K(T0 − T), 0 o ? additional dynamics, e.g. sensor and actuator time-delay or lag 1 - 9
  • 12. Motivating example: proportional control (P) Controller: u = K(T0 − T) Actual effect of increasing gain: High gain K is often de-stabilizing because of: ? nonlinearity, e.g. actuator saturation: u = min n ū, max K(T0 − T), 0 o ? additional dynamics, e.g. sensor and actuator time-delay or lag 1 - 9
  • 13. Motivating example: proportional + integral control (PI) Control signal proportional to tracking error and integral of tracking error: u = K(T0 − T) + K Ti Z t (T0 − T) dt ? If closed loop system is stable then T0 − T(t) → 0 as t → ∞, i.e. no steady state error (assuming T0 = constant) ? Controller has no knowledge of model parameters but increasing gain (K/Ti) generally degrades transient performance (overshoot and oscillations) ? Two controller parameters K, Ti to be tuned/optimized 1 - 10
  • 14. Motivating example: PID control Include the rate of change of tracking error: u = K(T0 − T) + K Ti Z t (T0 − T) dt + KTd d dt (T0 − T) ? The derivative term provides anticipation of future error (“feedforward”) ? Three PID gains K, Ti, Td need tuning, either using a system model or heuristic rules (e.g. Ziegler-Nichols) ? PID tuning is difficult with nonlinear dynamics and constraints ? Not obvious how to configure feedback loops for MIMO problems 1 - 11
  • 15. Controller optimization Can we optimize controller parameters for a given performance criterion? e.g. mean square error: min K,Ti,Td Z ∞ 0 E{(T0 − T)2 + ρu2 } dt KWWSVXQLR[IRUGQH[XVPVKDUHSRLQWFRPSHUVRQDOHQJVBR[BDFBXNBODRXWV'RFDVS[VRXUFHGRF ^FFHIDHEFGI` DFWLRQ« ? Optimization of linear controller gains (e.g. K, Ti, Td) is generally nonconvex ? It’s more common to optimize over control signals (e.g. LQG control) min u Z ∞ 0 E{(T0 − T)2 + ρ u2 } dt Unconstrained linear system =⇒ solution is linear state feedback but no closed-form solution in almost all other cases 1 - 12
  • 16. Model predictive control MPC optimizes predicted performance numerically over future control and state trajectories KWWSVXQLR[IRUGQH[XVPVKDUHSRLQWFRPSHUVRQDOHQJVBR[BDFBXNBODRXWV'RFDVS[VRXUFHGRF ^FFHIDHEFGI` DFWLRQ« ? The optimization is generally easier than optimizing feedback gains (e.g. convex for linear systems with linear state and input constraints) ? Single-shot solution is an open loop control signal MPC updates it by repeating the optimization periodically online ? This results in a feedback controller, providing robustness to model and measurement uncertainty and compensating for using finite numbers of optimization variables 1 - 13
  • 17. Model predictive control 1 Prediction using a dynamic model constraints 2 Online optimization 3 Receding horizon implementation 1. Prediction ? Plant model: xk+1 = f(xk, uk) ? Simulate forward in time (over a prediction horizon of N steps) predicted input sequence uk =      u0|k u1|k . . . uN−1|k      predicted state sequence xk =      x0|k x1|k . . . xN|k      Notation: (ui|k, xi|k) = predicted i steps ahead | evaluated at time k x0|k = xk 1 - 14
  • 18. Overview of MPC 2. Optimization ? Performance cost: J(xk, uk) = N X i=0 `i(xi|k, ui|k) `i(x, u): stage cost ? Optimize numerically to determine the optimal input sequence: u∗ k = arg min uk J(xk, uk) = u∗ 0|k(xk), . . . , u∗ N−1|k(xk) 3. Implementation ? Use first element of u∗ k =⇒ MPC law: uk = u∗ 0|k(xk) ? Repeat optimization at each sampling instant k = 0, 1, . . . 1 - 15
  • 19. Overview of MPC time prediction horizon time past predicted u x k k + N 1 - 16
  • 20. Overview of MPC time prediction horizon at time prediction horizon at time time u x k k + 1 k k + N k + 1 k + N + 1 1 - 16
  • 21. Example Plant model: xk+1 = 1.1 2 0 0.95 xk + 0 0.0787 uk yk = −1 1 xk Cost: N−1 X i=0 (y2 i|k + u2 i|k) + y2 N|k Prediction horizon: N = 3 Predicted input and state sequences: uk =   u0|k u1|k u2|k  , xk =     x0|k x1|k x2|k x3|k     1 - 17
  • 22. Example 0 1 2 3 4 5 6 7 8 9 10 input -4 -2 0 2 4 6 sample 0 1 2 3 4 5 6 7 8 9 10 output -1 -0.5 0 0.5 1 1 - 18
  • 23. Example 0 1 2 3 4 5 6 7 8 9 10 input -4 -2 0 2 4 6 sample 0 1 2 3 4 5 6 7 8 9 10 output -1 -0.5 0 0.5 1 1 - 18
  • 24. Example 0 1 2 3 4 5 6 7 8 9 10 input -4 -2 0 2 4 6 sample 0 1 2 3 4 5 6 7 8 9 10 output -1 -0.5 0 0.5 1 1 - 18
  • 25. Example 0 1 2 3 4 5 6 7 8 9 10 input -4 -2 0 2 4 6 sample 0 1 2 3 4 5 6 7 8 9 10 output -1 -0.5 0 0.5 1 1 - 18
  • 26. Example 0 1 2 3 4 5 6 7 8 9 10 input -4 -2 0 2 4 6 predicted at k=0 closed loop sample 0 1 2 3 4 5 6 7 8 9 10 output -1 -0.5 0 0.5 1 1 - 18
  • 27. Model predictive control Advantages B Flexible plant model – multivariable – linear or nonlinear – deterministic, stochastic or fuzzy B Handles constraints on control inputs and states – actuator limits – safety, environmental and economic constraints B Approximately optimal control Disadvantages B Requires online optimization – quadratic programming (QP) problem for linear-quadratic problems – high computational requirement for nonlinear systems 1 - 19
  • 28. MPC development Control strategy reinvented several times LQG optimal control 1950’s industrial process control 1980’s constrained nonlinear MPC 1990’s robust MPC 2000’s stochastic MPC 2010’s Current research challenges: – high sample rates, long prediction horizons, uncertain nonlinear models – embedded optimization sparse solvers – adaptive and stochastic MPC 1 - 20
  • 29. Prediction model Linear plant model: xk+1 = Axk + Buk B Predicted xk depends linearly on uk [details in Lecture 2] B Therefore LQ cost is quadratic in uk u k Huk + 2f uk + g(xk) and constraints are linear Acuk ≤ b(xk) B Online optimization: min u u Hu + 2f u s.t. Acu ≤ bc This is a convex Quadratic Program (QP), which is reliably and efficiently solvable 1 - 21
  • 30. Prediction model Nonlinear plant model: xk+1 = f(xk, uk) B Predicted xk depends nonlinearly on uk B In general the cost is nonconvex in uk: J(xk, uk) and the constraints are nonconvex: gc(xk, uk) ≤ 0 B Online optimization: min u J(xk, u) s.t. gc(xk, u) ≤ 0 – may be nonconvex – may have local minima – may not be solvable efficiently or reliably 1 - 22
  • 31. Prediction model Discrete time prediction model B Predictions optimized periodically at t = 0, T, 2T, . . . B Usually T = Ts = sampling interval of model B But T = nTs for any integer n ≥ 1 is possible, (e.g. if Ts time needed for online optimization) 1 - 23
  • 32. Prediction model Continuous time prediction model B Predicted u(t) need not be piecewise constant, e.g. continuous, piecewise linear u(t) or u(t) = polynomial in t (piecewise quadratic, cubic etc) B Continuous time prediction models can be solved online B This course: discrete-time model and T = Ts assumed 1 - 24
  • 33. Constraints Classify state and input constraints as either hard or soft B Hard constraints must be satisfied at all times, if this is not possible, then the problem is infeasible B Soft constraints can be violated to avoid infeasibility B Strategies for handling soft constraints: ? impose (hard) constraints on the probability of violating each soft constraint ? or remove active constraints until the problem becomes feasible 1 - 25
  • 34. Constraints Typical methods for handling input constraints: (a) Saturate the unconstrained control law (ignore constraints in controller design) (b) De-tune the unconstrained control law by increasing the penalty on u in the performance objective (c) Use an anti-windup strategy to limit the state of a dynamic controller (typically the integral term of a PI or PID controller) (d) Use MPC with inequality-constrained optimization 1 - 26
  • 35. Example: input constraints (a) Effects of controller saturation, u ≤ uk ≤ u unconstrained LQ optimal control: u0 (x) = Klqx saturated: u = max min{u0 , u}, u Input constraints: u ≤ u ≤ u u = −1, u = 1 Controller saturation causes ? poor performance ? possible instability 0 5 10 15 20 25 30 35 40 −2 0 2 4 6 8 u 0 5 10 15 20 25 30 35 40 −4 −2 0 2 4 6 y sample saturated lqr unconstrained lqr 1 - 27
  • 36. Example: input constraints (b) Effects of de-tuning the unconstrained optimal control law: Klq = optimal gain for LQ cost ∞ X k=0 y2 k + ρ u2 k Increase ρ until u = Klqx satisfies constraints (locally) Example 10−2 ≤ ρ ≤ 103 ⇓ settling time increased from 6 to 40 ? yk → 0 slowly ? stability can be ensured 0 10 20 30 40 50 60 −2 0 2 4 6 y sample 0 10 20 30 40 50 60 −2 0 2 4 6 8 u lqr, R=1000 lqr, R=0.01 1 - 28
  • 37. Example: input constraints (c) Effects of Anti-windup: Anti-windup attempts to avoid instability while control input saturated Many possible approaches, e.g. anti-windup PI controller: u = max min{(Ke + v), u}, u Tiv̇ + v = u ⇓ u ≤ u ≤ u =⇒ u = K e + 1 Ti Z t e dt u = u or u =⇒ v(t) → u or u exponentially Heuristic strategy may not prevent instability 1 - 29
  • 38. Example: input constraints (d) Comparison with optimal constrained LQ control (MPC) Example MPC vs saturated LQ (both using the same cost): ? settling time reduced to 20 by MPC ? stability is guaranteed with MPC 0 5 10 15 20 25 30 35 40 −1 0 1 2 3 u 0 5 10 15 20 25 30 35 40 −4 −2 0 2 4 6 y sample mpc, N=16 saturated lqr 1 - 30
  • 39. Summary B Predict performance using plant model e.g. linear or nonlinear, discrete or continuous time B Optimize future (open loop) control sequence computationally much easier than optimizing over feedback laws B Implement first sample, then repeat optimization provides feedback to reduce effect of uncertainty B Comparison of common methods of handling constraints: saturation, de-tuning, anti-windup, MPC 1 - 31
  • 40. Lecture 2 Prediction and optimization 2 - 1
  • 41. Prediction and optimization Input and state predictions Unconstrained finite horizon optimal control Infinite prediction horizons and connection with LQ optimal control Incorporating constraints Quadratic programming 2 - 2
  • 42. Review of MPC strategy At each sampling instant: 1 Use a model to predict system behaviour over a finite future horizon 2 Compute a control sequence by solving an online optimization problem 3 Apply the first element of optimal control sequence as control input Advantages ? flexible plant model ? constraints taken into account ? optimal performance Disadvantage ? online otimization required 2 - 3
  • 43. Prediction equations Linear time-invariant model: xk+1 = Axk + Buk assume xk is measured at time k Predictions: uk =    u0|k . . . uN−1|k   , xk =    x0|k . . . xN|k    Quadratic cost: J(xk, uk) = N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P (kxk2 Q = x Qx, kuk2 R = u Ru P = terminal weighting matrix ) 2 - 4
  • 44. Prediction equations Linear time-invariant model: xi+1|k = Axi|k + Bui|k assume xk is measured at time k x0|k = xk x1|k = Axk + Bu0|k . . . xN|k = AN xk + AN−1 Bu0|k + AN−2 Bu1|k + · · · + BuN−1|k ⇓ xk = Mxk + Cuk, M =        I A A2 . . . AN        , C =        0 0 · · · 0 B AB B . . . . . . ... AN−1 B AN−2 B · · · B        2 - 4
  • 45. Prediction equations Predicted cost: Jk = N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P = x k Q xk + u k R uk Q = diag{Q, . . . , Q, P} R = diag{R, . . . , R, R} ⇓ Jk = u k Huk + 2x k F uk + x k Gxk where H = C Q C + R ← u × u terms F = C Q M ← u × x terms G = M Q M ← x × x terms time-invariant model =⇒ H, F, G can be computed offline 2 - 5
  • 46. Prediction equations Predicted cost: Jk = N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P = x k Q xk + u k R uk Q = diag{Q, . . . , Q, P} R = diag{R, . . . , R, R} ⇓ Jk = u k Huk + 2x k F uk + x k Gxk where H = C Q C + R ← u × u terms F = C Q M ← u × x terms G = M Q M ← x × x terms time-invariant model =⇒ H, F, G can be computed offline 2 - 5
  • 47. Prediction equations – example Plant model: xk+1 = Axk + Buk, yk = Cxk A = 1.1 2 0 0.95 , B = 0 0.079 , C = −1 1 Prediction horizon N = 4: C =            0 0 0 0 0 0 0 0 0 0 0 0 0.079 0 0 0 0.157 0 0 0 0.075 0.079 0 0 0.323 0.157 0 0 0.071 0.075 0.079 0 0.497 0.323 0.157 0 0.068 0.071 0.075 0.079            Cost matrices Q = C C, R = 0.01, and P = Q: H =   0.271 0.122 0.016 −0.034 ? 0.086 0.014 −0.020 ? ? 0.023 −0.007 ? ? ? 0.016   F =   0.977 4.925 0.383 2.174 0.016 0.219 −0.115 −0.618   G = h 7.589 22.78 ? 103.7 i 2 - 6
  • 48. Prediction equations: LTV model Linear time-varying model: xk+1 = Akxk + Bkuk assume xk is measured at time k Predictions: x0|k = xk x1|k = Akxk + Bku0|k x2|k = Ak+1Akxk + Ak+1Bku0|k + Bk+1u1|k . . . xi|k = 0 Y j=i−1 Ak+jxk + Ci(k)uk, i = 0, . . . , N Ci(k) = 1 Y j=i−1 Ak+jBk 2 Y j=i−1 Ak+jBk+1 · · · Bk+i−1 0 · · · 0 # ? Q0 j=i−1 Ak+j = Ak+i−1 · · · Ak for i ≥ 1 and Q0 j=i−1 Ak+j = 0 for i = 0 ? H(k), F(k), G(k) depend on k and must be computed online 2 - 7
  • 49. Unconstrained optimization Minimize cost: u∗ = arg min u J, J = u Hu + 2x F u + x Gx differentiate w.r.t. u: ∇uJ = 2Hu + 2Fx = 0 ⇓ u = −H−1 Fx = u∗ if H is positive definite i.e. if H 0 Here H = C Q C + R 0 if: R 0 Q, P 0 or R 0 Q, P 0 C is full-rank m (A, B) controllable Receding horizon controller is linear state feedback: uk = − I 0 · · · 0 H−1 Fxk is the closed loop response optimal? is it even stable? 2 - 8
  • 50. Unconstrained optimization Minimize cost: u∗ = arg min u J, J = u Hu + 2x F u + x Gx differentiate w.r.t. u: ∇uJ = 2Hu + 2Fx = 0 ⇓ u = −H−1 Fx = u∗ if H is positive definite i.e. if H 0 Here H = C Q C + R 0 if: R 0 Q, P 0 or R 0 Q, P 0 C is full-rank m (A, B) controllable Receding horizon controller is linear state feedback: uk = − I 0 · · · 0 H−1 Fxk is the closed loop response optimal? is it even stable? 2 - 8
  • 51. Example Model: A, B, C as before, cost: Jk = N−1 X i=0 y2 i|k + 0.01u2 i|k + y2 N|k I For N = 4: u∗ k = −H−1 Fxk =    −4.36 −18.7 1.64 1.24 1.41 3.00 0.59 1.83   xk uk = −4.36 −18.7 xk I For general N: uk = L(N)xk N = 4 N = 3 N = 2 N = 1 L(N) −4.36 −18.69 −3.80 −16.98 1.22 −3.95 5.35 5.10 λ A + BL(N) 0.29 ± 0.17j 0.36 ± 0.22j 1.36, 0.38 2.15, 0.30 stable stable unstable unstable 2 - 9
  • 52. Example Horizon: N = 4, x0 = (0.5, −0.5) 0 2 4 6 8 10 −2 0 2 4 6 8 u 0 2 4 6 8 10 −1 −0.5 0 0.5 1 sample, k y closed−loop predicted 2 - 10
  • 53. Example Horizon: N = 3, x0 = (0.5, −0.5) 0 2 4 6 8 10 −5 0 5 10 u 0 2 4 6 8 10 −1 −0.5 0 0.5 1 sample, k y closed−loop predicted 2 - 10
  • 54. Example Horizon: N = 2, x0 = (0.5, −0.5) 0 2 4 6 8 10 −10 −5 0 5 u 0 2 4 6 8 10 −5 0 5 10 15 sample, k y closed−loop predicted 2 - 10
  • 55. Example Horizon: N = 2, x0 = (0.5, −0.5) 0 2 4 6 8 10 −80 −60 −40 −20 0 20 u 0 2 4 6 8 10 −5 0 5 10 15 sample, k y closed−loop predicted Observation: predicted and closed loop responses are different for small N 2 - 10
  • 56. Receding horizon control Why is this example unstable for N ≤ 2? System is non-minimum phase ⇓ impulse response changes sign ⇓ hence short horizon causes instability N 3 C21 Model Predictive Control 2 - 12 Unconstrained optimization: example • Unstable for short horizon closed-loop instability impulse response changes sign non-minimum phase System is • Solution: use infinite cost horizon but retain finite number of d.o.f. in predictions N = Solution: ? use an infinite horizon cost ? but keep a finite number of optimization variables in predictions 2 - 11
  • 57. Dual mode predictions An infinite prediction horizon is possible with dual mode predictions: ui|k = optimization variables i = 0, . . . , N − 1, mode 1 Kxi|k i = N, N + 1, . . . mode 2 mode 1 optimized explicitly mode 2 feedback law: u = Kx Feedback gain K: stabilizing and determined offline e.g. unconstrained LQ optimal for P∞ i=0(kxik2 Q + kuik2 R) 2 - 12
  • 58. Infinite horizon cost If the predicted input sequence is {u0|k, . . . , uN−1|k, KxN|k, KΦxN|k, . . .} then ∞ X i=0 kxi|kk2 Q + kui|kk2 R) = N−1 X i=0 kxi|kk2 Q + kui|kk2 R) + kxN|kk2 P where P − (A + BK) P(A + BK) = Q + K RK Lyapunov matrix equation (discrete time) ? If Q + K RK 0, then the solution P is unique and P 0 ? Matlab: P = dlyap(Phi’,RHS); Phi = A+B*K; RHS = Q+K’*R*K; ? P is the steady state Riccati equation solution if K is LQ optimal 2 - 13
  • 59. Infinite horizon cost If the predicted input sequence is {u0|k, . . . , uN−1|k, KxN|k, KΦxN|k, . . .} then ∞ X i=0 kxi|kk2 Q + kui|kk2 R) = N−1 X i=0 kxi|kk2 Q + kui|kk2 R) + kxN|kk2 P where P − (A + BK) P(A + BK) = Q + K RK Lyapunov matrix equation (discrete time) ? If Q + K RK 0, then the solution P is unique and P 0 ? Matlab: P = dlyap(Phi’,RHS); Phi = A+B*K; RHS = Q+K’*R*K; ? P is the steady state Riccati equation solution if K is LQ optimal 2 - 13
  • 60. Infinite horizon cost Proof that the predicted cost over the mode 2 horizon is kxN|kk2 P : Let J∞ (x) = ∞ X i=0 kxik2 Q + kuik2 R , with ui = Kxi, xi+1 = Φxi ∀i x0 = x – then J∞ (x) = ∞ X i=0 x Φi QΦi x + x K Φi RKΦi x = x ∞ X i=0 (Φi ) (Q + K RK)Φi | {z } =P x = kxk2 P – but Φ PΦ = ∞ X i=1 (Φi ) (Q + K RK)Φi = P − (Q + K RK) so P − Φ PΦ = Q + K RK 2 - 14
  • 61. Connection with LQ optimal control Let J(xk, uk) = N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P P − (A + BK) P(A + BK) = Q + K RK, K = LQ optimal Then the solution of the unconstrained optimization satisfies u∗ 0|k = Kxk where u∗ k = arg min u J(xk, u) = (u∗ 0|k, . . . , u∗ N−1|k) since {u0|k, u1,k, . . .} is optimal iff uk = {u0|k, . . . , uN−1|k} is optimal and {uN|k, uN+1|k, . . .} is optimal 2 - 15
  • 62. Connection with LQ optimal control – example I Model parameters (A, B, C) as before LQ optimal gain for Q = C C, R = 0.01: K = −4.36 −18.74 Lyapunov equation solution: P = 3.92 4.83 13.86 I Cost matrices for N = 4: H =     1.44 0.98 0.59 0.26 ? 0.72 0.44 0.20 ? ? 0.30 0.14 ? ? ? 0.096     F =     3.67 23.9 2.37 16.2 1.36 9.50 0.556 4.18     G = 13.8 66.7 ? 413 I Predictive control law: uk = − 1 0 0 0 H−1 Fxk = −4.35 −18.74 xk 2 - 16
  • 63. Connection with LQ optimal control – example I Response for N = 4, x0 = (0.5, −0.5) 0 2 4 6 8 10 u -2 0 2 4 6 8 sample, k 0 2 4 6 8 10 y -1 -0.5 0 0.5 closed loop predicted Infinite horizon cost no constraints =⇒ identical predicted and closed loop responses 2 - 17
  • 64. Dual mode predictions Pre-stabilize predictions to provide better numerical stability: B Control inputs mode 1 ui|k = Kxi|k + ci|k, i = 0, 1, . . . , N − 1 mode 2 ui|k = Kxi|k, i = N, N + 1, . . . B States mode 1 xi+1|k = Φxi|k + Bci|k, i = 0, 1, . . . , N − 1 mode 2 xi+1|k = Φxi|k, i = N, N + 1, . . . where (c0|k, . . . , cN−1|k) are optimization variables 2 - 18
  • 65. Dual mode predictions Pre-stabilize predictions to provide better numerical stability: B Vectorized form: xk = Mxk + Cck xk :=    x0|k . . . xN|k    , ck :=    c0|k . . . cN−1|k    M =        I Φ Φ2 . . . ΦN        , C =        0 0 · · · 0 B ΦB B . . . . . . ... ΦN−1 B ΦN−2 B · · · B        B Cost: J xk, (u0|k, . . . , uN−1|k) = J (xk, ck) 2 - 18
  • 66. Input and state constraints Infinite horizon unconstrained MPC = LQ optimal control but MPC can also handle constraints Consider constraints applied to mode 1 predictions: ? input constraints: u ≤ ui|k ≤ u, i = 0, . . . , N − 1 ⇐⇒ I −I uk ≤ u −u where u = u · · · u u = u · · · u ? state constraints: x ≤ xi|k ≤ x, i = 1, . . . , N ⇐⇒ Ci −Ci uk ≤ x −x + −Ai Ai xk, i = 1, . . . , N 2 - 19
  • 67. Input and state constraints Constraints on mode 1 predictions can be expressed Acuk ≤ bc + Bcxk where Ac, Bc, bc can be computed offline since model is time-invariant The online optimization is a quadratic program (QP): minimize u u Hu + 2x k F u subject to Acu ≤ bc + Bcxk which is a convex optimization problem with a unique solution if H = C QC + R is positive definite 2 - 20
  • 68. QP solvers: (a) Active set Consider the QP: u∗ = arg min u u Hu + 2f u subject to Au ≤ b and let (Ai, bi) = ith row/element of (A, b) B Individual constraints are active or inactive active inactive Aiu∗ = bi, ∀i ∈ I Aiu∗ ≤ bi, ∀i 6∈ I bi affects solution bi does not affect solution B Equality constraint problem: u∗ = arg min u u Hu + 2f u subject to Aiu = bi, ∀i ∈ I B Solve QP by searching for I ? one equality constraint problem solved at each iteration ? optimality conditions (KKT conditions) identify solution 2 - 21
  • 69. QP solvers: (a) Active set Consider the QP: u∗ = arg min u u Hu + 2f u subject to Au ≤ b and let (Ai, bi) = ith row/element of (A, b) B Individual constraints are active or inactive active inactive Aiu∗ = bi, ∀i ∈ I Aiu∗ ≤ bi, ∀i 6∈ I bi affects solution bi does not affect solution B Equality constraint problem: u∗ = arg min u u Hu + 2f u subject to Aiu = bi, ∀i ∈ I B Solve QP by searching for I ? one equality constraint problem solved at each iteration ? optimality conditions (KKT conditions) identify solution 2 - 21
  • 70. Active constraints – example −3 −2 −1 0 1 2 −2.5 −2 −1.5 −1 −0.5 0 0.5 1 1.5 2 2.5 u1 u 2 u∗ i = 4 i = 5 i = 3 i = 2 i = 1 A QP problem with 5 inequality constraints active set at solution: I = {2} 2 - 22
  • 71. Active constraints – example −3 −2 −1 0 1 2 −2.5 −2 −1.5 −1 −0.5 0 0.5 1 1.5 2 2.5 u1 u 2 u∗ i = 2 An equivalent equality constraint problem 2 - 22
  • 72. QP solvers: (a) Active set B Computation: O(N3 n3 u) additions/multiplications per iteration (conservative estimate) upper bound on number of iterations is exponential in problem size B At each iteration choose trial active set using: cost gradient constraint sensitivities ⇓ number of iterations needed is often small in practice B In MPC u∗ k = u∗ (xk) and Ik = I(xk) hence initialize solver at time k using the solution computed at k − 1 2 - 23
  • 73. QP solvers: (b) Interior point B Solve an unconstrained problem at each iteration: u(µ) = min u µ u Hu + 2f u + φ(u) where φ(u) = barrier function (φ → ∞ at constraints) u → u∗ as µ → ∞ Increase µ until φ(u∗ ) 1/ ( = user-defined tolerance) B # arithmetic operations per iteration is constant, e.g. O(N3 n3 u) # iterations for given is polynomial in problem size ⇓ Computational advantages for large-scale problems e.g. # variables 102 , # constraints 103 B No general method for initializing at solution estimate 2 - 24
  • 74. QP solvers: (b) Interior point B Solve an unconstrained problem at each iteration: u(µ) = min u µ u Hu + 2f u + φ(u) where φ(u) = barrier function (φ → ∞ at constraints) u → u∗ as µ → ∞ Increase µ until φ(u∗ ) 1/ ( = user-defined tolerance) B # arithmetic operations per iteration is constant, e.g. O(N3 n3 u) # iterations for given is polynomial in problem size ⇓ Computational advantages for large-scale problems e.g. # variables 102 , # constraints 103 B No general method for initializing at solution estimate 2 - 24
  • 75. Interior point method – example −0.5 0 0.5 1 1.5 2 2.5 3 3.5 0 1 2 3 4 5 6 7 8 9 10 u u(0.5) u(1) u(2) φ(u) A A K u Hu + 2f u 6 u(µ) → u∗ = 1 as µ → ∞ but minu µ u Hu + 2f u + φ(u) becomes ill-conditioned as µ → ∞ 2 - 25
  • 76. QP solvers: (c) Multiparametric Let u∗ (x) = arg min u u Hu + 2x F u subject to Au ≤ b + Bx then: ? u∗ is a continous function of x ? u∗ (x) = Kjx + kj for all x in a polytopic set Xj B In principle each Kj, kj and Xj can be determined offline B Large number of sets Xj (combinatorial in problem size) so online determination of j such that xk ∈ Xj is difficult 2 - 26
  • 77. Multiparametric QP – example −8 −6 −4 −2 0 2 4 6 8 −1.5 −1 −0.5 0 0.5 1 1.5 x1 x 2 Model: (A, B, C) as before, cost: Q = C C, R = 1, horizon: N = 10 constraints: −1 ≤ u ≤ 1, −1 ≤ x/8 ≤ 1 2 - 27
  • 78. Summary B Predicted control inputs: uk =    u0|k . . . uN−1|k    and states: xk =    x1|k . . . xN|k    = Mxk + Cuk B Predicted cost: J(xk, uk) = N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P = u k Huk + 2x k F uk + x k Gxk B Online optimization subject to linear state and input constraints is a QP: minimize u u Hu + 2x k F u subject to Acu ≤ bc + Bcxk 2 - 28
  • 79. Lecture 3 Closed loop properties of MPC 3 - 1
  • 80. Closed loop properties of MPC Review: infinite horizon cost Infinite horizon predictive control with constraints Closed loop stability Constraint-checking horizon Connection with constrained optimal control 3 - 2
  • 81. Review: infinite horizon cost Short prediction horizons cause poor performance and instability, so ? use an infinite horizon cost: J(xk, uk) = ∞ X i=0 kxi|kk2 Q + kui|kk2 R ? keep optimization finite-dimensional by using dual mode predictions: ui|k = optimization variables i = 0, . . . , N − 1, mode 1 Kxi|k i = N, N + 1, . . . mode 2 mode 1: uk =    u0|k . . . uN−1|k    uk optimized online mode 2: ui|k = Kxi|k K chosen offline 3 - 3
  • 82. Review: infinite horizon cost B Cost for mode 2: ∞ X i=N kxi|kk2 Q + kui|kk2 R = kxN|kk2 P P is the solution of the Lyapunov equation P − (A + BK) P(A + BK) = Q + K RK B Infinite horizon cost: J(xk, uk) = N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P = u k Huk + 2x k F uk + x k Gxk 3 - 4
  • 83. Review: MPC online optimization B Unconstrained optimization: ∇uJ(x, u∗ ) = 2Hu∗ + 2Fx = 0, so u∗ (x) = −H−1 Fx =⇒ linear controller: uk = KMPCxk KMPC = LQ-optimal if K = LQ-optimal (in mode 2) B Constrained optimization: u∗ (x) = arg min u u Hu + 2x F u subject to Acu ≤ bc + Bcx =⇒ nonlinear controller: uk = KMPC(xk) 3 - 5
  • 84. Constrained MPC – example B Plant model: xk+1 = Axk + Buk, yk = Cxk A = 1.1 2 0 0.95 , B = 0 0.0787 , C = −1 1 Constraints: −1 ≤ uk ≤ 1 B MPC optimization (constraints applied only to mode 1 predictions): minimize u N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P subject to − 1 ≤ ui|k ≤ 1, i = 0, . . . , N − 1 Q = C C, R = 0.01, N = 2 . . . performance? stability? 3 - 6
  • 85. Constrained MPC – example Closed loop response for x0 = (0.8, −0.8) 0 20 40 60 80 100 −1 −0.5 0 0.5 1 u 0 20 40 60 80 100 −200 −150 −100 −50 0 50 sample, k y unstable 3 - 7
  • 86. Constrained MPC – example Closed loop response for x0 = (0.5, −0.5) 0 20 40 60 80 100 −1 −0.5 0 0.5 1 u 0 20 40 60 80 100 −2 0 2 4 6 sample, k y stable, but . . . 3 - 8
  • 87. Constrained MPC – example Optimal predicted cost x0 = (0.5, −0.5) 0 20 40 60 80 100 0 10 20 30 40 50 60 70 80 90 sample, k Predicted cost J(k) . . . increasing Jk =⇒ closed loop response does not follow predicted trajectory 3 - 9
  • 88. Stability analysis How can we guarantee the closed loop stability of MPC? (a). Show that a Lyapunov function exists demonstrating stability (b). Ensure that optimization feasible is at each time k = 0, 1, . . . B For Lyapunov stability analysis: ? consider first the unconstrained problem ? use predicted cost as a trial Lyapunov function B Guarantee feasibility of the MPC optimization recursively by ensuring that feasibility at time k implies feasibility at k + 1 3 - 10
  • 89. Stability analysis How can we guarantee the closed loop stability of MPC? (a). Show that a Lyapunov function exists demonstrating stability (b). Ensure that optimization feasible is at each time k = 0, 1, . . . B For Lyapunov stability analysis: ? consider first the unconstrained problem ? use predicted cost as a trial Lyapunov function B Guarantee feasibility of the MPC optimization recursively by ensuring that feasibility at time k implies feasibility at k + 1 3 - 10
  • 90. Discrete time Lyapunov stability Consider the system xk+1 = f(xk), with f(0) = 0 B Definition: x = 0 is a stable equilibrium point if maxk kxkk can be made arbitrarily small by making x0 sufficiently small B If continuously differentiable V (x) exists with (i). V (x) is positive definite and (ii). V (xk+1) − V (xk) ≤ 0 then x = 0 is a stable equilibrium point 3 - 11
  • 91. Discrete time Lyapunov stability Consider the system xk+1 = f(xk), with f(0) = 0 B Definition: x = 0 is a stable equilibrium point if for all R 0 there exists r such that kx0k r =⇒ kxkk R for all k B If continuously differentiable V (x) exists with (i). V (x) is positive definite and (ii). V (xk+1) − V (xk) ≤ 0 then x = 0 is a stable equilibrium point 3 - 11
  • 92. Discrete time Lyapunov stability Consider the system xk+1 = f(xk), with f(0) = 0 B Definition: x = 0 is an asymptotically stable equilibrium point if (i). x = 0 is stable and (ii). r exists such that kx0k r =⇒ lim k→∞ xk = 0 B If continuously differentiable V (x) exists with (i). V (x) is positive definite and (ii). V (xk+1) − V (xk) 0 whenever xk 6= 0 then x = 0 is an asymptotically stable equilibrium point 3 - 12
  • 93. Lyapunov stability Trial Lyapunov function: J∗ (xk) = J(xk, u∗ k) where J(xk, uk) = ∞ X i=0 kxi|kk2 Q + kui|kk2 R ? J∗ (x) is positive definite if: (a). R 0 and Q 0, or (b). R 0 and Q 0 and (A, Q) is observable since then J∗ (xk) ≥ 0 and J∗ (xk) = 0 if and only if xk = 0 ? J∗ (x) is continuously differentiable . . . from analysis of MPC optimization as a multiparametric QP 3 - 13
  • 94. Lyapunov stability Construct a bound on J∗ (xk+1) − J∗ (xk) using the “tail” of the optimal prediction at time k u i optimal at k tail at k + 1 0 1 N −1 N Optimal predicted sequences at time k: u∗ k =            u∗ 0|k u∗ 1|k . . . u∗ N−1|k Kx∗ N|k . . .            x∗ k =            x∗ 0|k x∗ 1|k . . . x∗ N|k Φx∗ N|k . . .            (Φ = A + BK) optimal at k : J∗ (xk) = J(xk, u∗ k) = ∞ X i=0 kx∗ i|kk2 Q + ku∗ i|kk2 R tail at k + 1 : ˜ J(xk+1) = J(xk+1, ũk+1) = ∞ X i=1 kx∗ i|kk2 Q + ku∗ i|kk2 R 3 - 14
  • 95. Lyapunov stability Construct a bound on J∗ (xk+1) − J∗ (xk) using the “tail” of the optimal prediction at time k u i optimal at k tail at k + 1 0 1 N −1 N Tail sequences at time k + 1: ũk+1 =            u∗ 1|k . . . u∗ N−1|k Kx∗ N|k KΦx∗ N|k . . .            x̃k+1 =            x∗ 1|k . . . x∗ N|k Φx∗ N|k Φ2 x∗ N|k . . .            (Φ = A + BK) optimal at k : J∗ (xk) = J(xk, u∗ k) = ∞ X i=0 kx∗ i|kk2 Q + ku∗ i|kk2 R tail at k + 1 : ˜ J(xk+1) = J(xk+1, ũk+1) = ∞ X i=1 kx∗ i|kk2 Q + ku∗ i|kk2 R 3 - 14
  • 96. Lyapunov stability Construct a bound on J∗ (xk+1) − J∗ (xk) using the “tail” of the optimal prediction at time k u i optimal at k tail at k + 1 0 1 N −1 N Tail sequences at time k + 1: ũk+1 =            u∗ 1|k . . . u∗ N−1|k Kx∗ N|k KΦx∗ N|k . . .            x̃k+1 =            x∗ 1|k . . . x∗ N|k Φx∗ N|k Φ2 x∗ N|k . . .            (Φ = A + BK) optimal at k : J∗ (xk) = J(xk, u∗ k) = ∞ X i=0 kx∗ i|kk2 Q + ku∗ i|kk2 R tail at k + 1 : ˜ J(xk+1) = J(xk+1, ũk+1) = ∞ X i=1 kx∗ i|kk2 Q + ku∗ i|kk2 R 3 - 14
  • 97. Lyapunov stability Construct a bound on J∗ (xk+1) − J∗ (xk) using the “tail” of the optimal prediction at time k Predicted cost for the tail: ˜ J(xk+1) = J∗ (xk) − kxkk2 Q − kukk2 R but ũk+1 is suboptimal at time k + 1, so J∗ (xk+1) ≤ ˜ J(xk+1) Therefore J∗ (xk+1) ≤ J∗ (xk) − kxkk2 Q − kukk2 R 3 - 15
  • 98. Lyapunov stability The bound J∗ (xk+1) − J∗ (xk) ≤ −kxkk2 Q − kukk2 R implies: (i). the closed loop cost cannot exceed the initial predicted cost, since summing both sides over all k ≥ 0 gives ∞ X k=0 kxkk2 Q + kukk2 R ≤ J∗ (x0) (ii). x = 0 is asymptotically stable ? if R 0 and Q 0, this follows from Lyapunov’s direct method ? if R 0, Q 0 and (A, Q) observable, this follows from: (a). stability of x = 0 ⇐ Lyapunov’s direct method (b). lim k→∞ (kxkk2 Q + kukk2 R) = 0 ⇐ P∞ k=0 kxkk2 Q + kukk2 R ∞ 3 - 16
  • 99. Stability analysis How can we guarantee the closed loop stability of MPC? (a). Show that a Lyapunov function exists demonstrating stability (b). Ensure that optimization feasible is at each time k = 0, 1, . . . B For Lyapunov stability analysis: ? consider first the unconstrained problem ? use predicted cost as a trial Lyapunov function B Guarantee feasibility of the MPC optimization recursively by ensuring that feasibility at time k =⇒ feasibility at k + 1 3 - 17
  • 100. Stability analysis How can we guarantee the closed loop stability of MPC? (a). Show that a Lyapunov function exists demonstrating stability (b). Ensure that optimization feasible is at each time k = 0, 1, . . . B For Lyapunov stability analysis: ? consider first the unconstrained problem ? use predicted cost as a trial Lyapunov function B Guarantee feasibility of the MPC optimization recursively by ensuring that feasibility at time k =⇒ feasibility at k + 1 3 - 17
  • 101. Terminal constraint The basic idea terminal set origin stabilizing linear controller satisfies constraints more sophisticated controller needed to satisfy constraints ? @ @ @ @ R 3 - 18
  • 102. Terminal constraint Terminal constraint: xN|k ∈ Ω, where Ω = terminal set xk x1|k xN−1|k xN|k xN+1|k safe region for mode 2 control law Choose Ω so that: (a). x ∈ Ω =⇒ u ≤ Kx ≤ u x ≤ x ≤ x (b). x ∈ Ω =⇒ (A + BK)x ∈ Ω then Ω is invariant for the mode 2 dynamics and constraints, so xN|k ∈ Ω =⇒ u ≤ ui|k ≤ u x ≤ xi|k ≤ x for i = N, N + 1, . . . i.e. constraints are satisfied over the infinite mode 2 prediction horizon 3 - 19
  • 103. Stability of constrained MPC Prototype MPC algorithm At each time k = 0, 1, . . . (i). solve u∗ k = arg min uk J(xk, uk) s.t. u ≤ ui|k ≤ u, i = 0, . . . , N − 1 x ≤ xi|k ≤ x, i = 1, . . . , N xN|k ∈ Ω (ii). apply uk = u∗ 0|k to the system Asymptotically stabilizes x = 0 with region of attraction FN , FN =      x0 : ∃ {u0, . . . , uN−1} such that u ≤ ui ≤ u, i = 0, . . . , N − 1 x ≤ xi ≤ x, i = 1, . . . , N xN ∈ Ω      = the set of all feasible initial conditions for N-step horizon and terminal set Ω 3 - 20
  • 104. Terminal constraints Make Ω as large as possible so that the feasible set FN is maximized, i.e. Ω = X∞ = lim j→∞ Xj where ? Xj = initial conditions for which constraints are satisfied for j steps with u = Kx = x : u ≤ K(A + BK)i x ≤ u x ≤ (A + BK)i x ≤ x i = 0, . . . , j ? X∞ = Xν for some finite ν if |eig(A + BK)| 1 ⇓ x ∈ X∞ if constraints are satisfied on a finite constraint checking horizon 3 - 21
  • 105. Terminal constraints – Example Plant model: xk+1 = Axk + Buk, yk = Cxk A = 1.1 2 0 0.95 B = 0 0.0787 C = −1 1 input constraints: −1 ≤ uk ≤ 1 mode 2 feedback law: K = −1.19 −7.88 = KLQ for Q = C C, R = 1 3 - 22
  • 106. Terminal constraints – example Constraints: −1 ≤ u ≤ 1 −5 0 5 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 x1 x 2 X0 Kx = −1 Kx = 1 - 3 - 23
  • 107. Terminal constraints – example Constraints: −1 ≤ u ≤ 1 −5 0 5 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 x1 x 2 X1 KΦx = −1 KΦx = 1 - Kx = −1 Kx = 1 - 3 - 23
  • 108. Terminal constraints – example Constraints: −1 ≤ u ≤ 1 −5 0 5 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 x1 x 2 X2 KΦ2 x = −1 KΦ2 x = 1 - KΦx = −1 KΦx = 1 - Kx = −1 Kx = 1 - 3 - 23
  • 109. Terminal constraints – example Constraints: −1 ≤ u ≤ 1 −5 0 5 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 x1 x 2 X∞ X4 = X5 = · · · = Xj for all j 4 so X4 = X∞ 3 - 23
  • 110. Terminal constraints – example In this example X∞ is determined in a finite number of steps because A (A + BK) is strictly stable, and B (A + BK), K is observable A ⇒ shortest distance of hyperplane K(A + BK)i x ≤ 1 from origin = 1 kK(A + BK)ik2 → ∞ as i → ∞ B ⇒ X∞ is bounded because x0 / ∈ X∞ if x0 is sufficiently large Here {x : −1 ≤ K(A + BK)i x ≤ 1} contains X4 for i 4 ⇓ X∞ = X4 constraint checking horizon: ν = 4 3 - 24
  • 111. Terminal constraints – example In this example X∞ is determined in a finite number of steps because A (A + BK) is strictly stable, and B (A + BK), K is observable A ⇒ shortest distance of hyperplane K(A + BK)i x ≤ 1 from origin = 1 kK(A + BK)ik2 → ∞ as i → ∞ B ⇒ X∞ is bounded because x0 / ∈ X∞ if x0 is sufficiently large Here {x : −1 ≤ K(A + BK)i x ≤ 1} contains X4 for i 4 ⇓ X∞ = X4 constraint checking horizon: ν = 4 3 - 24
  • 112. Terminal constraints General case Let Xj = {x : FΦi x ≤ 1, i = 0, . . . j} with Φ strictly stable (Φ, F) observable then: (i). X∞ = Xν for finite ν (ii). Xν = X∞ iff x ∈ Xν+1 whenever x ∈ Xν Proof of (ii) (a). for any j, Xj+1 = Xj ∩ x : FΦj+1 x ≤ 1 so Xj ⊇ Xj+1 ⊇ limj→∞ Xj = X∞ (b). if x ∈ Xν+1 whenever x ∈ Xν , then Φx ∈ Xν whenever x ∈ Xν but Xν ⊆ x : Fx ≤ 1 and it follows that Xν ⊆ X∞ (a) (b) ⇒ Xν = X∞ 3 - 25
  • 113. Terminal constraints – constraint checking horizon Algorithm for computing constraint checking horizon Nc for input constraints u ≤ u ≤ u: C4A Model Predictive Control 3 - 28 Terminal constraint set Algorithm (computation of ) : umax := max x K(A+ BK)N +1 x s.t. u ! K(A+ BK)i x ! u, i = 0,…N umin := min x K(A+ BK)N +1 x s.t. u ! K(A+ BK)i x ! u, i = 0,…N Nc := N N := 0 umax ! u ? and umin u? N := N +1 no yes 2 linear programs solved at each step 3 - 26
  • 114. Constrained MPC Define the terminal set Ω as XNc MPC algorithm At each time k = 0, 1, . . . (i). solve u∗ k = arg min uk J(xk, uk) s.t. u ≤ ui|k ≤ u, i = 0, . . . , N + Nc x ≤ xi|k ≤ x, i = 1, . . . , N + Nc (ii). apply uk = u∗ 0|k to the system Note ? predictions for i = N, . . . N + Nc: xi|k = (A + BK)i−N xN|k ui|k = K(A + BK)i−N xN|k ? xN|k ∈ XNc implies linear constraints so online optimization is a QP 3 - 27
  • 115. Closed loop performance Longer horizon N ensures improved predicted cost J∗ (x0) and is likely (but not certain) to give better closed-loop performance Example: Cost vs N for x0 = (−7.5, 0.5) N 6 7 8 11 11 J∗ (x0) 364.2 357.0 356.3 356.0 356.0 Jcl(x0) 356.0 356.0 356.0 356.0 356.0 Closed loop cost: Jcl(x0) := P∞ k=0 kxkk2 Q + kukk2 R For this initial condition: MPC with N = 11 is identical to constrained LQ optimal control (N = ∞)! 3 - 28
  • 116. Closed loop performance – example Predicted and closed loop inputs for N = 6 0 5 10 15 20 25 30 −1 −0.8 −0.6 −0.4 −0.2 0 0.2 0.4 0.6 0.8 1 time step, k input, u predicted closed−loop 3 - 29
  • 117. Closed loop performance – example Predicted and closed loop states for N = 6 −8 −7 −6 −5 −4 −3 −2 −1 0 1 −0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 x 1 x 2 predicted closed−loop Ω F6 x6|0 - 3 - 29
  • 118. Closed loop performance – example Predicted and closed loop states for N = 11 x 1 -8 -7 -6 -5 -4 -3 -2 -1 0 1 x 2 -0.1 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 predicted closed-loop Ω F6 x11|0 3 - 29
  • 119. Choice of mode 1 horizon – performance B For this x0: N = 11 ⇒ xN|0 lies in the interior of Ω m terminal constraint is inactive ⇓ no reduction in cost for N 11 B Constrained LQ optimal performance is always obtained with N ≥ N∞ for some finite N∞ dependent on x0 B N∞ may be large, implying high computational load but closed loop performance is often close to optimal for N N∞ (due to receding horizon) in this example Jcl(x0) ≈ optimal for N ≥ 6 3 - 30
  • 120. Choice of mode 1 horizon – region of attraction Increasing N increases the feasible set FN −10 −8 −6 −4 −2 0 2 4 6 8 10 −1.5 −1 −0.5 0 0.5 1 1.5 x 1 x 2 N = 26 N = 24 N = 20 N = 16 N = 12 N = 8 N = 4 N = 0 Ω F4 F8 F12 3 - 31
  • 121. Summary B Linear MPC ingredients: ? Infinite cost horizon (via terminal cost) ? Terminal constraints (via constraint-checking horizon) B Constraints are satisfied over an infinite prediction horizon B Closed-loop system is asymptotically stable with region of attraction equal to the set of feasible initial conditions B Ideal optimal performance if mode 1 horizon N is large enough 3 - 32
  • 122. Lecture 4 Robustness to disturbances 4 - 1
  • 123. Robustness to disturbances Review of nominal model predictive control Setpoint tracking and integral action Robustness to unknown disturbances Handling time-varying disturbances 4 - 2
  • 124. Review MPC with guaranteed stability – the basic idea terminal set origin stabilizing linear controller satisfies constraints more sophisticated controller needed to satisfy constraints ? @ @ @ @ R 4 - 3
  • 125. Review MPC optimization for linear model xk+1 = Axk + Buk minimize uk N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc x ≤ xi|k ≤ x, i = 1, . . . , N + Nc where ? ui|k = Kxi|k for i ≥ N, with K = unconstrained LQ optimal ? terminal cost: kxN|kk2 P = ∞ X i=N (kxi|kk2 Q + kui|kk2 R), with P − ΦT PΦ = Q + KT RK, Φ = A + BK ? terminal constraints are defined by the constraint checking horizon Nc: u ≤ KΦi x ≤ u x ≤ Φi x ≤ x i = 0, . . . , Nc =⇒ u ≤ KΦNc+1 x ≤ u x ≤ ΦNc+1 x ≤ x 4 - 4
  • 126. Review MPC optimization for linear model xk+1 = Axk + Buk minimize uk N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc x ≤ xi|k ≤ x, i = 1, . . . , N + Nc where ? ui|k = Kxi|k for i ≥ N, with K = unconstrained LQ optimal ? terminal cost: kxN|kk2 P = ∞ X i=N (kxi|kk2 Q + kui|kk2 R), with P − ΦT PΦ = Q + KT RK, Φ = A + BK ? terminal constraints are defined by the constraint checking horizon Nc: u ≤ KΦi x ≤ u x ≤ Φi x ≤ x i = 0, . . . , Nc =⇒ u ≤ KΦNc+1 x ≤ u x ≤ ΦNc+1 x ≤ x 4 - 4
  • 127. Review MPC optimization for linear model xk+1 = Axk + Buk minimize uk N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc x ≤ xi|k ≤ x, i = 1, . . . , N + Nc where ? ui|k = Kxi|k for i ≥ N, with K = unconstrained LQ optimal ? terminal cost: kxN|kk2 P = ∞ X i=N (kxi|kk2 Q + kui|kk2 R), with P − ΦT PΦ = Q + KT RK, Φ = A + BK ? terminal constraints are defined by the constraint checking horizon Nc: u ≤ KΦi x ≤ u x ≤ Φi x ≤ x i = 0, . . . , Nc =⇒ u ≤ KΦNc+1 x ≤ u x ≤ ΦNc+1 x ≤ x 4 - 4
  • 128. Review MPC optimization for nonlinear model xk+1 = f(xk, uk) minimize uk N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P subject to u ≤ ui|k ≤ u, i = 0, . . . , N − 1 x ≤ xi|k ≤ x, i = 1, . . . , N − 1 xN|k ∈ Ω with ? mode 2 feedback: ui|k = κ(xi|k) asymptotically stabilizes x = 0 (locally) ? terminal cost: kxN|kk2 P ≥ ∞ X i=N (kxi|kk2 Q + kui|kk2 R) for mode 2 dynamics: xi+1|k = f xi|k, κ(xi|k) ? terminal constraint set Ω: invariant for mode 2 dynamics and constraints f x, κ(x) ∈ Ω u ≤ κ(x) ≤ u, x ≤ x ≤ x for all x ∈ Ω 4 - 5
  • 129. Review MPC optimization for nonlinear model xk+1 = f(xk, uk) minimize uk N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P subject to u ≤ ui|k ≤ u, i = 0, . . . , N − 1 x ≤ xi|k ≤ x, i = 1, . . . , N − 1 xN|k ∈ Ω with ? mode 2 feedback: ui|k = κ(xi|k) asymptotically stabilizes x = 0 (locally) ? terminal cost: kxN|kk2 P ≥ ∞ X i=N (kxi|kk2 Q + kui|kk2 R) for mode 2 dynamics: xi+1|k = f xi|k, κ(xi|k) ? terminal constraint set Ω: invariant for mode 2 dynamics and constraints f x, κ(x) ∈ Ω u ≤ κ(x) ≤ u, x ≤ x ≤ x for all x ∈ Ω 4 - 5
  • 130. Review MPC optimization for nonlinear model xk+1 = f(xk, uk) minimize uk N−1 X i=0 kxi|kk2 Q + kui|kk2 R + kxN|kk2 P subject to u ≤ ui|k ≤ u, i = 0, . . . , N − 1 x ≤ xi|k ≤ x, i = 1, . . . , N − 1 xN|k ∈ Ω with ? mode 2 feedback: ui|k = κ(xi|k) asymptotically stabilizes x = 0 (locally) ? terminal cost: kxN|kk2 P ≥ ∞ X i=N (kxi|kk2 Q + kui|kk2 R) for mode 2 dynamics: xi+1|k = f xi|k, κ(xi|k) ? terminal constraint set Ω: invariant for mode 2 dynamics and constraints f x, κ(x) ∈ Ω u ≤ κ(x) ≤ u, x ≤ x ≤ x for all x ∈ Ω 4 - 5
  • 131. Comparison B Linear MPC terminal cost ←− exact cost over the mode 2 horizon terminal constraint set ←− contains all feasible initial conditions for mode 2 B Nonlinear MPC terminal cost ←− upper bound on cost over mode 2 horizon terminal constraint set ←− invariant set (usually not the largest) for mode 2 dynamics and constraints 4 - 6
  • 135. Model uncertainty Common causes of model error and uncertainty: I Unknown or time-varying model parameters B unknown loads inertias, static friction B unknown d.c. gain I Random (stochastic) model parameters B random process noise or sensor noise I Incomplete measurement of states B state estimation error 4 - 7
  • 136. Setpoint tracking I Output setpoint: y0 y → y0 ⇒ x → x0 u → u0 where x0 = Ax0 + Bu0 y0 = Cx0 ⇓ y0 = C(I − A)−1 Bu0 I Setpoint for (u0 , x0 ) is unique iff C(I − A)−1 B is invertible e.g. if dim(u) = dim(y), then u0 = C(I − A)−1 B −1 y0 x0 = (I − A)−1 Bu0 I Tracking problem: yk → y0 subject to u ≤ uk ≤ u x ≤ xk ≤ x is only feasible if u ≤ u0 ≤ u and x ≤ x0 ≤ x 4 - 8
  • 137. Setpoint tracking I Unconstrained tracking problem: minimize uδ k ∞ X i=0 kxδ i|kk2 Q + kuδ i|kk2 R where xδ = x − x0 uδ = u − u0 has optimal solution: uk = Kxδ k + u0 , K = KLQ I Constrained tracking problem: minimize uδ k ∞ X i=0 kxδ i|kk2 Q + kuδ i|kk2 R subject to u ≤ uδ i|k + u0 ≤ u, i = 0, 1, . . . x ≤ xδ i|k + x0 ≤ x, i = 1, 2, . . . has optimal solution: uk = uδ∗ 0|k + u0 4 - 9
  • 138. Setpoint tracking If û0 is used instead of u0 (e.g. if d.c. gain C(I − A)−1 B unknown) then uk = uδ∗ 0|k + û0 implies uδ k = uδ∗ 0|k + (û0 − u0 ) xδ k+1 = Axδ k + Buδ∗ 0|k + B (û0 − u0 ) | {z } constant disturbance and if uδ∗ 0|k → Kxδ k as k → ∞, then lim k→∞ xδ k = (I − A − BK)−1 B(û0 − u0 ) 6= 0 lim k→∞ yk − y0 = C(I − A − BK)−1 B(û0 − u0 ) | {z } steady state tracking error 6= 0 4 - 10
  • 139. Additive disturbances Convert (constant) setpoint tracking problem into a regulation problem: x ← xδ , y ← yδ , u ← uδ Consider the effect of additive disturbance w: xk+1 = Axk + Buk + Dwk, yk = Cxk Assume that wk is unknown at time k, but is known to be: ? constant (wk = w for all k) or time-varying ? within a known polytopic set: wk ∈ W for all k where W = conv{w(1) , . . . , w(r) } or W = {w : Hw ≤ 1} 4 - 11
  • 140. Additive disturbances Convert (constant) setpoint tracking problem into a regulation problem: x ← xδ , y ← yδ , u ← uδ Consider the effect of additive disturbance w: xk+1 = Axk + Buk + Dwk, yk = Cxk Assume that wk is unknown at time k, but is known to be: ? constant (wk = w for all k) or time-varying ? within a known polytopic set: wk ∈ W for all k where W = conv{w(1) , . . . , w(r) } or W = {w : Hw ≤ 1} W w(1) w(2) w(3) w(4) w(5) w(6) 4 - 11
  • 141. Integral action (no constraints) Introduce integral action to remove steady state error in y by considering the augmented system: zk = xk vk , zk+1 = A 0 C I zk + B 0 uk + D 0 wk vk = integrator state vk+1 = vk + yk ? Linear feedback uk = Kxk + KIvk is stabilizing if eig A + BK BKI C I 1 ? If the closed-loop system is (strictly) stable and wk → w = constant then uk → uss =⇒ vk → vss =⇒ yk → 0 even if w 6= 0 but arbitrary KI may destabilize the closed loop system 4 - 12
  • 142. Integral action (no constraints) Introduce integral action to remove steady state error in y by considering the augmented system: zk = xk vk , zk+1 = A 0 C I zk + B 0 uk + D 0 wk vk = integrator state vk+1 = vk + yk ? Linear feedback uk = Kxk + KIvk is stabilizing if eig A + BK BKI C I 1 ? If the closed-loop system is (strictly) stable and wk → w = constant then uk → uss =⇒ vk → vss =⇒ yk → 0 even if w 6= 0 but arbitrary KI may destabilize the closed loop system 4 - 12
  • 143. Integral action (no constraints) Ensure stability by using a modified cost: minimize uk ∞ X i=0 kzi|kk2 Qz + kui|kk2 R Qz = Q 0 0 QI 0 with predictions generated by an augmented model zi+1|k = A 0 C I zi|k + B 0 ui|k, z0|k = xk vk ? this is a “nominal” prediction model since wk = 0 is assumed ? unconstrained solution: uk = Kzzk = Kxk + KIvk ? if R 0, A 0 C I , Q 0 0 QI is observable and wk → w = constant then uk → uss =⇒ vk → vss =⇒ yk → 0 4 - 13
  • 144. Integral action – example Plant model: xk+1 = Axk + Buk + Dw yk = Cxk A = 1.1 2 0 0.95 B = 0 0.0787 D = 1 0 C = −1 1 Constraints: none Cost weighting matrices: Qz = CT C 0 0 0.01 , R = 1 Unconstrained LQ optimal feedback gain: Kz = −1.625 −9.033 0.069 4 - 14
  • 145. Integral action – example + integrator no integrator 0 10 20 30 40 50 u -1 0 1 2 3 4 + integrator no integrator sample k 0 10 20 30 40 50 y -1 -0.5 0 0.5 1 1.5 Closed loop response for initial condition: x0 = (0.5, −0.5) no disturbance: w = 0 4 - 15
  • 146. Integral action – example + integrator no integrator 0 10 20 30 40 50 u -2 -1 0 1 2 3 4 + integrator no integrator sample k 0 10 20 30 40 50 y -5 -4 -3 -2 -1 0 Closed loop response for initial condition: x0 = (0.5, −0.5) constant disturbance: w = 0.75 4 - 16
  • 147. Constrained MPC Naive constrained MPC strategy: w = 0 assumed in predictions minimize uk N−1 X i=0 kzi|kk2 Qz + kui|kk2 R + kzN|kk2 P subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc x ≤ xi|k ≤ x, i = 1, . . . , N + Nc with: P and Nc determined for mode 2 control law ui|k = Kzzi|k and initial prediction state: z0|k = xk vk where vk+1 = vk + yk ? If closed loop system is stable then uk → uss =⇒ vk → vss =⇒ yk → 0 ? but disturbance wk is ignored in predictions, so J∗ (zk+1) − J∗ (zk) 6≤ 0 feasibility at time k 6⇒ feasibility at k + 1 therefore no guarantee of stability 4 - 17
  • 148. Constrained MPC Naive constrained MPC strategy: w = 0 assumed in predictions minimize uk N−1 X i=0 kzi|kk2 Qz + kui|kk2 R + kzN|kk2 P subject to u ≤ ui|k ≤ u, i = 0, . . . , N + Nc x ≤ xi|k ≤ x, i = 1, . . . , N + Nc with: P and Nc determined for mode 2 control law ui|k = Kzzi|k and initial prediction state: z0|k = xk vk where vk+1 = vk + yk ? If closed loop system is stable then uk → uss =⇒ vk → vss =⇒ yk → 0 ? but disturbance wk is ignored in predictions, so J∗ (zk+1) − J∗ (zk) 6≤ 0 feasibility at time k 6⇒ feasibility at k + 1 therefore no guarantee of stability 4 - 17
  • 149. Constrained MPC – example constraints violated * Closed loop response with initial condition: x0 = (0.5, −0.5) constraints: −1 ≤ u ≤ 1 disturbance: w = 0.75 4 - 18
  • 150. Robust constraints If predictions satisfy constraints for all prediction times i = 0, 1, . . . for all disturbances wi ∈ W then feasibility of constraints at time k ensures feasibility at time k + 1 B Decompose predictions into nominal predicted state si|k uncertain predicted state ei|k where xi|k = si|k + ei|k si+1|k = Φsi|k + Bci|k s0|k = xk ei+1|k = Φei|k + Dwi|k e0|k = 0 B Pre-stabilized predictions: ui|k = Kxi|k + ci|k and Φ = A + BK where K = KLQ is the unconstrained LQ optimal gain 4 - 19
  • 151. Pre-stabilized predictions – example Scalar system: xk+1 = 2xk + uk + wk, constraint: |xk| ≤ 2 uncertainty: ei|k = i−1 X j=0 2j w = (2i − 1)w, disturbance: wk = w |w| ≤ 1 4 - 20
  • 152. Pre-stabilized predictions – example Scalar system: xk+1 = 2xk + uk + wk, constraint: |xk| ≤ 2 uncertainty: ei|k = i−1 X j=0 2j w = (2i − 1)w, disturbance: wk = w |w| ≤ 1 Robust constraints: |si|k + ei|k| ≤ 2 for all |w| ≤ 1 m |si|k| ≤ 2 − max|w|≤1|ei|k| ⇓ |si|k| ≤ 2 − (2i − 1) ⇓ infeasible for all i 1 sample 0 1 2 3 4 5 -10 -8 -6 -4 -2 0 2 4 6 8 10 upper bound on ei|k @ @ R lower bound on ei|k 4 - 20
  • 153. Pre-stabilized predictions – example Avoid infeasibility by using pre-stabilized predictions: ui|k = Kxi|k + ci|k, K = −1.9, ci|k = ( free i = 0, . . . , N − 1 0 i ≥ N stable predictions: ei|k = i−1 X j=0 0.1j w = (1 − 0.1i )w/0.9, |w| ≤ 1 4 - 21
  • 154. Pre-stabilized predictions – example Avoid infeasibility by using pre-stabilized predictions: ui|k = Kxi|k + ci|k, K = −1.9, ci|k = ( free i = 0, . . . , N − 1 0 i ≥ N stable predictions: ei|k = i−1 X j=0 0.1j w = (1 − 0.1i )w/0.9, |w| ≤ 1 Robust constraints: |si|k + ei|k| ≤ 2 for all |w| ≤ 1 m |si|k| ≤ 2 − max|w|≤1|ei|k| ⇓ |si|k| ≤ 2 − (1 − 0.1i )/0.9 | {z } 0 for all i sample 0 1 2 3 4 5 -5 -4 -3 -2 -1 0 1 2 3 4 5 upper bound on ei|k ? lower bound on ei|k 6 4 - 21
  • 155. Pre-stabilized predictions B Feedback structure of MPC with open loop predictions: Plant MPC Optimization - - - x u ? w B Feedback structure of MPC with pre-stabilized predictions: Stablizing feedback Plant MPC Optimization 6 g - - - - x u c Kx + + ? w 4 - 22
  • 156. General form of robust constraints How can we impose (general linear) constraints robustly? ? Pre-stabilized predictions: xi|k = si|k + ei|k si+1|k = Φsi|k + Bci|k s0|k = xk ei+1|k = Φei|k + Dwi|k e0|k = 0 =⇒ ei|k = Dwi−1 + ΦDwi−2 + · · · + Φi−1 Dw0 ? General linear constraints: Fxi|k + Gui|k ≤ 1 are equivalent to tightened constraints on nominal predictions: (F + GK)si|k + Gci|k ≤ 1 − hi where h0 = 0 hi = max w0,...,wi−1∈W (F + GK)ei|k, i = 1, 2, . . . (i.e. hi = hi−1 + maxw∈W (F + GK)w requiring one LP for each row of hi) 4 - 23
  • 157. Tube interpretation The uncertainty in predictions: ei+1|k = Φei|k + Dwi, wi ∈ W evolves inside a tube (a sequence of sets): ei|k ∈ Ei|k, where Ei|k = DW ⊕ ΦDW ⊕ · · · ⊕ Φi−1 DW, i = 1, 2, . . . Hence we can define: ? a state tube xi|k = si|k + ei|k ∈ Xi|k Xi|k = {si|k} ⊕ Ei|k, i = 0, 1, . . . ? a control input tube ui|k = Kxi|k + ci|k = Ksi|k + ci|k + Kei|k ∈ Ui|k Ui|k = {Ksi|k + ci|k} ⊕ KEi|k, i = 0, 1, . . . and impose constraints robustly for the state and input tubes (where ⊕ is Minkowski set addition) 4 - 24
  • 158. Tube interpretation The uncertainty in predictions: ei+1|k = Φei|k + Dwi, wi ∈ W evolves inside a tube (a sequence of sets): ei|k ∈ Ei|k, where Ei|k = DW ⊕ ΦDW ⊕ · · · ⊕ Φi−1 DW, i = 1, 2, . . . e.g. for constraints Fx ≤ 1 (G = 0) s0|k X1|k s1|k s2|k X2|k s3|k X3|k s4|k X4|k sample Fx = 1 ? Xi|k = {si|k} ⊕ Ei|k 4 - 24
  • 159. Robust MPC Prototype robust MPC algorithm Offline: compute Nc and h1, . . . , hNc . Online at k = 0, 1, . . .: (i). solve c∗ k = arg min ck J(xk, ck) s.t. (F + GK)si|k + Gci|k ≤ 1 − hi, i = 0, . . . , N + Nc (ii). apply uk = Kxk + c∗ 0|k to the system ? tightened linear constraints are applied to nominal predictions ? Nc is the constraint-checking horizon defined by: (F + GK)ΦNc+1 s ≤ 1 − hNc+1 for all s satisfying (F + GK)Φi s ≤ 1 − hi, i = 0, . . . , Nc ? the online optimization is robustly recursively feasible 4 - 25
  • 160. Robust MPC Prototype robust MPC algorithm Offline: compute Nc and h1, . . . , hNc . Online at k = 0, 1, . . .: (i). solve c∗ k = arg min ck J(xk, ck) s.t. (F + GK)si|k + Gci|k ≤ 1 − hi, i = 0, . . . , N + Nc (ii). apply uk = Kxk + c∗ 0|k to the system nominal cost, evaluated assuming wi = 0 for all i: J(xk, ck) = ∞ X i=0 ksi|kk2 Q + kKsi|k + ci|kk2 R = kxkk2 P + kckk2 Wc (one possible choice) 4 - 25
  • 161. Convergence of robust MPC with nominal cost If ui|k = Kxi|k + ci|k for K = KLQ, then: ? the unconstrained solution is ck = 0, so the nominal cost is J(xk, ck) = kxkk2 P + kckk2 Wc and Wc is block-diagonal: Wc = diag{Pc, . . . , Pc} ? recursive feasibility ⇒ c̃k+1 = (c∗ 1|k, . . . , c∗ N−1|k, 0) feasible at k + 1 ? hence kc∗ k+1k2 Wc ≤ kc∗ kk2 Wc − kc∗ 0|kk2 Pc ⇒ ∞ X k=0 kc0|kk2 Pc ≤ kc∗ 0k2 Wc ∞ ⇒ limk→∞ c0|k = 0 ? therefore uk → Kxk as k → ∞ xk → the (minimal) robustly invariant set under unconstrained LQ optimal feedback 4 - 26
  • 162. Robust MPC with constant disturbance Assume wk = w = constant for all k combine: pre-stabilized predictions augmented state space model ? Predicted state and input sequences: xi|k = I 0 (si|k + ei|k) ui|k = Kz(si|k + ei|k) + ci|k ? Prediction model: nominal si+1|k = Φsi|k + B 0 ci|k Φ = A 0 C I + B 0 Kz uncertain ei|k = i−1 X j=0 Φj D 0 w s0|k = xk vk , e0|k = 0 ? Nominal cost: J(xk, vk, ck) = ∞ X i=0 ksi|kk2 Qz + kKzsi|k + ci|kk2 R 4 - 27
  • 163. Robust MPC with constant disturbance Assume wk = w = constant for all k combine: pre-stabilized predictions augmented state space model ? robust state constraints: x ≤ xi|k ≤ x ⇐⇒ x + hi ≤ si|k ≤ x − hi hi = max w∈W I 0 i−1 X j=0 Φj D 0 w ? robust input constraints: u ≤ ui|k ≤ u ⇐⇒ u + h0 i ≤ Kzsi|k + ci|k ≤ u − h0 i h0 i = max w∈W Kz i−1 X j=0 Φj D 0 w ? Nc and hi, h0 i for i = 1, . . . , Nc can be computed offline 4 - 27
  • 164. Robust MPC with constant disturbance – example + integrator no integrator 0 10 20 30 40 50 u -1 -0.5 0 0.5 1 + integrator no integrator sample k 0 10 20 30 40 50 y -6 -5 -4 -3 -2 -1 0 1 Closed loop response with initial condition: x0 = (0.5, −0.5) constraints: −1 ≤ u ≤ 1 disturbance: w = 0.75 4 - 28
  • 165. Summary B Integral action: augment model with integrated output error include integrated output error in cost then (i). closed loop system is stable if w = 0 (ii). steady state error must be zero if response is stable for w 6= 0 B Robust MPC: use pre-stabilized predictions apply constraints for all possible future uncertainty then (i). constraint feasibility is guaranteed at all times if initially feasible (ii). closed loop system inherits the stability and convergence properties of unconstrained LQ optimal control (assuming nominal cost) 4 - 29
  • 166. Overview of the course 1 Introduction and Motivation Basic MPC strategy; prediction models; input and state constraints; constraint handling: saturation, anti-windup, predictive control 2 Prediction and optimization Input/state prediction equations; unconstrained optimization. Infinite horizon cost; dual mode predictions. Incorporating constraints; quadratic programming. 3 Closed loop properties Lyapunov analysis based on predicted cost. Recursive feasibility; terminal constraints; the constraint checking horizon. Constrained LQ-optimal control. 4 Robustness to disturbances Setpoint tracking; MPC with integral action. Robustness to constant disturbances: prestabilized predictions and robust feasibility. Handling time-varying disturbances. 4 - 30