• Non ci sono risultati.

Systems identification and applications to advanced control of chemical processes

N/A
N/A
Protected

Academic year: 2021

Condividi "Systems identification and applications to advanced control of chemical processes"

Copied!
156
0
0

Testo completo

(1)

Department of Civil and Industrial

Engineering

Master’s degree in Chemical Engineering

Systems identification and applications to

advanced control of chemical processes

Candidate:

Giuseppe Armenise

Supervisor:

Prof. Gabriele Pannocchia

Examiner:

Prof. Cecilia Magherini

(2)
(3)

During the Chemical Engineering studies, I was amazed by how mathemati-cal, physical and chemical principles can be applied together in an industrial plant to control processes, reaching the right operative conditions for which the equipments have been designed. However, only PID controllers are stud-ied in this degree course and I have to thank Prof. Pannocchia for the possibility to deepen knowledge about these aspects of chemical engineering, other thanks go to Prof. Magherini for her useful tips on my work. I have to thank also Edoardo for his company and for being an alpha-tester of the identification package, Riccardo for his help and for his tolerance on me and Edoardo during our discussions in CPCLab and Marco for his help during the setting of the MPC. I thank my family for the support given during my studies and my girlfriend Francesca to have lifted up my mood when needed.

(4)
(5)

1 Introduction 1

1.1 Aims of this work . . . 1

1.2 Outline of the thesis . . . 2

2 An overview on advanced process control 5 2.1 Model-based controllers . . . 7

2.1.1 Control structures . . . 7

2.1.2 Model predictive control structure . . . 11

2.2 Systems identification . . . 15

3 Systems theory 17 3.1 Introduction to systems theory . . . 17

3.1.1 Models classification . . . 17

3.1.2 Models in discrete-time domain . . . 20

3.1.3 Stability, observability and controllability conditions . . 22

3.2 Input-output models . . . 25

3.3 State space models . . . 34

4 Identification of input-output models 37 4.1 ARX and ARMAX identification: SISO case . . . 37

4.2 MIMO systems: MISO approach . . . 42

4.3 Examples . . . 44

4.3.1 Example 1 . . . 45

4.3.2 Example 2 . . . 49

4.3.3 Example 3 . . . 51

4.3.4 Example 4 . . . 54

4.4 ARMAX algorithms comparison . . . 60 iii

(6)

5 Subspace identification methods 65

5.1 Some definitions . . . 65

5.2 Traditional methods: N4SID, MOESP and CVA . . . 66

5.3 Parallel and Sequential PARSIM methods . . . 70

5.4 Parsim-K method . . . 75

5.5 Examples . . . 78

5.5.1 Example 1 . . . 78

5.5.2 Example 2 . . . 81

5.6 SIMs algorithms comparison . . . 84

6 The information criteria 91 7 Applications 93 7.1 An example: the four-tank process . . . 93

7.2 Experiment design and collecting data . . . 95

7.3 Identification and validation steps . . . 101

7.3.1 Identification . . . 101

7.3.2 Validation . . . 106

7.4 Running the MPC . . . 115

8 Conclusions 121 A Identification package: User guide 123 A.1 Necessary parameters to be defined . . . 124

A.2 Optional parameters common to all methods . . . 125

A.3 Optional arguments if IC=’N one’ . . . 125

A.3.1 ’ARX’ and ’ARMAX’ methods . . . 125

A.3.2 Subspace identification methods: ’N4SID’, ’MOESP’, ’CVA’, ’PARSIM-P’, ’PARSIM-S’ and ’PARSIM-K’ . . . 127

A.4 Optional arguments if IC=’AIC’, ’AICc’ or ’BIC’ . . . 129

A.4.1 ’ARX’ and ’ARMAX’ methods . . . 129

A.4.2 Subspace identification methods: ’N4SID’, ’MOESP’, ’CVA’, ’PARSIM-P’, ’PARSIM-S’ and ’PARSIM-K’ . . . 130

A.5 Attributes of the model . . . 130

(7)

A.5.2 ’N4SID’, ’MOESP’, ’CVA’, ’PARSIM-P’, ’PARSIM-S’

and ’PARSIM-K’ methods . . . 131

A.6 Useful functions . . . 132

A.7 Methods summary . . . 135

(8)
(9)

2.1 Feedback control structure

r : set point, y: output, e: error, u: input, d : disturbances

C: controller, G: system . . . 6

2.2 Decentralized control of a system with two inputs and two outputs. . . 7

2.3 Centralized control of a system with two inputs and two outputs. 8 2.4 Distributed control of a system with two inputs and two outputs. 8 2.5 Two-level hierarchical control of a system with two inputs and two outputs. . . 9

2.6 A representation of plantwide control. . . 10

2.7 General structure of a MPC ˆ dk|k: disturbance estimate, ˆxk|k: state estimate, yk: output, uk: input, xs,k, us,k: calculated equilibrium point (state and input). . . . 11

2.8 Procedure for system identification . . . 16

3.1 Stability region in the complex plane for continuous-time systems 22 3.2 Stability region in the complex plane for discrete-time systems 23 3.3 SISO system . . . 25

3.4 System with disturbance . . . 26

3.5 The ARX structure . . . 30

3.6 The equation error model family . . . 31

3.7 The Output Error model structure . . . 32

3.8 The Box-Jenkins model structure . . . 32

3.9 Linear time invariant state space systems . . . 35

4.1 Schematic overview of the ARMAX identification algorithm. . 41

4.2 Identification data . . . 46 vii

(10)

4.3 Identification data . . . 47 4.4 Validation data . . . 48 4.5 Identification data . . . 50 4.6 Validation data . . . 51 4.7 Identification data . . . 52 4.8 Validation data . . . 53

4.9 Input sequence, identification data . . . 55

4.10 yout, identification data . . . 55

4.11 yerr, identification data . . . 56

4.12 ytot, identification data . . . 56

4.13 Input sequence, validation data . . . 58

4.14 yout, validation data . . . 58

4.15 yerr, validation data . . . 59

4.16 ytot, validation data . . . 59

4.17 Input sequence . . . 61

4.18 ytot, implemented method . . . 61

4.19 ytot, armax Matlab function . . . 62

5.1 Input sequence, identification data . . . 79

5.2 Output sequence, identification data . . . 79

5.3 Input sequence, validation data . . . 80

5.4 Output sequence, validation data . . . 80

5.5 Output 1, identification data . . . 82

5.6 Output 2, identification data . . . 82

5.7 Output 1, validation data . . . 83

5.8 Output 2, validation data . . . 83

5.9 Input sequence . . . 86

5.10 ytot, two of the implemented algorithms . . . 87

5.11 ytot, Matlab n4sid . . . 87

7.1 Four-tank process modelled on UniSim Design R451 . . . 94

7.2 Set points on Tank1 . . . 97

7.3 Set points on Tank2 . . . 97

7.4 Set points on Feed1 . . . 98

7.5 Set points on Feed2 . . . 98

7.6 Output 1 . . . 99

7.7 Output 2 . . . 99

(11)

7.9 Output 4 . . . 100

7.10 Output 1, identification data in the process form . . . 102

7.11 Output 2, identification data in the process form . . . 103

7.12 Output 3, identification data in the process form . . . 103

7.13 Output 4, identification data in the process form . . . 104

7.14 Output 1, identification data in innovation form . . . 104

7.15 Output 2, identification data in innovation form . . . 105

7.16 Output 3, identification data in innovation form . . . 105

7.17 Output 4, identification data in innovation form . . . 106

7.18 Set points on Tank1 . . . 107

7.19 Set points on Tank2 . . . 107

7.20 Set points on Feed1 . . . 108

7.21 Set points on Feed2 . . . 108

7.22 Output 1 . . . 109

7.23 Output 2 . . . 109

7.24 Output 3 . . . 110

7.25 Output 4 . . . 110

7.26 Set points on Tank1 . . . 111

7.27 Set points on Tank2 . . . 112

7.28 Set points on Feed1 . . . 112

7.29 Set points on Feed2 . . . 113

