Real Time Process Optimization Using a Recursive
Least Squares Impulse Weight Gradient Method
(Spine Title: Real Time Process Optimization)
(Thesis format: Monograph)
by
Yuanyuan Liu
Graduate Program in Engineering Science
Department of Chemical and Biochemical Engineering
Submitted in partial fulfillment
of the requirements for the degree of
Master of Engineering Science
The School of Graduate and Postdoctoral Studies
The University of Western Ontario
London, Ontario, Canada
August, 2008
© Yuanyuan Liu 2008
ii
THE UNIVERSITY OF WESTERN ONTARIO SCHOOL OF GRADUATE AND POSTDOCTORAL STUDIES
CERTIFICATE OF EXAMINATION Supervisor ______________________________ Dr. Arthur Jutan
Examiners ______________________________ Dr. Amarjeet Bassi _____________________________ Dr. Dimitre Karamanev ______________________________ Dr. Serguei Primak
The thesis by
Yuanyuan Liu
entitled:
Real Time Process Optimization Using a Recursive Least Squares Impulse Weight Gradient Method
is accepted in partial fulfillment of the
requirements for the degree of Master of Engineering Science
Date__________________________ _______________________________
Chair of the Thesis Examination Board
iii
Abstract
The chemical industry is increasingly compelled to operate profitably
in a very dynamic and global market. Real-time optimization plays an
important role in plant operation because it is at the level of the control
hierarchy at which business decisions are integrated into the operation.
Model-based optimization schemes require accurate models which are
sometimes hard to obtain in practice. The advantage of direct search
optimization becomes obvious when an explicit model is unavailable. In this
work, a new recursive least squares impulse weight, gradient based,
feedback optimization method is developed and tested in both simulation
and experimental applications. For a linearized dynamic system, the
gradient of the system output with respect to the system input can be
interpreted as the first non-zero impulse weight of the system. This
relationship was confirmed by open-loop and closed-loop tests on linear and
non-linear static and dynamic systems. This gradient information can thus
be used for extremum seeking. Closed-loop control real time case studies
demonstrated the ability of the new gradient based optimization method to
follow different time-varying optimal policies using a wide range of input
signals. Simulation studies also demonstrate that a strong advantage of this
new method is its ability to handle processes with changing dead time and
model structure.
iv
Keywords: Real-time optimization, Direct Search Method, Gradient Based
Optimization, Extremum seeking, Dead Time
v
Dedication
To my wonderful mother Guizhen Li
To my beloved grandmother Ping Cui
and
To my uncle Ming Li who has supported me all the way since the
beginning of my studies.
vi
Acknowledgement
I am deeply indebted to my supervisor Professor A. Jutan. Thank you
for accepting me to your research group and your kind help, excellent
guidance, continuous support and encouragement throughout my research
and the writing of this thesis. Words cannot express how grateful I am. I
feel extremely fortunate and honoured to be your last student. I would like
to thank Cheryll Rose Jutan, for her encouragement and kind support
during my study.
I would like to extend my thanks to the Department of Chemical and
Biochemical Engineering and its faculty and staff for the financial, academic
and technical support.
I would also like to thank all who have wished me good and made my
stay at London all the more pleasant.
Last but not least, I sincerely thank my parents Zhenwei Liu and
Guizhen Li for their love and constant support over all these years.
vii
Table of Contents
Title Page········································································································ i Certificate of Examination·············································································ii Abstract·········································································································iii Dedication······································································································v Acknowledgements·······················································································vi Table of Contents·························································································vii List of Figures·······························································································xi List of Acronyms ························································································· xv Nomenclature······························································································xvi 1 Introduction ··················································································1
1.1 General ······················································································2
1.2 Thesis Objective ··········································································4
1.3 Thesis Overview ··········································································4
1.3.1 Comparison of Some Recent Real-Time Optimization Methods ······5
1.3.2 A New Recursive Least Squares Impulse Weight Gradient Optimization Method······························································5
1.3.3 Simulation Examples······························································5
1.3.4 Real-Time Optimization ··························································6
1.3.5 Summary and Future Work ·····················································6
2 Comparison of Some Recent Real-Time Optimization Methods ······8
2.1 Introduction················································································9
2.2 Problem Formulation ································································· 10
2.3 Direct Search Methods ······························································· 11
2.3.1 Simplex Methods·································································· 11
2.3.1.1 Nelder-Mead Simplex Method··········································· 11
viii
2.3.1.2 Dynamic Simplex Method ················································ 16
2.3.2 Sign-Sign Optimization Method·············································· 18
2.3.3 Perturbation Method ···························································· 25
2.3.4 A Fuzzy Logic Based Approach··············································· 29
3 A New Recursive Least Squares Impulse Weight Gradient Optimization Method ··································································· 38
3.1 Introduction·············································································· 39
3.2 Impulse Weight Gradient Method ················································ 39
3.3 Theory of Recursive Least Squares Algorithms······························· 43
3.3.1 Least Squares······································································ 43
3.3.2 Recursive Least Squares ······················································· 44
3.3.3 Recursive Least Squares with Exponential Forgetting ··············· 46
3.4 Gradient Optimization ······························································· 49
3.5 Optimization Examples ······························································ 50
4 Simulation Examples ··································································· 53
4.1 Estimate Gradient using RLS······················································ 54
4.2 Gradient Estimate Simulation····················································· 55
4.2.1 A Linear Static System Example ············································ 55
4.2.2 A Second Order Non-Linear Static System ······························· 57
4.3 Combining the Perturbation Method with the Proposed Gradient
Method ···················································································· 61
4.3.1 Static Example ···································································· 62
4.3.1.1 Effect of random different test signals································ 67
4.3.2 Nonlinear Dynamic Example ················································· 68
ix
4.3.2.1 Simulation 1 ·································································· 71
4.3.2.2 Simulation 2 ·································································· 72
4.3.3 Comparison of proposed RLS Impulse Weight Gradient Method with Sign-Sign Method·························································· 73
4.4 Processes with Dead Time··························································· 74
4.5 Processes with Variable Dead Time ·············································· 79
4.6 Processes with Variable Dead Time and Changing Model Structure ·· 81
5 Real-Time Optimization ······························································· 84
5.1 Real-Time Application to CST······················································ 85
5.1.1 Experimental Setup······························································ 86
5.1.2 Experimental Runs ······························································ 89
5.1.3 Discussion··········································································· 93
5.2 Real-Time Application to Pressure Tank ······································· 94
5.2.1 Experimental Setup······························································ 95
5.2.2 Experimental Runs ······························································ 97
5.2.3 Discussion··········································································101 6 Summary and Future Work ······················································· 103 Appendix A –Experimental Setup ················································· 107
A.1 Data acquisition board ······························································107
A.2 MATLAB applications·······························································116
Appendix B – MATLAB Codes ······················································· 122
B.1 Generate simulated data ···························································122
B.2 S-Function of estimating first non-zero impulse weight for a linear
static problem·········································································122
x
B.3 S-Function of estimating first non-zero impulse weight for a second
order nonlinear static problem ···················································125
B.4 Generate data for a process with variable dead time and model·······128
B.5 S-Function for calculating delay ·················································129
B.6 S-Function of Gradient method on processes with dead time···········132
B.7 S-Function of Gradient method on CST and Pressure Tank ············135
Appendix C - Conversion Tables ··················································· 139
C.1 CST temperature measurement ·················································139
C.2 Pressure tank ··········································································140
Curriculum Vitae·········································································· 141
List of Figures
1.1 General structure of model-based RTO···········································3
2.1 Operations used in Nelder-Mead simplex algorithm ······················· 15
2.2 Successive reflection in 2-dimensional space ································· 17
2.3 Feedback optimizer ··································································· 18
2.4 The results from One-variable-at-a-time strategy ·························· 22
2.5 Contour plot of the Eq. (2.3)························································ 23
2.6 Optimization results of Eq. (2.3)·················································· 24
2.7 3-D optimization using Sign-Sign method ····································· 25
2.8 The principle of the perturbation method ······································ 26
2.9 The perturbation extremum seeking scheme ································· 27
3.1 Basic input-output configuration ················································· 40
3.2 Feedback optimization loop ························································ 49
4.1 Estimation of first impulse weight using RLS with a forgetting factor
0.99 and correlation method. Sampling time is 1s ··························· 54
4.2 Gradient estimation for a linear static system using Simulink
Toolbox ··················································································· 56
4.3 Gradient information for a linear static system ····························· 57
4.4 Gradient estimation using Simulink Toolbox for a second order
nonlinear static system······························································ 59
4.5 Gradient information for a second order nonlinear static system with
xi
se ······································································ 60 ( )= +sinx t noi
xii
4.6 Feedback optimization loop for a static system ······························ 61
4.7 Optimization feedback loop for Eq. (4.5) ······································· 63
4.8 Block diagrams in Simulink Toolbox for a static system·················· 64
4.9 Output for Example 4.5 ····························································· 65
4.10 Gradient and input information for Example 4.5·························· 66
4.11 Gradient comparison between RLS and Correlation method ·········· 66
4.12 Actual and optimal process input and output values for example 4.6
with random number as input signal··········································· 67
4.13 Feedback optimization loop for a nonlinear dynamic system ·········· 68
4.14 Simulation results for equation 4.8 ············································ 71
4.15 Simulation results for equation 4.8 with ramp optimal output········ 72
4.16 Minimum seeking for quadratic function 4.9 ······························· 73
4.17 Feedback optimization loop for processes with dead time··············· 75
4.18 Block diagrams in Simulink Toolbox for a process with dead·········· 77
4.19 Simulation results for equation 4.9 with dead time=3 ··················· 78
4.20 Dead time and gradient information for equation 4.10 ·················· 80
4.21 Dead time and gradient information for equation 4.11 ·················· 82
5.1 Continuous Stirred Tank ··························································· 85
5.2 Experimental setup for CST ······················································· 87
5.3 Picture of the CST used for experimental runs ······························ 88
5.4 Variation in CST temperature with both water valve and steam valve
25% open·················································································· 89
5.5 CST Real –Time optimization diagram········································· 90
xiii
5.6 Simulink© block diagrams for Real time Optimization of a CST······· 91
5.7 Real-Time Optimization-output of objective function Eq.(5.1) ·········· 92
5.8 Real-Time Optimization-temperature condition····························· 93
5.9 Pressure Tank·········································································· 94
5.10 Experiment Setup for Pressure Tank System ······························ 95
5.11 Picture of Pressure Tank ·························································· 96
5.12 Pressure Tank Real –Time optimization diagram························· 97
5.13 Simulink block diagrams for Real time Optimization of a Pressure
Tank ····················································································· 98
5.14 Optimization results for the pressure tank system with objective
function given as Eq. (5.2): objective output································· 99
5.15 Optimization results for the pressure tank system with objective
function given as Eq. (5.2): Pressure condition inside the tank ······100
A.1 Digital input ports of the data acquisition board···························108
A.2 Analog input ports of the data acquisition board ··························109
A.3 Thermocouple ·········································································109
A.4 Experiment setup for voltage measurement·································111
A.5 Experiment setup for valve control·············································111
A.6 Advantech Device Manager·······················································113
A.7 Device Setting·········································································114
A.8 Advantech Device Test ·····························································115
A.9 Real time toolbox library ··························································116
A.10 Simulink model for temperature measurement ··························117
xiv
A.11 Select ‘pci1710.rtd’ as the hardware driver ································118
A.12 Setup the connection mode and the input/output signal range ······119
A.13 Choose input range 0V ~ 10V ··················································119
A.14 Choose output range 0V ~ 10V·················································120
A.15 Simulink model for valve control ··············································121
xv
List of Acronyms
RTO Real Time Optimization
RLS Recursive Least Squares
CST Continuous Stirred Tank
DSM Dynamic Simplex Method
PID Proportional Integral Derivative
DT Dead Time
ARX Auto Regressive and eXogenous
MSE Mean Squared Error
SISO Single Input Signal Output
MPC Model Predictive Control
LMS Least Mean Squares
NLMS Normalized Least Mean Squares
Nomenclature
Chapter 2. Comparison of some Recent Real-Time
Optimization Methods
Symbols
f Function value
f Average function value
x Process inputs
y Process outputs
J Objective function
N Number of dimensions
S A Simplex which has vertices 1N +
0S Initial simplex
Greek letters
θ Time varying parameters
φ Measurement noise
ρ Scalar parameter of reflection
κ Scalar parameter of expansion
γ Scalar parameter of contraction
σ Scalar parameter of shrinkage
μ Step size of the Sign-Sign method
xvi
Subscripts
c Centroid
e Expansion
i Inside contraction
o Outside contraction
r Reflection
t Time, s
Chapter 3. A new Recursive Least Squares Impulse
Weight Gradient Optimization Method
Symbols
G Transfer function
q Shift operator
n Noise model
v Impulse response
r Covariance
P Covariance matrix
h Sampling interval
Greek letters
β Correlation
λ Forgetting factor
xvii
Chapter 4. Simulation Examples
Symbols
u Inputs
iF Input linear block
oF Output linear block
L Laplace transforms
Greek letters
θ Time varying parameters
δ Gain
Subscripts
nn Parameters of ARX model
nk Delay
Chapter 5. Real-Time Optimization
T Temperature, °C
P Pressure, psi
xviii
1
Chapter 1
Introduction
2
1.1 General
For the chemical process industry to remain competitive in the global
market, the determination of optimal control strategies which maximize
profit, minimize operating costs is becoming one of the main goals in the
design and operation of chemical processes [2]. Hence, real-time optimization
(RTO) is becoming an important concept because it is at the level of the
control hierarchy at which business decisions are integrated into the
operation. The benefits from RTO include [3]:
1. Improved product yields and/or quality;
2. Reduced energy consumption and operating costs;
3. Increased capacity of equipment, stream factors;
4. Less maintenance cost and better maintenance of instrumentation;
5. More efficient engineers and operators as a tool for process trouble
shooting and operation;
6. Tighter, lower cost process designs if new plant designs include a real
time optimizer.
Real-time optimization is most beneficial for processes with a wide range
of operating conditions due to variability in product prices and material costs,
large variations in ambient conditions or economic trade-offs and constraints.
To implement model-based RTO, an accurate process model is necessary.
A general structure of model-based RTO is shown in Fig. 1.1.
3
Fig.1.1 General structure of model-based RTO
Firstly, in the data validation step, the validity of data is checked before
using it for parameter estimation. In the model update step, the reconciled
data is then used to compute a new set of model parameters such that the
plant model represents the plant as accurately as possible at the current
operating point. The updated model is optimized in the optimization step.
After that, the optimization results are analyzed and transferred to the
computer control system for implementation.
Many applications in chemical engineering deal with nonlinear models of
complex physical phenomena. Therefore, the model used for plant design will
usually not represent the real process exactly. Under these circumstances,
the model free RTO is more attractive since it does not require an explicit
model, and based entirely on the process measurements.
4
The objective of this research is to develop a new online, non-model based,
recursive least squares, optimization scheme, to minimize operational cost
and maximize plant profitability while maintaining the desired product
quality.
1.2 Thesis Objective
Most chemical processes are operated under changing operating
conditions which result in changing optimal operating conditions. Good
tracking of optimal operating conditions is important for real-time
optimization. Model-based optimization requires an accurate model to be
applied in practice. However, some process models are either too difficult or
too costly to obtain or update due to process nonlinearity, complicated
physical phenomena, insufficient and noisy measurements or time-varying
parameters. Under these circumstances, the ‘direct search’ (non-model based)
optimization approach is more attractive since an explicit model is
unnecessary. However, most direct optimization methods deal with a static
(i.e. non-dynamic) optimum. In this work, we present a new Impulse Weight
Gradient-based Optimization approach with the ability of handling a
dynamic or a moving optimum.
1.3 Thesis Overview
This thesis is divided into the five chapters outlined below.
5
1.3.1 Chapter 2. Comparison of Some Recent Real-
Time Optimization Methods
In this chapter, some recent successfully non-model based optimization
methods are introduced and compared. They include the Nelder-Mead
Simplex Method and its extension-the Dynamic Simplex Method, the Sign-
Sign Optimization Method, the Perturbation Method, and the Fuzzy Logic
based Method.
1.3.2 Chapter 3. A New Recursive Least Squares
Impulse Weight Gradient Optimization
Method
In this chapter, the Recursive Least Squares (RLS) algorithm is
formulated and compared to the Correlation based impulse method [5]. The
principle of gradient based optimization is then formulated based on the RLS
method.
1.3.3 Chapter 4. Simulation Examples
The Recursive Least Squares (RLS) algorithm is used to estimate the
impulse weights for linear and nonlinear functions. The new Impulse Weight
Gradient Optimization Method is applied to several mathematical functions.
The optimization results are compared with an earlier dynamic optimization
method, the Sign-Sign Method. The new Gradient Optimization Method is
6
also tested on processes with dead time, processes with variable dead time
and processes with variable dead time and a changing model structure. The
simulation results are compared to the Sign-Sign Method.
1.3.4 Chapter 5. Real-Time Optimization
In order to fully test the effectiveness in an experimental setup, the new
RLS Impulse Weight Gradient Optimization method is applied to Real-Time
processes, a Continuous Stirred Tank (CST) and Pressure Tank.
1.3.5 Chapter 6. Summary and Future Work
A summary of major contributions of this thesis is given in this chapter
and some possible applications for future studies are discussed.
7
Bibliography
[1] Xiong, Qiang (2000). Optimization, Control and Identification of
Chemical Processes. M.E.Sc Thesis, University of Western Ontario.
[2] M. Hanke and P. Li (1998). Simulated Annealing For the
Optimization of Chemical Batch Production Processes.
[3] S. Engell (2006). Feedback Control for Optimal Process Operation.
Process Control Laboratory, Department of Biochemical and
Chemical Engineering, D-44221 Dortmund, Germany.
[4] A Toumi, M. Diehl, S. Engell, H.G. Bock, J.P. Schloder, Finite
horizon optimizing of control advanced SME chromatographic
processes, in: 16th IFAC World Congress, Fr-M06-TO/2,2005.
[5] M. Sheikhzadeh, S. Rohani and A. Jutan (2006). A New Non-Model
Based Extremum Seeking Controller. Optimal Control, Applications
and Methods Journal.
8
Chapter 2
Comparison of some
Recent Real-Time
Optimization Methods
9
2.1 Introduction
Real-Time optimization (RTO), or on-line operations optimization has
received a growing appeal in the process industries because of its promise for
reducing operation cost and improving process profitability [2]. Most chemical
processes are characterized by severe nonlinearity, use of inaccurate models,
presence of operational constrains, insufficient and noisy measurements,
time-varying parameters as well as ever changing operating conditions. The
operating conditions are affected by both the physical drifting of the process
itself, such as fouling of a heat exchanger, deactivation of the catalyst in a
reactor, temperature and flow-rate fluctuation of the feed etc. and the
changes in product demand and economic conditions. Real-time optimization
is attractive because it can account for these changes and drive the process
continuously toward its optimal operating point. All kinds of real-time
optimization fall into two categories: model-based approaches and direct
search approaches (or non-model based approaches) [3]. In model-based real-
time optimization, an updated process model is used to determine the
operating conditions for the plant which will act to increase the operating
profit, therefore, the success of model-based approaches rely highly on the
availability of a good process model. However, some chemical processes are
too difficult and/ or costly to model, and even if a model is obtainable it may
be difficult to update due to its complexity and nonlinearity. Thus, the
model–free direct search optimization approaches becomes preferable when a
10
good process model is unavailable, as these methods are based entirely on the
relationship between input and output collected online.
Several successful direct search optimization approaches have been
reported in the literature, such as, Dynamic Simplex Method (DSM) [4], Sign-
Sign Method [5], Fuzzy Logic Based Method [6], Perturbation Method [12],
etc. The algorithms and performance of these methods are reviewed in this
chapter.
2.2 Problem Formulation
A general nonlinear time-varying system to be optimised can be stated
as:
( , , ) ,ty f x tθ φ= + (2.1)
(2.2) ( , )J g y x=
In this formulation, f is a nonlinear function that defines a relationship
between the process input x and process output y , φ is the noise, J is the
objective function to be optimized. The process has a moving optimum due to
the time-varying parameters tθ and .The value of y is calculated by
evaluating the function
t
f in simulation or measurement in a real-time
application.
11
2.3 Direct Search Methods
The direct search methods do not need a process model in order to follow
the optimum operating conditions. This implies that the data required for
building and updating process models become unnecessary in direct search
methods, which greatly saves the time and cost associated with
measurements. Direct search methods are reasonably straightforward to
implement and can be applied almost immediately to many nonlinear
optimization problems [8].
2.3.1 Simplex Methods
After it was first proposed by Nelder and Mead in 1965 [9], the Simplex
search method has enjoyed enduring popularity. Based on the basic simplex
search method, a dynamic simplex method (DSM) [4] was developed in order
to track the moving optimum.
2.3.1.1 Nelder-Mead Simplex Method
A simplex S is a convex hull with N+1vertices in an N dimensional
space . When optimizing experimental systems using a simplex, each
vertex corresponds to a set of experimental conditions. For example, there is
a process with N input variables
Nℜ
{ }1
N
j jx
= , N+1 experiments are carried out in
12
a set of N dimensional experimental conditions. The corresponding
experimental results are labeled in a descending order:
1 2 ...... N 1f f f +> > >
Because the intention is to maximize the objective function f , 1f is referred
to as the best point, 1Nf + the worse point, and Nf the next to the worse point.
In the optimization algorithm the worst points are discarded and several
other movements are carried out for finding new experiment conditions
favorable for optimization. The possible movements include reflection,
expansion, contraction and shrinkage. The rules for the simplex algorithm
are presented as:
A) Rank
Rank the N+1vertices from best to worst as:
1 2 ...... N 1f f f +> > >
B) Reflection
By performing reflection the worst vertex is flipped through the centroid of
the opposite face and a new vertex rx is obtained. The new vertex is:
( )1r c c Nx x x xρ += + −
Where 1ρ = , 1
1 N
cj
jx xN =
= ∑ is the centroid of vertices excepting the worst vertex.
The new vertex ( )r rf f x= is then calculated and evaluated. If 1 r Nf f f≥ ≥ ,
which means that the response at the reflection vertex is not better than the
response at the previously best vertex neither worse than the response at the
13
next to the worst vertex. There is no clear evidence that the simplex is
moving in a particularly desirable or undesirable direction. Hence, the
reflected point is accepted as the vertex of the new simplex and the old worst
vertex is discarded.
C) Expansion
The expansion step allows for a more aggressive move by doubling the
length of the step from the centroid to the reflection point. If the reflected
point satisfies 1rf f≥ , which suggests the simplex is moving toward a
desirable direction, then an expansion movement is operated as:
( )1e c c Nx x x xκ += + −
where . If2κ = ( )e e rf f x f= > , accept ef and terminate the iteration, otherwise,
accept rf and terminate the iteration.
D) Contraction
If r Nf f≤ , which means the reflected point is worse than the next to the
worst point, it makes sense to perform a contraction move allowing for more
conservative moves by halving the length of the step from the centroid to
either the reflection point (outside contraction )or the worst point (inside
contraction) [8].
(1) Outside contraction.
If 1N r Nf f f+ ≤ ≤ , an outside contraction is conducted,
( )o c r cx x x xγ= + −
14
where 12
γ = , if o rf f> , accept of and terminate the iteration; otherwise
perform a shrink move.
(2) Inside contraction
If 1r Nf f +≤ , perform an inside contration
( )i c c rx x x xγ= − −
If i rf f> , accept if and terminate the iteration; other wise perform a shrink
move.
E) Shrinkage
In the shrinkage stage, a new simplex with vertices { } 1~
1
N
j
x+
=
is formed by
reducing the lengths of the edges adjacent to the current best vertex by half.
( )~ 1
1 1
1
, 2,3,..., 1jj
x jx
x x x j Nσ
=⎧⎪= ⎨ + − = +⎪⎩
Where 12
σ = .
The illustration of above operations for a two dimensional process is visually
demonstrated in Fig.2.1.
15
Fig.2.1: Operations used in Nelder-Mead simplex algorithm
16
2.3.1.2 Dynamic Simplex Method
Although the Nelder-Mead simplex method has been extensively used
in industries and research, especially in chemical engineering and chemistry,
it still has some limitations. It works well for processes with static optima;
nevertheless, it cannot deal with processes with moving optima because it
locks itself when the measurement is contaminated by noise or the process
optimum moves with time. Also it is not sensible to apply the simplex method
to a process with too many control variables, since the number of function
evaluations soars when the dimension of the problem increases. Based on
Nelder-Mead simplex method, the Dynamic Simplex Method (DSM) [4] was
developed to handle these limitations.
The Dynamic Simplex algorithm is presented as follows,
The initial simplex is { } 1
0 1
N
j jS x
+
== .
(1) Sort the vertices of the simplex from best to worst:
1 2 ...... N 1f f f +> > >
(2) Successive reflection
Reflect the worst point 1Nf + through the centroid of the opposite side and
obtain a new vertex 2Nx + , thus we have a new simplex { } 2
1 2
N
j jS x
+
==
1
2 12
2 N
N jj
x x xN
+
+=
= −∑
17
And then reflect the first point in the new simplex to obtain a new vertex 1S
3Nx + and a new simplex { } 3
2 3
N
j jS x
+
== . Keep repeating the reflection for M times
and we have { } 1
1
N M
M j j MS x
+ +
= += and a series of new simplices { } 1
Mi i
S=
(3) Select the initial simplex for the next iteration
In this step the average function value of the simplices { } 1
Mi i
S=
are calculated
as:
1
1
1 , 1,2,...,1
N i
i jj i
f f iN
+ +
= +
= =+ ∑ M
Select the simplex whose function value is the maximum and set as
the initial simplex for the next iteration. The response at the best point
maxS maxS
1x is
then re-measured.
The visual description is shown in Figure 2.2.
3x
6x
1x2x
4x
5x
0S
1S
2S
3S
Fig.2.2 Successive reflection in 2-dimensional space
18
The initial simplex is , the worst point 0S 1x is reflected to point 4x and a
new simplex is formed, and then new simplices and are obtained by
reflecting
1S 2S 3S
2x , 4x to 5x , 6x .
Two parameters should be chosen carefully, they are the simplex size and
the successive reflection M. The simplex size should be larger than the
distance that the optimum moves during one iteration in order to track the
moving optimum. A reasonably large simplex size favors reducing the effect
of noises.
2.3.2 Sign-Sign Optimization Method
In direct search methods, gradient information is calculated directly
based on the process measurements which can sometimes corrupted by a high
noise level. The sign-sign method was developed to solve the high noise
sensitivity which can cause suboptimal performance and even instability [5].
Consider a general optimizing feedback structure:
Fig.2.3 Feedback optimizer
Input(s) x
Process
Optimizer
Output y Objective function
( , )J g y x =
19
The system has n input variables: { }1 2, ,..., nx x x x= , the rules used for
driving the objective function to the optimum is:
1n ndJx xdx
μ+ = +
Where the gradient dJdx
can be calculated approximately as:
( 1) ( )( 1) ( ) ( ( 1) ( ))
( 1) ( ) ( ( 1) ( )) ( 1) ( )J n J ndJ J n J n sign J n J n
dx x n x n sign x n x n x n x n+ −+ − + −
≈ = ×+ − + − + −
Where 1 ( 0)
( )1 ( 0)
xsign x
x+ >⎧
= ⎨− <⎩
( ( 1) ( ))( ( 1) ( ))
sign J n J nsign x n x n
+ −+ −
is the sign information of the gradient, and ( 1) ( )( 1) ( )
J n J nx n x n
+ −+ −
is the magnitude information of the gradient. Consider that while process
noise can affect the magnitude of the gradient, it is less likely to corrupt the
sign of the gradient [5]. The sign information is used as the gradient search
direction and the magnitude information is incorporated into a step size μ as:
( 1) ( )( 1) ( )
J n J nx n x n
μ α+ −
= ×+ −
Where α is a scaling factor. One way is to keep step size μ fixed is with the
Basic Sign-Sign Method, another way is to use a changing step size, which is
the Variable Step Size Sign-Sign Method.
1. Basic Sign-Sign Method
In the Basic Sign-Sign Method, the gradient search direction is updated as
follows:
20
(1) μ>0, the process input is increased if
( ( 1) ( )) / ( ( 1) ( )) 0sign J n J n sign x n x n+ − + − >
(2) μ<0, the process input is decreased if
( ( 1) ( )) / ( ( 1) ( )) 0sign J n J n sign x n x n+ − + − <
2. Variable Step Size Sign-Sign Method
The Basic Sign-Sign method is not suitable in high noise level situations
where the measurements become corrupted. Hence, a Variable Step Size
Sign-Sign method was developed in order to restrain the effect of high noise
levels.
Based on Basic Sign-Sign method, the following improvements are made
in Variable Step Size Sign-Sign method:
(a) Take more than one measurements at each iteration and use the
average value of measurements.
The algorithm is written as:
(1) μ>0, the process input is increased if
( ( 1) ( ))/ ( ( 1) ( )) 0m msign J n J n sign x n x n+ − + − >
(2) μ<0, the process input is decreased if
( ( 1) ( )) / ( ( 1) ( )) 0m msign J n J n sign x n x n+ − + − <
21
where m is the number of measures taken at each iteration, the
measurements should be taken with a short period of time. 1
1( ) ( )m
m ii
J n J nm =
= ∑
is the average value of the m measures taken at the nth iteration.
(b) Adopt different step size value in different noise level. The step size
changes as follows:
1.2 var( ( )) :Small
var( ( )) : Medium/1.5 var( ( )) : Large
m
v m
m
J nJ nJ n
μμ μ
μ
⎧⎪= ⎨⎪⎩
Where vμ is the variable step size and the numerical factors are selected by
trail and error. The variance of measures var( ( ))mJ n is used for estimating the
nose level. When noise level is small, an enlarged step size accelerates the
move. When noise level is medium, a normal step size allows neutral moves.
When noise level is large, a reduced step size keeps the move conservative.
‘Large’, ‘Medium’, ‘Small’ are process dependent terms chosen by a process
engineer and are subjective.
3. Extension to multi-input systems
The Sign-Sign method will suffer from the suboptimal solution problem if
the “one-variable-at-a-time” strategy is used [13], in which only one input
variable is adjusted at one time.
Here a hypothetical example is used to illustrate the problem occurs with
the “one-variable-at-a-time” strategy. Consider a process with two inputs:
22
(2.3) 21 2 1 283.57 9.39 7.12 7.44 3.71 5.88y v v v v= + + − − − 1 2v v
Firstly, is fixed at -8, and is adjusted between -10 and 10, which is
shown in Fig. 2.4. From the plot, it is clear that the best result of is 4. Then
is fixed at 4, and is adjusted as shown in Fig.2.4. The best value of is
-2. It is reasonable to draw the conclusion that the best point is .
However, the true best point shown in the contour plot Fig.
2.5.is . The suboptimal solution problem is caused by the
interacting term .
2v 1v
1v
1v 2v 2v
1 24, 2v v= = −
1 20.4, 0.6v v= =
1 25.88v v
In order to remove the problem, sign-sign method dynamically adjusts the
input variables, and which input variable should be adjusted is selected
randomly at each sampling point [5].
-10 -8 -6 -4 -2 0 2 4 6 8 10-2000
-1500
-1000
-500
0v2=-8
v1
y
-10 -8 -6 -4 -2 0 2 4 6 8 10-600
-400
-200
0
200v1=4
v2
y
Fig.2.4: The results from One-variable-at-a-time strategy
23
X= 4Y= -2Level= 20.05
v1
v 2
X= 0.4Y= 0.6Level= 87.6608
-10 -8 -6 -4 -2 0 2 4 6 8 10-10
-8
-6
-4
-2
0
2
4
6
8
10
Optimization locked up here
Fig.2.5: Contour plot of the Eq. (2.3)
There are three parameters which should be chosen carefully in the Sign-
Sign method, they are: sampling time , step size T μ and the window
parameter , which is the number of measurements collected for calculating
a moving direction.
m
The Sign-Sign method is used to find the optimum of equation (2.3). The
result is shown in Fig. 2.6.
24
x1
x 2
-10 -8 -6 -4 -2 0 2 4 6 8 10-10
-8
-6
-4
-2
0
2
4
6
8
10
Optimization starts here
Fig.2.6: Optimization results of Eq. (2.3)
The results in Fig.2.6 indicate that the Sign-Sign method is able to find
the optimal solution regardless of the presence of the interacting term.
The Sign-Sign method is also applied to the following tree dimensional
function with moving optima:
2 21 2 3( 10 5cos(0.02 )) ( 10 5sin(0.02)) ( 0.02 ) 5 ( )y x t x x t t2 ξ= − − + − − + − + + (2.4)
where ( )tξ is the disturbance term
25
05
1015
20
05
1015
200
5
10
15
Variable x1Variable x2
Var
iabl
e x 3
Tracked inputTrue optimum
Start point
Fig.2.7: 3-D optimization using Sign-Sign method
The Sign-Sign method is applied to some simulation and experimental
applications as well.
2.3.3 Perturbation Method
This method is one of the oldest and most popular methods to estimate
the gradient for extremum control. The gradient of the process is indirectly
measured by analyzing the system response to a sine wave input. This
gradient is then passed to a feedback control structure which drives the
gradient to zero. As shown in Figure 2.8, the signal is slightly distorted by a
since wave and the correlation between the output and the input indicates at
which side of the maximum the operating point is located [14].
26
Fig.2.8: The principle of the perturbation method
The simplest nonlinear approximation of a nonlinear function
( )f u expanded around the optimal ( '( ) 0f u = ) as follows:
''*( ) ( )
2f * 2f u f u u= + − (2.5)
Any quadratic function ( )f u can be approximated locally by Eq. (2.5) using a
standard Taylor Series. The algorithm is to minimize *u u− so that the output
( )f u is driven to its optimum *f . For a maximizing problem, , for a
minimizing problem .
'' 0f <
'' 0f >
The basic extremum seeking loop is shown in Fig. 2.9.
27
( )f u
+ks
− × ss h+
sina tω sin tω
u
*u *f
ξ
y
Plant
u
Fig. 2.9: The perturbation extremum seeking scheme
The perturbation signal sina tω is injected into the plant in order to
measure the gradient information of ( )f u . denotes the estimate of the
unknown optimal input and
u
*u * ˆu u u= − denotes the estimation error. Thus,
(2.6) * sinu u a t uω− = −
Substituting the above equation into Eqn. (2.5),
* 2'' ( sin2fy f u a t)ω= + − (2.7)
By expanding this expression further, gives
2
* 2 2'' '''' sin sin2 2f a fy f u af u t tω ω= + − + (2.8)
By applying the basic trigonometric identity 22sin 1 cos 2t tω ω= − , the
expression can be organized as:
28
2 2
* 2'' '' '''' sin cos 24 2 4
a f f a fy f u af u t tω ω= + + − − (2.9)
The high pass filter ss h+
serves to remove *f and 2 ''4
a f , hence.
2
2'' ''[ ] '' sin cos 22 4
s f a fy u af u ts h
tω ω≈ − −+
(2.10)
Then this signal is multiplied bysin tω , giving
2
2 2'' ''sin '' sin cos 2 sin2 4f a fu t af u t t tξ ω ω ω≈ − − ω (2.11)
Again applying 22sin 1 cos 2t tω ω= − and 2cos 2 sin sin 3 sint t t tω ω ω ω= − , we
obtain
2
2'' '' '' ''cos 2 (sin sin 3 ) sin2 2 8 2
af af a f fu u t t t u tξ ω ω ω≈ − + + − + ω
u
(2.12)
Recall , since is constant, then we have , namely,
* ˆu u u= − *u ˆu = −
ˆ( ) ( )su s su s= −
We get
2
2
ˆ( ) ( )
'' '' '' ''[ cos 2 (sin sin 3 ) sin ]2 2 8 2
k ku s u ss s
k af af a f fu u t t t us
ξ ξ
tω ω ω
⎛ ⎞= − = − − =⎜ ⎟⎝ ⎠
≈ − + + − + ω (2.13)
Because we are interested in local analysis, the last term which is
quadratic in can be neglected. u
( )2~ '' '' ''[ cos 2 (sin si
2 2 8k af af a fu s u u t t ts
n 3 )]ω ω ω≈ − + + − (2.14)
The last two terms are high frequency signals which can be attenuated by
passing through an integrator, therefore, they can be neglected, which yields
29
''2
k afus
u⎡ ⎤≈ −⎢ ⎥⎣ ⎦ (2.15)
or
''2
kafu ≈ − u (2.16)
Since , we conclude that the system is stable and , i.e.,
converges to within a small distance of [15].
'' 0kf > 0u → ( )^u t
*u
A number of modifications of the perturbation principles have been made
to handle dynamics, several inputs, etc. The perturbation method has been
shown as an effective gradient search scheme. However, it is limited to
specific sinusoidal signals. Also when it comes to compensation of dynamics
the system can easily become unstable when the control parameters are
chosen poorly [14].
2.3.4 A Fuzzy Logic Based Approach
Fuzzy logic theory has been extended and extensively used in industry
since the basic theory of fuzzy sets was introduced by Zadeh (1965). A fuzzy
set is a set without a crisp, clearly defined boundary. It can contain elements
with only a partial degree of membership [22]. Fuzzy logic based approach is
one of the popular model-free approaches to system identification and control
due to the following advantages [6]:
(1) Explicit mathematical models are unnecessary
30
(2) Imprecise and uncertain inputs can be tolerated
(3) Nonlinearity can be handled effectively
(4) They can be blended with conventional control techniques.
(5) The approach is robust against variations in process parameters.
The fuzzy logic based optimizer receives crisp inputs from online
measurements and determines the degree to which these inputs belong to
each of the appropriate fuzzy sets via membership functions. Once the inputs
have been fuzzified, a set of fuzzy rules are applied to determine the fuzzy
output variable which is then defuzzified to crisp control actions.
Recall the general nonlinear time-varying system and its objective
function:
( , , ) ,ty f x tθ φ= + (2.17)
( , )J g y x= (2.18)
The fuzzy logic based optimization algorithm drives the process toward
optimal operating conditions by performing the following rules: if the last
change in the manipulated variable x has caused the objective function to
improve, keep moving the
J
x in the same direction; otherwise, if the last
change in the manipulated variable xhas cause the objective function to
drop, then move the
J
x in the opposite direction.
There are two input variables for the fuzzy logic based optimizer, one is
the last change in the manipulated variable which is L xΔ , the other one is the
change in the objective function JΔ . The output variable is the incremental
31
change in the manipulated variable xΔ . Then the fuzzy logic based optimizer
maps the input and output space of the process into fuzzy regions and defines
the membership functions for the input and output fuzzy variables.
Input variable L is subdivided into three fuzzy sets: Positive (P), Negative
(N), and Zero (Z).
xΔ
Input variable is subdivided into five fuzzy sets: Positive Small (PS),
Positive Big (PB), Negative Small (NS), Negative Big (NB), Zero (ZZ).
JΔ
The output variable xΔ is divided into seven fuzzy sets: Positive Small (PS),
Positive Medium (PM), Positive Big (PB), Negative Small (NS), Negative
Medium (NM), Negative Big (NB), Zero (ZZ).
The search algorithm for the iteration at k is described as follows:
Rule 1: when the system is operated under normal conditions
If kxΔ is P and kJΔ is PB then 1kx +Δ is PB
If kxΔ is P and kJΔ is PS then 1kx +Δ is PM
If kxΔ is N and kJΔ is PB then 1kx +Δ is NB
If kxΔ is N and kJΔ is PS then 1kx +Δ is NM
If kxΔ is P and kJΔ is NB then 1kx +Δ is PB
If kxΔ is P and kJΔ is NS then 1kx +Δ is NM
If kxΔ is N and kJΔ is NB then 1kx +Δ is PB
If kxΔ is N and kJΔ is NS then 1kx +Δ is PM
32
Rule 2: For processes operated under changing environmental conditions,
the objective function may change due to any sudden change in the
environment even if the manipulated variable x is kept the same. In order to
handle this situation, the following rules are required:
If kxΔ is Z and kJΔ is PB then 1kx +Δ is PM
If kxΔ is Z and kJΔ is PS then 1kx +Δ is PS
If kxΔ is Z and kJΔ is NB then 1kx +Δ is NM
If kxΔ is Z and kJΔ is NS then 1kx +Δ is NS
Rule 3: In situations where the objective function becomes flat, the search
may stop even if the manipulated variable changes. The flowing rules are
developed for avoiding a suboptimal solution.
If kxΔ is P and kJΔ is ZZ then 1kx +Δ is PS
If kxΔ is N and kJΔ is ZZ then 1kx +Δ is NS
Rule 4: Finally, it is necessary to provide the system with a rule that keeps
the operating condition optimal
If kxΔ is Z and kJΔ is ZZ then 1kx +Δ is ZZ
The above rules which describe different conditions shall be provided with
different rule weights, since the rules only become active when their
conditions apply. Rule 1 should be the strongest condition because it
describes the normal system operation. Rule 2 and Rule 3 have lower
strength, because they deal with special conditions. Rule 4 is only activated
33
when the system become close to the optimum point, thus it needs to be
weighted lightly.
First, the crisp inputs are fuzzified using appropriate membership
function. A membership function is a curve that defines how each point in the
input space is mapped to a membership value (or degree of membership)
between 0 and 1 [22]. After above fuzzy rules are evaluated, the fuzzy output
variable is transformed to a crisp number in defuzzification step. The
defuzzification is a mapping from a space of fuzzy control actions defined over
an output universe of discourse into a space of nonfuzzy control actions.
Many defuzzification strategies are used for performing defuzzification, for
example, Center of Gravity, Center of Sums, First of Maxima, Last of
Maxima, Middle of Maxima [23].
34
Bibliography
[1] S. Engell. (2006). Feedback Control for Optimal Operation. Process
Control Laboratory, Department of Biochemical and Chemical
Engineering. Dortmund, Germany.
[2] Y.Zhang, D.Monder and J.F. Forbes. Real-time optimization under
parameter uncertainty: a probability constrained approach. Journal of
Process Control 12(2002) 373-389.
[3] Garcia, C. E. and Morari, M. (1981). Optimal operation of integrated
processing systems, A.I.Ch.E. Journal, 27(6), 960.
[4] Q. Xiong & A. Jutan (2003). Continuous Optimization using a Dynamic
Simplex Method, Chemical Engineering Science, Vol.58, 3817 – 3828
[5] Yide Ping (2006). Non-model Based Real Time Optimization of
Chemical Processes. M.E.Sc Thesis, University of Western Ontario.
[6] D. Sarkar, A. Jutan & S. Rohani. A fuzzy Logic Based Approach to Real
Time Optimization of Dynamic Processes.
[7] M. Sheikhzadeh, S. Rohani and A. Jutan (2006). A New Non-Model
Based Extremum Seeking Controller. Optimal Control, Applications
and Methods Journal.
[8] R. M. Lewis, V. Torczon and M. W. Trosset. Direct search methods:
then and now. Journal of computational and applied mathematics 124
(2000) 191-207.
35
[9] J. A. Nelder & R. Mead (1965). A simplex method for function
minimization. Computer Journal, 7, 308–313.
[10] G.E.P. Box, W.G. Hunter & J.S. Hunter. (1978). Statics for
experimenter: An introduction to design, data analysis and model
building. John Wiley & Son, Inc.
[11] S. Larsson (2001). Literature study on extremum control. Control and
Automation Laboratory. Chalmers University of Technology.
[12] K.B. Ariyur & M. Krstic (2003). Real-time optimization by extremum-
seeking control, Wiley-Interscience, NJ.
[13] M. G. Simoes and N. N. Franceschetti (1999). Fuzzy optimization based
control of a solar array system, IEE proceedings of Electric Power
Applications, vol.146, no.5, pp.552-558, 1999.
[14] R. Hooke & T.A. Jeeves (1961). Direct Search, Solution of Numerical
and Statistical Problems. Journal of the ACM, Vol. 8, Issue 2, 212-229.
[15] Y. Tan, D. Nesic & I. Mareels (2006). On non-local stability properties
of extremum seeking control, Automatica 42, 889-903.
[16] M. Krstic & H.H. Wang (2000). Stability of extremum seeking feedback
for general nonlinear dynamic systems, Automatica, 36, 595–601.
[17] W.L. Brogan (1974). Modern Control Theory, Quantum Publishers, Inc.
[18] B.D. Prater, S.C. Tuller & L.J. Wilson (1999). Simplex optimization of
protein crystallization conditions, Journal of Crystal Growth 196, 674-
684.
36
[19] F.H. Walters, L.R. Parker, S.L. Morgan Jr. & S.N. Deming (1991).
Sequential Simplex Optimization. CRC Press, Boca Raton, Florida.
[20] P. D. Roberts (1979). An algorithm for steady-state optimization and
parameter estimation. International Journal of System Science, 10,
719–734.
[21] K.S. Peterson & A.G. Stefanopoulou (2004). Extremum seeking control
for soft landing of an electromechanical valve actuator, Automatica 40,
1063-1069.
[22] Fuzzy Logic Toolbox User’s Guide, Mathworks Inc., (2000).
[23] D. H. Rao, S. S. Saraf (1995). Study of Defuzzification Methods of Fuzzy
Logic Controller for Speed Control of a DC Motor, IEEE Transactions,
pp.782-787
[24] S. J. Citron. (1969). Elements of Optimal Control. Holt, Rinehart and
Winston, Inc.
[25] Frederick H. Walters, Lioyd R. Parker, Jr, Stephen L. Morgan and
Stanley N. Deming. (1991). Sequential Simplex Optimization: A
Technique for Improving Quality and Productivity in Research,
Development, and Manufacturing. CRC Press, Inc. Boca Raton, Florida.
[26] G. E. P. Box, G. M. Jenkins and G. C. Reinsel (1994). Time Series
Analysis: Forecasting and Control. Third Edition. Prentice Hall,
Englewood Cliffs, New Jersey 07632.
37
[27] C. T. Kelley. (1999). Iterative Methods for Optimization. North Carolina
State University, Raleigh, North Carolina.
[28] M. Sheikhzadeh (2006). Optimization and Control of Crystallization
Processes. Ph.D Thesis, University of Western Ontario.
38
Chapter 3
A New Recursive Least
Squares Impulse Weight
Gradient Optimization
Method
39
3.1 Introduction
Chemical processes often involve strong nonlinear behavior and time-
varying dynamics. The model based optimization algorithms need process
models with high degree of accuracy to be applied in practice [1]. However,
due to many reasons (expenses, time), it is sometimes hard to obtain a
reliable model. In order to be able to track the optimum value in the absence
of a process model, all kinds of direct optimization methods arise. Some of
them were introduced in Chapter 2. Based on these methods, the search
direction and gradient information is calculated directly using the output
measurements. A new impulse weight gradient approach is presented here
for real-time optimization of nonlinear dynamic chemical processes. This
method is tested in both simulation and real time studies in chapter 4 and
chapter 5.
3.2 Impulse Weight Gradient Method
Consider a system with input ( )x t and output ( )y t as depicted in
Fig.3.1, the input and output data are available at each interval.
40
Fig.3.1: Basic input-output configuration.
Assuming the signals are related by a linear system, the relationship
between input and output can be described by a transfer function:
( ) ( ) ( ) ( )y t G q x t n t= + (3.1)
Where is the shift operator and q ( )G q is transfer function, is the noise
model.
( )n t
( ) ( ) ( ) ( )1k
G q x t v k x t k∞
=
= −∑ (3.2)
where ( ){ }v k are called the impulse response of the system.
In order to directly estimate the impulse response coefficients, we define
an impulse response model:
( ) ( ) ( ) ( ) ( ) ( ) ( )0 1 1 2 2 ...y t v x t v x t v x t n t= + − + − + + ( ) (3.3)
There are different approaches to estimation the impulse response
coefficients. One is correlation method [2] which uses pre-whitened input
sequence to estimate the impulse response.
41
Correlation Method:
In correlation method, we multiply equation (3.3) by ( )x t k− ( )0k ≥ ,
gives:
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) (0 1 1 ... ( ) )x t k y t v x t k x t v x t k x t n t x t k− = − + − − + + − (3.4)
If we take expectation on both side of equation (3.4) and assume that the
input sequence is uncorrelated with the process noise, that is,
we have ( )( ) 0E n t x t k⎡ − =⎣ ⎤⎦
( ) ( ) ( ) ( ) ( )0 1 1 ... 0,1,2,...xy xx xxk v k v k kγ γ γ= + − + =
where ( ) are cross covariance between input and output,
( ) are auto-covariance of input sequence.
( )xy kγ 0,1, 2,...k =
( )xx kγ 0,1, 2,...k =
Assuming that the impulse weights are effectively zero after sufficiently
large lag(k)=M.
( ) ( ) ( ) ( ) ( ) ( ) ( )0 1 1 ... 0,1,2,...xy xx xx xxk v k v k v M k M kγ γ γ γ= + − + − = (3.5)
Writing above equation in a matrix form, gives
( )( )
( )
( ) ( ) ( )( ) ( ) ( )
( ) ( ) ( )
( )( )
( )
0 0 11 1 0 1
1 0
xy xx xx xx
xy xx xx xx
xx xx xxxy
M vM v
01
M M vM
γ γ γ γγ γ γ γ
γ γ γγ
⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥−⎢ ⎥ ⎢ ⎥=⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥
−⎢ ⎥ ⎢ ⎥⎣ ⎦⎣ ⎦M
⎡ ⎤⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦
(3.6)
After substituting estimated auto-covariance and cross covariance, the
generalized least square method can be used to solve above equation.
42
In order to simplify the identification processes, correlation method pre-
whitens the input sequence first to make the input signal as uncorrelated as
possible, then the equation (3.6) simplifies to:
( )( )
( )
( )( )
( )
( )( )
( )
0 0 0 0 01 0 0 0 1
0 0 0
xy xx
xy xx
xxxy
vv
v MM
γ γγ γ
γγ
⎡ ⎤ ⎡ ⎤ ⎡ ⎤⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥=⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎣ ⎦ ⎣ ⎦⎣ ⎦
(3.7)
The impulse weights can then be calculated easily from above equations:
( ) ( )( )
( )20
xy xy
xx x
k kv k
γ γγ σ
= = 0,1, 2,k = …
In terms of the cross correlation:
( ) ( )( )
( )2 0,1,2,
0xy xy y
xx x
k kv k k
γ β σγ σ
= = = … (3.8)
Thus, after pre-whitening the input sequence, the impulse weight is
proportional to the cross correlation between the pre-whitened input and
corresponding transformed output.
The correlation method takes advantage of the fact that pre-whitened
input simplifies the identification process, therefore the calculation is easy.
The disadvantages of correlation method are lack of accuracy and sensitivity
to noise. Also we need to carefully choose the window size which is how many
measurements should be collected before a new move.
We presented here an alternative method, the so called Recursive Least
Squares (RLS) method to estimate the impulse weights.
43
3.3 Theory of Recursive Least Squares
Algorithm
3.3.1 Least Squares
In least squares estimation unknown parameters of a linear model are
chosen in such a way that the sum of the squares of the difference between
the actually observed and the computed values, is a minimum [8].
The mathematical model of the least squares can be written in the form:
( ) ( ) ( ) ( ) ( )1 1 2 2T
n ny i v x i v x i v x i x i v= + + + =… (3.9)
Where y is the observed output, are the impulse weights
parameters to be determined, and
1 2, , , nv v v…
1 2, , , nx x … x are input sequence, and the two
vectors are
( ) ( ) ( ) ( )1 2[ ]Tnx i x i x i x i=
1 2[ ]Tnv v v v=
pairs of ( ) ( ){ }, , 1, 2, ,y i x i i t= … are obtained from an experiment. The least
squares method is used to estimate the parameters in such a way that the
outputs computed from the model in equation (3.9) are as close as possible
with the measured outputs ( )y i in the sense of least squares. That is, the
impulse weight parameters are chosen to minimize the least squares
criterion
44
( ) ( ) ( )( ) ( )2
2
1 1
1 1,2 2
t tT
i iL v t y i x i v i E Eε
= =
= − = =∑ ∑ 12
T
v
(3.10)
Where ( ) ( ) ( ) ( ) ( )Ti y i y i y i x iε∧
= − = −
( ) ( ) ( ) ( )1 2E t tε ε ε⎡ ⎤= ⎣ ⎦
By letting ( ),L v tv∂
=∂
0
⎞⎟⎠
, we have [4]
( ) ( ) ( )( ) ( ) ( )( ) ( ) ( ) ( ) ( )1
1
1 1
t tT T T
i iv t X t X t X t Y t x i x i x i y i
−∧ −
= =
⎛ ⎞ ⎛= = ⎜ ⎟ ⎜
⎝ ⎠ ⎝∑ ∑ (3.11)
Where ( )
( )( )
( )
12
T
T
T
xx
X t
x t
⎡ ⎤⎢ ⎥⎢ ⎥= ⎢ ⎥⎢ ⎥⎢ ⎥⎣ ⎦
, ( ) ( ) ( ) ( )1 2T
Y t y y y t⎡ ⎤= ⎣ ⎦ and ( ) ( )TX t X t is
nonsingular.
3.3.2 Recursive Least Squares
In real-time processes, the observations are obtained sequentially.
Therefore, it is desirable to estimate recursively in time, the impulse weight
parameters. In the recursive algorithm, the results obtained at time 1t − is
used to find estimates at time t .
We introduce the definition of the covariance matrix P
( ) ( ) ( ) ( )( ) ( ) ( )1
11
1
tT
iP t R t X t X t x i x iT
−−−
=
⎛= = = ⎜
⎝ ⎠∑ ⎞
⎟ (3.12)
45
Assume that the matrix ( )X t is nonsingular for all t , then
( ) ( ) ( ) ( ) ( ) ( ) ( )
( ) ( ) ( )
11
1 11 1
t tT T
i iT
P t x i x i x i x i x t x t
P t x t x t
−−
= =
−
= = +
= − +
∑ ∑ T
⎞⎟⎠
1
(3.13)
Equation (3.11) may be written as
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )1
1 1
t t
i i
v t P t x i y i P t x i y i x t y t−∧
= =
⎛ ⎞ ⎛= = +⎜ ⎟ ⎜
⎝ ⎠ ⎝∑ ∑ (3.14)
From equation (3.11), we have
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )1
1 1
11 1 [ ]
tT
ix i y i P t v t P t x t x t v t
− ∧ ∧− −
=
= − − = − −∑ (3.15)
Substituting in equation (3.14)
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )
( ) ( ) ( ) ( ) ( ) ( )
( ) ( ) ( )
1[ ] 1
1 1
1 1
1
T
T
T
v t P t P t x t x t v t x t y t
v t P t x t x t v t P t x t y t
v t P t x t y t x t v t
v t K t tε
∧ ∧−
∧ ∧
∧ ∧
∧
⎡ ⎤= − − +⎢ ⎥⎣ ⎦
= − − − +
⎡ ⎤= − + − −⎢ ⎥⎣ ⎦
= − +
(3.16)
where and ( ) ( ) ( )K t P t x t= ( ) ( ) ( ) ( )1Tt y t x t v tε∧
= − −
From equation (3.13) we have
( ) ( ) ( ) ( ) ( )( 11 1 1 TP t R t P t x t x t )−− −= = − + (3.17)
To avoid inverting ( )R t at each step, apply the Matrix Inversion Lemma
( ) ( ) 11 1 1 1 1 1A BCD A A B C DA B DA−− − − − −+ = − + − (3.18)
to the equation (3.17), with ( ) ( )1 1 , ,A P t B x t C I−= − = = and ( )TD x t= ,
46
(3.19) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )1
1 1 1T TP t P t P t x t I x t P t x t x t P t−
⎡ ⎤= − − − + − −⎣ ⎦ 1
After substituting above expression in the equation for ( )K t and simplifying,
we have
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) 11 T 1K t P t x t P t x t I x t P t x t
−⎡ ⎤= = − + −⎣ ⎦ (3.20)
We can now summarize RLS algorithm as:
( ) ( ) ( ) ( )1v t v t K t tε∧ ∧
= − + (3.21)
( ) ( ) ( ) ( )1Tt y t x t v tε∧
= − − (3.22)
( ) ( ) ( ) ( ) ( ) ( ) 11 T 1K t P t x t I x t P t x t
−⎡= − + −⎣ ⎤⎦
1
(3.23)
( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( )( ) ( ) ( )
11 1 1
1
T T
T
P t P t P t x t I x t P t x t x t P t
I K t x t P t
−⎡ ⎤= − − − + − −⎣ ⎦
⎡ ⎤= − −⎣ ⎦ (3.24)
with initial values ( ) ( )00 , 0v v P Iα= = , where α should be large.
3.3.3 Recursive Least Squares with Exponential
Forgetting
In the least squares model described by equation (3.9) the parameters
are assumed to be constant. In case of systems with varying parameters it is
necessary to extend the least squares method to account for time changing
parameters. There are two cases to consider in terms of varying parameters.
In one case, parameters are assumed to change abruptly but infrequently; in
47
the other case the parameters are assumed to change continuously but slowly.
In the case of systems with abrupt parameter change we use a technique
called covariance resetting. The covariance matrix P is then periodically reset
toα I , where α is a large number. In the case of systems with slowly varying
parameters it is useful to give more emphasis to recently observed data than
to older data. One approach to do this is to replace the least squares criterion
with
( ) ( ) ( )(2
1
1,2
tt i T
iL v t y i x i vλ −
=
= −∑ ) (3.25)
Where λ (0 1λ< ≤ ) is called forgetting factor. The least squares criterion of
Eq. (3.25) implies that a time-varying weighting of the data is introduced.
The recursive least squares estimate then becomes:
( ) ( ) ( ) ( )1v t v t K t tε∧ ∧
= − + (3.26)
( ) ( ) ( ) ( )1Tt y t x t v tε∧
= − − (3.27)
( ) ( ) ( ) ( ) ( ) ( )1
1 T 1K t P t x t I x t P t x tλ−
⎡= − + −⎣ ⎤⎦ (3.28)
( ) ( ) ( ) ( )1 /TP t I K t x t P t λ⎡ ⎤= − −⎣ ⎦ (3.29)
The memory of the estimator is given by 02
1hTλ
=−
, where h is the sampling
interval.
In the classical RLS, the covariance shrinks with time, losing its capability
to keep track of changes in the parameters. However, it can be seen that in
Eq. (3.29), the covariance matrix is divided by 1λ ≤ at each update. This
48
prevents the covariance matrix from becoming too small, and therefore
maintains the sensitivity of the algorithm and allows new data to contribute
to the parameter estimates.
Based on a well established experience, the RLS method is useful for real
time applications because each new data pair can be used to update the value
of impulse weights. The system must also be sufficiently excited in order to
keep the RLS algorithm active. During poor excitations old information is
gradually forgotten while there is only limited new information coming in.
This might cause the exponential growth of the covariance matrix and as a
result the estimator becomes extremely sensitive and susceptible to
numerical and computational errors [11].
Interpretation of impulse weights jv
Recall Eq. (3.3) ( ) ( ) ( ) ( ) ( ) ( ) ( )0 1 1 2 2 ... ( )y t v x t v x t v x t n t= + − + − + +
For a static system relating y to x, ( )0v can be interpreted as the
gradient of y respect to x. For a dynamic system, ( )0v thus represents the
current gradient. In case of systems with dead time (DT), the first non-zero
impulse coefficient ( ) ( )y v j
x j∂
=∂
represents the current gradient. This
gradient value is determined by the current input ( ) ( )x j . 0v is the gain of
the effect of the current input ( )x ( )y t t on the output
For example,
49
When DT=1, ( )0v = 0 , the current gradient is ( )1v
When DT=2,v v , the current gradient is ( ) ( )0 1 0= = ( )2v .
3.4 Gradient Optimization
The basic principle behind gradient based optimization is the fact that
we push a process in the negative gradient direction until the extremum is
reached and has a gradient with magnitude of zero [7]. The new algorithm
proposed here is to use the RLS method to sequentially estimate the gradient
direction based on input/output measurements. This gradient direction is
then used in a feedback loop as a pseudo gradient measurement . The
controller (PID) then drives v to zero and when v is zero the process
optimum is achieved. These concepts are combined into a feedback
optimization loop as shown in Figure 3.2.
v
Process
Test Signal
PID Controller
+
-
y
v (Pseudo gradient measurement)
Gradient Estimator (RLS)
x
Set point=0
Figure 3.2 Feedback optimization loop
50
3.5 Optimization Examples
In order to evaluate the effectiveness of the impulse weight gradient
optimization method, it is tested on both simulated models and real-time
processes. Simulation results using the RLS method to estimate impulse
weights are also compared to that of the simpler correlation method. The
simulation results are also compared with other successful direct search
methods in chapter 4.
51
Bibliography
[1] Xiong, Qiang (2000). Optimization, Control and Identification of
Chemical Processes. M.E.Sc Thesis, University of Western Ontario.
[2] M. Sheikhzadeh (2006). Optimization and Control of Crystallization
Processes. Ph.D Thesis, University of Western Ontario.
[3] System Identification Toolbox User’s Guide, Mathworks Inc., (2000).
[4] Ljung, Lennart (1989). System Identification: Theory for the User,
Prentice Hall.
[5] S. Haykin (2001), Adaptive Filter Theory, 4th edition, Prentice Hall, NJ,
ISBN-0-13-090126-1.
[6] Box G. P., Jenkins G. M., Reisel G. C. (1994). Time Series Analysis,
Prentice Hall, Englewood Cliffs, New Jersey.
[7] Larsson S. (2001). Literature Study on Extremum Control, Control and
Automation Laboratory, Chalmers University of Technology.
[8] Karl J. Astrom, Bjorn Witternmark (1995). Adaptive Control, second
edition, Addison-Wesley Publication Company, Inc.
[9] A. Vahidi, A. Stefanopoulou, H. Peng, Recursive Least Squares with
Forgetting for Online Estimation of Vehicle Mass and Road Grade:
Theory and Experiments. Mechanical Engineering Dept., University of
Michigan.
52
[10] R. Krneta, S. Antic and D. Stojanovic (December 2005) Recursive Least
Square Method in Parameters Identification of DC Motors Models, SER.:
ELEC. ENERG. vol. 18, no. 3, 467-478.
[11] T. R. Fortescue, L. S. Kershenbaum and B. E. Ydstie (1981).
Implementation of self-tuning regulators with variable forgetting
factors. Automatic, 17, 6:831-835.
53
Chapter 4
Simulation Examples
54
4.1 Estimate Gradient using RLS
We use simulated data to test the effectiveness of the RLS algorithm for
estimation of the impulse weights, and compare the results to correlation
method. The simulated data was generated using the model given in Eq. (4.1).
( ) ( ) ( ) ( ) ( ) ( )1 0.5 2 3 0.3 4 0.4 5y t x t x t x t x t x t= − + − − − + − + − (4.1)
We can see from the equation the first non-zero impulse response is 1. In
simulation we used 1000 data points to estimate the first nonzero weight. In
the correlation method, we chose the windows size as 50, in the RLS a
forgetting factor 0.99 is chosen. Figure 4.1 shows estimation results using
RLS and correlation method respectively.
0 100 200 300 400 500 600 700 800 900 10000
0.2
0.4
0.6
0.8
1
1.2
1.4
time,s
first
impu
lse
wei
ght
correlation methodRLS method
55
Figure 4.1 Estimation of first impulse weight using RLS with a forgetting
factor 0.99 and correlation method. Sampling time is 1s.
We can see from above figure that RLS method provides a smoother
estimate of the impulse weight and is also less sensitive to noise. It also
converges to a consistent estimate, which the correlation method does not.
4.2 Gradient Estimate Simulation
4.2.1 A Linear Static System Example
(4.2) = − + = =4 10, sin( )y x with x t and samplingtime 1
0 1]
The analytical derivative is -4. We use Matlab© command rarx which
estimates the impulse weights and choose the parameters such that
, where na and are orders of the respective
polynomials and nk is the number of delays from input to output. Specifically
[4],
[ ] [1 5nn na nb nk= = nb
ARX model structure:
( ) ( ) ( ) ( )A q y t B q u t nk= −
where ( )( )
11
1 11 2
1 nana
nbnb
A q a q a q
B q b b q b q
− −
− − +
= + + +
= + + +
…
…
The forgetting factor is chosen as 1 for a static model. Fig.4.2 shows the block
diagram of the linear static system using Simulink©. The input signal is a
56
sine wave. Sampling time is 1 sec. The s-function is a gradient estimator
using RLS algorithm. Figure 4.3 shows the simulation results.
Sine Wave1 Scope3
rarx1_linearstatic
S-Function
-1Z
Integer Delay1
-4 Gain
Add4
Constant3
10
Fig.4.2: Gradient estimation for a linear static system using Simulink
Toolbox
57
0 200 400 600 800 1000 1200 1400 1600 1800 2000-5
-4
-3
-2
-1
0
1
time,s
grad
ient
Fig.4.3: Gradient information for a linear static system
Figure 4.3 shows a good agreement between the analytical gradient of the
system and the first non zero impulse response weight, using a sinusoidal
signal with magnitude 1 and frequency 1rad/s as input to the static system.
4.2.2 A Second Order Non-Linear Static System
24y x x 10= − + − (4.3)
In this simulation, the input signal is a sine wave with unit amplitude and
1rad/s frequency, the sampling time is 0.01s. In order to examine the
robustness (to noise) of the proposed method, a Gaussian random number
58
with mean zero and variance 0.1 is added to the input signal. The forgetting
factor is chosen as 0.8 Figure 4.4 shows the block diagram of the nonlinear
static system using Simulink©. The simulation result in Figure 4.5 shows
that the gradient estimation is quite acceptable even under noisy conditions.
59
Scop
e
Zero
-Ord
erHo
ld1
Zero
-Ord
erHo
ld
Sine
Wav
e2
Sine
Wav
e
onlin
ear_
stati
S-Fu
nctio
n
Rand
omNu
mbe
r2
Rand
omNu
mbe
r1
u2
Mat
hFu
nctio
n
-1 Z
Inte
ger D
elay
1
-8 Gain
1
-4 Gain
1
Cons
tant
1
-10
Cons
tant
Fig.
4.4
Gra
dien
t est
imat
ion
usin
g Si
mul
ink
Tool
box
for
a se
cond
ord
er n
onlin
ear
stat
ic s
yste
m
60
150 155 160 165 170 175 180 185 190 195 200-20
-15
-10
-5
0
5
10
15
20
time,s
grad
ient
Estimated gradientAnalytical gradient
Fig.4.5: Gradient information for a second order nonlinear static system with
( )= +sinx t noise
61
4.3 Combining the Perturbation Method
with the Proposed Gradient Method
A nonlinear function ( )f θ can be approximated by expanding around the
optimum point:
( ) ( ) ( ) ( )''
2
2
ff f
θθ θ θ
∗∗ ∗ ∗= + −θ (4.4)
At the extremum points, the first derivative should be zero. We wish to
make θ θ ∗− as small as possible, so that the output ( )f θ is driven toward its
optimum f ∗ . For a minimization problem is made without loss of
generality.
'' 0f >
Figure 4.6 shows the basic feedback optimization loop using the new
impulse weight gradient search for a nonlinear algebraic function.
( )f θ
*θ *f
y θ
Gradient Estimator
(RLS)
0v PID Controller
-
θ
+
Plant
Test Signal
Set-point
Figure 4.6 Feedback optimization loop for a static system
62
The test signal must be uncorrelated with the system noise and be of
sufficient power to provide the enough excitation for the parameters
estimation [3]. The proposed RLS with forgetting factor algorithm is used to
estimate the current gradient of the system, and then the estimated gradient
is compared to the set point, which is zero at the optimum. A conventional
PID controller is used to eliminate the error between the process input
0v
θ and
optimal inputθ ∗ .
4.3.1 Static Example:
A nonlinear algebraic system given by:
* * * 2
*
*
( ) ( ) 0.1( )0.01 100 0.02 1000.01
Test Signal: , : 0.1 , : PID parameters: 1, 0.1, 0 Sampling Interval: 0.05 sec
f ff at time and at time
Sine Wave Amplitude FrequencyP I D
θ θ θ θ
θπ
⎧ = + −⎪
= < >⎪⎪⎪ =⎨⎪⎪ = = =⎪⎪⎩
(4.5)
In this example, the maximum value is changed from 0.01 to 0.02 at
. Figure 4.7 is the optimization feedback loop for this example. Figure
4.8 shows the block diagram of the static algebraic system using Simulink©
and Figure 4.9 shows the simulation results.
100t = s
63
( )( )
2
2
0.01 0.1 0.01 100( )
0.02 0.1 0.01 100
t sf
t s
θθ
θ
⎧ + − <⎪= ⎨+ − >⎪⎩
Gradient Estimator
(RLS) PID
Controller
0v
θ Test Signal
-
θ
+
Set-point=0
Fig.4.7: Optimization feedback loop for Eq. (4.5)
64
y
Zero
-Ord
erHo
ld
vo v
s erro
r
vo
u1
u
0.01
thet
a*
thet
a
erro
r
Zero
-Ord
erHo
ld2
Step
Sign
alG
ener
ator
1
rarx
1
S-Fu
nctio
n
PID
out
PID
PID
Cont
rolle
r
Add1
0.1 Gai
n
u2
Mat
hFu
nctio
nAd
d
1
Gai
n1
Mem
ory
0
Cons
tant
Fig.
4.8:
Blo
ck d
iagr
ams
in S
imul
ink
Tool
box
for
a st
atic
sys
tem
65
0 20 40 60 80 100 120 140 160 180 2000.01
0.012
0.014
0.016
0.018
0.02
0.022
time,s
f and
f*
f*
f
Fig.4.9: Output for Example 4.5
In this simulation, the parameters are and
forgetting factor is 1. The output is close to the true optimum and above the
true optimum because the process is quadratic.
[ ] [0 5na nb nk = 0 1]
Figure 4.10 shows the gradient information and comparison between
input and optimal input. The gradient is successfully driven to zero as it
would be for extremum seeking, and the input θ oscillated around its optimal
valueθ ∗ . The gradient information is also compared with the Correlation
method in Figure 4.11
66
0 20 40 60 80 100 120 140 160 180 200-0.1
-0.05
0
0.05
0.1
time,s
grad
ient
0 20 40 60 80 100 120 140 160 180 200-0.4
-0.2
0
0.2
0.4
time,s
θ an
d θ*
θ*
θ
Fig.4.10: Gradient and input information for Example 4.5
0 20 40 60 80 100 120 140 160 180 200-0.1
-0.05
0
0.05
0.1
0.15
time,s
grad
ient
RLS algorithmCorrelation method
Fig.4.11: Gradient comparison between RLS and Correlation method
67
4.3.1.1 Effect of random different test signals
The input test signals are not limited to sinusoids, we can choose
alternate signal. This example uses random number with variance 0.05 and
zero mean as the input signal. Fig.4.12 shows the input and output.
* * * 2
*
*
( ) ( ) 0.1( - )0.01 at time<100 and 0.02 at time>1000.01
Input Signal: Random number, variance: 0.005 , mean:0 PID parameters: 1, 0.1, 0 Sampling Interval: 0.05 sec
f ff
P I D
θ θ θ θ
θ
⎧ = +⎪
=⎪⎪⎪ =⎨⎪⎪ = = =⎪⎪⎩ (4.6)
0 20 40 60 80 100 120 140 160 180 2000.01
0.015
0.02
0.025
0.03
time,s
f and
f*
0 20 40 60 80 100 120 140 160 180 200-0.4
-0.2
0
0.2
0.4
time,s
θ an
d θ*
θ
θ*
f*
f
Figure 4.12 Actual and optimal process input and output values for example
4.6 with random number as input signal
68
4.3.2 Nonlinear Dynamic Example:
In the modeling a nonlinear dynamic systems, one approach is to
separate the linear and nonlinear parts into different blocks [3].
Figure 4.13 shows the nonlinear plant with static nonlinearity ( )f θ and
input linear block ( )iF s and output linear block ( )0F s .
Fig.4.13: Feedback optimization loop for a nonlinear dynamic system
69
Again we consider the static nonlinearity ( )f θ in the form:
( ) ( ) ( ) ( )''
2
2
ff f
θθ θ θ
∗∗ ∗ ∗= + −θ
Where is constant but unknown. The output is described by the
following equation:
'' 0f >
( ) ( )0y F s f θ=
We try to make θ θ ∗− as small as possible so that the output is driven
towards its optimum ( ) ( )0F s f θ∗ ∗ . The optimal input and output, θ ∗ and f ∗ ,
are allowed to be time varying here. Let us denote their Laplace transforms
by
{ }{ }
*
*
( ) ( )
( ) ( )f f
L t s
L f t s
θ θθ δ
δ
= Γ
= Γ (4.7)
where and fθδ δ are the gain of the optimal input and output functions. In
some cases, the shape of the profile is known but the gain of system is
unknown. For example in gas turbines, optimal profile for output is ramp and
therefore is equal to ( )f sΓ 2
1s
[2].
These two time dependant variables can be chosen to have different
profiles (for example a step change). By allowing and *( )tθ *( )f t to be time-
varying, we can track a time-varying optimum. In some cases, we may
have *f (extremum point) change in a linear fashion but we can also allow for
non-linear change. We require an integrator in a proportional-integral
70
controller (PI) to obtain a zero steady-state error. We make the following
assumptions on the system in Figure 4.12 that underlie the analysis to follow:
[1]
1. , are asymptotically stable and proper. ( ) and ( )i oF s F s
2. are strictly proper rational functions and poles of
that are not asymptotically stable are not zeros of .
( ) and ( )fsθΓ Γ s
( )sθΓ ( )iF s
These two assumptions ensure the existence of an extremum profile. We
selected an example from Ariyar and Krstic work [1] where these assumption
hold. We then applied our algorithm to this and similar processes.
To illustrate the flexibility of the new method, we used a difficult case
studied by Krstic (2003) [1].
* *
2
*
*
( ) ( ) 5( ( ))1( )
11( )
3 20.01 200
( )0.09 200
( ) 0.02sin( )
i
o
2f f t t
F ss
sF ss s
tf t
t
t t
θ θ θ
θ
⎧ = + −⎪⎪
=⎪ +⎪−⎪ =⎨ + +⎪
⎪ ≤⎧=⎪ ⎨ >⎩⎪
⎪ =⎩ (4.8)
Several simulations are carried out to investigate the effect of the choice
of the input signal, PID parameters and parameters for the RLS algorithm.
71
4.3.2.1 Simulation 1
In this simulation, we use a sine wave signal with amplitude 0.02 and
frequency 0.1π rad/s as desired input and sampling time 0.02s. Figure 4.14
shows the simulation results.
0 50 100 150 200 250 300 350 4000
0.1
0.2
time,s
f and
f* (t)
300 310 320 330 340 350 360 370 380 390 400-0.1
0
0.1
time,s
θ an
d θ* (t)
0 50 100 150 200 250 300 350 400-0.02
0
0.02
time,s
v0
f*(t)f
θ*(t)
θ
Fig.4.14: Simulation results for equation 4.8
The simulation results show that the proposed method is indeed able to
find the optimum even though the optimum input varies with time. The PID
parameters for this example are 10 8 and 0 found by trial and error. The
forgetting factor here is 1.
72
4.3.2.2 Simulation 2
We change the optimum output in such a way that it moves in a ramp
shape, say
*( ) 0.01f t t=
Again in Figure 4.15 we see a good optimal tracking ability.
0 50 100 150 200 250 300 350 4000
1
2
time,s
f and
f*
300 310 320 330 340 350 360 370 380 390 400-0.1
0
0.1
time,s
θ an
d θ* (t)
0 50 100 150 200 250 300 350 400-0.1
0
0.1
times,s
v0
f
f*
θ*(t)
θ
Fig.4.15: Simulation results for equation 4.8 with ramp optimal output
73
4.3.3 Comparison of proposed RLS Impulse Weight
Gradient Method with Sign-Sign Method
The new gradient approach is tested on the following quadratic function:
(4.9) ( )25 1y x= − + 0
and the optimization performance is compared in Figure 4.16 with the Sign-
Sign method. The compare plots show that the sign-sign method needs less
iteration to converge to the minimum point. However, the proposed gradient
method is more accurate than Sign-Sign method after they both reach the
steady state, which is shown in table 4.1 by averaging the Mean Squared
Error (MSE) of output over the last 1000 samples.
0 50 10010
15
20
25Sign-Sign Method
time,s
outp
ut
50 60 70 80 90 10010
15
20
25RLS method
time,s
outp
ut
50 60 70 80 90 1000
2
4
6
time,s
inpu
t
0 50 1000
2
4
6
time,s
inpu
t
74
Fig.4.16: Minimum seeking for quadratic function 4.9
By averaging the MSE of output over the last 1000 samples, we compare
the numerical error between proposed impulse weight gradient method and
sign-sign method as shown in Table 4.1
Table 4.1
Approach MSE over last 1000 samples
Gradient Method 3.3059e-004
Sign-Sign Method 0.0364
75
4.4 Processes with Dead Time
One of the major advantages of the new method is that it is able to track
more complicated processes with variable dead time. This is the only known
algorithm that is able to accomplish this. The following rules are followed:
If dead time =1, use as the current gradient ( )1v
If dead time=2, use ( )2v as the current gradient, etc.
In order to demonstrate the effectiveness of the approach, the method is
tested on processes with dead time and the performances are compared with
other direct methods. Figure 4.17 shows the feedback optimization loop for
processes with dead time.
Process
Test Signal
PID Controller
+
-
yDead time Estimator
Gradient Estimator (RLS)
x
Set point=0
Fig.4.17: feedback optimization loop for processes with dead time.
76
A quadratic model with dead time given by:
, dead time=3 ( )25 1y x= − + 0
The Simulink block diagram is shown in Figure 4.18. The performance of
the proposed method is shown in Figure 4.19 and compared to the Sign-Sign
Method.
The input and output data are injected to a S-function called ‘dtime’ which
estimates the dead time for the process using cross correlation method. And
then the process input, output data and the output from the S-function
‘dtime’ are provided to the S-function ‘rarxd1’ which estimates the gradient
information.
77
Sco
pe3
Zero
-Ord
erH
old4
Zero
-Ord
erH
old2
Zero
-Ord
erH
old1
In1
Out
1
Sub
syst
em
Sin
e W
ave1
Sin
e W
ave
Sco
pe2
Sco
pe1
Sco
pe
rarx
d1
S-F
unct
ion2
dtim
e
S-F
unct
ion1
Ran
dom
Num
ber3
Ran
dom
Num
ber1
2 Gai
n
-10
Con
stan
t3
Fig.
4.18
: Blo
ck d
iagr
ams
in S
imul
ink
Tool
box
for
a pr
oces
s w
ith d
ead
time
78
0 10 20 30 40 50 60 70 80 90 10010
15
20
25
30
time,s
outp
ut
0 10 20 30 40 50 60 70 80 90 1000
5
10
time,s
inpu
t
sign-sign methodgradient method
gradient methodsign-sign method
Fig.4.19: Simulation results for equation 4.9 with dead time=3
The Sign-Sign method and impulse weight gradient method are applied
respectively and it can be seen from the result shown in Figure 4.19 that the
Sign-Sign method cannot accommodate the changing process dead time,
however, the new gradient method is able to find the optimum and rapidly
finds the minimum value for the output 10, which corresponds to input 5x = .
79
4.5 Processes with Variable Dead Time
An even greater challenge is presented by processes that have
deadtimes that switch to new values at various times.
The data are generated by the model:
( ) ( ) ( ) ( )0.2 1 0.4 2y t u t nk u t nk u t nk= − + − − − − − (4.10)
Where sampling time=1s 1 0 10004 1000 30002 3000 5000
tnk t
t
< ≤⎧⎪= < <⎨⎪ ≤ ≤⎩
The current gradient of this model is given by the coefficient of the first input
which is 1.0. (u t nk− )
Figure 4.20 shows the simulation results of dead time and current
gradient information. It can be seen from the figure that the gradient method
is able to find the first non-zero impulse response even though the process
has a variable dead time.
This new algorithm is thus able to achieve solution to a very difficult
problem. The solution to this problem is not reported in the literature as far
as the author knows.
80
0 500 1000 1500 2000 2500 3000 3500 4000 4500 50001
2
3
4
time,s
dead
tim
e
0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000-0.5
0
0.5
1
1.5
time,s
curre
nt g
radi
ent
Fig.4.20: Dead time and gradient information for equation 4.10
81
4.6 Processes with Variable Dead Time
and Changing Model Structure
Some processes have a combination of difficulties and, for example, both
model structure and dead time can vary with time.
Consider the following process
( )( ) ( ) ( )( ) ( ) ( )
( ) ( )
1 0.2 2 0.4 3 0 10004 0.2 5 0.4 6 1000 30000.8 2 0.15 3 3000 5000
u t u t u t ty t u t u t u t t
u t u t t
− + − − − < ≤⎧⎪= − + − − − < ≤⎨⎪ − − + − < ≤⎩
(4.11)
This example represents the ultimate test for the new algorithm and has
not been reported solved in current literature to the best of the author’s
knowledge.
It can be seen from the equation that not only the dead time is changing
but the model is changed after t=3000s.
Again dead time and current gradient information is shown in Figure
4.21
82
0 500 1000 1500 2000 2500 3000 3500 4000 4500 50001
2
3
4
time,s
dead
tim
e
0 500 1000 1500 2000 2500 3000 3500 4000 4500 5000-1
0
1
2
time,s
curre
nt g
radi
ent
Fig.4.21: Dead time and gradient information for equation 4.11
It is clear from the results that the algorithm is able to pick off the first
coefficient (which represents the new gradient) of the models as they change
from one model to the next.
83
Bibliography
[1] K.B. Ariyur & M. Krstic (2003). Real-time optimization by
extremum-seeking control, Wiley-Interscience, NJ.
[2] M. Sheikhzadeh (2006). Optimization and Control of Crystallization
Processes. Ph.D Thesis, University of Western Ontario.
[3] L. Ljung (1989). System Identification: Theory for the User, Prentice
Hall.
[4] System Identification Toolbox User’s Guide, Mathworks Inc., (2000).
84
Chapter 5
Real-Time Optimization
85
In previous chapters, a new RLS, impulse weight gradient optimization
method was proposed and it was shown in simulations to perform well in
estimating the current gradient and keeping track of time-varying optimal
conditions. In a real time experimental scenario the situation can become
more challenging due to higher level of uncertainties and the presence of
noise, environmental changes, etc. In order to test the effectiveness of the
proposed method in real time optimization, the method is applied to an
experimental Continuous Stirred Tank (CST) and Pressure Tank,
respectively.
5.1 Real-Time Application to CST
In order to fully test the effectiveness of the proposed optimization method,
it is applied to a real-time chemical process, a Continuous Stirred Tank (CST)
which is shown in Figure.5.1
Fig.5.1 Continuous Stirred Tank
86
The laboratory scale 2L CST is filled with water and then sealed. Steam
and Water from regulated sources flow into and mix in a heating/cooling coil
inside the CST for controlling the temperature inside the tank. The fluid
enters the tank from the bottom, and exits through a float type steam trap at
the top of the tank. There are two manipulated variables: they are voltage
signals to the steam valve and water valve. The range of the steam and water
valves is normalized to lie between -1 with fully-closed position and 1 with
fully-open position. In the experimental runs, the steam valve is fixed at 25%
open, and the water valve was manipulated using the new gradient
optimization approach to search for the optimal temperature of the CST so
that an objective function, Eq. (5.1) was minimized.
2( 32)y T 5= − + (5.1)
5.1.1 Experimental Setup
The experimental setup is shown in Fig.5.2. A picture of the CST used
here is shown in Fig.5.3. The temperature measured by a thermocouple is
transmitted to the micro-computer through ADVANTEC data acquisition
board PCLD-8710. All the control actions were carried out by
Matlab/Simulink with the help of the Real-Time Toolbox [6]. The
optimization program was run in the Matlab/Simulink environment. The
signals were then transmitted to I/P transducers which control the valve
positions through the data acquisition board.
87
Fig.5.2: Experimental setup for CST
88
Fig.5.3 Picture of the CST used for experimental runs
89
5.1.2 Experimental Runs
Firstly, both the steam and water valve were fixed at 25% open, and the
changes in temperature shown in Fig.5.4 indicate that the process has severe
nonlinearity and significant measurement and process noise. Also the reactor
has a large time constant value and thus reacts to the changes in the input
very slowly. This has been confirmed in many previous studies [1]. Thus this
process poses a significant challenge to the new gradient optimization
method.
0 200 400 600 800 1000 120042
44
46
48
50
52
54
56
58
Time, s
Tem
pera
ture
, ° C
Fig.5.4 Variation in CST temperature with both water valve and steam valve
25% open
90
The feedback optimization diagram is shown in Fig.5.5. The Simulink©
diagram block is shown in Fig.5.6
CST 2( 32) 5y T= − +
Gradient Estimator
Steam flow=25% open Water flow
T (oc)
PID Controller -
0
Fig.5.5: CST Real –Time optimization diagram
91
2.5
stea
m
Qua
drat
ic fu
nctio
nTe
mpe
ratu
re re
cord
rarx
1
S-F
unct
ion
Wat
er s
uppl
y v
alve
Stea
m s
uppl
y v
alve
wate
r te
mpe
ratu
re
Rea
l CS
TR
0
Con
stan
t
Mem
ory1
PID
Con
trolle
r
PID
Fig.
5.6:
Sim
ulin
k© b
lock
dia
gram
s fo
r R
eal t
ime
Opt
imiz
atio
n of
a C
ST
92
During the experiment, the steam valve was fixed at 25% open and the
water valve was manipulated by the gradient optimization program to shift
the temperature of the CST in order to minimize the objective function Eq.
(5.1). Fig. 5.7 and 5.8 show the optimization results. The objective function,
Eq. (5.1) has a minimum value of 5.0 when the CST temperature reaches
32°C.
0 500 1000 1500 2000 25000
50
100
150
200
250
time,s
y
objective function :y=(T-32)2+5
Noisy experimental outputTrue optimum level
Fig.5.7 Real-Time Optimization-output of objective function Eq.(5.1)
93
Fig.5.8 shows that the value of the noisy temperature which approaches
the value of 32°C.
0 500 1000 1500 2000 250016
18
20
22
24
26
28
30
32
time,s
tem
pera
ture
T, °C
Fig.5.8 Real-Time Optimization-temperature condition for Eq. (5.1)
5.1.3 Discussion
The sever nonlinearity and measurement noise presents a great challenge
to the gradient optimization method. From the experimental results, we can
see that the proposed method is able to find the optimal temperature
condition in order to minimize the objective function, in spite of the excessive
level of measurement noise.
94
5.2 Real-Time Application to Pressure
Tank
The real-time application considered here is a pressure tank system
shown in Fig.5.9 through which compressed air flows from a regulated supply.
Two control valves are installed on the inlet and the outlet of the tank. The
pressure in the vessel and the outlet flow rate are measured by a pressure
meter and a flow rate meter respectively and transmitted to a micro-
computer via a data acquisition board. The pressure tank is operated with
outlet valve position fixed. The inlet valve was manipulated within the region
[-1, 1].
Figure 5.9 Pressure Tank
95
5.2.1 Experimental Setup
The real-time optimization was implemented in the Matlab/Simulink
environment to generate optimal control signals to the inlet control valve and
search for the optimal pressure in the vessel that maximizes the objective
function.
Figure 5.10 depicts a general control system setup. Figure 5.11 shows a
picture of the pressure tank used for experimental runs.
Fig.5.10: Experiment Setup for Pressure Tank System
96
Fig.5.11 Picture of Pressure Tank
97
5.2.2 Experimental Runs
Several experimental runs were conducted on the pressure tank using
Matlab/Simulink and the real time toolbox from Humusoft©. The objective
function shown in Equation (5.2) was used to evaluate the gradient
optimization method.
( )= − − + +236 1000 5sin(0.01 )y P t (5.2)
The feedback optimization diagram is shown in Fig.5.12. Simulink© block
diagram is shown in Fig.5.13. The optimization results are shown in Fig.5.14
and Fig.5.15.
Fig.5.12 Pressure Tank Real –Time optimization diagram
Notice that here the objective y is dynamic itself and presents a greater
tracking challenge for the algorithm.
Gas outlet=25% open Pressure
Tank
Gradient Estimator
Gas inlet P
PID Controller
( )=− − + +
236 1000 5sin(0.01)y P t
-
0
98
real
_tan
k_ou
tput
To
Wor
kspa
ce
0
Dis
play
Sco
pe2
flow
rat
e
pres
sure
Out
1
crea
t som
e op
timum
Sco
pe1
Sco
pe3
Sco
pe4
rarx
1
S-F
unct
ion
Gas
inle
t
Gas
out
let
flow
rat
e
pres
sure
Pre
ssur
e ta
nk
-0.5
Con
stan
t
0
Con
stan
t1
Mem
ory
PID
Con
trolle
r
PID
Fig.
5.13
: Sim
ulin
k bl
ock
diag
ram
s fo
r R
eal t
ime
Opt
imiz
atio
n of
a
Pres
sure
Tan
k
99
0 500 1000 1500 2000 2500 3000 3500 4000100
200
300
400
500
600
700
800
900
1000
1100
time,s
y
y=-(P-36)2+1000+5sin(0.01t)
Experimental outputTrue optimal output
Fig.5.14: Optimization results for the pressure tank system with objective
function given as Eq. (5.2): objective output
100
0 500 1000 1500 2000 2500 3000 3500 40005
10
15
20
25
30
35
40
time,s
pres
sure
,psi
Experiemental pressureTrue optimal pressure
Fig.5.15: Optimization results for the pressure tank system with objective
function given as Eq. (5.2): Pressure condition inside the tank
101
5.2.3 Discussion
In the Pressure Tank experiment, the optimum of the objective function
changes in a sinusoidal manner. The gas outlet valve was kept at 25% open
and the gas inlet valve was manipulated by the gradient optimization method.
The parameters of the PID controller were P=1, I=0.1, D=0. Fig.5.14 shows
that the objective function was driven toward its optimum rapidly and kept
at optimum by the gradient method.
102
Bibliography
[1] Xiong, Qiang (2000). Optimization, Control and Identification of
Chemical Processes. M.E.Sc Thesis, University of Western Ontario.
[2] Yide Ping (2006). Non-model Based Real Time Optimization of
Chemical Processes. M.E.Sc Thesis, University of Western Ontario.
[3] A. Jiang and A. Jutan (2000). Response Surface Tuning Methods in
Dynamic Matrix Control of a Pressure Tank System. Ind. Eng. Chem.
Res. 39, 3835-3843.
[4] B. Guo, A. Jiang, X. Hua, and A. Jutan (2001). Nonlinear Adaptive
Control for multivariable Chemical Processes. Chemical Engineering
Science 56: 6781-6791.
[5] Z. Ma and A. Jutan (2003). Control of a Pressure Tank System using
a Decoupling Control Algorithm with a Neural Network Adaptive
Scheme. IEE Proc.-Control Theory Appl., Vol. 150, No 4.
[6] Humusoft s.r.o. (2003). Real Time Toolbox for use with Simulink
version 3.12 user manual.
103
Chapter 6
Summary and Future Work
104
In this work, several non-model based optimization methods are reviewed
and compared. A new Recursive Least Squares, Impulse Weight, Gradient-
based, optimization strategy is developed. It is tested on various simulated
mathematical examples with different input signal and two real-time
laboratory processes. The experimental results are compared with another
non-model based optimization method, namely the Sign-Sign method and
show the advantages of the proposed Gradient-based method. The simulation
studies also show that the Gradient-based method is superior to the
perturbation method [1] in that it is not limited to specific sinusoidal signals.
A main advantage of the new Gradient-based method is that it can handle
processes with changing dead time and model structure. No other methods
can achieve this. The simulation studies on processes with changing dead
time and changing model structure demonstrate the possible application of
the Gradient-based method to a practical process with dead time and model
structure variation.
In its initial stage, the new RLS Impulse Weight Gradient-based method
has shown its possible application to practical problems. There are some
suggestions for further work:
1. A possible future application is to extend the new Gradient-based
method to a multivariable system. The RLS Impulse Weight Gradient
based method has only been tested on SISO system in this work. In the
next stage, problems with more variables can be examined.
105
2. Other controllers, such as Model Predictive Controller, can replace the
PID controller in the feedback optimization loop to test the ability of
more advanced controllers in this application.
3. Other algorithms can be used in estimating the gradient, such as,
Least Mean Squares (LMS) algorithm, Normalized Least Mean
Squares (NLMS) and a Kalman Filter based algorithm [2].
106
Bibliography
[1] Y. Tan, D. Nesic & I. Mareels (2006). On non-local stability properties of
extremum seeking control, Automatica 42, 889-903.
[2] System Identification Toolbox User’s Guide, Mathworks Inc., (2000).
107
Appendix A – Experimental
Setup
A.1 Data acquisition board
The type of the data acquisition board used for the lab experiment is
Advantech PCLD-8710 (Terminal board) and PCI-1710 (Internal PCI board).
Fig.A.1 shows a picture of the digital input ports of the data acquisition board.
Fig.A.2 shows the analog input ports and cold junction compensation
switches of the data acquisition board.
As we see from the pictures, the data acquisition board contains 16 digital
input ports (Channel 0 – Channel 15) and 16 analog input ports (Channel 0 –
Channel 15) with each channel (short for CH later) coupled with a ground
port.
Connection type:
There are two ways of instrumental connection:
(1) Single ended connection
(2) Double ended connection
A thermocouple is used throughout the instruction as a sample experiment
device.
108
A picture of the thermocouple is shown in Fig. A.3.
Fig. A.1 Digital input ports of the data acquisition board
109
Fig. A.2 Analog input ports of the data acquisition board
Fig. A.3 Thermocouple
110
Single ended mode (Thermocouple connection):
The ‘+’ wire should be connected to one of the channels (CH 0~CH 15) and the
‘-’ wire be connected to the ground ports (short for GND later on in this
instruction).
*Note: The CH0 should NOT be used when the cold junction compensation is
enabled.
Double ended mode:
In this case, two channels instead of one will be used. (The GND will NOT be
used) The ‘+’ wire is connected to the evenly numbered channels, say CH2
and the ‘-’ wire to the oddly numbered channels, say CH 3.
Note 1: When double ended mode is used, two channels next to each other
will be grouped together as one channel and the number of the oddly
numbered channel in the group will be assigned as the channel number. For
example, CH0 and CH1 are grouped as Channel 1; CH2 and CH3 are grouped
as Channel 3; CH4 and CH5 are grouped as Channel 5 and so on.
Note2: The double ended mode is less noise sensitive than single ended mode.
Test
The voltage measurement and valve control experiment will be conducted in
this chapter.
Hardware Connection
(1) Input part:
The experiment setup is shown below:
111
Fig. A.4 Experiment setup for voltage measurement
A power supply is connected to the data acquisition board in differential
mode. The channel 5 in differential mode is used (in this case, channel 4 and
5 will be grouped as channel 5). The positive pole is connected to the evenly
numbered channel 4 and the negative pole is connected to the oddly
numbered channel 5 (NO ground channel in differential connection mode).
And the voltage signal generated by the power supply is adjusted to 3.5V.
(2) Output part:
112
Fig. A.5 Experiment setup for valve control
The signal is sent by computer through the data acquisition board to the
converter which converts the 0-10V voltage signal to the 4-20mA current
signal and then to the transducer to control the valve. (Note that the output
from the board is voltage signal.)
Software setup
The Advantech testing software can be used to show the voltage signal being
sent to the data acquisition board.
To start the software:
Start All Programs Advantech Automation Device Manager
Advantech Device Manager
The device management window will pop up as shown in Fig. A.6.
113
Fig. A.6 Advantech Device Manager
All the boards installed on the computer will be listed in the ‘Installed
Devices’. Select the board which you want to test by clicking on the name.
Then click on the ‘setup’ button to start the ‘Device Setting’ window as shown
in Fig. A.7. In A/D Channel Configuration, choose the proper channels
(Channel 4 and 5 in our example) and set the proper connection mode
(Differential in our example). Then click on ‘OK’ to close the device setting
window and then on the ‘test’ button to start the following ‘Advantech Device
Test’ window (Fig. A.8).
After choosing the proper range for the connected channels, the voltage signal
measured by Channel 4 and 5 is shown in Fig. A.8 as 3.5V.
114
Fig. A.7 Device Setting
115
A.8 Advantech Device Test
116
A.2 MATLAB applications
Voltage measurement
The measured date can also be sent to MATLAB simulink for further
processing, which can be done by using the Real-time toolbox developed by
Humusoft.
To start the real-time tool box, type in the MATLAB command window the
command ‘rtlib’ to open the real time toolbox library:
Fig. A.9 Real time toolbox library
117
The library is very similar to the Simulink library and can be used in the
same way. The ‘Real-Time sources’ is equivalent to the Simulink sources and
the ‘Real-Time sinks’ is equivalent to the Simulink sinks. All the source or
sink blocks can be viewed by double clicking on the ‘Real-Time sources’ or
‘Real-Time sinks’ respectively.
The voltage measurement experiment done in the ‘Test’ chapter can also be
repeated in Simulink by constructing the following simulink model:
Fig. A.10 Simulink model for temperature measurement
118
The above Simulink model contains four blocks. They are ‘RT In’, ‘Lookup
Table’, ‘Display’ and ‘Adapter’ respectively.
‘RT In’ is a block which takes in data from the data acquisition board Before
this block can be used, which channel is to be measured should be chosen by
double clicking on the block and setting the channel number.
‘Lookup Table’ and ‘Display’ are standard MATLAB data conversion tables.
‘Adapter’ acts as the hardware driver for MATLAB which links the data
acquisition board with MATLAB.
To link MATLAB Simulink with the data acquisition board, one can double
click on the red ‘Adapter’ block and select the proper driver to start the device
setting dialogue box:
Fig. A.11 Select ‘pci1710.rtd’ as the hardware driver
119
Fig. A.12 Setup the connection mode and the input/output signal range
To properly setup the voltage measurement experiment, one should click
the ‘Differential A/D’ box to enable differential connection mode and then
click on the ‘Gains’ button to choose the proper input range.
Fig. A.13 Choose input range 0V ~ 10V
120
The detailed information is provided in the toolbox manual. One thing need
to be mentioned is that if data acquisition board works in double ended mode,
then channel 0 and 1 are grouped as port 1, channel 2 and 3 are grouped as
port 3, channel 4 and channel 5 are grouped as port 5 and so on.
Valve control
The control signal generated by MATLAB applications can also be sent out
via the data acquisition board to control the process peripheral devices. The
valve control experiment (see also Hardware connection) is repeated in
MATLAB/SIMULINK as follow:
(1) Clicking on the “D/A gains” button shown in Fig. A.12, we can select the
desired output range. Here we choose the output range to be 0-10 volt.
Fig. A.14 Choose output range 0V ~ 10V
(2) Constructing the following SIMULINK model:
121
Fig. A.15 Simulink model for valve control
Please note that the “RT Output” block is used for converting MATLAB
source signals to the analog signal and the input to this block can only range
from -1 to +1, that is, if we choose the output range to be 0-10 volt, then the
“RT Output” block will linearly convert the input signal (-1 to +1) into the
voltage signal (0 to 10 volt).
122
Appendix B – MATLAB
Codes
B.1 Generate simulated data
%generate simulated data using model %y(t)=x(t-1)+0.5*x(t-2)-x(t-3)+0.3*x(t-4)+0.4*x(t-5) %na=0,nb=6,nk=1 a=1; b=[0 1 0.5 -1 0.3 0.4]; u=randn(1000,1); % generate 1000 input data y=filter(b,a,u); % generate output data t=[0:999]';
B.2 S-Function of estimating first non-zero impulse weight for a linear static problem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %This s-function is used to estimate the first impulse weight parameter for % %a linear static problem = − + = =4 10, sin( )y x with x t and samplingtime 1 % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [sys,x0,str,ts] =rarx1(t,x,u,flag) switch flag, %%%%%%%%%%%%%%%%%% % Initialization % %%%%%%%%%%%%%%%%%% case 0, [sys,x0,str,ts]=mdlInitializeSizes;
123
%%%%%%%%%%%%%%% % Derivatives % %%%%%%%%%%%%%%% case 1, sys=[ ]; %%%%%%%%%% % Update % %%%%%%%%%% case 2, sys=[ ]; %%%%%%%%%%% % Outputs % %%%%%%%%%%% case 3, sys=mdlOutputs(t,x,u); %%%%%%%%%%%%%%%%%%%%%%% % GetTimeOfNextVarHit % %%%%%%%%%%%%%%%%%%%%%%% case 4, sys=[]; %%%%%%%%%%%%% % Terminate % %%%%%%%%%%%%% case 9, sys=[]; %%%%%%%%%%%%%%%%%%%% % Unexpected flags % %%%%%%%%%%%%%%%%%%%% otherwise error(['Unhandled flag = ',num2str(flag)]); end % end sfuntmpl % %============================================================================= % mdlInitializeSizes % Return the sizes, initial conditions, and sample times for the S-function. %=============================================================================
124
% function [sys,x0,str,ts]=mdlInitializeSizes % call simsizes for a sizes structure, fill it in and convert it to a % sizes array. % % Note that in this example, the values are hard coded. This is not a % recommended practice as the characteristics of the block are typically % defined by the S-function parameters. sizes = simsizes; sizes.NumContStates = 0; sizes.NumDiscStates = 0; sizes.NumOutputs = 1; % one output sizes.NumInputs = 2; % two input sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; % at least one sample time is needed sys = simsizes(sizes); % % initialize the initial conditions % x0 = [ ]; % % str is always an empty matrix % str = [ ]; % % initialize the array of sample times % ts = [-1 0]; % end mdlInitializeSizes % %============================================================================= % mdlOutputs % Return the block outputs. %============================================================================= % function sys=mdlOutputs(t,x,u) persistent th h p phi %initialization if t==0
125
[th,yh,p,phi]=rarx([u(2) u(1)],[1 50 1],'ff',1); h=th(2); sys=h; %estimate the impulse weights recursively else [th,yh,p,phi]=rarx([u(2) u(1)],[1 50 1],'ff',1,th,p,phi); %RLS with forgetting factor 1 h=th(end,2); %find the first non-zero impulse weight end sys=h; % end mdlOutputs
B.3 S-Function of estimating first non-zero impulse weight for a second order nonlinear static problem %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %This s-function is used to estimate the first impulse weight parameter for % %a second order nonlinear static problem 24y x x 10= − + − % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [sys,x0,str,ts] =rarx1(t,x,u,flag) switch flag, %%%%%%%%%%%%%%%%%% % Initialization % %%%%%%%%%%%%%%%%%% case 0, [sys,x0,str,ts]=mdlInitializeSizes; %%%%%%%%%%%%%%% % Derivatives % %%%%%%%%%%%%%%% case 1, sys=[]; %%%%%%%%%% % Update % %%%%%%%%%% case 2, sys=[];
126
%%%%%%%%%%% % Outputs % %%%%%%%%%%% case 3, sys=mdlOutputs(t,x,u); %%%%%%%%%%%%%%%%%%%%%%% % GetTimeOfNextVarHit % %%%%%%%%%%%%%%%%%%%%%%% case 4, sys=[]; %%%%%%%%%%%%% % Terminate % %%%%%%%%%%%%% case 9, sys=[]; %%%%%%%%%%%%%%%%%%%% % Unexpected flags % %%%%%%%%%%%%%%%%%%%% otherwise error(['Unhandled flag = ',num2str(flag)]); end % end sfuntmpl % %============================================================================= % mdlInitializeSizes % Return the sizes, initial conditions, and sample times for the S-function. %============================================================================= % function [sys,x0,str,ts]=mdlInitializeSizes % % call simsizes for a sizes structure, fill it in and convert it to a % sizes array. % % Note that in this example, the values are hard coded. This is not a
127
% recommended practice as the characteristics of the block are typically % defined by the S-function parameters. % sizes = simsizes; sizes.NumContStates = 0; sizes.NumDiscStates = 0; sizes.NumOutputs = 1; sizes.NumInputs = 2; sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; % at least one sample time is needed sys = simsizes(sizes); % % initialize the initial conditions % x0 = []; % % str is always an empty matrix % str = []; % % initialize the array of sample times % ts = [-1 0]; % end mdlInitializeSizes % %============================================================================= % mdlOutputs % Return the block outputs. %============================================================================= % function sys=mdlOutputs(t,x,u) persistent th h p phi if t==0
128
[th,yh,p,phi]=rarx([u(2) u(1)],[1 50 1],'ff',0.8); h=th(2); sys=h; else [th,yh,p,phi]=rarx([u(2) u(1)],[1 50 1],'ff',0.8,th,p,phi); %h=th(1); h=th(end,2); end sys=h; % end mdlOutputs
B.4 Generate data for a process with variable dead time and model %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Generate simulated data for a process with variable dead time and model %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% a=1; b1=[0 1 .2 -0.4]; b2=[0 0 0 0 1 .2 -0.4]; b3=[0 0 -0.8 +0.15]; u1=randn(1000,1); u2=randn(2000,1); u3=randn(2000,1); u=[u1;u2;u3]; %input data %generate output using model y(t)=u(t-1)+0.1*u(t-2)-0.4*u(t-3) y1=filter(b1,a,u1); %generate output using model y(t)=u(t-4)+0.1*u(t-5)-0.4*u(t-6) % the dead time changes, model doesn’t change y2=filter(b2,a,u2); %generate output using model y(t)=-0.8*u(t-2)+0.15*u(t-3) % both dead time and mode change y3=filter(b3,a,u3); y=[y1;y2;y3]; %output data t=[0:4999]';
129
B.5 S-Function for calculating delay function [sys,x0,str,ts] = deadtimel(t,x,u,flag) switch flag, %%%%%%%%%%%%%%%%%% % Initialization % %%%%%%%%%%%%%%%%%% case 0, [sys,x0,str,ts]=mdlInitializeSizes; %%%%%%%%%%%%%%% % Derivatives % %%%%%%%%%%%%%%% case 1, sys=[]; %%%%%%%%%% % Update % %%%%%%%%%% case 2, sys=[]; %%%%%%%%%%% % Outputs % %%%%%%%%%%% case 3, sys=mdlOutputs(t,x,u); %%%%%%%%%%%%%%%%%%%%%%% % GetTimeOfNextVarHit % %%%%%%%%%%%%%%%%%%%%%%% case 4, sys=[]; %%%%%%%%%%%%% % Terminate % %%%%%%%%%%%%% case 9, sys=[]; %%%%%%%%%%%%%%%%%%%% % Unexpected flags %
130
%%%%%%%%%%%%%%%%%%%% otherwise error(['Unhandled flag = ',num2str(flag)]); end % end sfuntmpl % %============================================================================= % mdlInitializeSizes % Return the sizes, initial conditions, and sample times for the S-function. %============================================================================= % function [sys,x0,str,ts]=mdlInitializeSizes % % call simsizes for a sizes structure, fill it in and convert it to a % sizes array. % % Note that in this example, the values are hard coded. This is not a % recommended practice as the characteristics of the block are typically % defined by the S-function parameters. % sizes = simsizes; sizes.NumContStates = 0; sizes.NumDiscStates = 0; sizes.NumOutputs = 1; % one output sizes.NumInputs = 2; % two input sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; % at least one sample time is needed sys = simsizes(sizes); % % initialize the initial conditions % x0 = []; % % str is always an empty matrix
131
% str = []; % % initialize the array of sample times % ts = [-1 0]; % end mdlInitializeSizes % %============================================================================= % mdlDerivatives % Return the derivatives for the continuous states. %============================================================================= % function sys=mdlDerivatives(t,x,u) sys = []; % end mdlDerivatives % %============================================================================= % mdlUpdate % Handle discrete state updates, sample time hits, and major time step % requirements. %============================================================================= % function sys=mdlUpdate(t,x,u) sys = []; % end mdlUpdate % %============================================================================= % mdlOutputs % Return the block outputs.
132
%============================================================================= % function sys=mdlOutputs(t,x,u) persistent atemp a btemp b nk z nktemp winsize if t==0 a=u(1); b=u(2); nktemp=1; else a=[atemp;u(1)]; b=[btemp;u(2)]; end atemp=a; btemp=b; winsize=size(atemp); if t<0.001 nk=1; end if winsize(1)>101 z=iddata(btemp,atemp); % package input-output data into the iddata object nk=delayest(z); %calculate the dead time nktemp=[nktemp;nk]; atemp(1:100,:)=[]; btemp(1:100,:)=[]; else nk=nk; end sys =nk; % end mdlOutputs
B.6 S-Function of Gradient method on processes with dead time function [sys,x0,str,ts] =rarxd1(t,x,u,flag) switch flag, %%%%%%%%%%%%%%%%%%
133
% Initialization % %%%%%%%%%%%%%%%%%% case 0, [sys,x0,str,ts]=mdlInitializeSizes; %%%%%%%%%%%%%%% % Derivatives % %%%%%%%%%%%%%%% case 1, sys=[]; %%%%%%%%%% % Update % %%%%%%%%%% case 2, sys=[]; %%%%%%%%%%% % Outputs % %%%%%%%%%%% case 3, sys=mdlOutputs(t,x,u); %%%%%%%%%%%%%%%%%%%%%%% % GetTimeOfNextVarHit % %%%%%%%%%%%%%%%%%%%%%%% case 4, sys=[]; %%%%%%%%%%%%% % Terminate % %%%%%%%%%%%%% case 9, sys=[]; %%%%%%%%%%%%%%%%%%%% % Unexpected flags % %%%%%%%%%%%%%%%%%%%% otherwise error(['Unhandled flag = ',num2str(flag)]); end % end sfuntmpl
134
% %============================================================================= % mdlInitializeSizes % Return the sizes, initial conditions, and sample times for the S-function. %============================================================================= % function [sys,x0,str,ts]=mdlInitializeSizes % % call simsizes for a sizes structure, fill it in and convert it to a % sizes array. % % Note that in this example, the values are hard coded. This is not a % recommended practice as the characteristics of the block are typically % defined by the S-function parameters. % sizes = simsizes; sizes.NumContStates = 0; sizes.NumDiscStates = 0; sizes.NumOutputs = 1; % one output sizes.NumInputs = 3; % three input sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; % at least one sample time is needed sys = simsizes(sizes); % % initialize the initial conditions % x0 = []; % % str is always an empty matrix % str = []; % % initialize the array of sample times % ts = [-1 0];
135
% end mdlInitializeSizes % %============================================================================= % mdlOutputs % Return the block outputs. %============================================================================= % function sys=mdlOutputs(t,x,u) persistent th h p phi z nk if t==0 [th,yh,p,phi]=rarx([u(2) u(1)],[1 100 1],'ff',0.8); h=th(u(3)+1); sys=h; else [th,yh,p,phi]=rarx([u(2) u(1)],[1 100 1],'ff',0.8,th,p,phi); %h=th(1); h=th(end,(u(3)+1)); end sys=h; % end mdlOutputs
B.7 S-Function of Gradient method on CST and Pressure Tank function [sys,x0,str,ts] =rarx1realtime(t,x,u,flag) switch flag, %%%%%%%%%%%%%%%%%% % Initialization % %%%%%%%%%%%%%%%%%% case 0, [sys,x0,str,ts]=mdlInitializeSizes;
136
%%%%%%%%%%%%%%% % Derivatives % %%%%%%%%%%%%%%% case 1, sys=[]; %%%%%%%%%% % Update % %%%%%%%%%% case 2, sys=[]; %%%%%%%%%%% % Outputs % %%%%%%%%%%% case 3, sys=mdlOutputs(t,x,u); %%%%%%%%%%%%%%%%%%%%%%% % GetTimeOfNextVarHit % %%%%%%%%%%%%%%%%%%%%%%% case 4, sys=[]; %%%%%%%%%%%%% % Terminate % %%%%%%%%%%%%% case 9, sys=[]; %%%%%%%%%%%%%%%%%%%% % Unexpected flags % %%%%%%%%%%%%%%%%%%%% otherwise error(['Unhandled flag = ',num2str(flag)]); end % end sfuntmpl % %============================================================================= % mdlInitializeSizes
137
% Return the sizes, initial conditions, and sample times for the S-function. %============================================================================= % function [sys,x0,str,ts]=mdlInitializeSizes % % call simsizes for a sizes structure, fill it in and convert it to a % sizes array. % % Note that in this example, the values are hard coded. This is not a % recommended practice as the characteristics of the block are typically % defined by the S-function parameters. % sizes = simsizes; sizes.NumContStates = 0; sizes.NumDiscStates = 0; sizes.NumOutputs = 1; sizes.NumInputs = 2; sizes.DirFeedthrough = 1; sizes.NumSampleTimes = 1; % at least one sample time is needed sys = simsizes(sizes); % % initialize the initial conditions % x0 = []; % % str is always an empty matrix % str = []; % % initialize the array of sample times % ts = [-1 0]; % end mdlInitializeSizes %
138
%============================================================================= % mdlOutputs % Return the block outputs. %============================================================================= % function sys=mdlOutputs(t,x,u) persistent a b htemp atemp btemp th z h winsize p phi if t==0 [th,yh,p,phi]=rarx([u(2) u(1)],[0 50 1],'ff',.99); h=th(1); sys=h; else [th,yh,p,phi]=rarx([u(2) u(1)],[0 50 1],'ff',0.998,th,p,phi); %h=th(1); h=th(end,1); end sys=h; % end mdlOutputs
139
Appendix C - Conversion
Tables
C.1 CST temperature measurement
*The input range should be chosen as: 05.0± v
RT In Temperature ( ) Co
-0.01807 -0.01465
-0.0002686 0.003906 0.006348 0.01172 0.01367 0.01953 0.02393 0.02686 0.03075 0.0376 0.04199 0.0459 0.05078 0.05225
6 9 19 30 34 40 43 49
54.5 58 62 70 75 79 84 86
140
C.2 Pressure tank
Air flow rate:
20.0016 0.009 2V F F= − +
Where
V: Voltage signal from the flow rate meter
F: Air flow rate
*The input range should be chosen as: 0 – 10 v
Pressure:
7521.11345.0 += PV
Where
V: Voltage signal from the pressure meter
P: Pressure
*The input range should be chosen as: 0 – 10 v
141
Curriculum Vitae
NAME: Yuanyuan Liu
PLACE OF BIRTH: Yantai, China
DATE OF BIRTH: 1982
DEGREES: Dalian Maritime University
Dalian, Liaoning, China
2002-2006, B.Eng.
The University of Western Ontario
London, ON, Canada
2006-2008, M.E.Sc.