03 - Model Predictive Control
03 - Model Predictive Control
Saverio Bolognani
K
X −1
min xkT Qxk + ukT Ruk + xKT SxK
u0 ,...,uK −1
x0 ,...,xK k=0
1 / 39
Open-loop optimal control
By solving the optimization in one shot, we get
u
planned input
K k
x
predicted state
K k
→ open-loop optimal control strategy
2 / 39
u
planned input
applied input
K k
x
predicted state
measured state
now K k
What if a disturbance/model mismatch takes you elsewhere?
3 / 39
u previously planned input
planned input
applied input
K k
now K k
Recompute!
4 / 39
u
K
past future k
K
past future k
Receding horizon
Apply only one control input, u0∗
Use new state measurement as new initial conditions
Same horizon length → receding horizon
If the system is time invariant → same optimization problem, different x0
5 / 39
Receding horizon
Apply only one control input, u0∗
Use new state measurement as new initial conditions
Same horizon length → receding horizon
If the system is time invariant → same optimization problem, different x0
5 / 39
Receding-horizon control
Parametric optimization
K
X −1
u0∗ (x) determined by min gk (xk , uk ) + gK (xK )
u,x
k=0
6 / 39
Feedforward or feedback?
uk xk
u0∗ (·) plant
7 / 39
Does MPC solve the optimal control problem?
Example
K
X −1
min ak |uk | + |x(K )|2 |a| < 1
x,u
k=0
subject to xk+1 = xk + uk
8 / 39
K
X −1
min xk⊤ Qxk + uk⊤ Ruk + xK⊤ SxK , Q, S ⪰ 0, R ≻ 0
u,x
k=0
Finite-time LQR
Backward computation of PK , PK −1 , . . . P1
Linear feedback uk = Γk xk with Γk = −(R + B⊤ Pk+1 B)−1 B⊤ Pk+1 A
MPC
Backward computation of PK , PK −1 , . . . P1
Linear time-invariant feedback uk = Γ0 xk
10 / 39
Option 1: Explicit computation of u0∗
11 / 39
Example
Consider the toy problem (time horizon 1, scalar integrator)
subject to x1 = x0 + u0
x1 ≤ 1
12 / 39
f (u0 ) = u02 + (x0 + u0 )2
g(u0 ) = x1 − 1 = x0 + u0 − 1
∇f (u0 ) = 4u0 + 2x0
∇g(u0 ) = 1
13 / 39
Piecewise-affine feedback
subject to x1 = x0 + u0
x1 ≤ 1
u0∗ = − 12 x0
2 2
x0 1
0
1 t
u0∗ = 1 − x0
14 / 39
Explicit MPC in practice
region no
found?
yes
compute
mn multiplications
control law
m(n+1) memory accesses
U = Fi X + Gi
15 / 39
Option 2: online computation
16 / 39
from www.embotech.com, ETH spin-off
17 / 39
Stability
MPC as a feedback design tool
K , Q, R, S
Closed-loop stability
Analysis: compute u0∗ (hard!) and assess stability
Design: derive conditions on K , Q, R, S that guarantee closed-loop stability
Tools:
Small-signal (local) stability?
Large-signal (global) stability?
18 / 39
Lyapunov analysis
Stable equilibrium
The equilibrium x = 0 is stable for the dynamics xk+1 = f (xk ) if a small perturbation
of the state perturbs the subsequent state trajectory in a continuous manner.
Lyapunov theorem
Let W be a real-valued function such that
→ https://arxiv.org/abs/1809.05289
19 / 39
Stability of infinite horizon MPC
x
k k +1
20 / 39
This makes W (x) = minu,x Vk∞ an obvious candidate Lyapunov function, under
very reasonable assumptions (for example on the functions gs ).
it is zero only at the target equilibrium x = 0
it decreases along the closed-loop trajectories of the system
Some subtleties
Technically, we haven’t defined the MPC control with an infinite-dimensional
optimization problem
We are assuming that the global minimum is found and attainable
The functions g need to satisfy some properties
(remember the observability assumptions on infinite-time LQR?)
21 / 39
Finite-time MPC stability
The same trick clearly does not apply to finite-time receding-horizon MPC.
x
k k +K
x
k +1 k +1+K
22 / 39
Stability with terminal constraint
K
X −1
W (x) = min gk (xk , uk )
u,x
k=0
x
xk+K = 0
k k +K
x
xk+1+K = 0
k +1 k +1+K
23 / 39
Theorem
The equilibrium x = 0 is asymptotically stable for the closed-loop dynamics
generated by a finite-time MPC controller with zero terminal constraint.
−1
k+K k+K
!
X X
W (xk+1 ) = min g(xs , us ) = min g(xs , us ) − g(xk , uk ) + g(xk+K , uk+K )
s=k+1 s=k
By definition of the minimum, this is small than the same quantity evaluated for an
arbitrary u.
Let’s evaluate it for the input that minimizes the optimization problem at time k, that
is
k+K
X −1
ũ = arg min g(xs , us ),
s=k
24 / 39
Key proof idea
x
xk+K = 0
k k +K
W (xk )
x
xk+1+K = 0
k +1 k +1+K
k +1 k +1+K
W (xk+1 )
25 / 39
Receding horizon as an approximation of infinite horizon
Infinite horizon
x
P∞
k=0 g (xk , uk )
k
Receding horizon
x
PK −1
k=0 g (xk , uk )
k K
Receding horizon with terminal cost
x
PK −1
k=0 g (xk , uk ) + gK (xK )
k K
Receding horizon with terminal constraint
x
PK −1
k=0 g (xk , uk ) xK ∈ XK
k K
26 / 39
MPC closed loop stability
Subtleties
We always assumed feasibility of the MPC problem, which may not be true
(for example with a zero terminal constraint)
Future feasibility of the problem may depends on the current control actions.
We always assume that the global minimum can be found.
27 / 39
28 / 39
Steady-state selection
T
X −1
min xt⊤ Qxt + ut⊤ Rut + xT⊤ SxT , Q, S ⪰ 0, R ≻ 0
u,x
t=0
We have implicitly assumed that we are trying to regulate the steady state
xs = 0 us = 0
However
we usually want plants to operate at a desireable working point xs
(not to stop! xs = 0)
we can often allow a constant input uS
29 / 39
Incremental formulation of MPC
xk
u0∗ (·) uk xk ∆u0∗ (·) ∆uk uk
1
plant z−1 plant
30 / 39
Non-zero steady state
us
31 / 39
Steady-state selection
q = a, q̇ = 0, d = D, ḋ = 0, u = g sin a
32 / 39
MPC control architecture
Steady-state
offline
optimization
xs , us
online MPC
xk uk
plant
33 / 39
Disturbance and zero-offset
Not surpisingly, MPC relies on having access to a model of the system.
Model mismatch
▶ what is the effect of an approximate model on the feedback gain?
▶ is (xs , us ) a steady-state?
Output/measurement noise
▶ what is the effect of an additive noise to the measurement?
Process noise
▶ what is the effect of an additive noise to the input?
34 / 39
Disturbance rejection in MPC
1 Add a model for the disturbance
2 Based on the augmented model and the available measurements, estimate
the disturbance
3 Correct the steady-state target based on the estimate of the disturbance
uk
MPC
xs , us x̃k+1 = Ax̃k + B ũk xk plant
Q, R
steady-state d̂k
target selection estimator
35 / 39
Step 1: Add a model for the disturbance
dk+1 = dk dk ∈ Rnd , nd ≤ n
xk+1 A Bd xk B
= + u
dk+1 0 I dk 0 k
36 / 39
Step 2: Estimate the disturbance
uk
MPC
xs , us x̃k+1 = Ax̃k + B ũk xk plant
Q, R
steady-state d̂k
target selection estimator
37 / 39
Correct the steady-state target
Based on the constant disturbance model, d̂k is out best estimate of the
steady-state ds .
uk
MPC
xs , us x̃k+1 = Ax̃k + B ũk xk plant
Q, R
steady-state d̂k
target selection estimator
38 / 39
And more...
Output-feedback MPC
Terminal constraints
More powerful stability guarantees
Examples
Chapters 1, 2, 7 of
Model Predictive Control:
Theory, Computation, and Design
James B. Rawlings, David Q. Mayne, Moritz M. Diehl
2nd edition, 2022
Free to download
https://sites.engineering.ucsb.edu/~jbraw/mpc/
39 / 39
This work is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License