7.30 Output 1 . . . 113 7.31 Output 2 . . . 114 7.32 Output 3 . . . 114 7.33 Output 4 . . . 115 7.34 Input 1 . . . 118 7.35 Input 2 . . . 118 7.36 Output 1 . . . 119 7.37 Output 2 . . . 119 7.38 Output 3 . . . 120 7.39 Output 4 . . . 120

(12)
(13)

3.1 Most common black-box SISO model structures . . . 33

4.1 MIMO ARMAX system of example 4 . . . 54

4.2 Identified system of example 4 . . . 57

4.3 Identified systems . . . 62

5.1 Weighting matrices corresponding to N4SID, MOESP and CVA algorithms. . . 70

5.2 Mean EV . . . 84

5.3 Mean EV . . . 85

5.4 Mean EV , closed loop results . . . 89

A.1 Example of MIMO ARMAX system . . . 127

A.2 Methods and their parameters and attributes . . . 135

(14)
(15)

Introduction

1.1

Aims of this work

Process control deals with satisfying the conditions established in the design of the plant and/or imposed by the particular situation. Among the principal issues of control, we can enumerate:

• Safety: the plant must be maintained in conditions such that there’s no risk of incident.

• Environment: emissions of pollutants must be kept under control in order not to damage the environment.

• Technical specifications: the plant has to produce the specified quantity of products and in the designated quality.

• Economic considerations: the use of raw materials and energy has to be minimized respecting the process specifications to allow the plant to be profitable.

Nowadays the advanced controllers are based on a model of the process, so it is possible to predict the variations of the operative conditions, when the process is subject to certain inputs. This is possible only having a model of the process. Several techniques have been developed to build a model, hav-ing input-output data available. The first aim of this work is to deepen the knowledge about systems identification, presenting the most used structures of models and some techniques to develop a model, then an implementation

(16)

of the proposed identification methods is made. In chemical engineering the process control is a wide field of research and ever more platforms are avail-able to simulate the action of a system and a controller. Python is playing an important role in process control, being a programming language quite easy to use and for the possibility to install modules and packages that allow new operations to the user. Moreover, Python can be used on Windows, Linux and Mac, covering the most known operating systems. This is why the implementation of the methods is made in Python language.

Chemical process modeling deals with building complicated models of pro-cesses using a software, a process simulator, that is able to take care of complex systems, interactions between different equipments, non-ideal be-haviours of chemical substances and so on. A process modelled using a modeling software can be very near to describe the real one. Due to the complexity of such a software, a modelled process cannot be used as model of the controller, that requires a simple characterization of the system. How-ever, it can be useful to test the response of a process and to see the ad-vantages of a model-based controller over the traditional controllers (PID). A well-known process simulator is UniSim Design: this offers different pos-sibilities, e.g. the process optimization in steady-state conditions, sizing and designing equipments, dynamic simulations. Another target of this work is to connect Python and UniSim Design R451 to collect input-output data on a UniSim-modelled process, then perform an identification and see how the MPC (Model Predictive Controller) can act on UniSim variables. This con-nection can be an additional assurance on a designed MPC, before installing it on the plant.

1.2

Outline of the thesis

The primary goal of this thesis is to deepen knowledge on advanced control and in particular on identification algorithms, that have to be implemented in Python. The plan of the thesis is as follows.

• Chapter 2: the typical approaches used in control - including decentral-ized, distributed and hierarchical control - are presented, then a con-textualization on the role of the model-based controllers is made. The modules that constitute the MPCs and a strategy for a linear MPC are explained. In the last Section of this Chapter, the identification procedure is presented.

(17)

• Chapter 3: this Chapter deals with the systems theory, starting from a general classification of models, showing the continuous-time structure and then focusing on linear time-invariant systems. Furthermore the systems properties important for control - including the controllabil-ity, the observability and the stability conditions - are discussed. The various model structures for input-output systems and the state space models are also included.

• Chapter 4: The implemented algorithms for input-output model struc-tures are explained, showing that the input-output system identifica-tion can be performed with a least square or a recursive least square method. Some examples of identification and a comparison with a Matlab algorithm are made.

• Chapter 5: this Chapter provides a treatment of different subspace identification methods(SIM) as using a deterministic approach, like the traditional methods (N4SID, MOESP and CVA), or enforcing causal models, like the PARSIM methods. Some results obtained from the comparison of methods are shown, including a Matlab SIM algorithm. • Chapter 6: in order to help the user in choosing the model order, three information criteria are implemented and are explained in this Chapter. A more accurate model means higher orders, i.e. more computational load for the controller, while a simpler model can give lower perfor-mances. The criteria can be used to look for the ”right” model order. • Chapter 7: A four-tank process is modelled in UniSim and an

iden-tification is made, after designing opportunely the experiments and collecting input-output data. The identified model quality is tested using validation data, then a simulation with an installed MPC, with adequate settings, is performed. The results of a comparison with a PI controller are shown.

• Chapter 8: in the end, final considerations are made with some com-ments as summary of this work.

(18)
(19)

An overview on advanced

process control

A system is an object in which variables of different kinds interact and pro-duce observable signals [27]. The observable signals that interest us are often called outputs. The system is affected by external stimuli. We can divide these latter into two categories:

1. Signals that can be manipulated by the user, called inputs

2. Disturbances, further divided into measurable and not measurable. In an industrial plant, an equipment can be considered as a system, in which the inputs are the manipulated variables and the outputs are the controlled variables.

During operation, an industrial plant is working under dynamic conditions, caused by inputs and disturbances that move it from steady state conditions. The purpose of the control system is to drive and maintain the process in the desired conditions. The simplest and the most common structure of control is the feedback control (Figure 2.1).

(20)

Figure 2.1: Feedback control structure

r : set point, y: output, e: error, u: input, d : disturbances C: controller, G: system

To obtain the desired conditions, more and more efficient controllers have been developed. In industrial applications, we can find:

1. Traditional controllers (PID) [55];

2. Advanced controllers (Model-based controllers).

PID controllers do not require detailed knowledge of the process, so they are fairly simple to adjust, but they have limits. Having knowledge about the process, better performance can be obtained. This is why, since 70’s, model-based controllers have been developed (see [46], one of the first applications).

(21)

2.1

Model-based controllers

2.1.1

Control structures

Model predictive controllers (MPC [45]) have been developed for many ad-vantages over traditional controllers. Advanced controllers are able to handle multivariable systems, complicated dynamics and constraints on manipulated and controlled variables. The main approaches applied to control can be clas-sified as (see [47]):

1. decentralized 2. distributed 3. hierarchical

The decentralized architecture consists in grouping the manipulated (inputs) and controlled (outputs) variables into disjoint sets (see Figure 2.2).

Figure 2.2: Decentralized control of a system with two inputs and two out-puts.

The system is divided into subsystems to operate with single input-single output controllers. This architecture is effective when the interactions among the inputs and the outputs of different pairs are weak, but when the interac-tions are strong this approach does not guarantee stability and performance. For model predictive controllers, the decentralization is not the first choice,

(22)

due to the ability of MPCs to operate with centralized structures (see Figure 2.3). Another disadvantage of decentralized control is the limited application to the only square systems, i.e. the number of outputs is equal to the number of inputs, if traditional single-input single-output (PID) controllers are used.

Figure 2.3: Centralized control of a system with two inputs and two outputs. In the distributed control structure, some information is transferred among the local controllers to give each of them knowledge about the other ones (see Figure 2.4).

(23)

Depending on the algorithm implemented in each controller, a further classification can be made for the distributed structure:

1. Independent algorithms: each controller minimizes a local cost function. 2. Cooperating algorithms: all controller minimizes a global cost function. The alternative to the previous one is a two level hierarchical control struc-ture (see Figure 2.5).

Figure 2.5: Two-level hierarchical control of a system with two inputs and two outputs.

(24)

In this structure, the higher level coordinates the local controllers (MPC), placed at the lower level. The fundamental idea is to model the overall system as subsystems linked through some interconnecting variables. An optimiza-tion problem is solved with an MPC for any subsystem, minimizing a local cost function. The local solutions have to satisfy the constraints on the in-terconnecting variables calculated by the local controllers, if not, an iterative method with a ”price coordination” is used.

In industrial plants, the overall system is designed with the hierarchical struc-ture of Figure 2.6.

