1 © 2012 the mathworks, inc. introduction to system identification lennart ljung april 4, 2012 t...

24
1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 4 3 2 2 s s s t y(t) Data to Model

Upload: quincy-rider

Post on 15-Dec-2015

222 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

1© 2012 The MathWorks, Inc.

Introduction to System Identification

Lennart Ljung

April 4, 2012

43

22

ss

st

y(t

)

Data to Model

Page 2: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

2

Modeling Dynamic Systems

Data-Driven ModelingFirst-Principles Modeling

SimscapeSimMechanicsSimHydraulics

SimPowerSystemsSimDriveline

SimElectronicsAerospace BlocksetSimulink

Tools for Modeling Dynamic Systems

Modeling Approaches

Neural NetworkToolbox

SimulinkDesign

Optimization

SystemIdentification

Toolbox

Page 3: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

3

The System

ruddersaileronthrust

velocitypitch angle

Input Output

Page 4: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

4

The Model

ruddersaileronthrust

velocitypitch angle

Input Outputu y

u, y: measured time or frequency domain signals

Page 5: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

5

The System and the Model

System

Model

+

-Minimize

errorMeasured input

Page 6: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

6

Fitting and Comparing Models

Core feature: Estimating models by tuning its parameters such that model outputs is close to measured output

COMPARE function:• Plots measured and model output curves together

• Shows a numerical measure of fit: the percent of the output variation reproduced by the model

DEMO: Model for data collected from a hair dryerInput signal: heating powerOutput signal: air temperature

Page 7: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

7

Estimation and Validation Go Together

A large enough model can reproduce a measured output arbitrarily well. We must verify that model is relevant for other data – data that was not used for estimation, but was collected for the same system.

Err

or

Number of parameters

Estimation data

Validation dataDEMO: “Validate” the hair-dryer models on new data set

Page 8: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

8

Process of Building Models from Data

Gather experimental data

Estimate model from data– Select a structure

– Find a model in it

Validate model with independent data

Input data Output dataReal System

Gather Sets of Experimental Data

Input data

Outut data

Estimated SystemSystem Identification Toolbox

Estimate Mathematical Model of System

Input data

Validate Mathematical Model of System

Estimated System

Real System

Compare Real and Estimated

Outputs

Page 9: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

13

The Identification Process

Collect the input-output data

Select a model structure

Find best model in a structure

Evaluate the resulting model

Page 10: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

15

Model Structures in System Identification Tool (GUI) IDENT

• Linear Parametric Models Input-Output models (transfer functions) State-space models

• Linear Nonparametric models• Impulse response model IMPULSE, STEP

• Frequency Response SPA, SPAFDR, ETFE

• Process Models PEM

• Nonlinear Models NLARX, NLHW

Page 11: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

16

Transfer Functions and State Space Models

Linear models are typically described by state-space models IDSS (SSST) or transfer functions IDTF (TFEST)

State-space

Number of states: n

𝑥ሺ𝑡+ 1ሻ= 𝐴𝑥ሺ𝑡ሻ+ 𝐵𝑢(𝑡) 𝑦ሺ𝑡ሻ= 𝐶𝑥ሺ𝑡ሻ

Both are just ways of writing a linear differential equation for relationship between input (u) and output (y) (take n=1)𝑦ሺ𝑡+ 1ሻ= 𝐶𝑥ሺ𝑡+ 1ሻ= 𝐶𝐴𝑥ሺ𝑡ሻ+ 𝐶𝐵𝑢ሺ𝑡ሻ= 𝐴𝑦ሺ𝑡ሻ+ 𝐶𝐵 𝑢(𝑡)

𝑌ሺ𝑧ሻ= 𝐶𝐵ሺ𝑧− 1ሻ𝐴𝑈(𝑧)

Transfer function

B-order: nb (zeros)F-order: nf (poles)

𝑌ሺ𝑧ሻ= 𝐵(𝑧)𝐹(𝑧) 𝑈(𝑧)

Page 12: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

17

Delays in TF and SS models

There could also be a delay (dead time) in the system: It takes nk samples before a change in u is visible in y.

y

u

nk

time

𝑦ሺ𝑡ሻ= 𝐶𝑥ሺ𝑡ሻ 𝑥ሺ𝑡+ 1ሻ= 𝐴𝑥ሺ𝑡ሻ+ 𝐵𝑢ሺ𝑡− 𝑛𝑘ሻ

𝑌ሺ𝑧ሻ= 𝐵(𝑧)𝐹(𝑧) 𝑧−𝑛𝑘𝑈(𝑧)

state space

transfer function

Linear parametric model structures are characterized by a few integers: n, or (np nz) and nk.

Commands such as n4sid, ssest, tfest use these integers to “create” models from data.

Page 13: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

18

Handling Disturbance

Knowledge of nature of disturbance is useful:– Essential for predicting future system outputs, by

understanding correlations between disturbances Handling technique for identification: treat a disturbance

source e as an extra unmeasured input.

e is not measured; its properties (white noise) are characterized statistically – mean, covariance

systemu y

input output

