Nonlinear Model Structure Identification Using ... - Semantic Scholar

4 downloads 0 Views 116KB Size Report
Terminal node. Non-Terminal node. Figure 1 Structure of genetic programming tree showing function y = √h1 + (u−1). In this paper, a method of genetic ...
Nonlinear Model Structure Identification Using Genetic Programming Gary J. Gray

David J. Murray-Smith

Yun Li

Ken C. Sharman

Centre for Systems & Control Dept. Elect. & E. Engineering University of Glasgow Glasgow, Scotland G12 8LT [email protected]

Centre for Systems & Control Dept. Elect. & E. Engineering University of Glasgow Glasgow, Scotland G12 8LT [email protected]

Centre for Systems & Control Dept. Elect. & E. Engineering University of Glasgow Glasgow, Scotland G12 8LT [email protected]

Centre for Systems & Control Dept. Elect. & E. Engineering University of Glasgow Glasgow, Scotland G12 8LT [email protected]

ABSTRACT Genetic programming can be used to evolve an algebraic expression as part of an equation representing measured input-output response data. Parts of the nonlinear differential equations describing a dynamic system are identified along with their numerical parameters using genetic programming. The results of several such optimisations are analysed to produce a nonlinear physical representation of the dynamic system. This method is applied to the identification of fluid flow through pipes in a coupled water tank system. A representative nonlinear model is identified.

1.

Introduction

Identification of nonlinear physical models presents many problems since both the structure and parameters of the physical model must be determined. Many existing system identification methods are based on parametric identification. Structure determination often uses a trial and error approach to test candidate model structures. Possible structures are deduced from engineering knowledge of the system and the parameters of these models are estimated. The resulting model performance is compared with experimental data from available measured quantities and with other model structures. It would be more efficient to be able to use an optimisation method to automatically determine the structure of the physical model. This paper reports an automatic procedure which can identify nonlinear structure components of a continuous time dynamic model from experimental data. Genetic Programming (GP) (Koza, 1992) can be used to evolve algebraic expressions from a database of nonlinear algebraic functional elements. Indeed, this is one of the main

application areas of genetic programming. Genetic programming has been applied to the development of signal processing algorithms (Sharman, Esparcia & Li, 1995) and to the identification of chemical processes (Bettenhausen et al., 1995). It allows optimisation of a tree structure representation of a symbolic expression. This tree structure is of variable length and is constructed of nodes. These nodes can be terminal nodes signifying an input or a constant, or functions performing some action on one or more signals within the structure to produce an output signal. An example of such a tree structure is shown in Figure 1. The terminal nodes in this case are system inputs and states and the non-terminal nodes are functions which could be found in a nonlinear description of a dynamic system. The program selects candidate terms from a library to build such trees which are then evaluated as algebraic expressions to give some fitness function defining the quality of the model with respect to experimental data. There is a population of such trees which evolves through crossover, selection and mutation towards an optimum structure. Genetic programming is not deterministic so it is likely that repreated runs will lead to different solutions. Analysis of a set of several runs is required to produce an expression for the structure of the model.

+

Terminal node

Non-Terminal node -

h1

u

1.0

Figure 1 Structure of genetic programming tree showing function y = √h1 + (u−1) In this paper, a method of genetic programming for structural modelling is described and applied to a coupled water tank system. The flow through the pipes within the system is identified and a representative nonlinear model deduced using this genetic programming approach.

2.

Method

2.1. Description Genetic programming may be used to identify an algebraic expression comprising some part of a set of nonlinear ordinary differential equations describing a dynamic system in the continuous time domain. Prior knowledge of the physical system is included in the set of differential equations. This expression could be the right hand side of a differential equation describing the behaviour of a system state or it could represent some other variable in the system such as friction or stiffness which forms part of another differential equation. The unknown dynamics evolve through the genetic programming as an algebraic expression which forms part of this set of ordinary differential equations. The genetic programming algorithm builds the models from a library of available functions. This function library is very important and should be flexible enough to be able to represent a wide range of systems but should not be so general as to facilitate the evolution of an empirical model. It can include the basic algebraic functions (+,-) as well as complex sub-functions representing some suspected dynamic characteristic of the system Each member of the genetic program population represents a candidate model for the system. It is necessary to evaluate each model and assign it some fitness value. The equation generated by the genetic programming is combined with the other equations describing the model and they are integrated using a numerical integration routine to produce a time response. This time response is compared with experimental data to give a fitness for that model. A sum of squared error function is used in this application. Terms with a numerical component (such as a gain) are estimated using a combination of Nelder-Simplex optimisation and simulated annealing (section 2.3). This parameter estimation phase can also be used to identify other numerical parameters in areas of the model where the structure is known but there are uncertainties about the parameter values. The sum of squared error value from the best parameter fit is used by the genetic programming algorithm to define the fitness of that specific function tree. After approximately 25 generations (normally within two hours on a Sun Sparc5 workstation for a two state nonlinear system and 400 data points), a solution symbolic expression tree evolves. This expression tree can be quite lengthy and complex but it usually contains a lot of redundant information. For example, a complete branch could be nullified by a gain of zero or by being subtracted from a copy of itself. After manual post-processing, the result is an algebraic expression describing the unmodelled part of the system with estimated values of any numerical parameters. The above optimisation is done several times. Even after simplification, it is not expected that each optimisation will