Figure 2.6: A representation of plantwide control.

At the higher level, there is the real time optimization (RTO), that computes the optimal operating conditions with economic criteria. At the lower level the advanced controllers work to achieve the desired conditions, computed by the RTO. At the lower levels, there are the traditional PID-controllers, then actuators and sensors. Each level has its own dynamics: the higher levels are slower than the lower ones. In this discussion, we shall focus on MPCs.

(25)

2.1.2

Model predictive control structure

The general structure of model predictive control includes three modules (see Figure 2.7):

1. Estimator

2. Steady-state optimization 3. Dynamic optimization

Figure 2.7: General structure of a MPC ˆ

dk|k: disturbance estimate, ˆxk|k: state estimate, yk: output, uk: input,

(26)

The state estimator (observer) evaluates the next step state ˆxk+1|k from

the measured output yk and the previous state evaluation ˆxk|k−1, then the

next output ˆyk+1|k can be evaluated. Considering the system:

     xk+1 = Axk+ Buk yk = Cxk ˆ x0 (2.1) where:

xk: state, with size n, at k-th sampling time,

yk: output, with size p, at k-th sampling time,

uk: input, with size m, at k-th sampling time,

A, B, C are the system matrices (see Chapter 3). Defining the state estimation error :

ek= xk− ˆxk|k−1

we obtain:

ek= (A − AKC)ek

where K is a filter, that must satisfy:

ek → 0, when k → ∞

Such a filter is the Kalman filter (see [22], [21]).

In many cases the number of controlled variables (CVs) is different from the number of manipulated variables (MVs): p 6= m.

Variables (CVs and MVs) have to comply with constraints: ymin ≤ yk ≤ ymax, umin ≤ uk ≤ umax

Only a few variables have fixed set-points: Hyk−→ rsp

Constraints may classified into two categories:

1. Hard constraints, that cannot be violated, on MVs.

(27)

The steady-state optimization module can have various formulations, usu-ally linear or quadratic (For details see [33] and [36]). The objective of the steady-state optimization module is to compute the equilibrium (xs, us, ys),

satisfying the constrains and tracking the set point. The linear formulation can be expressed as:

min us,xs,s,s qTs+ qTs+ rTus (2.2) subject to: xs= Axs+ Bus+ Bddˆk|k umin ≤ us≤ umax ymin− s ≤ Cxs+ Cddˆk|k ≤ ymax+ s s≥ 0 s≥ 0

where ˆd is the disturbance estimation, r ∈ Rm is the MV cost vector, q ∈Rp and q ∈ Rp are the weights of upper and lower bound CV violations. Bounds

umax, umin, ymax, ymin can be modified. Set points on MVs can be specified

with an equality constraint or by setting ymin = ymax = rsp. Sometimes the

following constraint is added to avoid large target changes: −∆umax ≤ us,k− us,k−1≤ ∆umax

The quadratic formulation can be expressed as: min us,xs,s,s ||s||2Ws + ||ys− yt|| 2 Qs + ||us− ut|| 2 Rs (2.3) subject to: xs= Axs+ Bus+ Bddˆk|k umin ≤ us≤ umax ymin− s ≤ Cxs+ Cddˆk|k ≤ ymax+ s

where yt and ut are the desired CV and MV set points. The norm ||x||2Q is

defined as: ||x||2

Q = xTQx.

Once selected (xs, us, ys), the advanced controlled can perform the dynamic

optimization, that has the general formulation: min

ˆ

x,u,VN(ˆx, u, ) (2.4)

denoting u and  as the input sequence and the deviation sequence from the output (soft) constraints respectively, subject to:

(28)

umin ≤ ui ≤ umax

−∆umax ≤ ui− ui−1≤ ∆umax

ymin− i ≤ ˆyi ≤ ymax+ i where: xk+1 = Axi+ Bui+ Bdd, xˆ 0 = ˆxk|k ˆ yi = Cxi+ Cddˆk|k, ys,k = Cxs,k+ Cddˆk|k VN(ˆxk|k, u, ) = PN −1

i=0 ||ˆyi− ys,k||2Q+ ||ui− us,k||2R+ ||ui− ui−1||2S+

||i||2W + ||xN − xs,k||2P

Q, R, S, W and P are positive definite matrices. The dynamic optimization can be treated as a QP (Quadratic Programming) problem and solved with one of available methods. The solution is the optimal control sequence u0. The linear MPC algorithm can be summarized in some steps:

1. Computing estimate: ˆxk|k−1, ˆdk|k−1;

2. solving steady state optimization problem and computing targets: (xs,k, us,k);

3. solving dynamic optimization problem to obtain the optimal control sequence u0;

4. doing the control action u0(0) and predicting successor state ˆx

k+1|k and

disturbance ˆdk+1|k.

The procedure is repeated at each sampling time. The presented MPC struc-ture is based on linear models, that cannot represent the system exactly. To have a better model fit, non-linear models can be used and non-linear MPC algorithms are available from vendors (see e.g. [43], [28], [16]). However, there is always a mismatch between the model and the real system, caused by disturbances and uncertainties. An important objective of the research is to achieve an offset free control and a strategy can be to design opti-mally the disturbance model (see e.g. [33], [37], [36]). One other challenge is guaranteeing the control stability and robustness, without losing the optimal performances (see e.g. [6], [13], [2], [3]). An actual problem is the computa-tional load: at each sampling time the MPC algorithm has to compute the best input sequence. This calculation can take few seconds, making the re-sponse slower (see e.g. [8]). Another task is reducing economic costs, reducing

(29)

energy demand on the plant with a dynamic optimization and steady-state economic performance (see e.g. [17], [30], [5], [11]). There are many difficult problems to be solved and the research is far from its end.

2.2

Systems identification

The MPC algorithm can be performed if a model of the controlled system is available. Moreover, a model of the system is useful to analyse the relation-ships between the variables. The route that allows to build a model is called system identification. Systems identification deals with the construction of a model of the considered process, given experimental data. The system identification involves three basic entities [27]:

1. A data set.

2. A set of candidate models.

3. An identification algorithm or a rule to set the model parameters. The data can be recorded from the normal operation of the system or during identification experiments. This latter is the best choice, when it is feasible, because the user may determine which variables to measure and may choose the inputs. The experiments are first planned properly in order to record data the more informative as possible. The most important and the most difficult choice is the set of models. A priori knowledge, experience and intuition have to be combined to make a good choice. A set of models can be obtained by modeling, using physical laws (first principles model ). In other cases a linear standard model can be used without reference to the physics of the process (black-box ) and the model parameters have to be adjusted according to the data. There are also semi-empirical models, with adjustable parame-ters and physical intuition (gray-box ). The most common model structures are discussed in Chapter 3. The objective of the identification method (the algorithm) is to determine the best model in the set using the data. This is discussed in Chapters 4 and 5. Once we have a model, we need to check if this model is valid for its purpose. There are various procedures to verify if a model is adequate, assessing how the model relates to the observed data. This step is known as model validation.

(30)

The procedure for identification can be summarized in some steps: 1. design the experiments;

2. collect the input-output data; 3. choose a model set;

4. determine the best model of the set;

5. validate model: if the model is adequate, use it. In the other case, the previous steps must be reviewed.

(31)

Systems theory

3.1

Introduction to systems theory

3.1.1

Models classification

In advanced controllers a model of the controlled system is used to evalu-ate the control action. A model describes how its variables relevalu-ate to each other [27]. Models can be in various forms and the expected use determines the degree of sophistication required to make the model purposeful. For advanced applications, mathematical models are used, which describe the re-lationships among the system variables in terms of mathematical expressions, for example differential of difference equations. The use of a model does not imply that this represents the real process, but only that it is adequate for the intended purpose. In model-based controllers, mathematical models are used. A process model must be able to describe the dynamic evolution of the process, subject to certain inputs. A further model structure classification can be made:

1. First principles models, based on fundamental equations and physical principles, like conservation of mass, energy, electrical charges, momen-tum and so on. This type of model requires a physical intuition. 2. Empirical models, that require experimental data and a route to obtain

the input-output relations. Those models are also called black-box. 3. Semi-empirical or gray-box models with adjustable parameters and

