You are on page 1of 36

System Identification: Black Box

Robert Grepl
Institute of Solid Mechanics, Mechatronics and Biomechanics
Faculty of Mechanical Engineering, Brno University of Technology
2010 - 2015
Black box - agenda

1. Prerequisities:
Least squares.
Discrete dynamic system.
2. How to use LS to estimate parameters of DDS?
Example: mechanical oscillator
3. Problem: Noise.

www.mechlab.cz 2
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Methods: Least Squares 1/2

generally: LS is Linear Optimization method


assume function
(linear)(ordinary) LS requires
linear parametrization:
example:
consider m measurements
... written in matrix form:

if m=n, then Problem: Find parameters of


line if 2 points are given.
www.mechlab.cz 3
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Methods: Least Squares 2/2

in real apps, the measurement is not ideal

task is: how to solve this overdetermined problem?


(m equations and n unknowns)
answer: minimize criterion

result:

Note: Penrose pseudoinversion

www.mechlab.cz 4
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
LS example: regression 1D function

fit 1D function
(this task = the fitting of static model linear in parameters)
noise added to measurement
regression matrix: 2.5
noisy data
2 original
fit
1.5

0.5

0
y
-0.5

-1

[E015] -1.5

-2

-2.5
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
t

www.mechlab.cz 5
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Recursive Least Squares (RLS) (Plackett's algorithm)

online estimation
gives identical result as OLS

assume model

in matrix form:

www.mechlab.cz 6
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Black box - agenda

1. Prerequisities:
Least squares.
Discrete dynamic system.

2. How to use LS to estimate parameters of DDS?


Example: mechanical oscillator
3. Problem: Noise.

www.mechlab.cz 7
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
OLS & RLS example:
Estimation of mass+spring+damper system 1/3
1) Discretization

www.mechlab.cz 8
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
OLS & RLS example:
Estimation of mass+spring+damper system 2/3
2) Create matrix X and vector Y

Y(k) = y(k);
X(k,:) = [y (k-1), y(k-2), u(k-2)];
{E003}

www.mechlab.cz 9
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
OLS & RLS example:
Estimation of mass+spring+damper system 3/3

3) Solve LS/RLS problem


both LS and RLS provide the same results
convergence of RLS/precision of LS depends on excitation signal
Oscilator position
10
continuous sim
0 ARX sim
{E003} -10
0 2 4 6 8 10
t [s]
Input excitation force [N]
50
input u

But: there is no noise 0

considered in our -50


simulation! 0 2 4
t [s]
6 8 10

convergence of Recursive LS (RLS)


2
a1
0 a2
b2
-2
0 2 4 6 8 10
t [s] www.mechlab.cz 10
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Black box - agenda

1. Prerequisities:
Least squares.
Discrete dynamic system.
2. How to use LS to estimate parameters of DDS?
Example: mechanical oscillator

3. Problem: Noise.

www.mechlab.cz 11
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Problem = noise: simple example study setup 1/4

consider first order system


discretization:

Ts

for simplicity, consider NO INPUT


xk 1 axk
TASK: estimate one parameter a. 2

1.5

simulation data : 1

x
0.5

0
0 2 4 6 8 10
t

1.5
x(k+1)

0.5

-1 0 1 2 www.mechlab.cz
3 12
ISMMB, Faculty of Mechanical Engineering, Brno
x(k) University of Technology
Problem = noise: simple example study
without noise 2/4
Consider ini value x_0 and simulate equation: xk 1 axk
On lower Fig. we see the plot x(k) vs. x(k+1).
From the equation, it is obvious, that it should be a line.
The slope of this line is a.
2
With data WITHOUT noise, 1.5

the estimation of a is precise. 1

x
0.5

0
0 2 4 6 8 10
t

1.5
x(k+1)

0.5

-1 0 1 2 3
x(k)