converge to the same solution. The algebraic expressions will look different and some will have better fitness values than others. Generally, however, each of the symbolic expressions will be a sum of terms and many of these terms will occur in most of the solutions. Moreover, these terms will often be the major contributors to the algebraic expression. In this way, examination of several solutions of the optimisation gives likely components of the nonlinear model of the system. More conventional modelling procedures can be used to further develop the model. 2.2. Genetic programming The genetic programming was done using a modified version of gpc++ (Fraser, 1994). This program is available on the internet and is written in C++ and was easy to modify to include the simulated annealing routine and the simulation program for the fitness function evaluation. Demetic populations were used because it was found that this reduced the likelihood of premature convergence to a less than optimal solution. Tournament selection was used with these populations. The mutation rate was 1%. A typical population size was 10 populations of 100 members each. Most of the execution time of the program is in the evaluation of the fitness functions. This is time consuming because it includes estimation of the numerical parameters. To speed up this process, each tree is stored in a linked list along with its fitness and before evaluation of a new tree the list is searched to see if its fitness has already been calculated. This seems to occur in about 25% of cases giving a substantial speed increase for the optimisation. 2.3. Parameter Estimation It is necessary to identify the numerical parameters of each nonlinear model before simulating it and evaluating its fitness. This must be done for every member of each population and therefore execution speed is very important. The models are randomly generated and will therefore contain linearly dependent parameters and parameters which have no effect on the output, so gradient based methods cannot be used. The method chosen was a combination of Nelder-Simplex and simulated annealing (Press et al 1992). Simulated annealing optimises by a method which is analogous to the cooling process of a metal. As a metal cools, the atoms organise themselves into an ordered minimum energy structure. The amount of vibration or movement in the atoms is dependent on temperature. As the temperature decreases, the movements, though still random, become smaller in amplitude and as long as the temperature decreases slowly enough, the atoms order themselves into the minimum energy structure. In simulated annealing, the parameters start off at some random value and they are allowed to change their values within the search space by an amount related to system temperature. If a parameter change improves overall fitness, it is accepted, if it reduces fitness it is accepted with a certain probability. The temperature decreases according to some pre-determined cooling schedule

and the parameter values should converge to some solution as the temperature drops. In this application, the simulated annealing process is combined with Nelder-simplex optimisation. The simplex is an (n+1) dimensional shape where n is the number of parameters. This simplex explores the search space slowly by changing its shape around the optimum solution. It closes in on the optimum of the function converging on the solution. The simulated annealing adds a random component and the temperature scheduling to the simplex algorithm thus improving the robustness of the method. If the system cools too fast, the parameters will not have time to adjust to their optimum and the optimisation will fail. If it cools too slowly, the optimisation will take longer to execute. The optimum cooling schedule depends on the number of parameters and the nature of the problem. For this problem, the cooling schedule varies according to the number of parameters being estimated. The temperature starts at 1.0 and reduces according to; (1) where np is the number of parameters. Four iterations are performed at each temperature until the temperature reaches 0.001.

3.

vi

H1 H2 Q v1 Q vo

Figure 2 Twin tank system It is known that for this system, the flow between the tanks and particularly in the output pipe is nonlinear and the main modelling error. If the connecting pipe and the output pipe are assumed to be orifices, Bernoulli’s theorem applies and the flow can be calculated thus, (4)

(5)

Example

The genetic programming structure identification technique was applied to the modelling of a coupled water tank system. As an example, a coupled water tank system (Murray-Smith 1995) is considered in this section. The system consists of two coupled water tanks with a connecting pipe between them, an input to the first tank, and an output pipe from the second tank. The system is nonlinear since even at the simplest approximation, the flow through the orifice varies as the square root of the water depth. The system is shown in Figure 2. The fluid flow in and out of the tanks is described by, (2)

(3)

where Qvi is the flow into tank one, Qv1 is the flow from tank one to tank two, and Qvo is the output flow from tank two. A1 and A2 are the cross-sectional areas of tanks one and two respectively. H1 is the depth of the water in tank one and H2 is the depth in tank two.