e: disturbance source

𝑌ሺ𝑧ሻ= 𝐵ሺ𝑧ሻ𝐹ሺ𝑧ሻ𝑈ሺ𝑧ሻ+ 𝐶ሺ𝑧ሻ𝐷ሺ𝑧ሻ𝐸(𝑧)

𝑥ሺ𝑡+ 1ሻ= 𝐴𝑥ሺ𝑡ሻ+ 𝐵𝑢ሺ𝑡ሻ+ 𝐾𝑒(𝑡)

𝑦ሺ𝑡ሻ= 𝐶𝑥ሺ𝑡ሻ+ 𝑒(𝑡)

state spacetransfer function

DEMO: Models with disturbance component for hair-dryer data.

Page 14: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

19

Non-Parametric Methods

Linear systems can also be described by non-parametric models that is curves that capture the system properties:– Transient responses

– Frequency response They can be estimated directly from data Often useful to take a first look at these before

parametric model estimation to get a feel for system’s basic properties.

Page 15: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

20

Transient Response

A system’s transient response is its output to a transient like an impulse or step in its input.

Can be found by special experimentation with such inputs

For an existing model, its transient response is obtained by simulation with such inputs. IMPULSE, SIM, STEP

Estimation: From experimental input/output data, transient response is typically estimated via a flexible (high order) linear model.

systemu y

Page 16: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

21

Frequency Response

A system’s frequency response H(ω) is its response to a sinusoidal input sin(ωt). The output has same frequency ω but a different amplitude and a phase shift y(t) = A(ω) sin(ωt+ϕ(ω))

Plotting A(ω) and ϕ(ω) vs. ω gives Bode plot. Can be found experimentally by subjecting the system to sinusoidal inputs of

various frequencies. For an existing model, it is obtained from the z- or Laplace transform of the

transfer function using z = exp(jωTs) or s = jω.

Estimation: From experimental input-output data, it may be estimated directly by using various Fourier-transform inspired techniques. SPA, SPAFDR, ETFE

systemu y

𝐻ሺ𝜔ሻ= 𝐵(𝑒𝑖𝜔𝑇𝑠)𝐹(𝑒𝑖𝜔𝑇𝑠)

DEMO: Direct frequency and transient response estimation for dryer data

Page 17: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

22

Process Models

Use a combination of gain (K), delay (Td) and one or more time constants (T) to describe the model.

Such forms are popular in process industry, hence called “process models”. IDPROC

Can be expanded to contain more poles, zeros and integrators.

Structure choices: – number/nature of poles

– whether a delay element, a zero and/or an integrator should be included.

𝑌ሺ𝑠ሻ= 𝐾𝑒−𝑠𝑇𝑑1+ 𝑠𝑇𝑈(𝑠)

Page 18: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

23

Use of Disturbance Model for Simulation and Prediction

Measured outputs contain disturbances. If there is a correlation between disturbances it is possible to better predict the future outputs from observing the past ones.

DEMO: Models with disturbance component for hair-dryer data.

Page 19: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

24

Residual Analysis

DEMO: Residual analysis on hair-dryer models

System

Model

+

-

errorinput e(t)

t

acceptable

Whiteness TestIndependence Test

Residuals = ”Leftovers” = 1-step-ahead prediction errors

Check correlation functions!

Should be uncorr-elated with known things

Page 20: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

26

Putting the Model to Work

Use them for understanding a system’s behavior, and predicting future response of a system

Import estimated models into Simulink using dedicated blocks for simulation and code generation

Controller design: Import into SISOTOOL and MPC design task

Page 21: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

27

Simplifying Complex Systems

Data Model

uy

• Simplify complex Simulink model using simulation data.

• Use Identified model to describe a component of a larger system

Page 22: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

28

Using Models for Control System Design

Dynamic Model

P + ∆P

Current Position

Noise Model

NPosition Error Control

Estimate plant with parameter uncertainties

Estimate noise model

ControllerControl System ToolboxSimulink Control DesignRobust Control ToolboxModel Predictive Control Toolbox

System Identification Toolbox

Page 23: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

29

More Information

Product page on mathworks.com:

http://www.mathworks.com/products/sysid/– Reach demos, webinars and documentation from here

Tech Support: http://www.mathworks.com/support/ Textbooks

– System Identification – Theory for the User, Lennart Ljung

– System Identification – A frequency domain approach, Rik Pintelon, Johan Schoukens

– Others…

Page 24: 1 © 2012 The MathWorks, Inc. Introduction to System Identification Lennart Ljung April 4, 2012 t y(t) Data to Model

30

Residual Analysis

Technique for validating a model’s quality. Works by analyzing the residues which are differences

between model’s response and measured values:

where is the model’s best prediction of y(t) made at time t-1.

ε(t) should ideally be uncorrelated with information known at time t-1. Hence we test correlation between ε(t1) and u(t2) and also between ε(t1) and ε(t2), t1≠ t2

𝜖ሺ𝑡ሻ= 𝑦ሺ𝑡ሻ− 𝑦ො��(𝑡|𝑡− 1)