Fachgebiet Systemanalyse Lecture Notes System Identification Summer Semester 2014 RCSE course Prof. Dr.-Ing. habil. Ch. Ament Date 03/2014 www.tu-ilmenau.de/systemanalyse TECHNISCHE UNIVERSITÄT ILMENAU Lecture „System Identification“ Prof. Dr.-Ing. Ch. Ament Page 0-1 0. Content 0 Content Basic methods 1 Introduction 2 Physical model approaches: White box models 3 General model approaches: Black box models 4 Parameter identification Experimental analysis 5 Design of experiment 6 Identification of signal models 7 Identification of continuous-time systems 8 Identification of discrete-time systems Online methods 9 Recursive parameter estimation 10 Kalman filtering Text books R. Isermann, M. Münchhof: Identification of Dynamic Systems – An Introduction with Applications, Springer, 2011 (93,80 €) L. Ljung: System Identification – Theory for the User, 2nd edition, Prentice Hall, 1998 (92 €) D. Simon: Optimal State Estimation – Kalman, H Infinity, and Nonlinear Approaches, Wiley, 2006 (112 €) Lecture „System Identification“ Prof. Dr.-Ing. Ch. Ament Page 1-1 1. Introduction 1 Introduction 1.1 Motivation For which purposes do we need models of technical processes? Analysis of a system (stability, time constants, etc.) Prediction of system behavior (by numerical simulation) Controller design Diagnosis and monitoring Optimization of system design 1.2 Models Definition A mathematical model is a description of a system using mathematical concepts and language. […] Mathematical models are used not only in the natural sciences (such as physics, biology, earth science, meteorology) and engineering disciplines (e.g. computer science, artificial intelligence), but also in the social sciences (such as economics, psychology, sociology and political science); physicists, engineers, statisticians, operations research analysts and economists use mathematical models most extensively. A model may help to explain a system and to study the effects of different components, and to make predictions about behaviour. [Wikipedia] Classification by the type of mapping Physical models Conceptual models are down-scaled or simplified physical realizations of the real system, e.g. architectural models, or rapid prototyping components. exist only in our mind, e.g. describing a system by mathematical equations or by a theoretical structure. Classification by the type of description White box models Black box models describe a system by causally determined relations. Such an analytical description is derived from physical laws („first principles“) and is mostly the result of theoretical modelling. characterize the relation of inputs and outputs in a descriptive way. General model approaches or non-parametric models are used as a result of experimental modeling. Also mixed models are used; they can be addressed as grey box models. Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 1-2 1. Introduction Parame etric models s Non--parametric c models are built from a strructured model approa ach and a finite numbe er of model parameterrs, which q quantify the e model app proach. Com mpared to o non-parametric mod dels these models achieve a more m compact represe entation. do not have a certain c struccture and characc teriz ze the syste em by data that is rece eived from m measurem ment, e.g. a step respo onse. In prrinciple they y have an i nfinite num mber of parameters. 1.3 M Modelling Definitio ons The pro ocess of dev veloping a mathematic m cal model is s termed mathematica al modelling g. [Wikipe edia]. The field of system m identification uses sstatistical methods m to build mathe ematical models m of dynamical systems from me easured datta. System identification also in cludes the optimal design o of experime ents for effficiently gen nerating infformative data for fittiing such models as well as model redu uction. [Wik kipedia] The mo odeling proc cess Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Modelin ng strategie es Page 1-3 1. Introduction Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 2-1 2. White bo ox models 2 Ph hysical model approac a ches: White W bo ox mod dels 2.1 B Balance eq quations Balancin ng a conserrved quantiity over tim me is a very y universal modelling m p principle, which can be applied e.g. forr process pla ants or biollogical syste ems. The con nserved qua antity m is balanced w within a spec cified volum me : The balance equattion in integ gral form is: t m(t ) m(0) q zu ( ) qab ( ) p( ) d 0 The balance equattion in differrential form m is: (t ) q zu (t ) qab (t ) p(t ) m Typical conserved quantities are: a Mass or vollume Energy Number of cells Electrical ch harge Momentum m For each volume we obtain one first order linear differential equation. Lecture „System Identification“ Prof. Dr.-Ing. Ch. Ament Page 2-2 2. White box models 2.2 Electrical systems Equations of RLC Networks Kirchhoff voltage law: u (t ) 0 j j Kirchhoff current law: i j (t ) 0 j Current voltage relation of network elements: Element Current voltage relation (time domain) u(t ) R i(t ) Resistance R Capacitor C 1 u(t ) C Inductor L t Ohm’s law (frequency domain) U(s) R I(s) 1 I(s) sC i( ) d U(s) di(t ) dt U(s) s L I(s) 0 u(t ) L The general Ohm’s law with impedance Z(s) is: U(s) Z(s) I(s) Mesh current analysis of RCL Networks 1. If applicable, current sources have to be transformed to voltage sources. 2. Plot the network graph. Select a tree out of this graph. Definitions: Nodes correspond to the connecting wires, edges to the devices. A closed loop within the graph is called a mesh. A tree connects all nodes of a graph without any meshes. 3. Introduce currents Ii with i=1,...,n in all edges of the graph that do not belong to the tree. Lecture „System Identification“ Prof. Dr.-Ing. Ch. Ament Page 2-3 2. White box models 4. The system of equations is: Z11 Z12 Z1n I1 U1 Z21 Z22 Z2n I2 U2 Z n1 Z n2 Z nn I n U n I U Z Z impedance matrix of the system with the main diagonal elements Zii and all other elements Zik: Zik : Impedance that is passed by Ii and Ik commonly. If the direction of both currents is similar use positive sign, otherwise negative sign. Zii : Sum of all impedances along mesh i I vector of currents Ii : Current of mesh i (with i=1,...,n) U vector of voltage sources Ui : Sum of independent voltage sources in mesh i. If the voltage source supports the mesh current, use positive sign. 2.3 Modeling analogies The analysis of systems with lumped elements (devices) can be generalized. For its characterization two complementary variables are used: Flow q(t): The flow is passing a network device and can be measured within the device. Due to the Kirchhoff current law the sum of all currents in relation to a network node is zero. Potential V(t): The potential is assigned to the connectors of a network device; a potential difference can be measured between two connectors. Due to the Kirchhoff voltage law the sum of potential differences within a network mesh is zero. A generalized Ohm’s law characterizes the relation of flow and potential difference regarding a lumped network element. Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 2-4 2. White bo ox models Applica ation in diffferent physical dom mains: Domain n Flow w q(t) Potential P (difference) ( V(t) Resistance Capacitor C (Storage ( of flow) f Inducto or (Storag ge of potentia al diff.) Electric cal system El. current I(t)) in A El. E voltage U(t) U in V El. res sistance R in V/A El. E capacitor C in F = As/V V uctor El. indu L in H = Vs/A Mechan nical system (transla atory) Forrce F(t)) in N Velocity V v(t) v in m/s Reciprrocal friction co onstant 1/k in m/Ns Mas M m in kg Recipro ocal spring constant c 1/c in m/N m Mechan nical system (rotatory) Torrque M(tt) in Nm Angular A velo ocity (t) in 1/s Reciprrocal friction co onstant 1/k in 1/Nms Moment M of inertia J in kg m2 Recipro ocal spring constant c 1/c in 1/Nm 1 Pneuma atic system s flow Mas (tt ) in kg/s m Pressure P Pneum matic rep(t) p in Pa= N N/m2 sistance in 1/m ms Storage S of m mas in kg m2/N – Therma al system Hea at flow Temperature T e q(t)) in W=J/s T(t) T in K, °C Thermal T capacity c in Ws/K – Therm mal resista ance in K/W W The pro oduct of flow w and poten ntial (differe ence) is usually a pow wer: P(t) = q q(t) V(t) Examp ple: Pneum matic syste em In the following a pneumatic c system ( including a supply pipe, a valve e and a pn neumatic muscle)) is describe ed using ele ectrical sym mbols: 2.4 B Block diag gram Advanta ages of bloc ck diagrams s: C Clear graph hical representation. Model imple ementation can be don ne step by step. S Substructurres may he elp to make it clearer. W Within a project blocks s can be ex xchanged ea asily. Numerical simulations s can be carrried out ba ased on bloc ck diagramss ((e.g. by Sim mulink) Lecture „System Identification“ Prof. Dr.-Ing. Ch. Ament Page 2-5 2. White box models C-Code can be generated from block diagrams. Classification: Object orientated modeling: Nodes are physical components; edges are physical interactions between these components. Description is close to physical reality. Causal modeling: Nodes are transfer functions; edges are signals. Useful for system analysis. Software: e.g. Matlab/Simulink Software: e.g. Modelica/Dymola 2.5 State space description The state of a dynamical system at time t is completely characterized by a set of states x1(t), … xn(t). These states are summarized as state vector x(t). System dynamics is defined by the state differential equation. It describes the change of states in time x (t ) as a function of the current state x(t) and the system’s input u(t). It is a system of first-order differential equations. Measurable outputs are summarized as output vector y(t). The output equation defines y(t) based on the current state x(t) and (in rare cases) the system’s input u(t). The output equation is an algebraic equation. System description State differential equation: Output equation: x (t ) f x(t ), u(t ) y(t) gx(t), u(t ) with the following variables: State vector x1 (t ) x 2 (t ) x(t ) x n (t ) with n: Number of states Input vector u1(t) u(t ) u m (t ) with m: Number of inputs y 1(t) Output vector y(t ) y p (t ) with p: Number of outputs Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 3-1 3. Black bo ox models 3 Ge eneral model m approac a ches: Bllack box x mode els If no ph hysical laws s (first princ ciples) are available or their deriv vation is to oo time-con nsuming, we can use genera al (nonphys sical) mode el approach hes. They describe the e input outp put relation of tthe real pro ocess. In th he following g commonly y used gene eral model approaches will be presentted. The mo odel parame eters have no n physical interpretattion. They are a unknow wn at that point and have to o be identifie ed based on n measurem ment (see chapter c 4). 3.1 Lo ook-up ta able mode els Look-up p tables deffine a functtional relatiion by sam mpling the whole w range e of an inpu ut u and storing the corresponding va alues for th he output ŷ explicitly. This migh ht be a sim mple and useful m method to map m e.g. a calibration curve. It can b be considere ed as a non n-parametriic model (se ee chapter 1). Examp ple of a loo ok-up table e model Resistan nce values of a PT100 sensor as a function of o temperatture [from w www.pt100 0.de]: ples for a graphical g representa r ation of mo odels: Examp 1. Pneumatic muscle: Functional rellation of mu uscle air pressure and muscle con ntracttion h to the resulting muscle forrce F. Data sheet of the pneumatiic muscle with w 20 mm diam meter from m Festo: Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 3-2 3. Black bo ox models 2. Performanc ce diagram of a combu ustion engin ne: Function nal relation n of motor speed s a and specific c motor work to motorr consumpttion: 3.2 Polynomia al models Approac ch for a sys stem with single s inputt (m=1) an nd single ou utput (SISO O system) with the order n of the poly ynomial app proach: ŷ a0 a1 u a 2 u 2 a n u n n ai u i i 0 uts (m>1), and single output (MIISO system Approac ch for a sys stem with multiple m inpu m): m ŷ a0 j 1 m ai u j m a j 1 k 1 j, k u j uk Lecture „System Identification“ Prof. Dr.-Ing. Ch. Ament Page 3-3 3. Black box models The output ŷ of this approach is a nonlinear function of the input in case n>1. Hence, nonlinear input output relations can be describes with this model approach. On the other hand, output ŷ is a linear function of the model parameters ai, which will be turn out to be a major advantage in the following chapter 4. 2 2 1 1 0 0 y y An unknown function can be characterized by a polynomial approach throughout its whole input range. But, local aberration can be characterized only insufficiently. Moreover, it cannot be expected to obtain good extrapolation properties as the following example will illustrate [from Nelles: Nonlinear System Identification]. A sin function is approximated by a polynomial approach with n=5 (left) und n=15 (right). -1 -1 -2 -2 0 2 4 6 8 -2 -2 0 2 4 6 8 u u 3.3 Radial basis function models A radial basis function approximates a given system within a local area of the input space that is defined by the input u. For the description of the entire input space multiple of these local descriptions are superimposed. Suitable radial basis functions have the following properties: The functional values are non-negative. It has a maximum value in the centroid point u0. With increasing distance to the centroid u0 the functional values are monotonically decreasing. The following figure shows two commonly used radial basis functions. In the upper part the one-dimensional case is shown. The bell-shaped Gaussian function 1 2 1 ˆ (u) e 2 y with u u0 is continuously differentiable, whereas the triangular function 1 ˆ (u) 1 y 0 1 u u0 with u0 u u0 2 2 1 u u0 with für u0 2 u u0 2 otherwise Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 3-4 3. Black bo ox models is not d differentiable in the co orner pointss. In both functions, f parameter p defines th he width of the b basis functio on. In the lower part of the figu ure the exttension for the two-dimensional case is plo otted for both rad dial basis fu unctions. In orde er to approx ximate a fu unctional re elation, mu ultiple radia al basis fun nctions i with w i = 1,…,n w will be supe erimposed. Each basiss function has h a differe ent centroid d u0,i and is scaled with a w weighing factor ai: n ŷ a i i (u) i 1 This app proach is able to describe a nonliinear function relations s between tthe input u and the output ŷ . Similar to the poly ynomial app proach in se ection 3.2 the model o output ŷ is a linear function n of the mo odel parame eters. Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 3-5 3. Black bo ox models As an e example, the following figure show ws the superposition of o a functio on (red line) by five triangullar radial ba asis functions (dashed blue lines)). 3.4 N Neural nettworks Artificia al neural networks are an abstracction of biolo ogical neural networkss. They are used to obtain a parallel and meshed d approach to the mod deling of te echnical pro ocesses. This architecture can also be b implemented and e evaluated in n parallel, which w can b be advanta ageous if subsysttems fail. Then, T the model m beha aves more robust suc ch that the basic func ction remains a available in most cases s, although the overalll performan nce is reducced. In the ffollowing, a very comm mon netwo ork architec cture is introduced, in which the neurons are arra anged in la ayers that do not of any feedba acks. It is called mult lti layer perrceptron (MLP) o or feed forw ward networrk. Neuron ns The inp puts u1,…,um at the ne euron j are weighed with w the nettwork weig hts wj,1,…,w wj,m. Together w with the bia as bj they are a summe ed up to the e signal xj, which is th he input of the t activation ffunction f. [see [ also Ma atlab, Neurral Network Toolbox, User’s U Guide e]: The fun nction f can be a nonlinear function, in man ny cases fun nctions are used that model a thresho old as 1 . f (x x ) tanh( x ) oder f ( x ) 1 ex Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 3-6 3. Black bo ox models Especially in the la ast layer of a network a linear fun nction f(x) = x may be e used. Intrroducing an input vector u u1 u m T and a vector of weights w w j w j ,1 w j , m T this rela- tion can n be written n as a comp pact equatio on: T y j f (w j u b j ) Layers A layer is built up out of n neurons in pa arallel. With h the bias vector b b1 bn T and the T matrix of network k weights W w1 w nT the functional f relation r forr the vectorr of outT e written as: puts y y1 y n T can be y f (W u b) The following figurres show th he block dia agram of on ne layer – on o the rightt hand side e using n single n neurons, on the right hand h side ussing vectorr signals: Multi L Layer Perce eptron (ML LP) A typica al MLP cons sists of two layers: Forr the first la ayer a nonlinear activa tion functio on f (1), for the second laye er a linear activation a fu unction f (2) is used: Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 3-7 3. Black bo ox models The corrresponding g functional relation is: y f (2) W (2) f (1) (W (1) (1) ub (2) )b Parame eters of this s model approach are the netwo ork weights W(.) and t he bias vallues b(.). They ca an be obtaiined from a nonlinearr parameter optimizattion that wiill be introd duced in the nex xt chapter 5. 5 3.5 Ex xtension to dynam mical mod dels The mo odel approaches presented in thiss section arre static approaches. IIn order to characterize d dynamical systems, s ex xternal dyna amics (as a “memory”) has to b be added. For F timediscrete e systems this t can be e realized b by storing passed p valu ues of the input u(k) and the output y y(k) in a de elay line: Hence, the static model m approaches can n be used again. But, the t length o of the delay y lines n and m a ave to be defined as well as the t sample e time T ha d in an a appropriiate way, such that the dyn namical prop perties are included an nd the num mber of (n+m m+1) inputts is not too o high. Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 4-1 4. Parrameter iden ntification 4 Pa aramete er identtificatio on 4.1 Problem definition The rea al system is defined by y a set of pa arameter, which w is sum mmarized in n a parame eter vector x p . For the ide entification of this set o of parameter, a mode el is built in parallel to the real a estimatiion x̂ p of tthese param meters. The e measured d values y(tt) of the system that uses an ˆ(t , x ˆ p ) of the model and real sys stem is co ompared with the outtput y d the output error ˆ p ) is determ ey (t , x mined. ˆ p ) will assess th An obje ect function n J( x he output error e within n a time in nterval. Usu ually the object ffunction is defined suc ch that its value will increase, iff the outpu ut error rise es. Now, ˆ p ) as a optimiza ation methods are req quired in orrder to min nimize the objective fu unction J(x x function n of the mo odel parameters x̂ p an d to adapt the model behavior tto the real system. Hence, the problem m of param meter identiffication is converted in nto an optim mization pro oblem. Block d diagram: In princ ciple the ob bjective function can b be defined independen i ntly in differrent ways. In most cases th he squared output erro or is integra ated over a time interv val T: T ˆ p ) : e 2 (t , x ˆ p ) dt J(x 0 Lecture „System Identification“ Prof. Dr.-Ing. Ch. Ament Page 4-2 4. Parameter identification 4.2 Direct optimization Linear parameter estimation It is assumed that the output y is a linear function of the unknown parameter vector x p : T y(t , x p ) c (t ) x p The model is defined in the same way: ˆ(t , x ˆ p ) c T (t ) x ˆp y Hence, the output error between the model ŷ and the real measurement y is: T ˆ p ) y(t ) y ˆ(t , x ˆ p ) y(t ) c (t ) x ˆp ey (t , x A set of measurements with k = 1,...,N is obtained and summarized as vectors: e(t1 , x ˆp ) y ( t1 ) ˆp ) e y (x , y , e(t N , x y (t N ) ˆ p ) c T (t 1 ) c T (t ) N Then, we can write the output error for all N measurements as: ˆp ) y x ˆp e y (x As objective function J the sum of the squared errors T ˆ p ) e y (x ˆ p ) e y (x ˆp ) J(x has to be minimized. It is also called “least square error” (Carl Friedrich Gauß: „Methode der kleinsten Quadrate“). The solution for the optimal parameter vector x̂ p is: ˆ p T x T 1 T y The system will be called identifiable, if is regular. If this is not the case, it might be that not enough measurements or only very similar measurements are available. Lecture „„System Identification“ Prof. Dr.-Ing. Ch. Am ment Page 4-3 4. Parrameter iden ntification Examp ple: Parameter identtification o of a vehicle e with constant acce eleration A vehicle with an unknown mass m m will be accelerrated with a constant force F0 sta arting at t = 0: F (t ) F0 (t ) with h F0 4 e vehicle position y(tk) is measure ed: At the ttimes tk the k 1 2 3 4 5 tk 5,0 6,0 7,0 8,0 9,0 y(tk) 0,2 1,2 3,0 4,8 7,1 For mod deling Newton’s law F (t ) m y((t ) can be applied. Initially the v vehicle is lo ocated in y(0) 0 . The unkn nown mass s m and the e unknown initial vehic cle velocity y (0) v 0 sh hould be determiined by parrameter identification. In the ffigure below w the mode el output ŷ (as solid line) and the measured d values (a as crossmarks) are plotted d. Lecture „System Identification“ Prof. Dr.-Ing. Ch. Ament Page 4-4 4. Parameter identification 4.3 Recursive Solution In order to obtain the direct solution for x̂ p as shown in section 4.2, the measurement of all samples in x̂ p has to be completed. This is no problem, if parameter optimization can ˆ p (k ) each time, be done offline. But, if we need an update of the identified parameter x when a new measurement y(k) is available a recursive solution would be more appropriate – which should be also called an online parameter identification. Recursive algorithm Initial step in k=0: Define ˆ p (0 ), P (0 ) x ˆ p (0 ) , matrix P (0 ) should If we have no information about the initial parameter vector x be chosen as a “large” positive definite matrix, e.g. P (0 ) 10 10 I . Recursive step from k to k+1: P (k ) c(k 1) 1. Step: K (k 1) 2. Step: ˆ p (k 1) x ˆ p (k ) K (k 1) y(k 1) c T (k 1) x ˆ p (k ) x 3. Step: P (k 1) I K (k 1)c (k 1) P (k ) T 1 c (k 1)P (k ) c(k 1) T T ˆ p ) e y (x ˆ p ) e y (x ˆ p ) (as in section 4.2). This will minimize the objective function J(x Recursive algorithm with fading memory In case of time-varying processes, it is appropriate to introduce time-depending weighing factors. A weighing factor with exponential forgetting will discount the weights for past measurements. Introducing a forgetting factor 0 1 (e.g. 0,99 ) the object function can be modified: T ˆ p ) e y (x ˆ p ) Q e y (x ˆp ) J(x Q diag(N 1 , 2 , , 1) with Modified recursive step from k to k+1: P (k ) c(k 1) 1. Step: K (k 1) 2. Step: ˆ p (k 1) x ˆ p (k ) K (k 1) y(k 1) c T (k 1) x ˆ p (k ) x 3. Step: P(k 1) T c (k 1)P (k ) c(k 1) 1 I K(k 1)c T (k 1) P(k )