where cd1 and cd2 are empirical discharge coefficients for the connecting pipe and the output pipe respectively, a1 is the area of the orifice between tanks one and two and a2 is the area of the orifice out of tank two. While this approximation may be valid for the pipe connecting tanks one and two (it is 5.5mm long), it is known to be inaccurate for the outlet pipe from tank two (106mm long). The genetic programming was therefore configured to find an algebraic expression for the flow out of tank two. The discharge coefficient for the flow from tank one to two, cd1, was estimated using the Nelder-simplex simulated annealing routine as part of the optimisation. Initial genetic programming runs with a general arithmetic library including xn where n was identified, resulted in empirical models which fit the data set used for the identification but had no physical significance and did not fit other validation data sets. A function library with more relevance to the physical dynamics of flow was required. Incompressible fluid flow can exist in two forms laminar and turbulent. Both these forms are nonlinear and a system of equations has to be solved to calculate the flow rate for any particular pipe, environmental conditions, and pressure difference. The Darcy-Weisbach equation for frictionally resisted flow through a straight pipe is; where H is the head difference, f is the Fanning friction factor (see equations (7), (8) and (9)), g is the acceleration due to gravity, L is the length of the pipe, D is the pipe

(6)

were the system input, the states, and 0 and 1. The genetic programming function library is shown in Table 1. 1

diameter, c is the average velocity in the pipe, Q is the flow rate and A is the cross-sectional area of the pipe. The friction factor depends on the type of flow. For laminar flow, the equation is; basis function

(7)

0.8

0.6

0.4

where the Reynolds number (NRE) is given by; 0.2

(8) 0

v is specific volume and µ is viscosity. For turbulent flow, the friction factor depends on the Reynolds number and the relative roughness (ε/D) of the tube. The Colebrook-White equation is solved to give f;

0.05

0.15 0.2 h2 (scheduling variable)

0.25

0.3

Figure 3 Basis function of h2 for a centre point of 0.06 and a width of 0.07 Table 1 Function library for genetic programming structure estimation routine.

(9) Whether flow is laminar or turbulent depends on the Reynolds number. But there is a crucial regime between laminar and turbulent flow where the flow can be a combination of these or one or the other (Thomas, 1995). The only variable in the water tank system is the pressure difference which is directly proportional to the depth difference of the water at either end of the pipe. The flow rate for every possible depth difference in this system was calculated by solving the equations ((6)-(9)) and stored in two look-up tables - one for laminar flow and one for turbulent. These look-up tables became non-terminal nodes for the genetic programming function library. They had one input - the depth variable used to determine the flow. The other non-terminal nodes included +, -, gain, time delay and square root. One additional non-terminal node was used. This was the basis function which is a Gaussian curve around a centre point with a certain width which depends on h2 (Figure 3). The basis value multiplies the input signal to generate an output. The nodes used in the genetic programming are listed in Table 1. The gain had an estimated parameter. The square root was included since it appears in the Bernoulli equation (Equation (4)). It was included in the genetic programming function set to allow the genetic programming to evolve certain dynamics for some values of H2 and different dynamics for others. Such a combination of weighted models is known as a local model network (Gray et al. 1996). This was not unreasonable since it is known that turbulent flow is more likely to occur at higher values of pressure differential. The terminal nodes

0.1

Function

inputs

parameters

+

2

0

-

2

0

gain

1

1

square root

1

0

basis function

1

2

laminar flow look-up

1

0

turbulent flow look-up

1

0

time delay

1

0

h1

-

0

h2

-

0

input

-

0

1.0

-

0

0.0

-

0

Non-terminal nodes

Terminal nodes

The population size was 1000 split into 10 demetic populations of 100. The mutation rate was 1%. The input signal was a binary signal so that different modes of the system would be excited and the complete operating range

This was done and a model for flow derived; (15) with a value for the discharge coefficient from tank one to tank two, cd1 of 0.75. This model was validated using additional data (Figure 4 and Figure 5). Validation system with real data :28−Jun−96, error=0.06383 0.3 tank 1 depth (m)

of H1 and H2 would be covered. The genetic programming allowed an expression for flow out of tank two to be developed, including numerical parameters estimated using the combined simplex- simulated annealing method. The expression was incorporated in a model description as part of a set of nonlinear ordinary differential equations which were numerically integrated over the experimental time range. The sum of the square of the error between predicted H2 and measured H2 was calculated for each simulation. A log function (Equation (10)) was used to convert this to a fitness function for the genetic programming. This conversion was used because the sum of square error function for integrated differential equations can cover a very wide range and the scaling was not important since a tournament based selection scheme was used.

0.2

0.1

0 0

50

(10)

100

150

200 250 time (seconds)

300

350

400

350

400

Validation system with real data :28−Jun−96, error=0.6447

Additional data sets were recorded for validation test of resulting models. The optimisation for the equation for flow from tank two and parameter cd1 was done four times. The resulting structure equations with their respective error norms were, (11)

tank 2 depth (m)

0.2 0.15 0.1 0.05 0 0

50

100

