Genetic Algorithm
Genetic Algorithm
1
1.0 Abstract
The aim of this project is to create a PID controller for the ball and hoop system
that is tuned online using genetic algorithms The ball and hoop system is notoriously
difficult to control optimally using a PID controller because the system parameters are
constantly changing. It is for this reason that an online tuning strategy was applied.
Genetic Algorithms are effective at finding high performance areas in large domains
and are the ideal choice to tune the online PID controller.
Genetic Algorithms were examined in detail, it was decided to create an objective
function that evaluated the optimum PID gains based on the controlled systems
overall error. GA’s outperformed standard tuning practices, e.g. Ziegler Nichols, at
designing PID controllers, in the tests carried out. It was experimentally determined
that the Mean Square Error (MSE) performance criterion produces the most effective
PID controllers when compared with other performance criterion.
The ball and hoop apparatus was experimented with to attain its transfer function.
A Recursive Least Squares estimator was then created to estimate the system online
and provide the most accurate estimation of the system for the genetic algorithm to
design a PID controller. It was discovered that the RLS estimator failed to work
accurately when used in conjunction with the real system and only worked in
simulation. As a result of this, it was infeasible to perform online tuning on the actual
ball and hoop rig and the rest of the project focuses on achieving this in simulation.
An online genetic algorithm was created. It was discovered that the GA would
sometimes create a controller that would make the overall system unstable. Despite
rigorous testing, the cause of this could not be established. To prevent any unstable
controllers being implemented by the genetic algorithm additional functionality was
added so that the last stable controller created by the genetic algorithm would be
implemented if the current controller were unstable.
The online genetic algorithm proved difficult to test in simulation due to the fact
that Simulink simulations don’t run in real time.
The online genetic algorithm was tested as thoroughly as possible and was
established as an effective controller for the Ball and Hoop system.
2
Table of Contents
1.0 ABSTRACT................................................................................................................................ 2
3
9.2 Creating a Discrete Genetic Algorithm .............................................................................. 59
9.3 Evaluating the Optimum PID Controller Gains .................................................................. 59
9.4 Online Genetic Algorithm .................................................................................................. 61
9.5 Genetic Algorithm Coding for Online Tuner....................................................................... 63
9.6 Testing the Genetic Algorithm used for Online Tuning........................................................ 64
10.0 CONCLUSIONS..................................................................................................................... 69
4
2.0 Introduction
The ball and hoop apparatus consists of a steel ball that is free to roll on the
inside of a rotating circular hoop. This system illustrates the complex dynamics of
liquid slosh i.e. the way liquid behaves in a moving container. The ball and hoop
apparatus is difficult to control optimally using a PID controller because the system
parameters are constantly changing. In order to retune the controller of the system it is
necessary to take the system offline.
It is proposed that an online PID controller would result in the best overall
performance of the system. The online controller will be tuned using Genetic
Algorithms. The application of genetic algorithms to PID optimisation has been
largely overlooked, particularly as a tuning technique for processes that are difficult to
tune [1].
Genetic Algorithms (GAs) are a stochastic global search method that mimics
the process of natural evolution. Genetic Algorithms have been shown to be capable
of locating high performance areas in complex domains without experiencing the
difficulties associated with high dimensionality or false optima as may occur with
gradient decent techniques [2]. Using genetic algorithms to perform the online tuning
of the controller will result in the optimum controller being evaluated for the system
every time.
To estimate the ever-changing parameters of the Ball and Hoop system, a
Recursive Least Squares (RLS) estimator will be implemented. This will provide an
up-to-date estimate of the system for the Genetic algorithm to evaluate the optimum
PID controller.
The online tuned PID controller will initially be tested in a simulation
environment and the results will then be compared to the online tuning of the ball and
hoop rig.
Matlab and the Real-Time Control box in Simulink will be utilized to provide
the online controller tuning of the PID values both in simulation and in conjunction
with the physical rig.
5
3.0 PID Control
PID control consists of three types of control, Proportional, Integral and
Derivative control.
6
3.5 Discrete PID Controller
This project proposes to use a PID controller that is tuned online. To facilitate
the real time aspect of this, a discrete PID controller must be used. The PID controller
will be discretised using the Trapezoidal Difference method.
7
4.0 Ball and Hoop System
The Ball and Hoop System [3] illustrates the dynamics of a steel ball that is
free to roll on the inside of a rotating circular hoop. There is a groove on the inside
edge of the hoop so that a steel ball can roll freely inside the hoop. This introduces the
complexity of the rolling radius of the ball being different to the actual radius of the
ball as illustrated in Figure 4.1
The overall system is shown in Figure 4.2 where the ball position is based on
the assumption that the hoop is rotating anti-clockwise. The hoop is mounted
vertically on the shaft of an electric motor so that it can be rotated about its axis.
When the hoop is rotated, the ball will tend to move in the direction of hoop rotation.
At some point, gravity will overcome the frictional forces and the ball will fall back.
This process will repeat, causing the ball to have oscillatory motion. The motor drives
the hoop so that its angular position can be placed under control. In Figure 4.2 the
angle, θ, is the hoop angular position. The position of the ball is given by:
1. Y, the position of the ball on the hoop periphery with respect to a
datum point.
2. ψ , the slosh angle which measures the deviation of the ball from its
rest position.
Figure 4.3 shows how the ball and hoop system is used to illustrate the
complex dynamics of the oscillations of a liquid in a container when the container is
moving and undergoing changes in velocity and direction.
Oscillation in liquids is called ‘slosh’ or ‘slop’ and is important because the
movement of large quantities of liquid can strongly influence the movement of the
container itself – this is usually undesirable and often dangerous.
8
Figure 4.2 The Ball and Hoop System [3]
9
Any action involving the rapid movement of large quantities of fluid can exhibit
the characteristic oscillations of liquid slop. Traditionally, for a system like the ball
and hoop system, a PID controller would be evaluated using standard tuning
techniques like Ziegler-Nichols and then implemented. The PID controller would
remain in place until the system had changed so much that the controller was no
longer effective. The system would be taken offline and a new PID controller would
be evaluated and implemented. This process is very laborious, time consuming and
difficult to apply because it is not always possible to take a system off-line. It is for
these reasons that online control is a better option for a system, like the ball and hoop,
which is constantly changing.
This project will look at how effective a PID controller, tuned on line using
genetic algorithms, is at reducing the impact of liquid slosh.
10
5.0 Genetic Algorithms
Genetic Algorithms (GA’s) are a stochastic global search method that mimics
the process of natural evolution. The genetic algorithm starts with no knowledge of
the correct solution and depends entirely on responses from its environment and
evolution operators (i.e. reproduction, crossover and mutation) to arrive at the best
solution. By starting at several independent points and searching in parallel, the
algorithm avoids local minima and converging to sub optimal solutions.
In this way, GAs have been shown to be capable of locating high performance areas
in complex domains without experiencing the difficulties associated with high
dimensionality, as may occur with gradient decent techniques or methods that rely on
derivative information [1].
A genetic algorithm is typically initialised with a random population
consisting of between 20-100 individuals. This population (mating pool) is usually
represented by a real-valued number or a binary string called a chromosome. For
illustrative purposes, the rest of this section represents each chromosome as a binary
string. How well an individual performs a task is measured is assessed by the
objective function. The objective function assigns each individual a corresponding
number called its fitness. The fitness of each chromosome is assessed and a survival
of the fittest strategy is applied. In this project, the magnitude of the error will be used
to assess the fitness of each chromosome.
There are three main stages of a genetic algorithm, these are known as
reproduction, crossover and mutation.
5.1 Reproduction
During the reproduction phase the fitness value of each chromosome is
assessed. This value is used in the selection process to provide bias towards fitter
individuals. Just like in natural evolution, a fit chromosome has a higher probability
of being selected for reproduction.
An example of a common selection technique is the ‘Roulette Wheel’ selection
method, Figure 5.1. Each individual in the population is allocated a section of a
roulette wheel; the size of the section is proportional to the fitness of the individual. A
pointer is spun and the individual to whom it points is selected. This continues until
the selection criterion has been met. The probability of an individual being selected is
11
thus related to its fitness, ensuring that fitter individuals are more likely to leave
offspring.
Multiple copies of the same string may be selected for reproduction and the
fitter strings should begin to dominate. However, for the situation illustrated in Figure
5.1, it is not implausible for the weakest string (01001) to dominate the selection
process.
There are a number of other selection methods available and it is up to the user
to select the appropriate one for each process. All selection methods are based on the
same principal i.e. giving fitter chromosomes a larger probability of selection.
Four common methods for selection are:
1. Roulette Wheel selection
2. Stochastic Universal sampling
3. Normalised geometric selection
4. Tournament selection
5.2 Crossover
Once the selection process is complete, the crossover algorithm is initiated. The
crossover operations swaps certain parts of the two selected strings in a bid to capture
the good parts of old chromosomes and create better new ones. Genetic operators
manipulate the characters of a chromosome directly, using the assumption that certain
individual’s gene codes, on average, produce fitter individuals. The crossover
probability indicates how often crossover is performed. A probability of 0% means
that the ‘offspring’ will be exact replicas of their ‘parents’ and a probability of 100%
means that each generation will be composed of entirely new offspring. The simplest
crossover technique is the Single Point Crossover. There are two stages involved in
single point crossover:
12
1. Members of the newly reproduced strings in the mating pool are ‘mated’
(paired) at random.
2. Each pair of strings undergoes a crossover as follows: An integer k is
randomly selected between one and the length of the string less one, [1,L-1].
Swapping all the characters between positions k+1 and L inclusively creates
two new strings.
Example: If the strings 10000 and 01110 are selected for crossover and the value of k
is randomly set to 3 then the newly created strings will be 10010 and 01100 as shown
in Figure 5.2.
More complex crossover techniques exist in the form of Multi-point and Uniform
Crossover Algorithms. Multi-point crossover is an extension of the single point
crossover algorithm and operates on the principle that the parts of a chromosome that
contribute most to its fitness might not be adjacent. There are three main stages
involved in a Multi-point crossover.
1. Members of the newly reproduced strings in the mating pool are ‘mated’
(paired) at random.
2. Multiple positions are selected randomly with no duplicates and sorted into
ascending order.
3. The bits between successive crossover points are exchanged to produce new
offspring.
Example: If the string 11111 and 00000 were selected for crossover and the
multipoint crossover positions were selected to be 2 and 4 then the newly created
strings will be 11001 and 00110 as shown in Figure 5.3.
In uniform crossover, a random mask of ones and zeros of the same length as the
parent strings is used in a procedure as follows.
13
1. Members of the newly reproduced strings in the mating pool are ‘mated’
(paired) at random.
2. A mask is placed over each string. If the mask bit is a one, the underlying bit
is kept. If the mask bit is a zero then the corresponding bit from the other
string is placed in this position.
Example: If the string 10101 and 01010 were selected for crossover with the mask
10101 then newly created strings would be 11111 and 00000 as shown in Fig. 5.4.
Uniform crossover is the most disruptive of the crossover algorithms [4] and
has the capability to completely dismantle a fit string, rendering it useless in the next
generation. Because of this Uniform Crossover will not be used in this project.
5.3 Mutation
Using selection and crossover on their own will generate a large amount of
different strings. However there are two main problems with this:
1. Depending on the initial population chosen, there may not be enough
diversity in the initial strings to ensure the GA searches the entire problem
space.
2. The GA may converge on sub-optimum strings due to a bad choice of initial
population.
These problems may be overcome by the introduction of a mutation operator into
the GA. Mutation is the occasional random alteration of a value of a string position. It
is considered a background operator in the genetic algorithm
The probability of mutation is normally low because a high mutation rate would
destroy fit strings and degenerate the genetic algorithm into a random search.
Mutation probability values of around 0.1% or 0.01% are common, these values
represent the probability that a certain string will be selected for mutation i.e. for a
probability of 0.1%; one string in one thousand will be selected for mutation.
Once a string is selected for mutation, a randomly chosen element of the string
is changed or ‘mutated’. For example, if the GA chooses bit position 4 for mutation in
14
the binary string 10000, the resulting string is 10010 as the fourth bit in the string is
flipped as shown in Figure 5.5.
15
The convergence criterion of a genetic algorithm is a user-specified condition e.g.
the maximum number of generations or when the string fitness value exceeds a
certain threshold.
5.5 Elitism
With crossover and mutation taking place, there is a high risk that the
optimum solution could be lost as there is no guarantee that these operators will
preserve the fittest string. To counteract this, elitist models are often used. In an elitist
model, the best individual from a population is saved before any of these operations
take place. After the new population is formed and evaluated, it is examined to see if
this best structure has been preserved. If not, the saved copy is reinserted back into the
population. The GA then continues on as normal [5]
16
5.7 Initialising the Population of the Genetic Algorithm
The following code is based on the Genetic Algorithm Optimisation Toolbox
(GAOT) [6].
17
and the ‘1’ term indicates that real numbers are being used (0 indicates binary
encoding is being used).
• Initialisega - This command combines all the previously described terms and
creates an initial population of 80 real valued members between –100 and 100
with 6 decimal place precision.
• Bounds - The bounds for the genetic algorithm to search within are set using
this command. These bounds may be different from the ones used to initialise
the population and they define the entire search space for the genetic
algorithm.
• startPop - The starting population of the GA, ‘startPop’, is defined as the
population described in the previous section, i.e. ‘initPop’, see Figure 5.7.
• opts - The options for the Genetic Algorithm consist of the precision of the
string values i.e. 1e-6, the declaration of real coded values, 1, and a request for
the progress of the GA to be displayed, 1, or suppressed, 0.
• TermFN - This is the declaration of the termination function for the genetic
algorithm. This is used to terminate the genetic algorithm once certain
criterion has been met. In this project, every GA will be terminated when it
reaches a certain number of generations using the ‘maxGenTerm’ function.
This termination method allows for more control over the compile time (i.e.
the amount of time it takes for the genetic algorithm to reach its termination
18
criterion) of the genetic algorithm when compared with other termination
criteria e.g. convergence termination criterion.
• TermOps - This command defines the options, if any, for the termination
function. In this example the termination options are set to 100, which means
that the GA will reproduce one hundred generations before terminating. This
number may be altered to best suit the convergence criteria of the genetic
algorithm i.e. if the GA converges quickly then the termination options should
be reduced.
• SelectFN - Normalised geometric selection (‘normGeomSelect’) is the primary
selection process to be used in this project. The GAOT toolbox provides two
other selection functions, Tournament selection and Roulette wheel selection.
Tournament selection has a longer compilation time than the rest and as the
overall run time of the genetic algorithm is an issue, tournament selection will
not be used. The roulette wheel option is inappropriate due to the reasons
mentioned in section 5.1.
• SelectOps - When using the ‘normGeomSelect’ option, the only parameter that
has to be declared is the probability of selecting the fittest chromosome of
each generation, in this example this probability is set to 0.08.
• XOverFN - Arithmetic crossover was chosen as the crossover procedure.
Single point crossover is too simplistic to work effectively on a chromosome
with three alleles, a more uniform crossover procedure throughout the
chromosome is required. Heuristic crossover was discarded because it
performs the crossover procedure a number of times and then picks the best
one. This increases the compilation time of the program and is undesirable.
The Arithmetic crossover procedure is specifically used for floating point
numbers and is the ideal crossover option for use in this project.
• XOverOptions -This is where the number of crossover points is specified. In
the example shown in Figure 5.8, the number of crossovers points is set to
four.
• mutFNs - The ‘multiNonUnifMutation’, or multi non-uniformly distributed
mutation operator, was chosen as the mutation operator as it is considered to
function well with multiple variables.
19
• MutOps - The mutation operator takes in three options when using the
‘multiNonUnifMutation’ function. The first is the total number of mutations,
normally set with a probability of around 0.1%. The second parameter is the
maximum number of generations and the third parameter is the shape of the
distribution. This last parameter is set to a value of two, three or four where
the number reflects the variance of the distribution.
The best population may be plotted to give an insight into how the genetic
algorithm converged to its final values as illustrated in Figure 5.10
20
Figure 5.10 Illustration of the Genetic Algorithm Converging through Generations
21
Figure 5.11 Creating PID Controller in Objective Function
Additional code was added to ensure that the genetic algorithm converges to a
controller that produces a stable system. The code, shown in Figure 5.12, assesses the
poles of the controlled system and if they are found to be unstable i.e. on the right half
of the s-plane, the error is assigned an extremely large value to make sure that the
chromosome is not reselected.
22
Figure 5.12 Checking the Stability of the Controlled System
In order to evaluate an optimum genetic algorithm for use in this project, several GAs
were created and analysed as shown in the next section.
23
6.0 Development of Genetic Algorithm for PID Tuning
To aid with the development of this project a system was chosen at random
and a PID controller was designed for it using conventional methods. A genetic
algorithm was then created to evaluate the PID coefficients of the same system and
the results of the two techniques were compared. A fourth order system was selected
as the Ball and Hoop system is of order four.
The system chosen was:
1
G(s) = (6.1)
s + 6s + 11s 2 + 6 s
4 3
2π
Tc = = 6.28 sec
ωc
24
Placing the values of K c and Tc into Table 6.1
Controller Kp TI TD
PID 0.6 K C TC / 2 TC / 8
Table 6.1 Ziegler-Nichols PID tuning parameters
Gives
Controller Kp TI TD
PID 6 3.14 0.79
Table 6.2 Ziegler-Nichols PID Tuning Values
KP
Using the relationship K I = and K D = K P TD , the PID gains can be evaluated.
TI
Controller Kp KI KD
PID 6 1.91 4.74
Table 6.3 Ziegler-Nichols PID Gain values
Table 6.3 shows the PID gain values for the system G(s). A genetic algorithm,
Initial_PID_GA.m, (Appendix A.1) was created to evaluate the optimum PID gain
values for the system G(s). A number of objective functions were created in order to
evaluate the PID values chosen by the Genetic Algorithm.
were:
25
The ITAE weights the error with time and hence emphasises the error values later on
in the response rather than the initial large errors.
26
6.2.4 Mean of the Square of the Error (MSE)
1 n
I MSE = ∑
n i =1
( e(t )) 2 (6.4)
MSE reflects all variation and deviation from the target value.
27
Figure 6.6 Graph of Ziegler-Nichols designed PID controller (red) Vs GA designed
PID Controller (green) using (a) ITAE, (b) IAE, (c) ISE and (d) MSE as performance
criterion.
Under the conditions of this experiment, it can be seen that the ISE and MSE
objective functions perform almost identically, having a smaller rise time, smaller
overshoot and bigger settling time than the other controllers. Each of the genetic
algorithm-tuned PID controllers outperforms the Ziegler-Nichols tuned controller in
terms of rise time and overshoot but only the ITAE and IAE objective functions
outperform it in terms of settling time. The MSE objective function was chosen as the
primary performance criterion for the remainder of this project due to its smaller rise
time and smaller overshoot than any other method in conjunction with a slightly faster
compile time due to there being just one multiplication to be carried after the error has
been calculated. This is coupled with the fact that MSE has been a ‘proven measure
of control and quality for many years’ [7] makes it the ideal performance criterion for
this project.
28
7.0 Identifying the Ball and Hoop System
7.1 Operating Conditions
The hoop in the Ball and Hoop system is driven by a motor, this introduces
two common operational characteristics associated with motors i.e. saturation and
dead band. The saturation effect is caused because the magnitude of the current that
the amplifier is capable of creating is lower than may be required in certain situations.
Dead band in a system is a region where for a given input there is no output. The dead
band in this system is caused mainly due to the static friction of the motor and the
load.
The dead band level of the system was found by increasing the input voltage
by .01V until the hoop began to move. Using this procedure the dead band level was
found to be 0.7V. The operating conditions in the manual of the Ball and Hoop
system stipulate that the maximum input into the ball and hoop system should not
exceed 10V. Due to this requirement, the ball and hoop system should never reach its
saturation level. Consequently, the input voltage level to the Ball and Hoop system
must remain in the linear region of the graph between 0.7V -10V.
29
Figure 7.2 Transfer Function Relating Input Voltage and Hoop Position
voltage was chosen to be 4V, as this will give an output of around 3000RPM. The
30
step increase was added in the form of a ± 1V square-wave with a frequency of
0.05Hz as can be seen in Figure 7.4.
In a first-order system such as the motor, there is no overshoot. Due to this, the
rise time of the system is calculated as the time at which the system reaches 63.2% of
its final value. The time taken for the speed to change by 0.632∆ω is equal to the time
constant of the system, τ .
The time constant was evaluated using Matlab and was found to have a value
of .66 seconds.
τ = 0.66 sec
31
Figure 7.5 Plot of Data in Table 7.1
Calculating the slope of the line in Figure 7.5 and hence the value of H gives;
135
H= = 67.5
2
Now that the coefficients for G, H and τ are known the transfer function for
the hoop is as depicted in Figure 7.6
The derived transfer function for the hoop was compared against the actual
hoop for a step input of 4V, using the hoop speed, ω , as the output. Simulink scales
down the voltage by a factor of ten, hence the amplitude shown in the graphs is ten
times smaller than the actual voltage. For a step input of 4V there was a large
discrepancy in the outputs of the actual hoop and the mathematical model of the hoop
as shown in Figure 7.7.
The difference in outputs is a gain of just under two. In order to remedy this
error the gain value of the derived transfer function of the hoop, i.e. G, was adjusted
manually until the error between the predicted output and the actual output for a step
input of 4V was minimal as shown in Figure 7.9.
32
Figure 7.7 Graph of the Real Vs Simulated Output of the Hoop
The newly found gain has a value of 1.75 and the overall transfer function for
the hoop is now as depicted in Figure 7.8
The new transfer function for the hoop only represents the hoop for an input of
4V. For any other input an error occurs. If the model for the ball and hoop project is
based around an input of 4V then this transfer function is an accurate representation of
the hoop.
33
7.6 Evaluation of ξ and ω n
The ball was placed in the hoop between the blades of the Slop Angle
transducer arms. It was deflected by hand to an angle of 40o and then released. The
oscillatory response of the ball was recorded using Matlab. Utilizing the oscillatory
response, the values of ξ and ω d may be determined by comparing the ball response to
the standard response characteristic of a second order system.
34
The fractional overshoot of the system was measured at 0.825 using Matlab.
Rearranging Equation (7.2) and solving for ξ yields a value of 0.066 for the damping
factor.
ξ = 0.066
π
tp = (7.3)
ωd
A time to first peak value of t p = 0.32 was evaluated in Matlab. Rearranging the
The transfer function relating the hoop angle, θ (s) , to the slop angle, ψ (s) , is
detailed in Equation (7.5)
2 rb 2 b
s s + b 2
ψ ( s) 5 r mr
= (7.5)
θ ( s ) 2 rb 2 2
s + bb s + g
5 r mr 2 R
Where:
rb = Radius of the Ball (= 9.53mm)
35
All of these coefficients for the ball and hoop system are known except one. The next
step is to calculate the coefficient of rolling friction.
bb g
⇒ s2 + s+ =0
2 r 2
2 r 2
mr 2 b + 1 R b + 1
5 r 5 r
bb
2ξω n =
2 r 2
mr 2 b + 1
5 r
Rearranging,
2 r 2
bb = 2ξω n mr 2 b + 1 (7.7)
5 r
Where:
ξ = 0.066
ω n = 9.987 rad/sec.
m = 28.2g
rb = 9.53mm
r = 9.3mm
Substituting these values into Equation (7.7) gives:
2 9.53 2
bb = 2(0.066)(9.987)(.0282)(.0093) 2
+ 1
5 9.3
bb = 4.57 × 10 −6
36
Now that the coefficient of rolling friction is known, the transfer function shown in
Equation (7.5) can be evaluated as:
ψ ( s) 0.42s 2 + 1.873s
=
θ ( s ) 1.42 s 2 + 1.873s + 112.11
The experimentally derived Ball and Hoop transfer function is shown in Figure 7.12
Figure 7.13 Overall Transfer Function of the Ball and Hoop System
7.8 Ziegler-Nichols PID Controller for the Ball and Hoop System.
The Ziegler-Nichols tuning technique was again used to design a PID controller for
evaluation purposes. Using the same method as described in Section 6.1, the
crossover point and gain of the system were found to be j12.6233 and 1.5813
respectively, as illustrated in Figure 7.14.
37
2π
With a frequency ( ω c ) of 1 rad/s, the period Tc is calculated as = 0.5 sec.
ωc
Controller Kp TI TD
PID .9478 0.25 .0625
Table 7.2 Ziegler-Nichols PID Tuning Values
KP
Using the relationship K I = and K D = K P TD the PID gains can be evaluated.
TI
Controller Kp KI KD
PID .9478 3.7912 .06
Table 7.3 Ziegler-Nichols PID Gain values
Analysing the transfer function in Figure 7.13 shows that the ball and hoop system is
stable as it has three poles located on the left hand side of the s-plane at -0.6595 +
8.8609i, -0.6595 - 8.8609i and -1.5152 and one critically stable pole located at the
origin. The presence of a critically stable pole will result in a more oscillatory open
loop response. From the transfer function, it is clear that there will be an open-loop
206.1
steady state gain of = 1.84 . This gain is shown in Figure 7.15 when the open
112.1
loop response of the system is plotted against a PID controlled system using the
previously derived Ziegler-Nichols controller.
Figure 7.15 Open Loop Vs PID Controlled Response of Ball and Hoop System
38
8.0 System Estimator
The ball and hoop system parameters are constantly changing. Because of this,
a mechanism is need by which the system parameters can be obtained. It is proposed
that a Recursive Least Squares estimator, implemented in the form of an
s-function will perform this task.
And the regression vector, x(t), is a matrix of input and output variables in the form:
x T (t ) = [ y (t − 1),..., y (t − na ), u (t − 1),..., u (t − nb − 1), e(t − 1),..., e(t − nc ),1, t ,..., t nd ]
e(t ) represents the error of the estimates at time t. The aim of least squares is to select
a value for θ so that the overall error is minimised. To be able to estimate parameters
effectively the number of equations must not be less than the number of unknown
parameters in the vector θ .
Rearranging the Equation (8.2) in terms of the error gives:
eˆ = y − Xθˆ (8.3)
x T (1)
T
x ( 2)
Where, X =
:
T
x ( N )
To find θˆ , minimise the Error Performance Index, J, where J is the sum of the squares
of the error.
N
J = ∑ eˆ 2 (t ) = eˆT eˆ (8.4)
t −1
39
To find the least squares estimate, insert Equation (8.3) into Equation (8.4).
J = ( y − Xθˆ) T ( y − Xθˆ)
Figure 8.1 graphically illustrates the RLS technique. At each sample time the
input and output data of the system becomes available. The estimated system θˆ(t − 1) ,
40
predicts an output and compares it to the system output. The error of the two outputs
is then used to update the parameter estimates.
The RLS derivation is detailed in Appendix B. The procedure for updating
θˆ(t ) using Recursive Least Squares is detailed in the following summary.
At time step t + 1 :
(i) Form x (t + 1) using the new data.
(ii) Form ε (t + 1)
using ε (t + 1) = y (t + 1) − x T (t + 1)θˆ( t )
x (t + 1) x T (t + 1) P (t )
P (t + 1) = P (t ) I m −
1 + x T (t + 1) P (t ) x (t + 1)
(8.6)
41
Laplace Transform z-transform
G(s) G(z)
1 τs
s z −1
Table 8.1 Single Integrator with Unit Gain
Given that the Ball and Hoop system has already been identified, θ (0) will be
initialised to the experimentally derived coefficients of the system. (See Equation
(8.11) for derivation)
2.964
− 2.936
0.9721
θ (0) =
0.002477
0.0001215
− 0.002382
42
Figure 8.2 Dither Signal System
There are four main choices for the proposed dither signal.
1. Gaussian Distributed Noise
2. Uniformly Distributed Noise
3. Square Wave
4. Pseudo Random Binary Signal (PRBS)
43
of linearity of the system. The main advantage of PRBS is that it has a rich spectrum
and is an ideal input for a system to be estimated. (See Appendix A.6 for code)
44
The least squares approach, Equation (8.5), to minimising the cost function at
each time t implies that all the values of eˆ(i ) from i = 1 to i = t carry an equal
weighting.
t
J t = ∑ eˆ(i) (8.7)
i =1
The discounting effect of λ on past errors can be seen by writing (8.8) in the
form:
J t = λJ t −1 + eˆ 2 (t ) (8.9)
The forgetting mechanism uses the influence of lambda to progressively reduce
the importance given to old data.
Figure 8.4 Variations of Data Weighting with Constant Forgetting Factor λ [8]
It is clear from Figure 8.4, that the optimal value for a forgetting factor is
between 0.95 and 1. By reducing the value of λ it increases the sensitivity of the
system to change but this also increases the variability of the estimates so a
compromise must be reached. It is proposed that a value of 0.975 is used for the
forgetting factor in this project.
With the inclusion of a forgetting factor the equation for updating the
covariance matrix, Equation (8.6), becomes:
45
1 P (t ) x (t + 1) x T (t + 1) P (t )
P (t + 1) = −
λ λ + x T (t + 1) P (t ) x (t + 1)
P ( t ) (8.10)
8.10 S-Functions
To incorporate an RLS estimator into the control scheme for the Ball and
Hoop system requires that the RLS algorithm is able to fully interact with the Real-
Time toolbox in Simulink. To this end, the RLS estimator must be written as an S-
Function in Simulink.
An S-function is a computer language description of a Simulink block that
may be written in MATLAB, C, C++, Ada, or Fortran. S-functions allow the user to
create their own blocks in Simulink. They use a special calling syntax that enables
direct interaction with Simulink equation solvers. This interaction is similar to the
interaction that takes place between the solvers and built-in Simulink blocks. The
form of an S-function is general and can accommodate continuous, discrete, and
hybrid systems. S-functions are fully compatible with the Real-Time toolbox. [9]
46
Each S-function utilises a set of callback methods that perform tasks required at
each stage. Simulink calls the appropriate methods for each S-Function block in the
model at the relevant stage during simulation. Tasks performed by S-function
methods include
• Calculation of next sample hit – Used for variable sample time systems only,
calculates the time of the next sample hit; i.e. calculates the next step size.
• Calculation of outputs in the major time step – Validates all output ports for
the current time step.
• Updates discrete states in the major time step – All blocks perform once-per-
time-step activities e.g. updating discrete states for next simulation loop.
• Integration -- This applies to models with continuous states and/or nonsampled
zero crossings. If your S-function has continuous states, Simulink calls the
output and derivative portions of your S-function at minor time steps. This is
so Simulink can compute the states for your S-function.
47
Figure 8.6 Tasks Performed by S-function [9]
t - Current time
48
Simulation Stage S-Function Routine Flag
Calculation of next sample hit (variable sample time only) mdlTimeOfNextVarHit flag = 4
49
Figure 8.7 Graph of Bode Plot of System
Figure 8.8 Step Response of Discrete System using Different Sample Times
50
Continuous Ball and Hoop Transfer Function:
Y (s) 46.21s 2 + 206.1s
=
U ( s ) 0.9372 s 4 + 2.656 s 3 + 75.87 s 2 + 112.1s
Discrete Ball and Hoop Transfer Function (Using ZOH):
Y ( z ) 0.002477 z 2 + 0.0001215 z − 0.002382
=
U ( z) z 3 − 2.964 z 2 + 2.936 z − 0.9721
Converting to the form of z −1 :
Y ( z −1 ) 0.002477 z −1 + 0.0001215 z −2 − 0.002382 z −3
=
U ( z −1 ) 1 − 2.964 z −1 + 2.936 z −2 − 0.9721−3
y(k) - 2.964y(k-1) + 2.936y(k-2) – 0.9721y(k- 3) = 0.002477u(k-1) + 0.0001215u(k-2) – 0.02382u(k-3)
y ( k ) = X T θ (k )
2.964
− 2.936
0.9721
y(k ) = [ y(k − 1) y(k − 2) y(k − 3) u(k − 1) u(k − 2) u(k − 3)] (8.11)
0 .002477
0.0001215
− 0.002382
The regression vector, X T , is an input into the RLS estimator. U and Y are the
inputs and outputs of the system, respectively. The (k-1) etc. terms represent the
various time slots e.g. y(k-2) is the output two sample times ago. In order to achieve
the appropriate delays in Simulink a unit delay block will be inserted as required. The
RLS Simulink file should take the form of the diagram illustrated in Figure 8.9.
The RLS estimator requires a minimum of three inputs. The first input is the
number of parameters to be identified, the second is the forgetting factor and the final
input is the sample time of the system.
51
Figure 8.9 Simulink Illustration of RLS Set-up
In this project, the quick convergence of the RLS algorithm to the system
parameters is essential. To assist this, two additional inputs were added to the RLS S-
function. The two extra inputs are the initial covariance matrix P(0) and the initial
parameter estimate θ (0) . The initial parameter estimate will be the same as was
derived in (8.12) and because θ (0) can be presumed accurate the covariance matrix
will be initialised small.
2.964 10 0 0 0 0 0
− 2.936 0 10 0 0 0 0
0.9721 0 0 10 0 0 0
θ (0) = P(0) =
0.002477 0 0 0 10 0 0
0.0001215 0 0 0 0 10 0
− 0.002382 0 0 0 0 0 10
Equation 8.12 Initial Parameter and Covariance matrix
When writing an S-Function a mandatory four inputs are required. These are:
T - The Current Time
X - The Current State Vector
U- The Input Vector
Flag - The current value of the FLAG
52
These four inputs are taken care of internally by Simulink and require no user
interaction. Any additional inputs must be coded and specified by the user.
When using the RLS.m S-Function (Appendix A1.7), five inputs are requested from
the user:
n - number of parameters,
theta_init - initial parameter estimates,
P_init - initial covariance matrix,
lambda - forgetting factor,
samp_t - sampling interval.
53
these estimates were requested by the genetic algorithm at an early stage, the
estimated system would turn out to be largely inaccurate and result in an inadequate
controller being designed by the GA.
Because of the large error, it is vital that the parameter estimates are initialised
to the values derived in Equation (8.11). Figure 8.11 shows the RLS estimator
response when the initial parameter estimates have been set to these values. At first
glance, there seems to be a lot of agitation before the estimates converge to their final
values but when the amplitude of the estimations is observed it can be seen that the
estimates are only varying minutely. If these estimates were requested at an early
stage of the RLS algorithm, the estimated system would be highly accurate and the
controller designed by the genetic algorithm would perform adequately.
54
Figure 8.12 RLS Estimates with θˆ(0) Initialised to their Derived Values
8.13 Testing the RLS estimator on the Ball and Hoop Apparatus
The RLS estimator s-function, rls.m, was tested on the ball and hoop rig to establish if
it would function correctly. The file used is described in Figure 8.13.
55
Figure 8.13 RLS Estimator Simulink file for Ball and Hoop Rig
The RLS estimator was initialised as described in Figure 8.10. The resulting output
was as shown in Figure 8.14. It is obvious that the RLS estimator did not perform as
desired as it converged to the wrong parameter estimates. The RLS estimator was
tested again with different sized covariance matrices but the system never converged
to the correct values.
All of the estimates in Figure 8.14 show noise like qualities when they reach a steady
state value. This is most likely caused be the chipped paint on the ball and hoop rig
making the ball to vibrate as the hoop rotates. When trying to estimate coefficients
that have values to six decimal places, this noise could have a substantial effect on the
overall accuracy. Analysing the denominator coefficients, which are of magnitude 1-
3, the estimates are still incorrect and indicate that the RLS estimator doesn’t function
correctly in conjunction with the physical ball and hoop rig.
As a result of this, it is infeasible to perform the online tuning on the ball and hoop rig
and the remainder of this project shall be carried out in simulation only.
56
Figure 8.14 RLS estimator working on the Ball and Hoop system
57
9.0 Online Genetic Algorithm
9.1 Choosing the Discrete Transfer Function
The RLS estimator estimates the coefficients of the discrete transfer function
of the ball and hoop system. Initially, it was decided to take the discrete estimated
system, perform a ‘discrete to continuous’ transformation and then execute a genetic
algorithm similar to the one described in Initial_PID_GA.m to find the ideal PID
values of the system.
However, there was one major problem encountered with this approach; when
performing the ‘discrete to continuous’ transformation, the resulting continuous
system was discovered to be different than the derived continuous ball and hoop
system.
Figure 9.1 Illustration of C2D and D2C Irregularity using Zero-Order Hold
58
9.2 Creating a Discrete Genetic Algorithm
Creating a genetic algorithm that evaluates the discrete gains of a PID
controller for the discrete ball and hoop transfer function was achieved by extending
the functionality of previous algorithms. The main change introduced was in the
objective function. Now, the continuous PID gains are passed into the objective
function from the genetic algorithm just like before but when the continuous PID
controller transfer function is evaluated, it is converted into its discrete form using the
trapezoidal difference method. This controller is then evaluated using the Mean
Square Error of the step response of the controlled system. This genetic algorithm,
described in Ultimate_GA.m, will return the continuous gains of a PID controller
whose discrete equivalent was used for evaluation, these gains are converted into their
discrete form, again using the trapezoidal difference method to give the optimum
discrete controller evaluated by the genetic algorithm.
59
Performing a continuous to discrete transformation on a PID controller with
these gain values using the trapezoidal difference method yields the discrete
controller:
407.6 z 2 - 806.9 z + 402.1
C PID ( z ) = (9.1)
z2 −1
The controller in Equation (9.1) produces an output as described in Figure 9.2
when used to control the discrete ball and hoop system for a step input of 0.4.
From Figure 9.2, it is apparent that this is a well-controlled system, there is a visibly
small over shoot with very well damped oscillations. The steady state characteristics
of the system are:
Rise time = 0.01
Overshoot of = 1.36%
Settling Time = 0.11
From the plot of the convergence of the genetic algorithm to its final values, Figure
9.3, it can be seen that the GA searched a large range of possible combinations for the
P,I and D gains between the bounds of –10000 and 10000.
60
Figure 9.3 Convergence of the Genetic Algorithm to its Final Values
Now that the optimum PID controller values are known, the bounds of the
online genetic algorithm can be reduced to a smaller range of numbers. This will
ensure quick convergence and a reduction in the number of generations necessary for
the algorithm to converge to optimum PID gain values, which in turn will reduce the
overall runtime of the online genetic algorithm.
61
Figure 9.4 Simulink file used for On-line Simulations
The majority of the blocks in Figure 9.4 are used as part of the RLS estimation of the
ball and hoop system. The main point to note is that the PID controller is not hard
coded but takes the shape of a variable transfer function i.e. both the numerator,
Discrete_PID_num, and the denominator, Discrete_PID_den, are variables that are
defined by the Genetic Algorithm. This allows the genetic algorithm to update the
gain values of the PID controller instantaneously by just assigning a new value to the
Discrete_PID_num variable.
The main problem with the genetic algorithm, used to tune the controller
online, is its compilation time. The compile time of the algorithm is highly dependent
on the speed of the hardware being used. Considering this, it was decided not to create
a GA that updated the PID controller values every ‘time period’ (where a ‘time
period’ is the time it takes for the genetic algorithm to compile). This would cause
incompatibility between different hardware and may cause difficulties when using the
same hardware but the CPU usage varies, as both would cause the compile time of the
GA to vary. If the compile time of the GA exceeded the allotted time-period, then the
controller would not be updated until the next time-period.
62
In order to avoid this problem, the online genetic algorithm is designed to run
in an infinite while loop, this allow the genetic algorithm to constantly reiterate. Once
the genetic algorithm has calculated the optimum PID gain values for the system it
immediately updates the online controller, then gets the most recent estimation of the
plant from the RLS estimator and then performs a the genetic algorithm on the new
plant
63
The RLS estimates are entered into the GA using the ‘To Workspace’ function in
Simulink. This block saves the RLS output in a matrix format. Getting the most recent
entry into the matrix attains the most recent estimate. Example: The latest entry for
the B0 coefficient into the matrix is acquired by the command:
B0=b0 (max (size (b0)));
In order to avoid the matrices containing the RLS estimates becoming
excessively large and crashing the computer the sample time of the ‘To Workspace’
function is enlarged to a value of around 2 seconds.
Once the RLS estimates have been updated and the discrete ball and hoop
transfer function formed, the genetic algorithm is carried out as normal.
64
Figure 9.5 Code used to Analyse the Stability of the Discrete Controlled System
65
Figure 9.6 Step Response Using Controller Evaluated in Iteration 1 of the GA
The population analysed for the fourth iteration of the genetic algorithm to see if any
of the population resulted in a controller that produced a stable system. The code
segment in Figure 9.7 was inserted into the objective function to record the population
that produced stale controllers during the fourth iteration of the genetic algorithm.
66
The cause for the genetic algorithm producing an unstable controller could not
be established. To prevent an unstable controller being implemented by the genetic
algorithm, the code in Figure 9.8 was added.
67
Figure 9.10 Screen-grab of GA Evaluated PID Values
Adding the extra functionality provided by the code in Figure 9.8 negates the
rational for using genetic algorithms to derive an optimal controller. Genetic
algorithms have been shown to reliably evaluate PID controllers that outperform
standard tuning methods, as shown in section 6.3. The fact that the genetic algorithm
described in Selftuning_RLS_GA.m produces an unstable controller at regular
intervals is more than likely a coding error or a ‘bug’ in the Genetic Algorithm
Optimisation Toolbox.
The overall testing of the online tuned PID controller was impossible due to
the lack of real-time simulation facilities provided by the Simulink software package.
The testing of the online tuned PID controller on the physical ball and hoop system
was hampered by the RLS estimator not converging to the correct coefficients when
tested on the actual rig. As a result of this conclusive testing of the ball and hoop
system could not be achieved.
68
10.0 Conclusions
It was established, by comparison of their steady state characteristics that GA’s
outperformed standard tuning practices, e.g. Ziegler Nichols, when designing a PID
controller. It was determined that the Mean Square Error (MSE) performance criterion
based objective function produced the most effective PID controllers when compared
with other performance criterion i.e. IAE, ITAE and ISE.
When the transfer function for the hoop was derived experimentally, a
discrepancy was found between the actual output and the simulated output of the hoop
to a step input of 4V. This discrepancy was overcome by adjusting the gain manually
until the two outputs matched. The difference in gains between the simulated and real
system may have occurred due to the misreading of the voltage from the voltmeter.
When the experiments were being carried out the voltage reading on the voltmeter
was constantly changing, a mean value was taken but this leave scope for error that
may emerge in the form of a gain error.
The hoop position, ϑ (s) , is the input to the ball transfer function as shown in
Figure 7.12. The simulated output of the hoop position, ϑ (s) , is a ramp output
whereas the output of ϑ (s) in the physical ball and hoop system is a saw tooth
function. This may account for the difference in outputs between the physical rig and
the simulated system. A function was created that converted the ramp output in the
simulated system into a saw tooth output but this still resulted in a mismatch between
the simulated system and the physical system. Since there is no mention of the
requirement for this function in the ball and hoop manual it was omitted.
The sample time of the system was calculated as 0.2635 sec using the
bandwidth of the system. This was discovered to be too slow a sample time for a ball
and hoop system so a sample time of 0.01 sec was used instead.
The RLS s-function performed well in simulation, accurately predicting the
parameter estimates of the ball and hoop system. When the RLS estimator was
applied to the ball and hoop rig it failed to correctly identify the systems parameters.
One possible reason for this is due to the paint on the hoop being chipped. When the
hoop is rotating, the uneven surface causes the ball to vibrate up and down. This
reduces the force of friction acting on the ball and leads to the difference in predicted
output and actual output.
69
Considering, the error in the hoop transfer function, the failure of the RLS
estimator to function correctly when used with the physical rig and the difference in
outputs between the physical ball and hoop system and the simulated one, it may be
concluded that the derived transfer function of the ball and hoop system may be
somewhat erroneous. If this is true, there are two possible explanations:
1. The transfer functions/descriptions of experiments in the manual are wrong.
2. The experiments undertaken to derive the various parameters produces false
results.
The testing of an online tuned PID controller for the ball and hoop system in
simulation proved to be difficult due to the lack of real-time simulation facilities in
Simulink. The individual components of the online tuned controller were tested to
evaluate if the overall controller was effective.
When testing the genetic algorithm component, it was discovered to frequently
produce controllers that made the overall controlled system unstable. The exact cause
for this could not be determined. To rectify this problem, the genetic algorithm was
modified so it would analyze the controller it evaluates. If the controller produces an
unstable system, it is replaced with the last stable controller evaluated by the genetic
algorithm.
The genetic algorithm online tuned PID controller proved to be a capable
controller. Adequate testing of the controller could not be performed due to the
simulation difficulties mentioned previously.
Recommendations for a continuation of this project would include; designing a
more robust RLS estimator that will estimate any system and does not have to be
manually tailored to the system it is estimating. Test the genetic algorithm used to
tune the PID controller online i.e. Selftuning_RLS_GA.m using a different toolbox
than GAOT. This will evaluate if it is the GAOT toolbox that is causing the genetic
algorithm to produce controllers that make the overall system unstable.
70
11.0 References
[1] O’ Mahony, T., Downing,C.J. and Klaudiuz, F., ‘Genetic Algorithms for PID
Parameter Optimisation: Minimising Error Criteria’, [online], URL:
http://www.pwr.wroc.pl/~i-8zas/kf_glas00.pdf
[2] Linkens, D.A., & H.O. Nyongesa, ‘Genetic algorithms for fuzzy control’, IEE
Proc. Control Theory Appl., Vol. 142, No. 3, pp.161-185
[7] G.J. Battaglia and J.M. Maynard, ‘‘Mean square Error: A Useful Tool for
Statistical Process Management,’’AMP J. Technol. 2, 47-55 (1992).
[8] SELF TUNING SYSTEMS Control and Signal Processing, P.E. Wellstead
and M.B Zarrop (Publishers(WILEY))1991 pp 140-150
71
Appendix A
Matlab Script and Function
Files
72
Appendix A.1 Initial_PID_GA.m
%Initial_PID_GA.m
%Written by Ian Griffin July 2003
%Last Modified 20-08-03
%____________________________________________________________________
clc
clear
close all
global sys_controlled
global time
global sysrl
%____________________________________________________________________
%Defining sysrl
den1=[1 6 11 6 0];
num1=[1];
sysrl=tf(num1,den1);
%____________________________________________________________________
%Initialising the genetic algorithm
populationSize=80;
variableBounds=[-100 100;-100 100;-100 100];
evalFN='PID_objfun_MSE';
%Change this to relevant object function
evalOps=[];
options=[1e-6 1];
initPop=initializega(populationSize,variableBounds,evalFN,...
evalOps,options);
%____________________________________________________________________
%Setting the parameters for the genetic algorithm
bounds=[-100 100;-100 100;-100 100];
evalFN='PID_objfun_MSE';%change this to relevant object function
evalOps=[];
startPop=initPop;
opts=[1e-6 1 0];
termFN='maxGenTerm';
termOps=100;
selectFN='normGeomSelect';
selectOps=0.08;
xOverFNs='arithXover';
xOverOps=4;
mutFNs='unifMutation';
mutOps=8;
%____________________________________________________________________
%Iterating the genetic algorithm
[x,endPop,bPop,traceInfo]=ga(bounds,evalFN,evalOps,startPop,opts,...
termFN,termOps,selectFN,selectOps,xOverFNs,xOverOps,mutFNs,mutOps);
%____________________________________________________________________
%Plotting Genetic algorithm controller Vs Root locus controller
den1=[1 6 11 6 0];
num1=[1];
sysrl=tf(num1,den1);
73
%Creating the optimal PID controller from GA results
ga_pid=tf([x(1) x(2) x(3)],[1 0]);
ga_sys=feedback(series(ga_pid,sysrl),1);
figure(1)
hold on;
step(ga_sys,time,'g');%Green-genetic algorithm
step(time,rl_sys,'r');%Red-Root locus
legend('ZN Controlled Sys','GA Controlled Sys',0);
%____________________________________________________________________
%Printing to screen the PID values and
%comparing them to the Zeigler Nichols values
disp(' Kd Kp Ki');
disp('Z-N: 4.74 6 1.91');
disp( x );
%____________________________________________________________________
%Plotting best population progress
figure(2)
subplot(3,1,1),plot(bPop(:,1),bPop(:,3)),...
title('Kp Value'),, ylabel('Gain');
subplot(3,1,2),plot(bPop(:,1),bPop(:,4)),...
title('Ki Value'),, ylabel('Gain');
subplot(3,1,3),plot(bPop(:,1),bPop(:,2)),...
title('Kd Value'),xlabel('Generations'), ylabel('Gain');
%____________________________________________________________________
for i=1:301
error(i) = (abs(1-y(i)))*t(i);
end
%Integral of Squared Error
ITAE=sum(error);
74
%____________________________________________________________________
%to make sure controlled system is stable
poles=pole(sys_controlled);
if poles(1)>0
ITAE=100e300;
elseif poles(2)>0
ITAE=100e300;
elseif poles(3)>0
ITAE=100e300;
elseif poles(4)>0
ITAE=100e300;
elseif poles(5)>0
ITAE=100e300;
end
fx_val=1/ITAE;
%____________________________________________________________________
time =0:0.1:30;
[y t] = step(sys_controlled,time); % Step response of closed-loop
system
%____________________________________________________________________
for i=1:301
error(i) = 1-y(i);
end
IAE=sum(abs(error));%Integral of absolute error
%____________________________________________________________________
%to make sure controlled system is stable
poles=pole(sys_controlled);
if poles(1)>0
IAE=100e300;
elseif poles(2)>0
IAE=100e300;
elseif poles(3)>0
IAE=100e300;
elseif poles(4)>0
75
IAE=100e300;
elseif poles(5)>0
IAE=100e300;
end
fx_val=1/IAE;
%____________________________________________________________________
for i=1:301
error(i) = 1-y(i);
end
error=error*error';
ISE=sum(error); %Integral of Squared Error
%____________________________________________________________________
%to make sure controlled system is stable
poles=pole(sys_controlled);
if poles(1)>0
ISE=100e300;
elseif poles(2)>0
ISE=100e300;
elseif poles(3)>0
ISE=100e300;
elseif poles(4)>0
ISE=100e300;
elseif poles(5)>0
ISE=100e300;
end
fx_val=1/ISE;
%____________________________________________________________________
76
Appendix A.5 PID_objfun_mse.m
%Initial_PID_objfun_MSE.m
%Written by Ian Griffin July 2003
%Last Modified 20-08-03
%____________________________________________________________________
function [x_pop, fx_val]=PID_objfun_MSE(x_pop,options)
global sys_controlled
global time
global sysrl
%____________________________________________________________________
Kp=x_pop(2);
Ki=x_pop(3);
Kd=x_pop(1);
%____________________________________________________________________
%creating the PID controller from current values
pid_den=[1 0];
pid_num=[Kd Kp Ki];
pid_sys=tf(pid_num,pid_den); %overall PID controller
77
Appendix A.6 m_prbs.m
%Initial_PID_objfun_MSE.m
%Written by Ian Griffin July 2003
%Last Modified 29-07-03
%____________________________________________________________________
function y=prbs(u)
%This prbs file is used to provide a small noise signal to the system
%so that the RLS estimator values may be calculated.
if u<.5
y=-.01;
else y=.01;
end
%%%%%%%%%%%%%%%%%%
% Initialization %
%%%%%%%%%%%%%%%%%%
case 0,
[sys,x0,str,ts] = mdlInitializeSizes(n,theta_init,P_init,samp_t);
%%%%%%%%%%
% Update %
%%%%%%%%%%
case 2,
sys = mdlUpdate(x,u,n,lambda);
%%%%%%%%%%
% Output %
%%%%%%%%%%
78
case 3,
sys = mdlOutputs(x,n);
%%%%%%%%%%%%%%%%%%%%
% Unexpected flags %
%%%%%%%%%%%%%%%%%%%%
otherwise
sys = [];
end
%____________________________________________________________________
% mdlInitializeSizes
% Return the sizes, initial conditions, and sample times for the S-
function.
%____________________________________________________________________
function [sys,x0,str,ts] =
mdlInitializeSizes(n,theta_init,P_init,samp_t)
sizes = simsizes;
sizes.NumContStates = 0;
sizes.NumDiscStates = n+n^2;
sizes.NumOutputs = n;
sizes.NumInputs = n+1;
sizes.DirFeedthrough = 0;
sizes.NumSampleTimes = 1;
sys = simsizes(sizes);
x0 = mdlPack(theta_init,P_init,n);
str = [];
ts = [samp_t 0];
%____________________________________________________________________
% mdlUpdate
% Update theta and P
%____________________________________________________________________
function sys = mdlUpdate(x,u,n,lambda)
sys = x;
%____________________________________________________________________
% mdlOutputs
% Return theta and P
%____________________________________________________________________
79
function sys = mdlOutputs(x,n)
sys=x(1:n);
sys=sys(:);
%____________________________________________________________________
% mdlPack
% Pack theta and P in x
%____________________________________________________________________
function x = mdlPack(theta,P,n)
P_vec = [];
for j = 1:n
P_vec = [P_vec;P(:,j)];
end
x = [theta;P_vec];
%____________________________________________________________________
% mdlUnpack
% Unpack theta and P from x
%____________________________________________________________________
function [theta,P] = mdlUnpack(x,n)
theta = x(1:n,1);
P = [];
for j = 1:n
P = [P,x(j*n+1:(j+1)*n,1)];
End
%____________________________________________________________________
rlocus(Ball_Hoop);
80
Appendix A.9 Ultimate_PID_GA.m
%Ultimate_PID_GA.m
%Written by Ian Griffin July 2003
%Last Modified 20-08-03
%____________________________________________________________________
clc
clear
close all
%global sys_controlled
%global time
global Ball_Hoop_d
rand('state',0);
%____________________________________________________________________
%Defining the ball and hoop system
hoop=tf([1.63],[.66 1]);
H=tf([67.5],[1 0]);
sys_ball=tf([.42 1.873 0],[1.42 1.873 112.11]);
sys_hoop=series(hoop,H);
Ball_Hoop=series(sys_hoop,sys_ball);
Ball_Hoop_d=c2d(Ball_Hoop,.01,'zoh');
%____________________________________________________________________
%Initialising the genetic algorithm
populationSize=3000;
variableBounds=[-10000 10000;-10000 10000;-10000 10000];
evalFN='Ultimate_PID_objfun_mse';%Change this to relevant object
function
evalOps=[];
options=[1e-6 1];
initPop=initializega(populationSize,variableBounds,evalFN,evalOps,opt
ions);
%____________________________________________________________________
%Setting the parameters for the genetic algorithm
bounds=[-10000 10000;-10000 10000;-10000 10000];
evalFN='Ultimate_PID_objfun_mse';%change this to relevant object
function
evalOps=[];
startPop=initPop;
opts=[1e-6 1 0];
termFN='maxGenTerm';
termOps=300;
selectFN='normGeomSelect';
selectOps=0.08;
xOverFNs='arithXover';
xOverOps=4;
mutFNs='unifMutation';
mutOps=500;
%____________________________________________________________________
%Iterating the genetic algorithm
[x,endPop,bPop,traceInfo]=ga(bounds,evalFN,evalOps,startPop,opts,...
termFN,termOps,selectFN,selectOps,xOverFNs,xOverOps,mutFNs,mutOps);
%____________________________________________________________________
%Generating the Continuous PID Controller
den_pid=[1 0];
num_pid=[x(1) x(2) x(3)]; %Kd Kp Ki
sys_pid=tf(num_pid,den_pid);
81
sysd_pid=c2d(sys_pid,.01,'tustin')
%____________________________________________________________________
%Creating the controlled System
sys_controlled=feedback(series(sysd_pid,Ball_Hoop_d),1);
figure(1)
time =0:0.01:10;
u=.4*ones(size(time));
lsim(sys_controlled,u,time);
%____________________________________________________________________
%Printing to screen the PID values
%x
disp('_________________________________')
disp('| PID GAIN VALUES |')
disp('|________________________________|')
disp('| Kd Kp Ki |');
disp([x(1) x(2) x(3)]);
disp('|________________________________|')
%____________________________________________________________________
%Printing to screen the PID values
%x
%disp(' Kd Kp Ki');
%disp('ZN: 4.74 6 1.91');
%disp( x );
%____________________________________________________________________
%Plotting best population progress
figure(2)
subplot(3,1,1),plot(bPop(:,1),bPop(:,3)),...
title('Kp Value'),, ylabel('Gain');
subplot(3,1,2),plot(bPop(:,1),bPop(:,4)),...
title('Ki Value'),, ylabel('Gain');
subplot(3,1,3),plot(bPop(:,1),bPop(:,2)),...
title('Kd Value'),xlabel('Generations'), ylabel('Gain');
%____________________________________________________________________
%Informing user if the system is unstable
poles=pole(sys_controlled);
if abs(real(poles(1)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 1%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('REAL POLE VALUE')
disp(poles(1))
elseif abs(imag(poles(1)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 1%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('IMAGINARY POLE VALUE')
disp(poles(1))
elseif abs(real(poles(2)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 2%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('REAL POLE VALUE')
disp(poles(2))
elseif abs(imag(poles(2)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 2%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('IMAGINARY POLE VALUE')
disp(poles(2))
elseif abs(real(poles(3)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
82
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 3%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('REAL POLE VALUE')
disp(poles(3))
elseif abs(imag(poles(3)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 3%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('IMAGINARY POLE VALUE')
disp(poles(3))
elseif abs(real(poles(4)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 4%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('REAL POLE VALUE')
disp(poles(4))
elseif abs(imag(poles(4)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 4%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('IMAGINARY POLE VALUE')
disp(poles(4))
elseif abs(real(poles(5)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 5%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('REAL POLE VALUE')
disp(poles(5))
elseif abs(imag(poles(5)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 5%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('IMAGINARY POLE VALUE')
disp(poles(5))
elseif abs(imag(poles))<1
disp('This system is stable');
elseif abs(real(poles))<1
disp('This system is stable');
end
%____________________________________________________________________
%Ultimate_PID_objfun_mse.m
%Written by Ian Griffin July 2003
%Last Modified 20-08-03
%____________________________________________________________________
function [x_pop, fx_val]=Ultimate_PID_objfun_mse(x_pop,options)
%global sys_controlled
global time
global Ball_Hoop_d
Kp=x_pop(2);
Ki=x_pop(3);
Kd=x_pop(1);
83
pid_num=[Kd Kp Ki];
pid_sys=tf(pid_num,pid_den); %overall PID controller
time =0:0.01:8;
u=.4*ones(size(time));
[y t] = lsim(sys_controlled,u,time); % Step response of closed-
loop system to
% an input of 0.4.
for i=1:801
error(i) = 0.4-y(i);
end
error_sq = error*error';
MSE=error_sq/max(size(error));
%____________________________________________________________________
%Making sure overall system is stable
poles=pole(sys_controlled);
if abs(real(poles(1)))>1
MSE=100e306;
elseif abs(imag(poles(1)))>1
MSE=100e306;
elseif abs(real(poles(2)))>1
MSE=100e306;
elseif abs(imag(poles(2)))>1
MSE=100e306;
elseif abs(real(poles(3)))>1
MSE=100e306;
elseif abs(imag(poles(3)))>1
MSE=100e306;
elseif abs(real(poles(4)))>1
MSE=100e306;
elseif abs(imag(poles(4)))>1
MSE=100e306;
elseif abs(real(poles(5)))>1
MSE=100e306;
elseif abs(imag(poles(5)))>1
MSE=100e306;
end
fx_val=1/MSE;
%____________________________________________________________________
84
Appendix A.11 Selftuning_RLS_GA.m
%Selftuning_RLS_GA.m
%Written by Ian Griffin July 2003
%Last Modified 20-08-03
%____________________________________________________________________
clc
clear
global sys_controlled
global time
global Ball_Hoop
global u
global time
global Ball_Hoop_rls
global z%remove
global ROW
global observe_pop
ROW=1;
close all
last_stable=1;
rand('state',0);%keeps using the same initial values
%____________________________________________________________________
%Initalising the PID parameters to ones found in root locus as a
backup
%incase the GA doesn't compile before the step signal initiates.
Discrete_PID_num=[12.97 -23.96 11.07];
Discrete_PID_den=[1 0 -1];
%____________________________________________________________________
%Simulating the Adaptive_GA_RLS_rls simulink file
sim('Adaptive_GA_RLS_rls');
%____________________________________________________________________
%Creating a while loop so the Genetic Algorithm will compute PID
gains indefinately
z=1;
while z<5
sys_unstable=0;
%if z==2
% co=100;
%elseif z==4
%co=50;
%end
%____________________________________________________________________
%Displaying the Iteration number on screen
disp('ITERATION')
disp(z)
%____________________________________________________________________
%Getting the most recent estimates from the RLS estimator
B0=b0(max(size(b0)));
B1=b1(max(size(b1)));
B2=b2(max(size(b2)));
A1=a1(max(size(a1)));
A2=a2(max(size(a2)));
A3=a3(max(size(a3)));
%____________________________________________________________________
%Discrete Ball and Hoop system from RLS estimates
rls_discrete_num=[B0 B1 B2];
rls_discrete_den=[1 -A1 -A2 -A3]; %Multiplying by a minus to make
signs match
disp('RLS Estimation Of Plant')
Ball_Hoop_rls=tf(rls_discrete_num,rls_discrete_den,.01)
disp('')
85
%rls_continuous_tf=d2c(rls_discrete_tf)
%____________________________________________________________________
%Initialising the genetic algorithm
populationSize=30;
variableBounds=[-5 10;-5 10;100 200];
evalFN='Selftuning_RLS_GA_OBJFUN';%Change this to relevant object
function
evalOps=[];
options=[1e-6 1];
initPop=initializega(populationSize,variableBounds,evalFN,evalOps,opt
ions);
%____________________________________________________________________
%Setting the parameters for the genetic algorithm
bounds=[-5 10;-5 10;100 200];
evalFN='Selftuning_RLS_GA_OBJFUN';%change this to relevant object
function
evalOps=[];
startPop=initPop;
opts=[1e-6 1 0];
termFN='maxGenTerm';
termOps=80;
selectFN='normGeomSelect';
selectOps=0.08;
xOverFNs='arithXover';
xOverOps=4;
mutFNs='unifMutation';
mutOps=2;%one thousanth of the (population size x maxGenTerm)
%____________________________________________________________________
%Iterating the genetic algorithm
[x,endPop,bPop,traceInfo]=ga(bounds,evalFN,evalOps,startPop,opts,...
termFN,termOps,selectFN,selectOps,xOverFNs,xOverOps,mutFNs,mutOps);
%____________________________________________________________________
%Printing to screen the PID values
%x
disp('_________________________________')
disp('| PID GAIN VALUES |')
disp('|________________________________|')
disp('| Kd Kp Ki |');
disp([x(1) x(2) x(3)]);
disp('|________________________________|')
%____________________________________________________________________
%Plotting best population progress
figure(z)
subplot(3,1,1),plot(bPop(:,1),bPop(:,3)),...
title('Kp Value'),, ylabel('Gain');
subplot(3,1,2),plot(bPop(:,1),bPop(:,4)),...
title('Ki Value'),, ylabel('Gain');
subplot(3,1,3),plot(bPop(:,1),bPop(:,2)),...
title('Kd Value'),xlabel('Generations'), ylabel('Gain');
%____________________________________________________________________
%Generating the Continuous PID Controller
den_pid=[1 0];
num_pid=[x(1) x(2) x(3)]; %Kd Kp Ki
sys_pid=tf(num_pid,den_pid);
86
[Discrete_PID_num,Discrete_PID_den]=tfdata(sysd_pid,'v');
87
disp(poles(4))
sys_unstable=1;
%break
elseif abs(imag(poles(4)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 4%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('IMAGINARY POLE VALUE')
disp(poles(4))
sys_unstable=1;
%break
elseif abs(real(poles(5)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 5%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('REAL POLE VALUE')
disp(poles(5))
sys_unstable=1;
%break
elseif abs(imag(poles(5)))>1
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('%THIS SYSTEM IS UNSTABLE DUE TO POLE 5%')
disp('%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%')
disp('IMAGINARY POLE VALUE')
disp(poles(5))
sys_unstable=1;
%break
end
%____________________________________________________________________
%creating a matrix to store the PID values
pid_trace(z,:)=x;
%____________________________________________________________________
%if the GA designed system is Unstable use the Last stable controller
if sys_unstable==1
x=pid_trace(last_stable,:);
if z==1
x=Discrete_PID_num;
end
else
last_stable=z;
end
stable_pid_trace(z,:)=x;
%____________________________________________________________________
%Generating the Continuous PID Controller
den_pid=[1 0];
num_pid=[x(1) x(2) x(3)]; %Kd Kp Ki
sys_pid=tf(num_pid,den_pid);
88
end
error_sq = error*error';
MSE=error_sq/max(size(error));
%____________________________________________________________________
%Making sure overall system is stable
poles=pole(sys_controlled);
if abs(real(poles(1)))>1
MSE=100e306;
elseif abs(imag(poles(1)))>1
MSE=100e306;
elseif abs(real(poles(2)))>1
MSE=100e306;
89
elseif abs(imag(poles(2)))>1
MSE=100e306;
elseif abs(real(poles(3)))>1
MSE=100e306;
elseif abs(imag(poles(3)))>1
MSE=100e306;
elseif abs(real(poles(4)))>1
MSE=100e306;
elseif abs(imag(poles(4)))>1
MSE=100e306;
elseif abs(real(poles(5)))>1
MSE=100e306;
elseif abs(imag(poles(5)))>1
MSE=100e306;
elseif outside_system_limits_flag==1
MSE=100e306;
end
fx_val=1/MSE;
%____________________________________________________________________
90
Appendix B
RLS Derivation
91
Appendix B.1 Derivation of Recursive Least Squares
Using least squares, Equation (8.5), as a starting point and defining:
X (t ) y (t )
X (t + 1) = .... And, y (t + 1) = ...
x T (t + 1) t (t + 1)
Gives,
θˆ(t + 1) = [ X T (t + 1) X (t + 1)]−1 X T (t + 1) y (t + 1)
Where,
X T (t + 1) X (t + 1) = X T (t ) X (t ) + x(t + 1) x T (t + 1)
X T (t + 1) y (t + 1) = X T (t ) y (t ) + x (t + 1) y (t + 1) (B.1)
Defining Shorthand Notation
P(t ) = [ X T (t ) X (t )]−1
B(t ) = X T (t ) y (t )
P −1 (t + 1) = P −1 (t ) + x(t + 1) x T (t + 1)
B(t + 1) = B(t ) + x(t + 1) y (t + 1)
Using this shorthand
In order to directly update P(t) to P(t+1) the Matrix Inversion Lemma must be used.
The Matrix Inversion Lemma is defined as:
( A + BCD) −1 = A −1 − A −1 B(C −1 + DA −1 B) −1 DA −1
Assigning
A = P −1 (t ) , C = 1, B = x(t + 1) , D = x T (t + 1)
Gives
[ (
P(t +1) = P(t ) I m − x(t +1) 1+ xT (t +1)P(t) x(t +1) xT (t +1)P(t) )
−1
] (B.3)
Using Equation (B.3), it is possible to update from P(t) to P(t+1) without inverting a
matrix. The only term that needs to be inverted is a scalar.
Defining the error, ε , as:
92
ε (t + 1) = y (t + 1) − x T (t + 1)θˆ(t )
And substituting for y(t+1) into Equation (B.1) gives:
B (t + 1) = B (t ) + x(t + 1) x T (t + 1)θˆ(t ) + x(t + 1)ε (t + 1)
Substituting for B(t ), B(t + 1) using Equations (8.7) gives:
93
Appendix C
Genetic Algorithm Tuned Controller
Results
94
Appendix C.1 First Ten GA Results
ITERATION
1
_________________________________
| PID GAIN VALUES |
|________________________________|
| Kd Kp Ki |
1.8869 2.6542 136.9328
|________________________________|
PID controller
Transfer function:
380.7 z^2 - 753.4 z + 375.4
---------------------------
z^2 - 1
_________________________________
| PID GAIN VALUES |
|________________________________|
| Kd Kp Ki |
2.0278 2.4886 149.9009
|________________________________|
PID controller
Transfer function:
408.8 z^2 - 809.6 z + 403.8
---------------------------
z^2 - 1
_________________________________
| PID GAIN VALUES |
|________________________________|
| Kd Kp Ki |
2.0352 2.7816 149.6656
|________________________________|
PID controller
Transfer function:
410.6 z^2 - 812.6 z + 405
-------------------------
z^2 - 1
_________________________________
95
| PID GAIN VALUES |
|________________________________|
| Kd Kp Ki |
2.0039 2.7325 147.9990
|________________________________|
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%THIS SYSTEM IS UNSTABLE DUE TO POLE 1%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
REAL POLE VALUE
-1.0289 + 0.1000i
PID controller
Transfer function:
410.6 z^2 - 812.6 z + 405
-------------------------
z^2 - 1
_________________________________
| PID GAIN VALUES |
|________________________________|
| Kd Kp Ki |
2.0322 2.4364 153.1424
|________________________________|
PID controller
Transfer function:
409.6 z^2 - 811.4 z + 404.8
---------------------------
z^2 - 1
_________________________________
| PID GAIN VALUES |
|________________________________|
| Kd Kp Ki |
2.0614 2.5629 152.9685
|________________________________|
PID controller
Transfer function:
415.6 z^2 - 823 z + 410.5
-------------------------
z^2 - 1
_________________________________
| PID GAIN VALUES |
96
|________________________________|
| Kd Kp Ki |
2.0109 2.4026 149.7018
|________________________________|
PID controller
Transfer function:
405.3 z^2 - 802.9 z + 400.5
---------------------------
z^2 - 1
_________________________________
| PID GAIN VALUES |
|________________________________|
| Kd Kp Ki |
1.9977 2.6486 143.5183
|________________________________|
PID controller
Transfer function:
402.9 z^2 - 797.7 z + 397.6
---------------------------
z^2 - 1
_________________________________
| PID GAIN VALUES |
|________________________________|
| Kd Kp Ki |
2.0008 2.4663 147.9964
|________________________________|
PID controller
Transfer function:
403.4 z^2 - 798.8 z + 398.4
---------------------------
z^2 - 1
_________________________________
| PID GAIN VALUES |
|________________________________|
| Kd Kp Ki |
2.0547 2.4698 152.8903
|________________________________|
PID controller
97
Transfer function:
414.2 z^2 - 820.4 z + 409.2
---------------------------
z^2 - 1
98
2.0166 3.5936 133.6904
1.8243 0.8581 111.4890
1.9798 2.7854 142.3950
2.0144 2.1172 127.2980
1.9777 1.8664 124.0881
2.2479 2.6671 171.0242
1.8168 8.6768 109.9954
1.8961 1.9911 114.6813
1.9819 3.1325 128.2210
2.2279 2.8195 162.8366
2.1954 3.0663 149.5784
1.9944 3.2977 130.1814
1.9183 2.2869 118.1903
2.0911 2.9304 146.1030
2.0841 2.9213 145.8704
1.8168 8.6768 109.9954
1.8168 8.6768 109.9954
1.9944 3.2977 130.1814
1.9944 3.2977 130.1814
2.0179 5.6148 127.6079
1.9742 6.2806 123.7782
1.8935 1.9574 114.2817
1.8862 1.8595 113.1205
2.1655 4.2917 167.5272
3.0164 4.2917 167.5272
1.9864 3.0180 136.8499
1.9877 3.0651 135.7265
1.9802 2.8607 139.3185
1.9815 3.0571 131.2975
2.0896 2.9436 145.8555
2.0181 3.5803 133.9380
1.9871 3.0415 136.2893
1.9804 2.8090 141.8323
1.9798 6.8626 142.3950
2.0166 4.9898 133.6904
1.9867 3.0272 136.6300
1.9802 2.7997 142.0544
2.0232 2.8420 143.8423
2.0476 2.8738 144.6558
2.0376 2.8607 144.3210
1.9898 2.7985 142.7298
1.9798 2.7854 142.3950
1.9798 2.7854 142.3950
1.9798 3.9154 142.3950
1.9814 2.8815 142.0155
2.0150 4.8937 134.0700
1.9975 2.8085 142.9873
2.0054 2.8188 143.2500
1.9810 2.8564 142.1148
1.9802 2.8105 142.2958
1.9798 2.7854 144.0886
1.9953 2.8057 142.9137
1.9899 2.7985 142.7314
1.9875 2.7954 142.6521
1.9821 2.7884 142.4727
1.9934 2.8031 142.8482
1.9918 2.8010 142.7952
1.9798 2.7854 143.3680
1.9798 2.7854 143.1157
1.9798 2.7854 120.9368
2.0196 2.8373 143.7219
99
1.9935 2.8032 142.8518
2.0039 2.8168 143.4835
1.9954 2.8058 143.3541
1.9839 2.7908 142.5328
1.9893 2.7978 142.7141
2.0017 2.8139 143.1247
1.9971 2.8080 142.9735
1.9918 2.8010 153.4055
1.9954 6.4597 143.3541
2.0037 2.8165 143.4692
1.9896 2.7982 142.7284
2.0011 2.8131 143.1045
1.9977 2.8088 142.9937
1.9993 2.8108 143.1232
2.0019 2.8143 143.3333
1.9920 2.8013 142.8025
1.9894 2.7980 142.7176
1.9798 1.7905 144.0886
2.0013 2.8135 143.1732
2.0017 2.8139 143.2647
2.0034 2.8162 143.4053
2.0022 2.8145 143.2029
2.0032 2.8159 143.3941
2.0022 2.8146 143.3445
2.0022 4.9674 143.3445
2.0022 2.8146 143.3540
2.0037 2.8165 143.4628
1.9999 2.8116 143.1694
2.0033 2.8161 143.4373
2.0039 2.8168 143.4835
2.0039 2.8168 143.4835
2.0017 7.0385 143.2647
2.0039 2.8168 143.4835
2.0039 2.8168 143.4835
1.9998 2.8114 143.1235
2.0012 2.8132 143.1244
2.0039 1.2050 143.4835
2.0039 2.8168 106.6067
2.0036 2.8165 143.4395
2.0019 2.8143 143.1688
2.0026 2.8151 143.2749
2.0033 2.8160 143.3773
2.0039 9.5754 143.4835
2.0039 9.9465 143.4835
2.0012 2.8133 143.2741
2.0020 2.8143 143.3325
2.0031 2.8158 143.3536
2.0034 2.8162 143.4048
1.5595 2.8168 143.4835
2.0039 2.8168 143.4835
2.0039 2.8168 143.4835
2.0039 2.8168 143.4835
2.0039 2.8168 143.4835
2.0039 5.3826 143.4835
2.0039 2.8168 106.3944
2.0012 2.8133 143.2751
2.0039 2.8168 143.4825
2.0039 2.8168 143.4835
2.0039 2.8168 143.4835
2.0036 2.8165 143.4361
2.0037 2.8166 143.4522
100
2.0037 2.8166 182.6622
2.0039 2.8168 144.4339
2.0039 2.8168 143.4835
2.0039 2.8168 143.4835
2.9758 2.8168 143.4835
2.0039 2.8168 143.4835
2.0039 2.8168 111.8495
0.9865 2.8168 143.4835
2.0039 2.8168 143.9347
2.0039 2.8168 143.9826
2.0039 2.8168 143.9081
2.0039 2.8168 144.0093
2.0039 -0.5434 144.4339
2.0039 6.4263 144.4339
2.0039 2.8168 143.8665
2.0039 2.8168 144.0508
2.0039 2.8168 144.0896
2.0039 2.8168 143.8277
2.0039 2.6629 143.4835
2.0039 9.3111 143.9081
2.0039 2.7821 144.2194
2.0039 2.6977 143.6979
2.0039 2.8129 143.5673
2.0039 2.7861 144.1356
2.0039 2.8097 144.3646
2.0039 2.7932 144.2048
2.0039 2.8168 144.4339
2.0039 2.8168 144.4339
2.0039 2.7932 152.9392
2.0039 2.8168 177.9213
2.0039 2.8168 144.4339
2.0039 2.8168 144.4339
2.0039 2.8168 137.6735
2.0039 2.8168 140.5360
2.0039 3.2198 144.4339
2.0039 9.3131 144.4339
2.0039 6.3250 144.4339
2.0039 1.9149 144.4339
2.0039 0.1423 144.4339
2.0039 2.8168 191.9369
2.0039 2.8168 196.4608
2.0039 5.8517 144.4339
2.0039 2.8168 157.0043
2.0039 7.5586 144.4339
2.0039 2.8168 137.7765
2.0039 0.1982 144.4339
2.0039 2.7325 144.4339
2.0039 2.8168 144.4339
2.0039 2.8168 144.4339
2.0039 2.7534 144.4339
2.0039 2.7959 144.4339
2.0039 1.5929 144.4339
2.0039 2.8168 144.4339
2.0039 2.8168 144.4339
2.0039 2.8093 144.4339
2.0039 2.8035 144.4339
2.0039 2.8168 127.5816
2.0039 2.8133 144.4339
2.0039 2.8071 144.4339
2.0039 2.8117 144.4339
2.0039 2.8011 144.4339
101
2.0039 2.8155 133.9194
2.0039 2.8146 138.0960
2.0039 2.7413 143.3223
2.0039 2.8067 135.0310
2.0039 5.6952 144.4339
2.0039 9.2374 144.4339
2.0039 2.7731 144.4339
2.0039 2.7664 144.4339
2.0039 2.8059 144.4339
2.0039 2.8069 144.4339
2.0039 2.8014 144.4339
2.0039 2.7981 144.4339
2.0039 2.8033 143.5034
2.0039 2.8127 139.0265
2.0039 2.6436 144.4339
2.0039 3.4725 144.4339
2.0039 2.7516 144.4339
2.0039 2.7541 144.4339
2.0039 2.7135 144.4339
2.0039 2.7470 144.4339
2.0039 2.7430 144.4339
2.0039 2.7411 144.4339
2.0039 0.6288 144.4339
2.0039 2.6572 144.4339
2.0039 2.7189 144.4339
2.0039 2.6936 144.4339
2.0039 2.6825 144.4339
2.0039 2.6821 144.4339
2.0039 2.6550 144.4339
2.0039 2.6853 144.4339
2.0039 2.7297 144.4339
2.0039 8.9536 144.4339
2.0039 2.7325 145.2633
2.0039 2.7029 144.4339
2.0039 2.6868 144.4339
2.0039 2.6859 144.4339
2.0039 2.6862 144.4339
2.0039 2.7321 145.1480
2.0039 2.7301 144.5492
2.0039 2.7168 145.1171
2.0039 2.6592 144.5800
1.8028 2.6550 144.4339
2.0039 2.7024 144.9827
2.0039 2.6893 144.8606
2.0039 2.7199 145.1457
2.0039 2.7019 144.9782
2.0039 2.6953 144.8611
2.0039 2.6961 144.8669
2.0039 2.7322 145.1825
2.0039 2.7324 145.2288
2.0039 2.7024 123.6254
2.0039 6.4623 145.2288
2.0039 2.6630 144.6153
2.0039 2.7130 145.0818
2.0039 2.7078 145.0328
2.0039 2.6683 144.6644
2.0039 2.6439 144.4366
2.0039 2.7165 145.1144
2.0039 2.7307 145.1477
2.0039 2.7213 145.1460
2.0039 2.7199 163.3547
102
2.0039 2.6692 144.6731
2.0039 2.6942 144.9064
2.0039 2.7278 145.1414
2.0039 2.7197 145.1234
2.0039 2.7226 145.1550
2.0039 2.7296 145.2317
2.0039 2.7206 145.1481
2.0039 2.7219 145.1526
2.0039 5.6964 145.2633
2.0039 2.6663 144.6456
2.0039 2.6972 144.9339
2.0039 2.7219 145.1646
2.0039 2.7305 145.2444
2.0039 2.7275 145.1480
2.0039 2.7252 145.1481
2.0039 2.7325 130.5211
2.0039 2.7325 131.4483
2.0039 2.7325 144.3362
2.0039 2.7325 145.2633
2.0039 2.7325 145.2633
2.0039 2.7274 145.2158
2.0039 2.7250 145.1932
2.0039 2.7325 132.3852
2.0039 2.7325 144.3264
2.0039 0.2690 145.2633
2.0039 2.7325 199.8797
2.0039 7.6152 145.2633
2.0039 1.0859 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 104.9362
2.0039 7.6306 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 145.2633
2.0039 7.9217 145.2633
2.0039 2.7325 139.1215
2.0039 6.4211 145.2633
2.0039 6.9893 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 117.8089
2.0039 2.7325 115.5249
2.0039 2.7325 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 115.2115
2.0039 1.7807 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 145.2633
2.0039 8.3708 145.2633
2.0039 0.2513 145.2633
2.0039 0.7131 145.2633
2.0039 2.5962 145.2633
2.0039 2.7325 147.9990
2.0039 2.7325 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 145.2633
2.0039 2.7325 147.3924
2.0039 2.7325 145.8698
2.0039 7.3083 145.2633
2.0039 2.7325 107.4221
103
2.0039 2.7325 146.8061
2.0039 2.7325 146.4562
2.0039 2.7325 145.4347
2.0039 2.7325 147.8276
2.0039 2.7325 146.3969
2.0039 2.7325 145.6725
2.0039 2.7325 145.3083
2.0039 2.7325 147.7825
2.0039 2.7325 147.1364
2.0039 2.7325 147.3187
2.0039 2.7325 147.7066
2.0039 2.7325 147.6848
1.3319 2.7325 147.7825
2.0039 -1.3865 147.9990
2.0039 2.7325 147.0808
2.0039 2.7325 145.8673
2.0039 2.7325 147.4499
2.0039 2.7325 146.4163
2.0039 2.7325 178.5742
2.0039 5.9737 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 198.1139
2.0039 2.7325 117.0134
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 135.3905
2.0039 2.7325 155.3785
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 150.1005
2.0039 2.7325 153.2770
2.0039 2.7325 107.2023
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 175.0642
2.0039 6.6883 147.9990
2.0039 9.7951 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 7.5702 147.9990
2.0039 2.7528 147.9990
2.0039 -1.0850 147.9990
2.0039 2.7325 132.6889
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.0039 2.7325 147.9990
2.39 2.7325 147.9990
104
105