APC Part 6 Introduction To State Estimation
APC Part 6 Introduction To State Estimation
Outline
IIT Bombay
Motivation
IIT Bombay
Dynamic Model
(ODEs/ PDEs)
Soft Sensing
Techniques
dh1 a a3 k
1 2 gh1 2 gh3 1 1 v1
dt A1 A1 A1
Tank3 Tank 4
dh2 a a k
2 2 gh2 4 2 gh4 2 2 v 2
dt A2 A2 A2
dh3 a3 (1 1 )k1
2 gh3 v2
dt A3 A3
dh4 a (1 2 )k2
Tank 1
Tank
2 4 2 gh4 v1
Pump1
Pump 2 dt A4 A4
V2
V1
Manipulated Inputs : v1 and v2
Measured Outputs : h1 and h2
model is perfect
Initial State
IIT Bombay
x(0) b
A
(nr ) n (nr ) 1
A unique solution x(0) can be found only if matrix A has rank equal to 'n'
Automation Lab
Observability
IIT Bombay
0.9233 0 0.1813 0
0 0.9462 0 0.1493
0 0 0.8112 0
0 0 0 0.8465
0.4001 0.02276
0.01209 0.3055
0.5 0 0 0
C
0 0.2159 0 0.5 0 0
0.1438 0
1/16/2014 State Estimation 19
Automation Lab
0.5000 0 0 0
0 0.5000 0 0
C 0.4617 0 0.0906 0
C 0 0.4731 0 0.0746
C 2 0.4263 0 0.1572 0
3
C 0 0.4476 0 0.1338
0.3936 0 0.2048 0
0 0.4235 0 0.1800
min N
xˆ (0)
ˆ
v
k 0
( k )T
R 1
vˆ(k ) Measurement
True Value subject to Noise
k 1
vˆ(k ) y (k ) C xˆ (0) C u(k j )
k j 1
j 1
Process Y(k)
u(k) Note
Model yˆ (k ) ˆ
x(0) x(0)
Process Y(k)
u(k)
Model yˆ (k )
Difficulty:
Defining Estimation error Cannot be used
If process is marginally
ε(k) x(k ) xˆ (k ) Stable or unstable.
Subtracting (2) from (1), we have
ε(k 1) ε(k) ε(k) k ε(0) Even when () 1
() decides rate of
If process is stable, i.e., () 1, convergenc e of (k )
then (k ) 0 as k Can we accelerate
the convergenc e?
1/16/2014 State Estimation 24
Automation Lab
IIT Bombay
“Closed Loop” State Observer
Process +
u(k) Y(k) e(k )
Model -
yˆ (k )
Recursive Estimation
IIT Bombay
Luenberger Observer
Deterministic Observer Design:
Choose observer gain matrix L such
that matrix LC has poles at the
desired locations (Pole Placement)
Choice of observer poles: Compromise between
decay of estimation error and sensitivity to
measurement noise/modeling errors
Choice of poles so as to systematically account for
Measurement noise and Unmeasured Disturbances
is difficult
Consequence: sub-optimal performance
in presence of stochastic disturbances
1/16/2014 State Estimation 28
Automation Lab
IIT Bombay
SOS Luenberger Observer
Coordinate Transforma tion : (k) Tx(k)
Coordinate Transformation
η Tx
~ 1
T WOBS WOBS
Co C
CΦ CΦ
~ o o
WOBS ; WOBS
..... .....
C Φn 1 CΦn 1
o o
CSTR Example
IIT Bombay
p1 1.518
L p T 1
p2 0.836
1
1 0 0 1 0 1
~
T WOBS
1
WOBS
1.518 1 73.492 1.333 73.492 - 0.185
1/16/2014 State Estimation 34
Automation Lab
IIT Bombay
0.3
0.25
0.2
0 1 2 3 4 5
Time (min)
State Estimates: (-) True (+) estimated
405
400
Temp.(K)
395
390
385
0 1 2 3 4 5
Time (min)
0.1
-0.1
-0.2
0 1 2 3 4 5
Time (min)
15
Error in Temp. Estimate
10
-5
-10
0 1 2 3 4 5
Time (min)
0 .3 5
0 .3
0 .2 5
0 .2
0 0 .5 1 1 .5 2
T im e (m in)
400
395
390
0 0 .5 1 1 .5 2
T im e (m in)
0.1
0.05
-0.05
0 0.5 1 1.5 2
Time (min)
10
Error in Temp. Estimate
0
0 0.5 1 1.5 2
Time (min)
0.4
0.3
0.2
0.1
0 0.5 1 1.5 2
Time (min)
420
(0) 0.1 2
Temp.(K)
410
400
390
0 0.5 1 1.5 2
Time (min)
1/16/2014 State Estimation 39
Automation Lab
IIT Bombay
CSTR Example: Dead-beat Observer
Linear Plant- Linear Observer
Luenberger Observer: Error Dynamics
Error in Conc. Estimate
0.15
0.1
Dead-
0.05
0
beat
-0.05
0 0.5 1 1.5 2 Observer
Time (min) Poles
Error in Temp. Estimate
10
at
5 (0,0)
0
-5
0 0.5 1 1.5 2
Time (min)
1/16/2014 State Estimation 40
Automation Lab
IIT Bombay
CSTR Example: Dead-beat Observer
0.2
0.1
0 2 4 6 8 10
Time (min)
420
410
Temp.(K)
400
390
380
0 2 4 6 8 10
Time (min)
0.1
0.05
-0.05
0 2 4 6 8 10
Time (min)
Error in Temp. Estimate
10
-5
-10
0 2 4 6 8 10
Time (min)
Unmeasured Disturbances
What if there are unknown disturbances
influencing state dynamics?
What if the measurements are corrupted with
measurement noise?
Suppose we have stochastic models for time
evolution of these unmeasured disturbances and
measurement noise, then
can we use these models to design a state estimator,
which filters out the measurement noise but
compensates for the unmeasured disturbances?
Difficulty
Disturbance inputs d(t) are NOT piecewise constant functions!
How to develop a discrete time model?
Simplifying Assumption 2 :
d(k ) : zero mean white noise process
with Covw (k ) E w (k )w (k )T Qd Simplifying Assumption 3 :
Measurements are corrupted
with zero mean white noise process
v(k) with Covv(k) Ev(k) v(k)T R
1/16/2014 State Estimation 46
Automation Lab
IIT Bombay
Unmeasured Disturbances
Define w (k ) d(k )
E w (k ) E d(k ) 0
Cov w (k ) E w (k )w (k )T E d(k )d(k )T T Qd T
Let Q Qd T
Primary Requirement
Error between the state estimate and the true
process state should be “as small a possible”
1/16/2014 State Estimation 47
Automation Lab
Preliminaries
IIT Bombay
Define set
Y k y (0), u(0) , y (1), u(1) ,....., y (k ), u(k )
xˆ (k | k ) E x(k ) | YK
Prediction Step
E x(k ) | Y k 1 E x(k 1) u(k 1) w (k 1) | Y k 1 0
E x(k 1) | Y k 1 u(k 1) Ew (k 1)
OR xˆ (k | k 1) xˆ (k 1 | k 1) u(k 1)
1/16/2014 State Estimation 50
Automation Lab
Preliminaries
IIT Bombay
Cov x(k ) | Y k 1 E x(k ) x(k ) x(k ) x(k ) | Y k 1
T
x(k ) E x(k ) | Yk 1
Subtracting the equation governing the mean
xˆ (k | k 1) xˆ (k 1 | k 1) u(k 1)
Preliminaries
IIT Bombay
Update Step
xˆ (k | k ) xˆ (k | k 1) L(k )e(k )
e(k ) y (k ) yˆ (k | k 1)
(with an arbitrary gain matrix L(k))
where "innovation " e(k )
is related to state estimation error as follows
e(k ) y (k ) yˆ (k | k 1)
Cx(k ) v (k ) Cxˆ (k | k 1)
Cε(k | k 1) v (k )
Error Dynamics
ε(k | k 1) ε(k 1 | k 1) w (k 1)
ε(k | k ) I L(k )Cε(k | k 1) L(k ) v (k )
Combining
ε(k | k ) I L(k )Cε(k 1 | k 1) w (k 1) L(k ) v(k )
Simplifying Assumption 4
Initial State at k 0 is a Random Variable such that
Ex(0) Eˆ
x(0 | 0) Covx(0) P(0)
Ex(0) ˆ
x(0 | 0) Eε(0 | 0) 0
Define
P (k | k 1) Covε(k | k 1) E ε(k | k 1)ε(k | k 1)T
P (k 1 | k 1) Covε(k 1 | k 1) Eε(k 1 | k 1)ε(k 1 | k 1)
T
Now
ε(k | k 1)ε(k | k 1)T ε(k 1 | k 1) w (k 1)ε(k 1 | k 1) w (k 1)
T
Prediction Error
IIT Bombay
The innovation
e(k ) y (k ) yˆ (k | k 1)
Cε(k | k 1) v(k )
Cε(k 1 | k 1) w (k 1) v (k )
contains informatio n about w (k 1) and v (k )
Covariance of Innovation s
Pe (k ) E e(k )e(k )T E Cε(k | k 1) v(k )Cε(k | k 1) v(k )
T
CCovε(k | k 1)CT Covv(k );
CP(k | k 1)CT R
Estimation Error
Estimation Error
we have
P (k | k ) P (k | k 1) L(k )Pe (k )L(k )T L(k )Pe (k )T Pe (k )L(k )T
Rules of Differentaition
tr AX tr XA
AT
X X
Let B represent a symmetric matrix
tr XBXT 2 XB
X
1/16/2014 State Estimation 60
Automation Lab
tr L(k )Pe (k )L(k )T 2L(k )Pe (k )
L(k )
tr L(k )Pe (k )T Pe (k )L(k )T
2
tr L(k )Pe (k )T
2Pe (k )
L(k ) L(k )
Update
e(k ) y(k ) Cˆ
x(k | k 1)
x(k | k ) ˆ
ˆ x(k | k 1) L*(k )e(k )
P(k | k ) I L*(k )C P(k | k 1)
1/16/2014 State Estimation 62
Automation Lab
Interpretations
IIT Bombay
x1 x1
Prediction Update
step step
Gaussian Distributions
IIT Bombay
p ( x ) x, P ) n /2
(2 )
1
det(P )
T
exp x x P 1 x x
Let the process noise, the measurement noise and the initial state
have Gaussian normal distributions, i.e.
w ~ 0, Q), v ~ 0, R ) and x(0) ~ xˆ (0 | 0), P (0))
p e (k ) | Yk ~ 0, Pee (k ))
Pee (k ) CP(k | k 1)CT R
Automation Lab
When the process noise, the measurement noise and the initial state
have Gaussian normal distributions, it can be shown that
x(k) R 1 P (k |k 1) 1
L* (k ) P (k | k 1)CT CP(k | k 1)CT R
1
P(k | k ) I L*(k )C P(k | k 1)
where Q >0;R > 0 are tuning matrices
Automation Lab
IIT Bombay
Convergence of Estimation Errors
Kalman Filter
xˆ (k 1 | k ) xˆ (k | k ) u(k )
xˆ (k | k ) xˆ (k | k 1) L* (k )y (k ) Cxˆ (k | k )
Define matrices
(k | k 1) P (k | k 1) and (k | k ) P (k | k )
1 1
A 1
B
1
A A A B 1 1
A
(k 1 | k ) c (k ) (k | k 1) c (k )
T 1
c (k ) I L* (k )C
(k ) (k | k 1) (k | k ) Q (k | k 1) T 1
1
Automation Lab
IIT Bombay
Convergence of Estimation Errors
1
1
(k ) (k | k 1) (k | k ) Q (k | k 1)
T
Since (k ) is always ve definite
ε(k | k 1)T (k )ε(k | k 1)T 0
and error dynamics given by equation (3) is Lyapunov stable
Automation Lab
IIT Bombay
Convergence of Estimation Errors
1 1
ε(k | k 1) V (k ) ε(k | k 1)
pH pL
1
(k ) (k | k 1) (k | k ) T Q 1 (k | k 1)
1
pH2 pH / Q 1
2
1
V (k 1) V (k ) ε(k | k 1)
2
pH2 pH / Q 1
2
xˆ (k | k 1) xˆ (k 1 | k 1) u(k 1)
-2
0 100 200 300 400
Time (sec)
2
0
Level 2
True State
-2
Estimated State
-4
0 100 200 300 400
Time (sec)
Automation Lab
IIT Bombay
Example: Quadruple Tank System
-1
0 100 200 300 400
Time (sec)
1
0
Level 4
-1 True State
Measured State
-2
0 100 200 300 400
Time (sec)
Automation Lab
IIT Bombay
Example: Quadruple Tank System
0.08
0.07
0.06
0.05
0.04
0.03
0 100 200 300 400
Time (sec)
Automation Lab
Dealing with Non-stationary IIT Bombay
Disturbances
Augment state space model with extra artificial
states (equal to no. of outputs), which behave as
integrated white noise sequence and can capture drifting
x(k 1) x(k ) u(k ) η(k ) w (k )
η(k 1) η(k ) w (k )
y (k ) Cx(k ) v (k )
Q [0]
State Noise Covarance :
[ 0] Q
Choice of matrix Tuning
Bias in Input Model : Parameter
Mean shift in diaturbance :
Design Kalman Filter / Predictor using augmented model
Fast changing disturbance: use high values of co-variance Q
1/16/2014 State Estimation 80
Automation Lab
(0) 0.1 2
Conc.(mod/m3)
0.4
0.3
0.2
0.1
0 0.5 1 1.5 2 2.5 3 3.5 4
Time (min)
430
420
Temp.(K)
410
400
390
0 0.5 1 1.5 2 2.5 3 3.5 4
Time (min)
1/16/2014 State Estimation 83
Automation Lab
IIT Bombay
CSTR Example: Kalman Predictor
0.1
-0.1
-0.2
0 0.5 1 1.5 2 2.5 3 3.5 4
Time (min)
20
10
-10
-20
0 0.5 1 1.5 2 2.5 3 3.5 4
Time (min)
1/16/2014 State Estimation 84
Automation Lab
IIT Bombay
CSTR Example: Kalman Predictor
0.2
0.1
0
0 2 4 6 8 10
Time (min)
460
420
400
380
0 2 4 6 8 10
Time (min)
1/16/2014 State Estimation 85
Automation Lab
IIT Bombay
CSTR Example: Kalman Predictor
0.2
-0.2
-0.4
0 2 4 6 8 10
Time (min)
20
-20
-40
0 2 4 6 8 10
Time (min)
Lemma
Assume pair (, Q ) is controllab le and R is non - singular
Then all eigen values of ( L*p , C) are inside the unit circle.
(Dynamics governing the estimation error ε(k | k - 1) is asymptotically stable)
Notation
IIT Bombay
Control Relevant
tk 1
F x(k ), u(k ), w (k ), θ
Automation Lab
IIT Bombay
Extended Kalman Filter: Summary
Prediction Step
xˆ (k | k 1) F xˆ (k 1 | k 1), u(k 1), 0
P(k | k 1) (k , k 1)P(k 1 | k 1) (k , k 1)T d (k , k 1)Q d d (k , k 1)T
Update Step
e(k ) y (k ) H xˆ (k | k 1)
xˆ (k | k ) xˆ (k | k 1) L(k )e(k )
0.3
0.2
0.1
0 2 4 6 8 10
Time (min)
440
Temp.(K)
420
400
380
0 2 4 6 8 10
Time (min)
Automation Lab
IIT Bombay
EKF : CSTR Example
Estimation Error Dynamics
Error in Temp. EstimateError in Conc. Estimate
Extended Kalman Predictor: Error Dynamics
0.3
0.2
0.1
-0.1
0 2 4 6 8 10
Time (min)
10
-10
-20
0 2 4 6 8 10
Time (min)
Automation Lab
IIT Bombay
T T T Tj-5, TR-5
CA(1,t), CB(1,t)
A B C
(Endothermic Reaction)
Tj(0,t)
Tj Tj
T T
U wj
u ……..Jacket Temp.
t z mjCpmj
r j
V j
Automation Lab
IIT Bombay
Plant Model
No. of internal discretization points 19 4
No. of states 80 20
Simulation Parameters
Concentration
Automation Lab
Actual and Estimated Exit IIT Bombay
Concentration of B
Automation Lab
IIT Bombay
Simulation Result: Concentration profiles
of product B at different time instants
Automation Lab
IIT Bombay
State and Parameter Estimation
θ(k 1) θ(k ) w θ (k )
y (k ) Hx(k ) v(k )
Updated Covariance
Pa (k | k ) I L(k )C a (k )Pa (k | k 1)
3-15 psi
Cold Water Flow Input
CV-1
CV-2
Cold Water Flow
T Tank - 1
T
L
T
Tank - 2
Thyrister
4-20 mA Control
Input Unit
Signal
T
T
Automation Lab
IIT Bombay
Summary
IIT Bombay
References
IIT Bombay