150

200 250 time (seconds)

300

Figure 4 Model of y=0.75lam(h2) for different data set Validation system with real data :28−Jun−96, error=0.3803

(12)

tank 1 depth (m)

0.3 0.2 0.1 0 −0.1 0

(13)

50

100

150 200 time (seconds)

250

300

350

Validation system with real data :28−Jun−96, error=0.5055 0.2

3.1. Results Analysis A common feature from these four expressions is the function basis(pn,pn+1) lam(h2). The turbulent flow term in equation (11) is not large although the error for this solution is significantly larger than the others. Equation (12) can be approximated by one basis function multiplied by the laminar flow. In Equation (14), the lam(h2) term added to h2 is several orders of magnitude smaller than h2 and therefore insignificant in this case. Equation (13) was accepted as the best representation of flow out of tank two. The next stage of the modelling process was to identify the parameters p0 and p1 with a variety of data sets and to validate the final model with yet more data.

0.15

tank 2 depth (m)

(14)

0.1 0.05 0 −0.05 0

50

100

150 200 time (seconds)

250

300

350

Figure 5 Model of y=0.75lam(h2) for different data set The fit for H1 and H2 is of a reasonable quality both in dynamic response and in steady-state indicating that the model described in equation (15) is a good representation of this system. There is some drift evident in the predicted values of H2. This is caused by the identified flow equation is integrated to generate the tank depth time histories. Any discrepancy will therefore cause this drift.

4.

Discussion

This procedure is a valuable tool for the modelling of nonlinear dynamic systems. As with all such tools,

engineering knowledge must also be applied when searching for a physically significant nonlinear expression but the genetic programming automates the trial and error process of structure modelling. The genetic programming can therefore test a lot more potential model components and structures. It is also capable of retaining the best parts of these structures and recombining them to give new and sometimes better models. The selection of the library functions is important. It has been found that if the functions are too general, the genetic programming produces a model which is an empirical fit to the data. This could be desirable in some cases but the main objective here was to achieve physical models. System specific nonlinear elements such as look up tables or hard discontinuities can be implemented even if their importance is doubtful. Experience with this method has shown that specific nonlinearities not present in the system being modelled will not occur in the genetic programming solution. The model resulting form the genetic programming estimation is often a useful nonlinear description of the system under consideration. It can reveal some aspects of the physical structure of the system and their importance. Such information can be used for further investigation of the physical system or to validate the structure of an existing model developed in some other way. This method is to be applied to the identification of engine speed and aircraft yaw dynamics for helicopters. This is a known problem area of nonlinear helicopter simulation models and it is hoped that with genetic programming, a more representative structure of this helicopter sub-system can be found.

5.

Conclusions

Genetic programming is a useful technique for identification of the structure of nonlinear dynamic models. Used with a carefully selected library of functions, it can reveal information about the physical structure of a system and produce an accurate model describing the system. Including more complex functions in the library can reveal if that function is indeed present in the model. The technique was applied to the identification of a coupled water tank system. A simple nonlinear structure was found that gave an accurate representation of the system and had physical significance.

Acknowledgements This research is supported by the UK Engineering and Physical Sciences Research Council under grant GR/K24987 ("Evolutionary Programming for Nonlinear Control"). The authors would like to thank the other members of the evolutionary computing research group for their useful discussions and helpful suggestions from P.J. Thomas concerning the modelling of flow phenomena. The core

program for the genetic programming is called gpc++ and was written by A.P. Fraser (1994).

Bibliography Bettenhausen, K.D., Marenbach, P., Freyer, S., Rettenmaier, H. & Nieken, U., 1995, ’Self-organizing structured modelling of a biotechnological fed-batch fermentation by means of genetic programming’, Proceedings of IEE/IEEE GALESIA ’95, England, pp.481-486. Fraser, A.P., 1994, ’Genetic Programming in C++’, University of Salford, Salford, England. Gray, G.J., Murray-Smith, D.J., Li, Y. & Sharman, K.C., 1996, ’Nonlinear system modelling using output error estimation of a local model network’, Society for Computer Simulation Summer Computer Simulation Conference, Portland, Oregon. Koza, J., 1992, ’Genetic Programming: On the programming of computers by means of natural selection’, The MIT Press. Murray-Smith, D.J., 1995, Continuous System Simulation, Chapman and Hall, London. Press, W.H., Teukolsky, S.A., Vetterling, W.T., Flannery, B.P., 1992, Numerical Recipes in C, 2nd Edition, Cambridge University Press, Chapter 10. Sharman, K.C., Esparcia-Alcazar, A.I. & Li, Y., 1995, ’Evolving signal processing algorithms by genetic programming’, Proceedings of IEE/IEEE GALESIA ’95, England, pp.473-480. Thomas, P.J., 1995, Unpublished note to D.J. Murray-Smith.