physical interpretation.

(32)

First principles models take the general form:      dx dt = f (x, u, t), x ∈ R n(state) y = h(x, u, t), y ∈ Rp(output) x(0) = x0, u ∈ Rm(input) (3.1)

In the time invariant case:      dx dt = f (x, u), x ∈ R n(state) y = h(x, u), y ∈ Rp(output) x(0) = x0, u ∈ Rm(input) (3.2)

State space models in the linear form can be expressed as:      dx dt = A(t)x(t) + B(t)u(t), x ∈ R n(state)

y(t) = C(t)x(t) + D(t)u(t), y ∈ Rp(output) x(0) = x0, u ∈ Rm(input)

(3.3)

where: A ∈ Rn×n, B ∈ Rn×m, C ∈ Rp×n, D ∈ Rp×m.

In the time invariant case:      dx dt = Ax(t) + Bu(t), y(t) = Cx(t) + Du(t), x(0) = x0 (3.4)

Input-output linear models (black-box), in single input-single output case, take the form:

ar dry dtr + ar−1 dr−1y dtr−1 + ... + a1 dy dt + y = = bq dqu dtq + bq−1 dq−1u dtq−1 + ... + b1 du dt + b0u (3.5)

Remembering the Laplace transform of a function f (t): L[f (t)] = f (s) =

Z ∞

0

f (t)e−stdt (3.6) The (3.5) can be written as transfer function model:

(33)

With g(s): g(s) = bqs q+ b q−1sq−1+ ... + b1s + b0 arsr+ ar−1sr−1+ ... + a1s + 1 (3.8) When many variables have to be handled, multi-input multi-output models can be used. They take the form:

        

y1(s) = g11(s)u1(s) + g12(s)u2(s) + ... + g1m(s)um(s)

y2(s) = g21(s)u1(s) + g22(s)u2(s) + ... + g2m(s)um(s)

... = ...

yp(s) = gp1(s)u1(s) + gp2(s)u2(s) + ... + gpm(s)um(s)

(3.9)

where:

m : number of inputs p : number of outputs

The system represented by (3.9) can be written in a compact form:

y(s) = G(s)u(s) (3.10) where: y(s) = [y1(s) y2(s) ... yp(s)]T u(s) = [u1(s) u2(s) ... um(s)]T G(s) =      g11(s) g12(s) g13(s) . . . g1m(s) g21(s) g22(s) g23(s) . . . g2m(s) .. . ... ... ... ... gp1(s) gp2(s) gp3(s) . . . gpm(s)     

We can convert State space model in input-output model, applying Laplace transform to the (3.4) and replacing the state vector, we find that:

G(s) = [C(sI − A)−1B + D] (3.11) Where I ∈ Rn×n is the identity matrix.

We can perform a reverse transformation, converting an input-output model in a state space model, but this is not unique. The poles of G(s) must be equal to the eigenvalues of A and D is determined, C and B are not fixed, but the relation (3.11) must be satisfied. This operation is called state space realization.

(34)

3.1.2

Models in discrete-time domain

We have shown how linear systems can be represented to describe their dy-namic evolution. However, all modern controllers, either traditional PID and advanced, work in discrete time. The measurements (or evaluations) of outputs are executed at each sampling time. So we have to use models in discrete-time domain. Usually, the inputs calculated at a sampling time are kept constant until the next sampling time, this assumption is called zero-order hold (ZOH):

u(t) = uk, kts ≤ t ≤ (k + 1)ts (3.12)

where k: number of sampling time, uk: input at k-th sampling time,

ts: sampling time. Defining the forward shift operator and the backward shift

operator :

Forward shift operator z : zuk= uk+1 (3.13)

Backward shift operator z−1 : z−1uk = uk−1 (3.14)

the MIMO input-output models in discrete time take the form:

A(z)yk = B(z)uk (3.15) where: yk = [y1,k y2,k ... yp,k]T uk= [u1,k u2,k ... um,k]T A(z) = I + A1z−1+ A2z−2+ ... + Arz−r B(z) = B0+ B1z−1+ B2z−2+ ... + Blz−l

We can rewrite in the compact form:

(35)

with: G(z) = A(z)−1B(z) =      g11(z) g12(z) g13(z) . . . g1m(z) g21(z) g22(z) g23(z) . . . g2m(z) .. . ... ... ... ... gp1(z) gp2(z) gp3(z) . . . gpm(z)      The sampled version of (3.2) takes the form:

(

xk+1 = F (xk, uk)

yk = h(xk, uk)

(3.17) Assuming valid the hypothesis (3.12), we find:

F (xk, uk) = xk+ Z tk+ts tk f (x(t), uk)dt (3.18) The (3.4) becomes:      xk+1 = Axk+ Buk yk = Cxk+ Duk x0 initial condition (3.19)

The relations between discrete time and continuous time matrices are:      A = eAts B = (Rts 0 e Aτdτ )B C = C, D = D (3.20)

(36)

3.1.3

Stability, observability and controllability

condi-tions

Remind that the stability condition in continuous time can be expressed as: A necessary and sufficient condition for a system G(s) to be stable is that all poles must have their real part negative.

or the equivalent in state space models:

A necessary and sufficient condition for a system to be stable is that all eigenvalues of A must have their real part negative.

(37)

The discrete-time poles can be obtained from continuous-time poles: λi = eλits (3.21)

The stability condition in discrete-time domain is:

A necessary and sufficient condition for a system G(z) to be stable is that all poles must be into the unit circle centred in the origin of the complex plane.

and for the state space models:

A necessary and sufficient condition for a system to be stable is that all eigenvalues of A must be into the unit circle centred in the origin of the complex plane.

(38)

Once we have a model, it is possible to implement the advanced controller and optimize the system control. The conditions for effective control are:

1. Observability of the system, in order to estimate the state.

2. Controllability of the system, in order to lead the state toward the desired equilibrium.

A system is observable in n steps, if, given the output sequence [y0, y1, ..., yn−1],

it is possible to stablish x0 uniquely.

This condition of observability of a system is:

rank(Γn) = n (3.22)

where Γn is the observability matrix:

Γn,        C CA CA2 .. . CAn−1       

A system is controllable at the origin in n steps, if a sequence of inputs [u0, u1, ..., un−1] such that xn = 0 exists. The system is reachable if a

sequence of input exists for any xn.

This condition of controllability/reachability of a system is:

rank(Ln) = n (3.23)

Where Ln is the controllability matrix:

Ln,B AB A2B . . . An−1B

(39)

3.2

Input-output models

Consider a single input-single output system (SISO, Figure 3.3):

Figure 3.3: SISO system

A linear time-invariant system can be characterized by its impulse response g(τ ):

y(kts) =

Z ∞

τ =0

g(τ )u(kts− τ )dτ (3.24)

With the knowledge of g(τ ), the output y(kts) can be computed given the

inputs. Usually, the hypothesis (3.12) is still valid and the (3.24) can be rewritten: y(kts) = ∞ X l=1 g(l)uk−l (3.25) defined: g(l) = Z lts τ =(l−1)ts g(τ )dτ (3.26)

Using the (3.25), we can know the output at any sampling time. We shall refer to the sequence {g(l)}∞l=1 as the impulse response of the system and we shall use t to enumerate the sampling instants t = 0, 1, 2, · · · . Therefore, the (3.25) can be written as:

y(t) =

X

k=1

g(k)u(t − k) (3.27) Introducing the notation:

G(z) =

X

k=1

(40)

where G(z) is the transfer function of the linear system of (3.27) and the z-transform of {g(k)}∞1 . The relation (3.27) between the input and the output can be described by G(z) as follow:

y(t) = G(z)u(t) (3.29) Note that the argument of G is z instead of z−1. This choice is made to be in formal agreement with z-transform and Fourier-transform expression. Using the relation (3.29), it seems that the output can be exactly calculated knowing the input. This is unrealistic, due to signals that affect the system, but that cannot be measured or controlled. Grouping these effects into the additive term v(t) at the output (see Figure 3.4):

y(t) = G(z)u(t) + v(t) (3.30)

Figure 3.4: System with disturbance The disturbance term can have many sources, as:

1. Measurement noise: the measuring sensors are subject to noise.

2. Disturbance inputs: signals that affect the system, but that the user cannot manipulate, e.g. the room temperature affects the system tem-perature.

(41)

At time t, the value of v(t) can be calculated from (3.30), but its value cannot be known beforehand. Information about the past disturbances are also important to make guess about the future. Remembering the definition of probability density function ρ(x):

P (x ∈ Ω) = Z

ρ(x)dx (3.31)

where P (x ∈ Ω) is the probability that x ∈ Ω, being Ω a set. Assuming that the variable x has an expected value equal to E[x] = µ (E is the expected value operator), the variance of the random variable x is:

σ2 = E[(x − µ)2] (3.32) We can assume that v(t) is given by:

v(t) =

X

k=0

h(k)e(t − k) (3.33) where {e(t)} is white noise:

A sequence of independent (identically distributed) random vari-ables with a certain probability density function (PDF).

or:

A sequence of independent (identically distributed) random vari-ables with zero mean values and variances σ2.

We assume that H(z) is monic, i.e. h(0) = 1. This characterization is useful for practical purposes. Defining:

H(z) = ∞ X k=0 h(k)z−k = 1 + ∞ X k=1 h(k)z−k (3.34) we can write: v(t) = H(z)e(t) (3.35) The basic description for a linear system can be summarized as:

(42)

The determination of the coefficients in (3.28) and (3.34) is the purpose of the system identification. Note that it is not possible to determine an infinite number of parameters, but the number of parameters must be finite and specified. Denoting such parameters by the vector θ, the model description can be written as follows:

y(t) = G(z, θ)u(t) + H(z, θ)e(t) (3.37) Since e(t) has zero mean, the conditional expectation of v(t) is:

ˆ

v(t|t − 1) = [H(z) − 1]e(t) (3.38) As consequence, the conditional expectation of y(t) is:

ˆ

y(t|t − 1) = G(z)u(t) + [H(z) − 1]e(t) (3.39) Observing that: e(t) = H−1(z)v(t) (3.40) from the (3.30): v(t) = y(t) − G(z)u(t) (3.41) it follows that: ˆ y(t|t − 1) =G(z)u(t) + [1 − H−1(z)]v(t) =

=G(z)u(t) + [1 − H−1(z)][y(t) − G(z)u(t)] = =y(t) − H−1(z)y(t) + H−1(z)G(z)u(t) = =H−1(z)G(z)u(t) + [1 − H−1(z)]y(t)

(3.42)

or we can write:

H(z)ˆy(t|t − 1) = G(z)u(t) + [H(z) − 1]y(t) (3.43) The prediction error is given by:

y(t) − ˆy(t|t − 1) = −H−1(z)G(z)u(t) + H−1(z)y(t) = e(t) (3.44) The part of the output that cannot be predicted from past data is e(t), also called innovation. Considering the (3.37) and the (3.42), we have:

ˆ

(43)

This is the one-step-ahead predictor for (3.37). The parametrized set of models (3.45) is a model structure, denoted by M , while M (θ) is used to denote the specific model associated with θ.

A simple representation of a system input-output relation can be ex-pressed by a linear difference equation:

a0y(t) + a1y(t − 1) + a2y(t − 2) + ... + anay(t − na) =

=b0u(t) + b1u(t − 1) + ... + bnbu(t − nb) + e(t)

(3.46) The following assumptions are usually made:

a0 = 1, b0 = 0 (3.47)

Using the backward shift operator z−1, defined in (3.14), the (3.46) becomes: (1 + a1z−1+ ... + anaz −na)y(t) = =(b1z−1+ ... + bnbz −nb)u(t) + e(t) (3.48) Defining: A(z) = 1 + a1z−1+ ... + anaz −na (3.49) B(z) = b1z−1+ ... + bnbz −nb (3.50)

where na: output order, nb: input order, the (3.48) can be rewritten as:

y(t) = G(z)u(t) + H(z)e(t) (3.51) where:

G(z) = B(z)

A(z) (3.52)

H(z) = 1

A(z) (3.53)

This model structure is called ARX, where AR stands for the autoregressive part, that is A(z)y(t), and X stands for the extra input part, that is B(z)u(t) (see Figure 3.5).

(44)

Figure 3.5: The ARX structure

In the ARX structure, the white noise undergoes the effect of the system poles. In the case that na = 0, the finite impulse response (FIR) structure

is obtained. The ARX structure can be useful for many applications, but in other cases the disturbance term needs a more appropriate description. Treating the noise model as a moving average gives:

y(t) + a1y(t − 1) + ... + anay(t − na) =

=b1u(t − 1) + ... + bnbu(t − nb) + e(t) + c1e(t − 1) + ... + cnce(t − nc)

(3.54) Considering A(z) and B(z) defined in (3.49) and (3.50), defining:

C(z) = 1 + c1z−1+ ... + cncz

−nc (3.55)

The (3.54) can be rewritten:

A(z)y(t) = B(z)u(t) + C(z)e(t) (3.56) Considering G(z) defined in (3.52), defining the noise model:

H(z) = C(z)

A(z) (3.57)

This is the ARMAX structure, where MA stands for ”moving average”. Note that in the case that nc= 0 the ARMAX structure reduces to ARX structure.

Assuming that the noise model is an autoregressive term, the following model structure is obtained:

A(z)y(t) = B(z)u(t) + 1

(45)

where:

D(z) = 1 + d1z−1+ ... + dndz

−nd (3.59)

This can be called ARARX. A general structure is given by (see Figure 3.6): A(z)y(t) = B(z)u(t) + C(z)

D(z)e(t) (3.60)

Figure 3.6: The equation error model family

The model of (3.60) assumes that the transfer functions G(z) and H(z) have the common factor A(z) in the denominators. If the disturbances in-clude only the white measurement noise e(t), we obtain the following model structure: y(t) = B(z) F (z)u(t) + e(t) (3.61) where: F (z) = 1 + f1z−1+ ... + fnfz −nf (3.62)

(46)

Figure 3.7: The Output Error model structure

A model structure where the transfer functions G(z) and H(z) are inde-pendently parametrized has been developed by Box and Jenkins [15] (B-J model, see Figure 3.8):

y(t) = B(z) F (z)u(t) +

C(z)

D(z)e(t) (3.63)

Figure 3.8: The Box-Jenkins model structure

(47)

Table 3.1: Most common black-box SISO model structures Polynomials (z) Used Model structure

B FIR A B ARX A B C ARMAX A B D ARARX A B C D ARARMAX B F OE B C D F B-J

All the presented structures can be seen as special cases of the general structure:

A(z)y(t) = B(z) F (z)u(t) +

C(z)

D(z)e(t) (3.64) Consider now the multivariable case, where the input u(t) is an

m-dimensional vector, the output y(t) is a p-dimensional vector, while e(t) is a white noise vector with the same dimensions of the output. The poly-nomials in z A(z), B(z), C(z), D(z) and F (z) in the multivariable case are matrix polynomials in z (or more properly in z−1). The (3.49) and (3.50) become:

A(z) = I + A1z−1+ ... + Anaz

−na (3.65)

B(z) = B1z−1+ ... + Bnbz

−nb (3.66)

The system is given by (same as 3.51):

y(t) = G(z)u(t) + H(z)e(t) (3.67) where:

G(z) = A−1(z)B(z) p × m matrix (3.68) H(z) = A−1(z) p × p matrix (3.69) The ARMAX structure becomes:

y(t) + A1y(t − 1) + ... + Anay(t − na) =

=B1u(t − 1) + ... + Bnbu(t − nb) + e(t) + C1e(t − 1) + ... + Cnce(t − nc)

(48)

and G(z) and H(z) are:

G(z) = A−1(z)B(z) (3.71) H(z) = A−1(z)C(z) (3.72) Similarly, the MIMO expressions for the black-box structures can be obtained (see the Appendix 4A in [27]).

3.3

State space models

The state space model have been presented in Section 3.1, the time invariant form has been described in (3.4). The relationship between the input, noise and output is written as first-order differential or difference equations using an auxiliary state vector x(t). Models with physical insight are more easily constructed in continuous time domain, that leads to the general form:

     ˙x(t) = A(t, θ)x(t) + B(t, θ)u(t) y(t) = C(t, θ)x(t) + D(t, θ)u(t) x(0) = x0 (3.73)

The modelling is carried out in terms of state variables x, in some cases with physical significance, and the measured outputs are combinations of the states. We shall focus on the discrete-time domain, time-invariant case. Recalling the assumption 3.12:

u(t) = uk, kts ≤ t ≤ (k + 1)ts (3.74)

The state space form in discrete time can be written as follows (see (3.20)):      xk+1 = Axk+ Buk yk = Cxk+ Duk x0 initial condition (3.75)

For a detailed exposition on state space theory, see [10]. Henceforth we will use A, B, C and D instead of A, B, C, D for discrete time domain. For state-space description, it is more convenient to split the noise term into mea-surement noise vk and process noise wk. Both vk and wk are unmeasurable

(49)

vector signals. Adding those terms to (3.75) gives: (

xk+1 = Axk+ Buk+ wk

yk = Cxk+ Duk+ vk

(3.76) This state space model representation is called noise representation or process form(see e.g. [27], [39], [52]).

Figure 3.9: Linear time invariant state space systems

We assume that the system 3.76 is observable and controllable. {wk} and

{vk} are sequences of independent random variables with zero mean values

and covariances:

E[wkwTk] = Q

E[wkvTk] = S

E[vkvTk] = R

(3.77)

where E denotes the expected value operator. If the system is observable, a Kalman filter can be designed to estimate the state variables:

ˆ

xk+1 = A ˆxk+ Buk+ K(yk− C ˆxk− Duk) (3.78)

where K is the steady state Kalman gain, obtained from an algebraic Riccati equation. Defining the innovations of the Kalman filter as:

ek = yk− C ˆxk− Duk (3.79)

we obtain the innovation form: (

ˆ

xk+1= Aˆxk+ Buk+ Kek

yk = C ˆxk+ Duk+ ek

(50)

The innovation ek is white noise and is independent of past data, it is the

part that cannot be predicted. The innovation covariance matrix is denoted by Re.

The state space models can be represented also in the predictor form: ( ˆ xk+1 = AKxˆk+ BKuk+ Kyk yk = C ˆxk+ Duk+ ek (3.81) where: AK = A − KC BK = B − KD

State space models present three forms, i.e. the process form, the inno-vation form and the predictor form. All forms can represent the input and the output data exactly. The process form and the innovation form use the A, B, C, D matrices, while the predictor form uses AK, BK instead of A,

B. We can use the state space formulations for models based on physical insight (specially in continuous time), but also in the other cases. In fact, the states do not necessarily have a direct physical interpretation. The im-portance of the state space models is growing up, due to their convenience to work with in computer aided control system design and they become even more advantageous in MIMO cases.

(51)

Identification of input-output

models

The first two identification methods that have been implemented during this work concern the two most common input-output structures: ARX and AR-MAX model sets.

4.1

ARX and ARMAX identification: SISO

case

Recall the ARX structure (3.48): (1 + a1z−1+ ... + anaz

−na)y(t) = (b

1z−1+ ... + bnbz

−nb)u(t) + e(t) (4.1)

The purpose of the identification method is to determine the coefficient of the model set: a1,...,ana,b1,...,bnb, where na and nb are defined by the user.

In order to find the best model of the set, the predictor form is used. To obtain the predictor form of ARX structure, the (3.52) and (3.53) are sub-stituted in (3.45):

ˆ

y(t) = B(z)u(t) + [1 − A(z)]y(t) (4.2) 37

(52)

Introducing the vector: φk =          −yk−1 .. . −yk−na uk−1 .. . uk−nb          (4.3)

the (4.2) can be rewritten:

ˆ

yk = φTkθ (4.4)

where the parameter vector is defined as:

θ = [a1a2... ana b1... bnb]

T (4.5)

Note that the predictor is a scalar product between the known data vector φk and the parameter vector θ. Given the output and input sequences:

output sequence y: [y0y1 · · · yN]

input sequence u: [u0u1 · · · uN]

the data are arranged in the matrix Φ:

Φ =      φTM φT M +1 .. . φT N      (4.6)

where M = max(na, nb). The output vector is built to perform a linear

regression: ¯ y =      yM yM +1 .. . yN      (4.7)

The θ vector is the unknown of the overdetermined system: ¯

y = Φθ (4.8)

The solution can be obtained using a least square approach, that gives a well known solution:

(53)

where Φ† denotes the Moore-Penrose pseudo-inverse of Φ. The route to obtain the parameters of an ARX structure is fairly simple and it is direct: after the first calculation of the θ vector, the model can be built. Note that if the user wants a finite impulse response (FIR) model, na has to be setted

as zero. Remembering the ARMAX model structure (see (3.54)): (1 + a1z−1+ ... + anaz −na)y(t) = =(b1z−1+ ... + bnbz −nb)u(t) + (1 + c 1z−1+ ... + cncz −nc)e(t) (4.10)

the parameter vector in the ARMAX structure is: θ = [a1a2... ana b1 ... bnb c1... cnc]

T

(4.11) where na,nb and nc are defined by the user. From (3.45), the predictor form

of the ARMAX structure is: ˆ y(t|θ) = B(z) C(z)u(t) + " 1 − A(z) C(z) # y(t) (4.12) This can be written as follows:

ˆ

y(t|θ) = B(z)u(t) + [1 − A(z)]y(t) + [C(z) − 1][y(t) − ˆy(t|θ)] (4.13) Defining the predictor error:

k = yk− φTkθ = yk− ˆyk (4.14)

and the vector φk:

φk =                 −yk−1 .. . −yk−na uk−1 .. . uk−nb k−1 .. . k−nc                 (4.15) the (4.13) becomes: ˆ y(t|θ) = φT(t, θ)θ (4.16)

(54)

The (4.16) is not a linear regression: the terms k can be computed having

θ, i.e. φk depends on θ, hence we shall call this pseudo-linear regression.

The ARMAX structure requires an iterative procedure to get the ”best” model of the set. The output vector ¯y is defined same as in (4.7), with M = max(na, nb, nc). The matrix Φ is the same defined in (4.6), using

the ARMAX φk vector. We can see that to calculate the θ vector, the

knowledge of the  sequence is required. The procedure starts with an ARX identification, so the error vector can be calculated:

 = ¯y − Φθ (4.17) Using this vector to update the matrix Φ, a new θ is evaluated. The procedure goes on updating the error sequence and the matrix Φ. At each step, the following norm is calculated:

VN(θ) = 1 2(N − M + 1) N X k=M (yk− φTkθ) 2 = 1 2(N − M + 1) X i 2i (4.18) Let θnew be the new calculated parameter vector and θold the previous, if:

VN(θnew) < VN(θold) (4.19)

then the new θ vector is taken to update the matrix Φ, but, in the other case, a re-evaluation of θ is performed (line search method):

θ∗ = λsθnew+ (1 − λs)θold (4.20)

where λs is defined as:

λs=

1

2s (4.21)

being s = 1, 2, 3, · · · the s-th step of re-evaluation. At each step of re-evaluation, the norm VN is calculated and θ∗ is taken as the next parameter

vector only if VN(θ∗) < VN(θold), otherwise a new re-evaluation is performed.

If 21s becomes less than eps ≈ 10

−7 (the smallest representable positive

num-ber such that 1.0 + eps 6= 1.0 in Python 2.7, using 32 bit NumPy), the procedure is stopped and θ = θold is taken to build the model.

(55)

Concluding, the ARMAX identification route is stopped when (see Figure 4.1):

1. The method finds a minimum of VN(θ);

2. The maximum number of iterations, that can be defined by the user, is reached.

Figure 4.1: Schematic overview of the ARMAX identification algorithm. In some cases, the system can have an input delay Θ and the (4.1) be-comes:

(1 + a1z−1+ ... + anaz

−na)y(t) =

=(b1z−(1+Θ)+ ... + bnbz

−(nb+Θ))u(t) + e(t) (4.22)

and the φk vector:

φk =          −yk−1 .. . −yk−na uk−(1+Θ) .. . uk−(nb+Θ)          (4.23)

(56)

The ARX identification procedure is the same described above, with

M = max(na, nb + Θ), while in the ARMAX case M = max(na, nb+ Θ, nc)

and analogous considerations for φk in (4.15) can be made. The input delay

can be defined by the user.

4.2

MIMO systems: MISO approach

In the section 4.1 we have seen the identification procedures used for a single input-single output ARX and ARMAX models. When the plant is operating, an output is affected by many manipulated variables and the relationships between the output and the inputs is needed to have a deeper knowledge about the process. These relationships may be required for more than one output, hence the identification procedures for multi inputs-multi outputs ARX and ARMAX systems have been developed. In the multi-inputs case, the input sequence is a matrix:

     u1,0 u1,1 u1,2 u1,N u2,0 u2,1 ... u2,N .. . um,0 um,1 ... um,N     

with m = number of inputs. In the ARX case, a MISO (multi input-single output) relation can be described extending the (4.1):

(1 + a1z−1+ ... + anaz −na)y(t) = =(b1,1z−1+ ... + b1,nb1z −nb1)u 1(t) + (b2,1z−1+ ... + b2,nb2z −nb2)u 2(t)+ + ... + e(t) (4.24)

where nbi denotes the order of the i-th input and bi,j denotes the j-th

(57)

The identification steps are the same of the SISO case, extending the φk vector of (4.3) as follows: φk =                    −yk−1 .. . −yk−na u1,k−1 .. . u1,k−nb1 u2,k−1 .. . u2,k−nb2 .. .                    (4.25)

In this case M = max(na, nb1, nb2, ...). As consequence, the parameter vector

of (4.5) becomes:

θ = [a1a2... ana b1,1... b1,nb1 b2,1... b2,nb2...]

T (4.26)

From (4.9) the parameters are obtained and the transfer functions G1(z),

G2(z),... can be built for each input-output relation. If a system with p

outputs and m inputs has to be identified, the user has to define the orders for each input-output relation:

na = [na1 na2 ... nap] (4.27) nb =      nb11 nb12... nb1m nb21 nb22... nb2m .. . . .. nbp1 nbp2 ... nbpm      (4.28)

(58)

In addition, each input-output relation can have a delay: Θ =      Θ11 Θ12... Θ1m Θ21 Θ22... Θ2m .. . . .. Θp1 Θp2... Θpm      (4.29)

In this notation, naidenotes the i-th output order, nbij is the order associated

to the j-th input - i-th output and Θij is the delay associated to the j-th input

- i-th output. If an input has no influence on an output, nbij has to be setted

as 0. While performing the i-th MISO identification, Mi will be take as:

Mi = max

j (nai, max(nbij+ Θij)) (4.30)

In the ARMAX structure, the orders of the error models are needed:

nc= [nc1 nc2 ... ncp] (4.31)

Mi = max

j (nai, max(nbij + Θij), nci) (4.32)

where nci is the error model order associated to the i-th output. The overall

MIMO model is built grouping the MISO relations of each output (4.24) in a single transfer function which contains all the relations between the inputs and the outputs.

4.3

Examples

In order to verify if the implemented methods work, many tests have been performed and below few of them are reported. The input and output data are generated in Python 2.7, using the package ”control 0.7.0”. The inputs in these tests are pseudo-random binary sequences (PRBS), with a defined switch probability. In these examples, we assume to have an infinite number of past inputs and outputs equal to zero to calculate the output sequence starting from the input sequence:

(59)

4.3.1

Example 1

Consider the following ARX system: G(z) = z 3+ 0.89z2+ 0.746z + 0.2415 z5− 2.21z4 + 1.749z3− 0.5843z2+ 0.0684z (4.33) H(z) = z 5 z5− 2.21z4+ 1.749z3− 0.5843z2+ 0.0684z (4.34)

in this example: na = 4, nb = 4, Θ = 1. Using a PRBS sequence as input

without adding a noise to the output, the identification function returns the transfer function G(z) of (4.33) exactly, if the correct orders are setted (in these examples, we shall assume that the orders are known). Adding to the output the error term H(z)e:

ytot = yout+ yerr = G(z)u + H(z)e (4.35)

where e is a white noise with variance σ2 ≈ 6. The graphics containing the

input sequence, the two output terms and the overall output are reported in Figure 4.2. Note that, from the identification algorithm point of view, only ytot and u are known, while e, yout and yerr are unknown. This is valid for

(60)

(a) Input sequence (b) yout

(c) yerr (d) ytot

(61)

The identified system is: ˆ G(z) = 0.7744z 3+ 1.412z2+ 0.6529z − 0.1902 z5− 2.147z4+ 1.537z3− 0.3507z2− 0.01734z (4.36) ˆ H(z) = z 5 z5− 2.147z4+ 1.537z3− 0.3507z2− 0.01734z (4.37)

Using the same inputs applied to the identified system, the generated outputs compared to the original system are shown in Figure 4.3.

(a) yout (b) yerr

(c) ytot

(62)

From the identification data, the identified system seems to be able to fol-low the original system, but a validation step is needed to test the reliability of the identified model. Using another PRBS sequence with a different range and switch probability, the output terms generated by the original system and the identified one are compared (see Figure 4.4).

(a) Input sequence (b) yout

(c) yerr (d) ytot

(63)

4.3.2

Example 2

Another example for the ARX identification:

G(z) = z 6+ 4.2z5+ 7.42z4+ 7.14z3+ 4.037z2+ 1.339z + 0.2411 z11+ 0.1z10 (4.38) H(z) = z 11 z11+ 0.1z10 (4.39)

In this example: na= 1, nb = 7, Θ = 4. The identified system is:

ˆ G(z) = 0.9795z 6+ 4.476z5+ 6.992z4+ 7.107z3+ 4.791z2+ 0.9945z + 0.6224 z11+ 0.1267z10 (4.40) ˆ H(z) = z 11 z11+ 0.1267z10 (4.41)

The results of the identification and validation tests are shown in the Figures 4.5, 4.6.

(64)

(a) Input sequence (b) yout

(c) yerr (d) ytot

(65)

(a) Input sequence (b) yout

(c) yerr (d) ytot

Figure 4.6: Validation data

4.3.3

Example 3

Now consider the ARMAX system:

G(z) = z 2 − 2.07z + 1.315 z14− 2.21z13+ 1.749z12− 0.5843z11+ 0.0684z10 (4.42) H(z) = z 14+ 0.3z13 z14− 2.21z13+ 1.749z12− 0.5843z11+ 0.0684z10 (4.43)

In this example: na = 4, nb = 3, nc = 1, Θ = 11 and the white noise has a

(66)

Using the identification data, shown in Figure 4.7, the ARMAX identifi-cation function returns:

ˆ G(z) = 1.002z 2− 2.092z + 1.328 z14− 2.227z13+ 1.776z12− 0.5887z11+ 0.06322z10 (4.44) ˆ H(z) = z 14+ 0.2725z13 z14− 2.227z13+ 1.776z12− 0.5887z11+ 0.06322z10 (4.45)

(a) Input sequence (b) yout

(c) yerr (d) ytot

(67)

A model validation is performed and the results are reported in Figure 4.8.

(a) Input sequence (b) yout

(c) yerr (d) ytot

(68)

4.3.4

Example 4

Consider the MIMO ARMAX system reported in Table 4.1:

Table 4.1: MIMO ARMAX system of example 4

Output 1 Output 2 Output 3

Input 1 g11= 4z 3+3.3z2 z5−0.3z4−0.25z3−0.021z2 g21= −85z 2−57.5z−27.7 z4−0.4z3 g31= 0.2z 3 z4−0.1z3−0.3z2 Input 2 g12= 10z 2 z5−0.3z4−0.25z3−0.021z2 g22=z71z+12.34−0.4z3 g32= 0.821z 2+0.432z z4−0.1z3−0.3z2 Input 3 g13= 7z 2+5.5z+2.2 z5−0.3z4−0.25z3−0.021z2 g23= −0.1z 3 z4−0.4z3 g33= 0.1z 3 z4−0.1z3−0.3z2 Input 4 g14= −0.9z 3−0.11z2 z5−0.3z4−0.25z3−0.021z2 g24= 0.994z 3 z4−0.4z3 g34= z40.891z+0.223−0.1z3−0.3z2 Error model h1= z 5+0.85z4+0.32z3 z5−0.3z4−0.25z3−0.021z2 h2= z 4+0.4z3+0.05z2 z4−0.4z3 h3= z 4+0.7z3+0.485z2+0.22z z4−0.1z3−0.3z2

Using the notation of the equations 4.27, 4.28, 4.31 and 4.29:

na= [3 1 2], nb =   2 1 3 2 3 2 1 1 1 2 1 2  , nc= [2 2 3], Θ =   1 2 2 1 1 2 0 0 0 1 0 2  

The white noises e1, e2 and e3 have variances σ21 = 50, σ22 = 100 and σ32 = 1.

The input sequence and the system outputs yi,out =

P

jgijuj, yi,err= hiei,

yi,tot = yi,out+yi,errcompared to the outputs of the identified one are reported

(69)

Figure 4.9: Input sequence, identification data

(70)

Figure 4.11: yerr, identification data

(71)

The identified system is shown in Table 4.2.

Table 4.2: Identified system of example 4

Output 1 Output 2 Output 3

Input 1 z5−0.3415z4.074z4−0.1682z3−1.766z3−0.09232z2 2 −96.3z2−50.23z−28.85 z4−0.3716z3 −0.5981z3 z4−0.6645z3+0.02811z2 Input 2 z5−0.3415z4−0.1682z11.27z23−0.09232z2 71.81z+14.38z4−0.3716z3 0.8708z 2−0.001791z z4−0.6645z3+0.02811z2 Input 3 6.861z2+5.426z+1.488 z5−0.3415z4−0.1682z3−0.09232z2 −0.1057z3 z4−0.3716z3 0.09113z 3 z4−0.6645z3+0.02811z2 Input 4 −1.852z3+0.749z2 z5−0.3415z4−0.1682z3−0.09232z2 1.063z 3 z4−0.3716z3 z4−0.6645z0.8169z−0.16723+0.02811z2 Err. model z5−0.3415zz5+0.7403z4−0.1682z4+0.282z3−0.09232z3 2 z4+0.4582z3−0.1213z2 z4−0.3716z3 z4+0.123z3+0.3278z2−0.09094z z4−0.6645z3+0.02811z2

A validation is performed and the results are shown in the Figures 4.13 ÷ 4.16.

(72)

Figure 4.13: Input sequence, validation data

(73)

Figure 4.15: yerr, validation data

(74)

4.4

ARMAX algorithms comparison

In this section is presented a comparison with the ARMAX function of the System Identification ToolboxT M in MATLAB R2017a. Consider the

follow-ing ARMAX system:

G(z) = z0.8z4+0.7z2+0.5z+0.13+0.33z2

H(z) = zz44+0.21z+0.7z33+0.33z+0.09z22

In our notation: na = 2, nb = 3, nc = 2, Θ = 1. The 500 simulations

are performed with 500 sampling times, the inputs are generated as PRBS sequences in the range [-10,+10] with a switch probability equal to the five percent, the white noise has a variance equal to 0.05. For each simulation, the explained variance (EV ) is calculated:

EV = 1 − P k 2 k P k(yk− y)2 (4.46) where y is the mean value of the output.

The mean value of the EV is equal to ≈ 0.999977640987 for the identified systems, using the implemented procedure, while the ”armax” function of Matlab Toolbox gives a mean value equal to ≈ 0.999999961670, using the same sequences of input and white noise (note that the EV values are high, maybe a stronger white noise should be used). One of these simulations is reported below. The input sequence of this test is reported in Figure 4.17:

(75)

Figure 4.17: Input sequence

The outputs generated by the ARMAX implemented method and by the Matlab function are shown respectively in the Figures 4.18 and 4.19.

(76)

Figure 4.19: ytot, armax Matlab function

Both the algorithms give excellent performances, following the original system. In this test, the EV is ≈ 0.999982403819 for the implemented pro-cedure, while ≈ 0.999999965587 for the Matlab function. The identified systems are reported in Table 4.3.

Table 4.3: Identified systems

Python Matlab ˆ G(z) 0.7986z2+0.5096z+0.09268 z4+0.7061z3+0.3239z2 0.7985z2+0.5078z+0.09572 z4+0.704z3+0.3275z2 ˆ H(z) zz44+0.1496z+0.7061z33+0.0634z+0.3239z22 z4+0.1502z3+0.08426z2 z4+0.704z3+0.3275z2

The Python code is much faster than the Matlab code, but being the identification an offline step, the computational speed should not be a prob-lem. We can observe that the Matlab function has better performances: Matlab has available several line search algorithms, e.g. Gauss-Newton and Levenberg-Marquardt methods( [27], see chapter about computing the esti-mate). In these tests, the SearchMethod option was setted as ’auto’(the default option), i.e. a combination of the available algorithms is tried in

(77)
(78)
(79)

Subspace identification

methods

State space models are particulary convenient for model predictive controllers synthesis and if a model is available as transfer function, a realization can be made to convert it into the state space formulation. The methods to evaluate a state space model, starting from the data, are called ”subspace identification methods” (SIMs). SIMs are a valid alternative to input-output methods for their simple parametrization for MIMO systems [39].

5.1

Some definitions

Before explaining the implemented SIMs, some definitions are needed. We shall use the matrices A ∈ Rp×j, B ∈ Rq×j, C ∈ Rr×j for the following definitions. The operator that projects the row space of a matrix on the row space of the matrix B is:

ΠB, BT(BBT)†B (5.1)

The projection of the row space of A on the row space of the B is denoted by:

A/B = AΠB = ABT(BBT)†B (5.2)

The operator that projects the row space of A on the orthogonal complement of the row space of B is Π⊥B:

A/B⊥ , AΠB (5.3) 65

(80)

defined:

Π⊥B , I − ΠB (5.4)

The oblique projection of the row space of A along the row space of B on the row space of C can be defined as:

A/BC = [A/B⊥][C/B⊥]†C (5.5)

We define the covariance between the matrices A and B as:

Φ[A,B] , E[ABT] (5.6)

where E denotes the expected value operator. Due to the limited measure-ments, we approximate the covariance as:

Φ[A,B] ≈

1 jAB

T

(5.7) being j the number of measurements.

5.2

Traditional methods: N4SID, MOESP and

CVA

Three highly used subspace methods are N4SID [34], MOESP [54] and CVA [25] methods. These subspace methods can be seen as a singular value de-composition of a weighted matrix, based on the unifying theorem discussed in [35]. The implemented algorithm is the ”Combined algorithm 2” proposed in [52] with some differences (see also [12]).

Recalling the process form of the state space model structure (3.76): (

xk+1 = Axk+ Buk+ wk

yk = Cxk+ Duk+ vk

(5.8) where: A ∈ Rn×n, B ∈ Rn×m, C ∈ Rl×n, D ∈ Rl×m.

Considering the input-output data:

u = [u0 u1 u2 · · · uL−1],

y = [u0 y1 y2 · · · yL−1],

Riferimenti

Documenti correlati

caratteri ordinari, in questo caso la scanf si aspetta l’introduzione proprio di quei caratteri in quella esatta sequenza. I caratteri letti sono scartati ad uno ad uno

Il contenuto della parentesi che seguono l'istruzione writeln può essere sia un'espressione (stringa o numerica), sia una variabile sia una combinazione. La parte testuale è

• Regola 3: Anche se le stringhe di formato della scanf() assomigliano molto a quelle della printf(), hanno una semantica leggermente differente (leggete il manuale!). • Regola

 saves pertinent information including last instruction executed and data values in registers in the PCB (process control block).  branches to

¨  Se la stringa di formato contiene un white space, la scanf legge zero o più white space, che verranno scartati, fino al primo carattere non white space.

 An efficient means of transferring data directly between I/O and memory for large data transfers since programmed I/O is suitable only for slow devices and individual

In the context of the theory of symplectic-Haantjes manifolds, we construct the Haantjes structures of generalized St¨ ackel systems and, as a particular case, of the

To this regard, we showed that the model checking technique can be suitable to perform planning and universal planning for continuous systems, by analysing the dynamics of a