www.mechlab.cz 13
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Problem = noise: simple example study
noise on output 3/4
Consider further the noise on output (e.g. noise of sensor).
Equation: xk 1 axk
(w is random number with normal distribution (Gauss) yk xk w
We can observe a problem with estimation of parameter a.
6
% simulation
5 5 x(1) = x0;
for i = 2:length(t)
4 4
x(i,1) = a*x(i-1);
3 5
3
y(i,1) = x(i) + randn*0.2;
end
x(k+1)

2
x

4 2

1
1
0
3
x(k+1)

0
-1
2
-1
-2
0 2 4 6 8 10 -1 0 1 2 3 4 5
t 1 x(k)

0
Example:
-1
SI 004
4 6 8 10 -1 0 1 2 3 4 5
t x(k) www.mechlab.cz 14
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Problem = noise: simple example study

Next, consider noise inside the system


which modifies the state of x(k). xk 1 axk w
Equation:
y k xk
This noise can be considered as a random
disturbance (input) influencing the system.
Using the simulation, we can observe, that the estimation of
parameter a is perfect.
12
10
10 10 % simulation
8 for i = 2:length(t)
8 8
6 x(i,1) = a*x(i-1) + randn*0.2;
6 6 y(i,1) = x(i) ;
4
4
4
end
x(k+1)

2
2
x

x(k+1)

2
0 0
0
-2 -2
-2
-4 -4

-6 -4
-6
Example:
-8
0 2 4 6 8 10
-6
-5 0 5 10
SI 004
t x(k)
0 2 4 6 8 10 -5 0 5 10 www.mechlab.cz 15
t x(k)
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Linear Models for System Identification

q = forward shift operator


e.g.: q-1 x(k) = x(k-1)

linear models = relation between y(),u(), and noise v(k) through


transfer functions
general form:

www.mechlab.cz 16
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Linear Models for System Identification

AR autoregressive model

MA moving average

example: smoothing

www.mechlab.cz 17
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Linear Models for System Identification
Very popular linear in parameters
OLS
ARMA

ARX

ARMAX

OE

Example: system completely deterministic,


BJ noise added only to output (e.g. position
sensor = potentiometer)

www.mechlab.cz 18
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Black-box identification
- the use of a tool System Identification/GUI
Robert Grepl
Institute of Solid Mechanics, Mechatronics and Biomechanics
Faculty of Mechanical Engineering, Brno University of Technology
2010 - 2015
System Identification Toolbox - GUI

System Identification Toolbox


very (very) complex tool, author L. Ljung
you can work using
command line
GUI
how to run it?: ident

www.mechlab.cz 20
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
System Identification Toolbox GUI: Import data

www.mechlab.cz 21
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
System Identification Toolbox GUI: Preprocessing

preprocessing of the data


check data
select estimation divide
and verification data Estimation and
Verification
data

Check
imported data

www.mechlab.cz 22
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
System Identification Toolbox GUI: Select data

Select data for Estimation and for Verification

Data for
estimation

Data for
verification

www.mechlab.cz 23
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
System Identification Toolbox GUI:
Estimate order of the system
Example:
You can estimate ARX
several ARX models at
once.
Think about noise...

Example:
OE
www.mechlab.cz 24
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Exercise

S005

www.mechlab.cz 25
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Dodatky

Offline vs. online odhad parametr


IV (Instrumental variable) method
Nelinern nejmen tverce

www.mechlab.cz 34
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Offline vs. online odhad parametr

batch estimation
measurement in time (0,T)
data processing
parameter estimation using all data
online estimation
parameter estimation during system operation
recursive algorithm
advantages:
memory requirements (often) reduced OLS vs. RLS
the slow changes of parameters can be captured

www.mechlab.cz 35
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Recursive Least Squares (RLS) (Plackett's algorithm)

online estimation
gives identical result as OLS

assume model

in matrix form:

www.mechlab.cz 36
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
OLS & RLS example:
Estimation of mass+spring+damper system 3/3

Solve LS/RLS problem


both LS and RLS provide the same results
convergence of RLS/precision of LS depends on excitation signal
Oscilator position
10
continuous sim
0 ARX sim
{E003} -10
0 2 4 6 8 10
t [s]
Input excitation force [N]
50
input u

No noise considered in our 0


simulation! -50
0 2 4 6 8 10
t [s]
convergence of Recursive LS (RLS)
2
a1
0 a2
b2
-2
0 2 4 6 8 10
t [s] www.mechlab.cz 37
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
OLS & RLS example:
Estimation of mass+spring+damper system with noise

Assume noise added to measurement (e.g. if potentiometer used)


noise_stdvar = 0.1;
(later, we name this noise model Output Error = OE model)
Oscilator position
2
0
-2
-4
-6
{E003} 5.5 6 6.5 7 7.5continuous8sim
t [s] ARX sim
Input excitation force [N]
50
input u

-50
0 2 4 6 8 10a1
t [s] a2
convergence of Recursive LS (RLS) b2
2
1
0
-1
0 2 4 6 8 10
t [s]
www.mechlab.cz 38
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Estimation of OE: Instrumental Variable (IV) Method

solution for consistency problem


1. Estimate ARX
2. Simulate model with estimated parameters
3. Create instrumental matrix Z

4. Estimate

repeat steps 2-4 (usually upto 3-4 steps) [E009]

www.mechlab.cz 39
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Nonlinear Least Squares 1/2

motivation: need to find parameters for functions which are


nonlinear in parameters
assume vector field
goal: minimize criterion

Taylor series

gradient:

www.mechlab.cz 40
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Nonlinear Least Squares 2/2

all NLS methods are iterative


methods for computation of h:
Steepest descent

Newtons method

Gauss-Newton

Levenberg-Marquardt

www.mechlab.cz 41
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Example NLS: Solution of overdetermined system

Assume vector field

clearly, the system is overdetermined


x = 1 / 0.4115
Task: Find solution which has minimal mean square error.
convergence of iteration method

0.8
values of x

0.6 LM lambda = 2
0.4 GN alpha = 0.5
solution of individual equations
0.2

0
0 2 4 6 8 10 12 14 16 18 20
[E002] iterations
Plot of square error
0.8
f21
0.6
f22
0.4
f21 + f22

0.2

0
0.4 0.5 0.6 0.7 0.8 0.9 1 1.1 1.2 1.3
variable x
www.mechlab.cz 42
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
References

[Iserman 2011] Isermann, R., Muenchhof, M.: Identification of Dynamics Systems,


Springer 2011
[Nelles, 2001] O. Nelles: Nonlinear system identification: from classical approaches to
neural networks and fuzzy models, Springer-Verlag, 2001
google books
[Noskievi, 1999] P. Noskievi: Modelovn a identifikace systm, Montanex, 1999
[Ljung 2008] L. Ljung: Perspectives on System Identification, Seoul 2008,
http://www.control.isy.liu.se/~ljung/
[Denery 2005] T. Denery: Modeling Mechanical, Electric and Hydraulic Systems in
Simulink, Matlab webinars, 2005
[Blaha] doc. Ing. Petr Blaha, PhD., FEKT, CAK
http://sites.google.com/site/modelovaniaidentifikace/
[Gander, 1980] Gander, W.: Algorithms for QR-Decomposition, research report, 1980
http://www.emeraldinsight.com/journals.htm?articleid=1943785&show=html
http://courses.ae.utexas.edu/ase463q/design_pages/fall02/AWE_web/secondorder.htm
http://www.ni.com/white-paper/4028/en/

www.mechlab.cz 43
ISMMB, Faculty of Mechanical Engineering, Brno University of Technology
Kontakt: www.mechlab.cz
stav mechaniky tles, mechatroniky a biomechaniky
Fakulta strojnho inenrstv
Vysok uen technick v Brn
doc. Ing. Robert Grepl, Ph.D.
grepl@fme.vutbr.cz

You might also like