07 - Data-driven Predictive Control
07 - Data-driven Predictive Control
Saverio Bolognani
y0 C 0 0 ... u0
y1 CA CB 0 ... u1
CA2
y2 x0 + CAB CB 0 ... u2
=
.
.. .. .
.. ..
. .
yL−1 CAL−1 CAL−2 B CAL−3 B ... CAB CB 0 uL−1
| {z } | {z }
OL GL
y0 C
y1 CA
CA2
y2= x0
.
..
..
.
yL−1 CAL−1
| {z } | {z }
yL OL
2 / 36
Example, n = 1
1
xt+1 = xt + ut
2
yt = xt
C 1
CA 1/2
2
OL = CA = 1/4
. ..
.. .
CAL−1 1/2L−1
Assuming no input, can you reconstruct x0 from
y0 = 1 ?
y0 = 2, y1 = 1?
y0 = 1, y1 = 1?
What are all the output sequences produced by the free response of this system?
Exercise: Try with an undamped oscillator, n = 2.
3 / 36
Suppose that the input sequence u0 , . . . , uL is non zero, but known.
y0 C 0 0 ... u0
y1 CA CB 0 ... u1
CA2
y2 x0 + CAB CB 0 ... u2
=
.. . .. .
.. ..
. .
L−2
yL−1 CAL−1 CA B CAL−1 B ... CAB CB 0 uL−1
| {z } | {z }
OL GL
y0 0 0 ... u0 C
y1 CB 0 ... u1 CA
u2 CA2
y2 CAB CB 0 ...
− = x0
.. .. . .
.. ..
. .
L−2
yL−1 CA B CAL−1 B ... CAB CB 0 uL−1 CAL−1
| {z } | {z }
GL OL
4 / 36
yL − GL uL = OL x0
yL − GL uL
5 / 36
All input-output trajectories of length N of the system need to satisfy
uL I 0 uL
= L
yL GL OL x0
| {z }
ΛL
ΛL ∈ R(L+L)×(L+n)
if L ≥ n, ΛL has rank L + n
Behavioral representation
Trajectories uL , yL of the system need to belong to the column image of ΛL .
6 / 36
L = n (observability problem)
un In 0 un
=
yn Gn On x0
| {z }
Λn
Λn has dimension 2n × 2n
Λn has rank 2n
→ invertible matrix
xt+1 = xt + ut
yt = xt
7 / 36
L=n+1
u0
..
.
u0
un−1
..
.
un = In+1 0
un−1
y0 G O
n+1 n+1
un
|
.. {z }
.
Λn+1
x0
yn−1
yn
Toy example:
8 / 36
L = n + 1 (prediction problem)
u0
..
.
u0
un−1
..
.
un = In+1 0
un−1
y0 G O
n+1 n+1
un
|
.. {z }
.
Λn+1
x0
yn−1
yn
Prediction problem
Suppose that yn is missing. Can you reconstruct it?
Intuitively:
▶ We already know that we can reconstruct x0 from the first n input/output samples
▶ Once we have x0 we can “simulate” the output until yn .
9 / 36
L = n + K (prediction problem)
u0
..
.
un−1
u0
un
..
..
.
.
un−1
un+K −1 In+K 0
= un
y0 G O
| n+K {z n+K }
..
.. .
. Λn+K
un+K −1
yn−1
x0
yn
..
.
yn+K −1
Prediction problem
Suppose that the sequence yn . . . yn+K −1 is missing. Can you reconstruct it?
10 / 36
“Linear-algebra” interpretation
Any I/O sequence of length L > n belongs to a subspace of dimension L + n
u0
..
.
un−1
un
..
.
un+K −1
= Hg
y0
..
.
yn−1
yn
..
.
yn+K −1
Image representation
columns of H ∈ R2L×(L+n) are a basis of the subspace
g ∈ RL+n is a vector of coefficients
11 / 36
A basis for this subspace is given by the columns on ΛL
▶ We need A, B, C to build ΛL
Can you find another basis?
Hint: m linearly independent vectors from a subspace of dim. m form a basis.
How would you generate columns from this subspace? Data!
" #" #" # " #
(1) (2) (3) (L+n)
uL uL uL uL
(1) (2) (3) ··· (L+n)
yL yL yL yL
with g ∈ RL+n .
12 / 36
13 / 36
Exercise
xt+1 = xt + ut
yt = xt
14 / 36
Data matrix
... u0 u1 u2 u3 u4 u5 u6 u7 ...
rearranged as
u0 u1 u2 ... uL+n−1
u1 u2 u3
HL (u) =
u2 u3 u4
...
uL−1 u2L+n−2
Have you met this matrix before?
15 / 36
u0 u1 u2 ... uL+n−1
u1 u2 u3
HL (u) =
u2 u3 u4
...
uL−1 u2L+n−2
y0 y1 y2 ... yL+n−1
y1 y2 y3
HL (y) =
y2 y3 y4
...
yL−1 y2L+n−2
16 / 36
K -step predictor (L = n + K )
Given the past input, past output, and future input, compute future output.
upast
HL (udata ) ufuture
g=
HL (ydata ) ypast
yfuture
Many uses:
Filtering
Recover missing data
Prediction / simulation
Control
17 / 36
Model-based Predictive Control
K
X −1
min yk2 + ruk2
u,x,y
k=0
The model equations enforce that u and y are trajectories of the plant for the next
K steps.
18 / 36
Data-enabled Predictive Control
where
a new decision variable g has been introduced
upast and ypast are the last n inputs and outputs of the system, and play the
role of the initial condition
19 / 36
K −1 K
X −1
min yk2 + ruk2
X
min yk2 + ruk2 u,y,g
u,x,y k=0
k=0
subject to xk+1 = Axk + Buk upast
HL (udata ) u
yk = Cxk subject to g=
HL (ydata ) ypast
x0 = x y
uk ∈ Uk ∀k uk ∈ Uk ∀k
yk ∈ Yk ∀k yk ∈ Yk ∀k
20 / 36
A few remarks
Assumption
We assumed persistence of excitation in the collected data
technically, to ensure that the data matrix has full rank
intuitively, because we want the data to represent all dynamics of the system
21 / 36
MIMO case
The theory extends very naturally to multiple inputs and multiple outputs.
Lag of a system
The lag of a system is the smallest ℓ such that
C
CA
Oℓ = ...
CAℓ−1
has rank n.
22 / 36
Lag and system size estimation
First principles
▶ for example, electro-mechanical systems
A posteriori verification
▶ Build increasingly bigger Hankel matrices and verify the rank
Once the order is estimated, Tini = n is a valid solution, although in some cases
side information can allow to choose a smaller Tini .
K is determined by the control specifications (similar to MPC).
23 / 36
The effect of noise
In theory, adding data to our data matrix does not hurt
it ensures that we have enough data in case we are uncertain about n
it ensures that all the system modes have been excited
the rank of H stops increasing after mL + n
" #
(1) (2) (3)
uL uL uL ...
(1) (2) (3) g
yL yL yL ...
| {z }
H
24 / 36
Consequences of noise in the data
Consider the (pathological) case in which one of the outputs is identically zero.
⋆ ⋆ ⋆
yk = Cxk = x
0 0 0 k
All output sequences should be of the form
⋆
yk =
0
However, if the data contains noise, some columns in the data matrix may present
a non-zero second coordinate in the output
" #
(1) (2) (3)
uL uL uL ...
(1) (2) (3) g
yL yL yL + ϵ . . .
| {z }
H
25 / 36
Enforcing the rank condition
Model selection and enforcement of model dimension was easier in identification.
Remember?
Σ1 0r×n−r ⊤
= U1 Σ1 V1⊤
Hk,ℓ = U1 U2 V1 V2
0m−r×r 0m−r×n−r
K
X −1
min ∥yk ∥2Q + ∥uk ∥2R
u,y,g
k=0
upast
HL (udata ) u
subject to g=
HL (ydata ) ypast
| {z } y
H
uk ∈ Uk ∀k
yk ∈ Yk ∀k
26 / 36
Rank constrained data-driven control
K
X −1
min ∥yk ∥2Q + ∥uk ∥2R
u,y,g,ûdata ,ŷdata
k=0
27 / 36
Step 1: At most L + n non-zero elements of g are needed
K
X −1
min ∥yk ∥2Q + ∥uk ∥2R
u,y,g,ûdata ,ŷdata
k=0
28 / 36
Step 2: Convex relaxation → drop the rank constraint
K
X −1
min ∥yk ∥2Q + ∥uk ∥2R
u,y,g,ûdata ,ŷdata
k=0
29 / 36
Step 3: from sparsity of g to a bound on ∥g∥1
K
X −1
min ∥yk ∥2Q + ∥uk ∥2R
u,y,g
k=0
upast
HL (udata ) u
subject to g=
HL (ydata ) ypast
y
∥g∥1 ≤ α
uk ∈ Uk ∀k
yk ∈ Yk ∀k
30 / 36
Step 4: Replace the bound on ∥g∥1 with a regularization term
K
X −1
min yk2 + ruk2 +λg ∥g∥1
u,y,g
k=0
upast
HL (udata ) u
subject to g=
HL (ydata ) ypast
y
uk ∈ Uk ∀k
yk ∈ Yk ∀k
31 / 36
Noise in the real-time measurements
K
X −1
min yk2 + ruk2 +λg ∥g∥1 +λσ ∥σ∥1
u,y,g,σ
k=0
upast
HL (udata ) u
subject to g=
HL (ydata ) ypast +σ
y
uk ∈ Uk ∀k
yk ∈ Yk ∀k
32 / 36
What is hard to do with data-driven control
State constraint
If a state is known and its value needs to be controlled, then a model-based
approach may work better.
Prior/side information
If some system information is available (range of parameters, nominal values,
structure of the problem) then sysID can typically incorporate this information.
Nonlinearity
The theory we have seen today strongly relies on LTI system theory.
Extensions to nonlinear systems are complicated.
Computational complexity
A data representation is less compact than state-space models (what is a
model, by the way?). This requires memory and computation time.
33 / 36
https://control.ee.ethz.ch/research/theory/data-enabled-predictive-control.html
34 / 36
Surely, nobody would put apply such a shaky data-driven method
on the world’s most complex engineered system (the electric grid),
using the world’s biggest actuators (Gigawatt-sized HVDC links),
and subject to real-time, safety, & stability constraints . . . right?
!"#$%&'()'(%#(*%+,-$'#(.
%
/% 0123% 21)4'5"*% #% 6"$7% 8#6-1$#),"% $"6'"9% -8% 7-1$% :#:"$% ;<=% 9>'?>% /% )",'"6"% ?-1,*% )"% -8%
'4:-$3#(?"%3-%-1$%9-$@%#3%A'3#?>'%B-9"$%C$'*2D%E"%*-%>#6"%%;<=%$"F1'$"%-GH,'("%31('(I%3>#3%%;<=%%
?-4'22'2'-('(I%"(I'(""$%?#(%*-%-(%>'2%-9(%%;<=%%#(%#*#:J6"%#::$-#?>%9-1,*%)"%6"$7%'(3"$"2J(ID
<%8"9%*#72%#Q"$%
% 2"(*'(I%-1$%?-*"
/8% :-22'),"% /% 9-1,*% ,'@"% 3-% 3$7% 3>"% *"?"(3$#,'K"*% !""BL% #::$-#?>% 9'3>% -1$% 4-$"% *"3#',"*% AM!L%
2723"4% 4-*",2% -(% 3>"% '(3"$#$"#% -2?',,#J-(% :$-),"4D% L-1,*% 2-% 2-4"% ?-*"% )"% 4#*"% #6#',#),"%%
;<=%%N%E-1,*%7-1%)"%'(3"$"23"*%'(%9-$@'(I%3-I"3>"$%3-%*-%21?>%#%*"4-(23$#J-(%N%%;<=
%/3%9-$@2O%<%"6"(%
-(%#(%"(J$",7%
*'G"$"(3%4-*",%P%
2-Q9#$"%:,#R-$4
35 / 36
The control engineer flowchart
36 / 36
This work is licensed under a
Creative Commons Attribution-ShareAlike 4.0 International License
https://bsaver.io/COCO