Genetic Algorithm and Accleration Technique

advertisement
Genetic Algorithm and Acceleration Techniques
UNIVERSITY OF QUEENSLAND
DEPARTMENT OF INFORMATION TECHNOLOGY
& ELECTRICAL ENGINEERING
ELEC 4802 THESIS PROJECT
Genetic Algorithm and Acceleration Techniques
THESIS SUPERVISOR:
Dr Dong Zhao-Yang
WRITTEN BY:
Yeo Su Yuin Melinda
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
23rd May, 2003
Yeo Su Yuin Melinda
2/119 Munro Street
St Lucia QLD 4067
Executive Dean
Faculty of Engineering and Physical Sciences and Architecture
The University of Queensland
ST LUCIA QLD 4072
Dear Professor A. Lister,
In accordance with the requirements of the degree of Bachelor of Engineering
(Honours) in the division of Electrical Engineering, I present the following thesis
entitled Genetic Algorithm and Acceleration Techniques. This work was performed
under the supervision of Dr Dong Zhao-Yang. I declare the work submitted in this
thesis is my own, except as acknowledged in the text and footnotes, and has not been
previously submitted for a degree at the University of Queensland or any other
institution.
Yours sincerely,
Yeo Su Yuin Melinda
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
1. Abstract
This is a report on the thesis project based on genetic algorithm optimisation and
acceleration techniques. The thesis first starts off with an introduction of the basic
concept of genetic algorithm. It explains how a virtual population is created and how
reproduction is carried out. It then progresses to a brief description of the DeJong
functions and acceleration techniques. The purpose of this project is to research on
acceleration techniques that can be used in accelerating convergence in genetic
algorithm, implement the techniques, gather the simulated data and compare them with
the results from conventional techniques. From this, a conclusion can be drawn on how
successful and effective the acceleration techniques are.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
2. Acknowledgements
Firstly, I would like to thank my thesis supervisor, Dr Dong Zhao-Yang, for his
supervision, assistance and guidance throughout the year. I would also like to thank my
family and friends for their support and assistance. In addition, thanks to the staff at
PSE library for the assistance that they rendered aiding in my research.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
Table Of Contents
1. Abstract
I
2. Acknowledgement
II
3. Introduction
3.1 Introduction to Genetic Algorithm
3.2 Why Genetic Algorithm
3.3 Genetic Algorithm Terminology
3.4 Brief Outline of Genetic Algorithm
3.5 Limitations of Genetic Algorithm
6-6
6-7
8-8
9-12
12-13
13-13
4. DeJong Functions and Acceleration Techniques
4.1 DeJong Functions
4.2 Acceleration Techniques
4.3 Brief Outline of The Project
14-14
14-15
15-15
16-16
5. Results and Findings
5.1 DeJong Function 1
5.2 DeJong Function 2
5.3 DeJong Function 3
5.4 DeJong Function 4
17-17
17-22
23-27
28-33
34-38
6. Conclusion and Recommendations
39-40
7. Appendix 1. Program Code
41-48
8. References
49-50
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
3. Introduction to Genetic Algorithm
The main focus of this thesis is on genetic algorithm and acceleration technique. This
chapter of the report aims to provide an introduction to genetic algorithm (GA), such
that even readers who do not have the background knowledge, will be able to
understand the rest of the report.
This chapter will first start off with section 3.1 Introduction to Genetic Algorithm,
where an introduction will be given on genetic algorithm, together with what makes
genetic algorithm unique. This will be followed by section 3.2 Why Genetic Algorithm,
where the benefits of using genetic algorithm will be illustrated. The next section, 3.3
Genetic Algorithm Terminology will present the basic terminologies and jargons used in
genetic algorithm. Section 3.4 Brief Outline of Genetic Algorithm, provides an outline
of the flow of a genetic algorithm and reinforces the concepts presented in the previous
sections. The chapter will end off with section 3.5 Limitations of Genetic Algorithm,
which details the flaws and limitations of genetic algorithm.
After completing this chapter, the reader should be equipped with the basic knowledge
of what genetic algorithm and this thesis is about.
3.1 Introduction to Genetic Algorithm
Genetic algorithm is a powerful, domain-independent search technique that was inspired
by Charles Darwin’s “species evolution theory” [1]. As the name suggests, it emulates
the natural process of evolution to perform an efficient and systematic search of the
solution space to progress toward the optimum. It is based mainly on the theory of
natural selection, which dictates that individuals with certain characteristics or fitness
are more likely to survive, and hence pass on their characteristics to their offsprings.
Genetic algorithms are simulated with the idea of a virtual population, which is made up
of a collection of individuals. The individuals are actually the solutions, encoded as
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
strings. These strings represent points in the search space. In each iteration, referred to
as a generation, a new set of strings called offsprings are created by reproduction.
Occasionally new characteristics are injected to the existing individuals to add diversity,
and in such cases, the individual is said to have undergone mutation. At the end of each
generation, the fitness level of the individuals and the offsprings are evaluated, and
those that are deemed to be less fit will be discarded. In turn, the offsprings that have
high fitness levels will take their place and represent new solutions.
Genetic algorithms are very different from other search algorithms, and the main
characteristics of GA that make them different from other search heuristics are listed
below [2]:
They work with coding of parameters: GAs work with a coding of the parameter set,
not the parameters themselves. Therefore, one requirement when employing GAs
to solve a combinatorial optimisation problem is to find an efficient representation
of the solution in the form of a chromosome (encoding string).
They search from a set of points: Simulated annealing or tabu search moves from a
single point in the search space, using some transition rule, to the next point. This
type of point to point movement most often causes trapping in local optima. In
contrast, GAs simultaneously work from a rich collection of points (a population
of solutions). Therefore, the probability of getting trapped in the false valleys (in
case of minimization problem) is reduced.
They only require objective function values: GAs are not limited by assumptions
about the search space (such as continuity, existence of derivatives, etc.), and they
do not need or use any auxiliary information. To perform an effective search for
better and better structures, they only require objective (cost) function values.
They are non-deterministic: GAs are probabilistic transition rules, not deterministic
rules. Mechanism for choice of parents to produce offsprings, or for combining of
genes in various chromosomes are probabilistic.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
They are blind: They are blind in the sense that they do not know when they hit the
optimum, and therefore they must be told when to stop.
3.2 Why Genetic Algorithm
The real world of search is filled with discontinuities and large multi-modal, noisy
search spaces. Traditional methods of search and optimisation are too slow in finding a
solution in a very complex search space, even when implemented in supercomputers,
and are not robust enough since they are local in scope and the optima they seek are the
best in a neighbourhood of the current point. Genetic algorithm, on the other hand, is a
robust and effective search method requiring little information to search effectively in a
large or poorly understood search space. Due to the nature that GAs goes through
reproduction and mutation, they are able to produce offsprings that have a significant
chance of inheriting the best characteristics of both parents, and have a higher fitness
value. Thus, making GAs independent of the initial selection of the configurations, and
is always able to produce high quality solutions. In addition to it, GAs are
computationally simple and easy to implement.
The above-mentioned advantages of genetic algorithm are summarised below in a
concise manner [3], [4]:
•
GA do not have much mathematical requirements about the optimisation
problems. Due to their evolutionary nature, genetic algorithms will search for
solutions without regard to the specific inner workings of the problem. GAs can
handle any kind of objective functions and any kind of constraint (i.e. linear or
non-linear) defined on discrete, continuous, or mixed search spaces.
•
The nature of evolution operators makes GA very effective at performing global
search (in probability). The traditional approaches perform local search by a
convergent stepwise procedure, which compares the values of nearby points and
moves to the relative optimal points. Global optimisation can be found only if
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
the problem possesses certain convexity properties that essentially guarantee that
any local optima, is a global optima.
•
GA provides us a great flexibility to hybridise with domain-dependent heuristics
to make an efficient implementation for a specific problem.
3.3 Genetic Algorithm Terminology
For readers who are totally new to the concept of genetic algorithm, this report may
seem pretty baffling. As to provide the readers with a better idea of the concepts, and
aide in their understanding of the rest of the report, this section of the report will
introduce the main terminologies and illustrate some of the important concepts with
examples. The main terminologies are as shown [5], [6], [7]:
Population: It is a group of individuals, which may interact together, for example by
mating and producing offsprings. An initial population constructor or generator is
generally required to generate a certain predefined number of solutions within the
prescribed limits. The quality of the final solution produced by a GA depends on the
size of the population, the limits selected and how the initial population is constructed.
The initial population is generally comprises of random solutions that were generated.
Chromosomes: Is the structure that encodes how the organism is to be constructed.
Each member of the population may be associated with one or more chromosomes.
Chromosomes usually contain information about the solution, which it is to represents.
The most common way of encoding chromosomes is usually in a binary string and to
simplify the explanation, binary string and colour would be used. An example of how a
pair of binary chromosomes will look like is shown below, and binary chromosomes
would be used for all subsequent illustrations, as they are easier to represent and
understand.
•
Chromosome 1 : 1101100100110110
•
Chromosome 2 : 1101111000011110
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
The complete set of chromosomes is called a genotype, and the resulting organism is
called a phenotype. Similarly, the representation of a solution to the optimisation
problem in the form of an encoded string is termed as a chromosome. In most
combinatorial optimisation problems, a single chromosome is generally sufficient to
represent a solution, that is, the genotype and the chromosome are the same. The
symbols that make up a chromosome are known as genes. The different values a gene
can take are called alleles.
Fitness: The fitness value of an individual (genotype or a chromosome) is a positive
number that is a measure of its goodness. It is a value assigned to an individual, which
reflects how well the individual solves the task in hand. When the chromosome
represents a solution to the combinatorial optimisation problem, the fitness value
indicates the cost of the solution. In the case of a minimization problem, solutions with
lower cost correspond to individuals that are more fit.
Reproduction: Is the creation of new individuals from selected parent/s. Common GA
reproduction operators are crossover and mutation. They are derived by analogy from
the biological process of evolution. When the crossover operator is applied to a pair of
chromosomes, the two individuals selected are called parents. Mutation is a genetic
operator that is applied to a single chromosome. The resulting individuals produced
when genetic operators are applied on the parents are termed as offsprings. The
selection of the parents is usually done probabilistically in proportion to their fitness
level, in hope that the offsprings produced would inherit the best of both parents and
attain a higher fitness level. This selection of chromosomes for reproduction is
sometimes carried out using the roulette wheel method. The wheel is divided into
sectors of different size. The fitness level of the individual in each sector determines the
size of the sector. Technically, the higher the fitness level of the individual, the larger
the sector size, in proportion to the rest of the wheel. In concept, to select a parent, the
wheel is spun, and whichever individual comes up becomes the selected parent.
Therefore, in this method, individuals with lower fitness values also have a finite but
lower probability of being selected for reproduction.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
Crossover: Is the main genetic operator used for reproduction, and it allows the
offsprings to inherit the characteristics of both the parents. The offsprings formed do not
always inherit the best of its parents, but children formed with poor fitness generally do
not last long. There are several crossover operators, which can be selected depending on
the combinatorial optimisation problem being solved. Some are more effective than
others. The simple crossover method illustrated below uses the “cut-catenate” operation.
It consists of choosing a random cut point and dividing each of the two chromosomes
into two parts. The offspring is then generated by catenating the segment of one parent
to the left of the cut point with the segment of the second parent to the right of the cut
point, as shown below.
•
Chromosome 1
: 11011 | 00100110110
•
Chromosome 2
: 11011 | 11000011110
•
Offspring 1
: 11011 | 11000011110
•
Offspring 2
: 11011 | 00100110110
Mutation: Is the occasional random alteration of an offspring from two individuals, by
randomly changing allele values of some genes. In the case of binary chromosomes, it
corresponds to changing single bit positions. It is not performed on all members of the
population, but only probabilistically on some. When used sparingly with reproduction
and crossover, mutation protects against premature loss of important notions, in the case
when the offspring looses some of the good features of its parent. For instance during
crossover, when the offspring inherits the worst feature of its parent, mutation may alter
the bad feature/s inherited by the offspring to that that is beneficial, and increases its
chances of survival. An example of mutation, shown using binary chromosomes is
shown on the following page.
•
Original offspring 1
: 1101111000011110
•
Original offspring 2
: 1101100100110110
•
Mutated offspring 1
: 1100111000011110
•
Mutated offspring 2
: 1101101100110100
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
Elitism: Elitism (or an elitist strategy) is a mechanism, which is employed in some
Genetic Algorithm to ensure that the chromosomes of the most highly fit member(s) of
the population are passed on to the next generation without being altered by genetic
operators. Using elitism ensures that the maximum fitness of the population can never
be reduced from one generation to the next. Elitism usually brings about a more rapid
convergence of the population. In some applications elitism improves the chances of
locating an optimal individual, while in others it reduces it.
Generation: Is an iteration of the measurement of fitness and the creation of a new
population by means of reproduction operators. Because of the addition of offsprings,
the size of the population increases. In order to keep the number of the members in a
population fixed, a constant number of individuals are selected from this set, which
consists of both the individuals of the initial population, and the generated offsprings.
Those that possess higher fitness values are selected and those that have lower values
are discarded.
3.4 Brief Outline of Genetic Algorithm
As to provide the reader with a clearer picture on the flow of the genetic algorithm, and
to serve as a summary to the previous few sections, this section of the report is designed
to give brief outline of how a genetic algorithm program will function. The skeletal
outline of the genetic algorithm is as illustrated below [8].
1. [Start] Generate random population of n chromosomes.
2. [Fitness] Evaluate the fitness f(x) of each chromosome x in the population.
3. [New population] Create a new population by repeating following steps until
the new population is complete.
•
[Selection] Select two parent chromosomes from a population according
to their fitness level.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
•
[Crossover] With a crossover probability cross over the parents to form
a new offspring. If no crossover was performed (elitism), offspring is an
exact copy of parents.
•
[Mutation] With a mutation probability mutate new offsprings at each
locus.
•
[Accepting] Place new offspring in a new population depending on their
fitness level.
4. [Replace] Use new population (parent and offsprings) for a further run of
algorithm.
5. [Test] If optimum has been achieved, stop and display results.
6. [Loop] Else, go to Step 2.
3.5 Limitations of Genetic Algorithm
This section presents the limitations of genetic algorithm [9]. As stated earlier in the
report in section 3.1, genetic algorithms are blind, as in they do not know it when they
hit the optimum, and therefore, they must be told when to stop. This is also the main
limit of GA, the stopping criterion, as it is hard to determine if the GA has converged
enough. The difficulty is to decide if it is better to observe the mean performance, the
best performance, or the number of global iterations and stop when a threshold is
reached. Furthermore, it is also difficult to select a method for computing the final
solution of the optimisation problem. Whether is it better to consider the best
chromosome, to use a mean of the best elements arguing that a population is more
representative than a stand-alone individual, or is it better to choose an hybrid solution.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
4. DeJong Functions & Acceleration Techniques
This chapter of the report will present to the reader with the basic knowledge on the
DeJong Functions. It starts off with section 4.1 DeJong Fucntions, giving an
introduction on what are DeJong Functions and the DeJong Functions that were used for
this thesis.
Genetic algorithms are by no doubt fast in achieving optimum, but in the world of
engineering, there is always a search for even faster better techniques. The main
purpose of this project is to do so. In 4.2 Acceleration Technique, the acceleration
technique used and tested in this project will be briefly touched on.
The chapter will conclude with section 4.3 Brief Outline of The Project, where a
skeletal outline of this thesis project is shown with explanation.
4.1 DeJong Functions
As explained in the previous chapter, Section 3.5 of the report, GAs do not know it
when they hit the optimum, and has to told when to stop. Thus, test functions have to be
used. For this thesis project, DeJong functions has been selected and implemented to
test for the achievement of optimum. DeJong functions are a group of mathematical
functions designed and used to test genetic algorithms.
DeJong constructed a test environment of problems in function minimization [10]. His
work translated Holland’s theories into practical function optimisation. DeJong used
two performance measures for judging the genetic algorithms. First, he defined on-line
performance as an average of all costs up to the present generation. It penalizes the
algorithm for too many poor costs and rewards the algorithm for quickly finding where
the lowest costs lie. Second, he defined off-line performance as the best costs found up
to the present generation. The functions suggested by DeJong have certain
characteristics, which depict many of the difficulties, found in optimisation problems.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
There is a whole list of DeJong functions, but for the purpose of this project, only the
first four were chosen and implemented in the simulation. The DeJong functions (X
represent vectors) that were used for the project and their respective limits are as shown
[11], [12]:
function 1: f(xi) = sum of (xi2) while i ranges from 1 to 3 and -5.12 <= x i <= 5.12
function 2: f(xi) = 100(x12-x2)2 + (1-x1)2 while -2.048 <= x i <= 2.048
function 3: f(xi) = sum of integer of (xi) while i ranges from 1 to 5 and -5.12 <= xi
<= 5.12
function 4: f(xi) = sum of ixi4 + Gauss(0,1) while i ranges from 1 to the total
number of problem variables (about 30) and -1.28 <= x i <= 1.28
4.2 Accelerator Techniques
This section of the report presents and explains the accelerator technique that was
implemented and tested in the project. The code for the accelerator is as shown:
population[i].gene[j]
=
(1.0-H_Co)*(population[POPSIZE].gene[j])
+
H_Co*(population[i].gene[j])
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
4.3 Brief Outline of The Project
This section of the report will explain briefly the layout of the program for the project.
A layout of the final program is shown below, added to it are the DeJong functions and
the accelerator technique. For the full source code of the program [13], refer to
Appendix 1.
1. [Start] Generate random population of n chromosomes.
2. [DeJong] Evaluate individual according to selected DeJong function.
3. [Fitness] Evaluate the fitness f(x) of each chromosome x in the population.
4. [New population] Create a new population by repeating following steps until
the new population is complete.
•
[Selection] Select two parent chromosomes from a population according
to their fitness level.
•
[Crossover] With a crossover probability cross over the parents to form
a new offspring. If no crossover was performed (elitism), offspring is an
exact copy of parents.
•
[Mutation] With a mutation probability mutate new offsprings at each
locus.
•
[Accepting] Place new offspring in a new population depending on their
fitness level.
5. [Accelerator] Accelerator used when selected.
6. [Replace] Use new population (parent and offsprings) for a further run of
DeJong.
7. [Test] If optimum has been achieved, stop and display results.
8. [Loop] Else, go to Step 2.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
5. Results and Findings
This chapter of the report presents and analyses the results gathered from the simulation
of the program. The results will be presented in the sequence as such, section 5.1
DeJong Function 1, section 5.2 DeJong Function 2, section 5.3 DeJong Function 3, and
section 5.4 DeJong Function 4. For each section, results obtained using the respective
DeJong Function, with and without the use of the accelerator will be presented together,
as is to facilitate comparison between the two. Other than the tabulated results, the
results will be presented in graphical format for easy analysis.
5.1 DeJong Function 1
Shown below in Figure 1 and Figure 2 are the graphical presentation of the result
obtained for DeJong Function 1, without and with the use of acceleration technique. The
vertical axis denotes the fitness level while the horizontal axis represents the number of
iterations. For the full results data, refer to Table 1 and Table 2 respectively.
14
12
10
8
Series1
6
4
2
0
0
100
200
300
400
Fig 1. DeJong Function 1 Without Accelerator.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
9000
8000
7000
6000
5000
Series1
4000
3000
2000
1000
0
0
100
200
300
400
Figure 2. DeJong Function 1 With Accelerator.
Comparing Figure 1 and Figure 2, it is clearly shown that with the aid of the
accelerator, a much higher fitness level can be obtained in a shorter time.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
No. Generation
Best fitness
No. Generation Best fitness No. Generation Best fitness
0
0.348501
101 11.559675
202
11.559675
1
0.727274
102 11.559675
203
11.559675
2
0.727274
103 11.559675
204
11.559675
3
0.727274
104 11.559675
205
11.559675
4
0.727274
105 11.559675
206
11.559675
5
0.727274
106 11.559675
207
11.559675
6
0.727274
107 11.559675
208
11.559675
7
0.727274
108 11.559675
209
11.559675
8
0.727274
109 11.559675
210
11.559675
9
0.727274
110 11.559675
211
11.559675
10
0.727274
111 11.559675
212
11.559675
11
0.727274
112 11.559675
213
11.559675
12
0.727274
113 11.559675
214
11.559675
13
0.727274
114 11.559675
215
11.559675
14
0.727274
115 11.559675
216
11.559675
15
0.727274
116 11.559675
217
11.559675
16
0.727274
117 11.559675
218
11.559675
17
0.727274
118 11.559675
219
11.559675
18
0.727274
119 11.559675
220
11.559675
19
0.727274
120 11.559675
221
11.559675
20
0.727274
121 11.559675
222
11.559675
21
0.727274
122 11.559675
223
11.559675
22
0.727274
123 11.559675
224
11.559675
23
0.727274
124 11.559675
225
11.559675
24
0.727274
125 11.559675
226
11.559675
25
0.727274
126 11.559675
227
11.559675
26
0.727274
127 11.559675
228
11.559675
27
0.727274
128 11.559675
229
11.559675
28
0.727274
129 11.559675
230
11.559675
29
0.727274
130 11.559675
231
11.559675
30
0.727274
131 11.559675
232
11.559675
31
0.727274
132 11.559675
233
13.154111
32
0.727274
133 11.559675
234
13.154111
33
0.727274
134 11.559675
235
13.154111
34
0.727274
135 11.559675
236
13.154111
35
0.727274
136 11.559675
237
13.154111
36
0.727274
137 11.559675
238
13.154111
37
0.727274
138 11.559675
239
13.154111
38
0.727274
139 11.559675
240
13.154111
39
0.727274
140 11.559675
241
13.154111
40
0.727274
141 11.559675
242
13.154111
41
0.727274
142 11.559675
243
13.154111
42
0.727274
143 11.559675
244
13.154111
43
0.727274
144 11.559675
245
13.154111
44
0.727274
145 11.559675
246
13.154111
45
0.727274
146 11.559675
247
13.154111
46
0.727274
147 11.559675
248
13.154111
47
5.000912
148 11.559675
249
13.154111
48
5.000912
149 11.559675
250
13.154111
49
5.000912
150 11.559675
251
13.154111
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
50
5.000912
151 11.559675
252
13.154111
51
5.000912
152 11.559675
253
13.154111
52
5.000912
153 11.559675
254
13.154111
53
5.000912
154 11.559675
255
13.154111
54
5.000912
155 11.559675
256
13.154111
55
5.000912
156 11.559675
257
13.154111
56
5.000912
157 11.559675
258
13.154111
57
5.000912
158 11.559675
259
13.154111
58
5.000912
159 11.559675
260
13.154111
59
5.000912
160 11.559675
261
13.154111
60
5.000912
161 11.559675
262
13.154111
61
5.000912
162 11.559675
263
13.154111
62
5.000912
163 11.559675
264
13.154111
63
5.000912
164 11.559675
265
13.154111
64
5.000912
165 11.559675
266
13.154111
65
5.000912
166 11.559675
267
13.154111
66
5.000912
167 11.559675
268
13.154111
67
5.000912
168 11.559675
269
13.154111
68
5.000912
169 11.559675
270
13.154111
69
5.000912
170 11.559675
271
13.154111
70
5.000912
171 11.559675
272
13.154111
71
5.000912
172 11.559675
273
13.154111
72
5.000912
173 11.559675
274
13.154111
73
5.000912
174 11.559675
275
13.154111
74
5.000912
175 11.559675
276
13.154111
75
5.000912
176 11.559675
277
13.154111
76
5.000912
177 11.559675
278
13.154111
77
5.000912
178 11.559675
279
13.154111
78
5.000912
179 11.559675
280
13.154111
79
5.000912
180 11.559675
281
13.154111
80
5.000912
181 11.559675
282
13.154111
81
5.000912
182 11.559675
283
13.154111
82
5.000912
183 11.559675
284
13.154111
83
5.000912
184 11.559675
285
13.154111
84
5.000912
185 11.559675
286
13.154111
85
5.000912
186 11.559675
287
13.154111
86
5.000912
187 11.559675
288
13.154111
87
5.000912
188 11.559675
289
13.154111
88
5.000912
189 11.559675
290
13.154111
89
5.000912
190 11.559675
291
13.154111
90
11.559675
191 11.559675
292
13.154111
91
11.559675
192 11.559675
293
13.154111
92
11.559675
193 11.559675
294
13.154111
93
11.559675
194 11.559675
94
11.559675
195 11.559675
95
11.559675
196 11.559675
96
11.559675
197 11.559675
97
11.559675
198 11.559675
98
11.559675
199 11.559675
99
11.559675
200 11.559675
100
11.559675
201 11.559675
Table 1. DeJong Function 1 Without Accelerator.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
No. Generation
Best fitness
No. Generation
Best fitness No. Generation Best fitness
0
0.348501
101 1248.564131
202 7702.003375
1
3.198907
102 1248.564131
203 7702.003375
2
3.198907
103 1248.564131
204 7702.003375
3
3.198907
104 1248.564131
205 7702.003375
4
6.035775
105 1248.564131
206 7702.003375
5
6.227704
106 1248.564131
207 7702.003375
6
24.880495
107 1248.564131
208 7702.003375
7
30.872786
108 1248.564131
209 7702.003375
8
45.002367
109 1248.564131
210 7702.003375
9
45.002367
110 1248.564131
211 7702.003375
10
45.002367
111 1296.985378
212 7702.003375
11
45.002367
112 1296.985378
213 7702.003375
12
45.002367
113 1296.985378
214 7702.003375
13
45.002367
114 1296.985378
215 7702.003375
14
45.002367
115 1296.985378
216 7702.003375
15
45.002367
116 1296.985378
217 7702.003375
16
45.002367
117 1296.985378
218 7702.003375
17
52.517067
118 1296.985378
219 7702.003375
18
52.517067
119 1296.985378
220 7702.003375
19
52.517067
120 1296.985378
221 7702.003375
20
61.422947
121 1296.985378
222 7702.003375
21
61.422947
122 1296.985378
223 7702.003375
22
61.422947
123 1296.985378
224 7702.003375
23
111.319194
124 1296.985378
225 7702.003375
24
111.319194
125 1296.985378
226 7702.003375
25
111.319194
126 1296.985378
227 7702.003375
26
111.319194
127 1296.985378
228 7702.003375
27
111.319194
128 1296.985378
229 7702.003375
28
111.319194
129 1296.985378
230 7702.003375
29
111.319194
130 3548.597104
231 7702.003375
30
111.319194
131 3548.597104
232 7702.003375
31
111.319194
132 3548.597104
233 7702.003375
32
111.319194
133 3548.597104
234 7702.003375
33
111.319194
134 3548.597104
235 7702.003375
34
111.319194
135 3548.597104
236 7702.003375
35
111.319194
136 3548.597104
237 7702.003375
36
111.319194
137 3548.597104
238 7702.003375
37
111.319194
138 3548.597104
239 7702.003375
38
111.319194
139 3548.597104
240 7702.003375
39
111.319194
140 3548.597104
241 7702.003375
40
111.319194
141 3548.597104
242 7702.003375
41
111.319194
142 3548.597104
243 7702.003375
42
111.319194
143 3548.597104
244 7702.003375
43
111.319194
144 3548.597104
245 7702.003375
44
277.593606
145 3548.597104
246 7702.003375
45
277.593606
146 3548.597104
247 7702.003375
46
277.593606
147 3548.597104
248 7702.003375
47 1114.024969
148 3548.597104
249 7702.003375
48 1114.024969
149 3548.597104
250 7702.003375
49 1114.024969
150 3548.597104
251 7702.003375
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
50 1114.024969
151 3548.597104
252 7702.003375
51 1114.024969
152 3548.597104
253 7702.003375
52 1114.024969
153 3548.597104
254 7702.003375
53 1114.024969
154 3548.597104
255 7702.003375
54 1114.024969
155 4336.843388
256 7702.003375
55 1114.024969
156 4336.843388
257 7702.003375
56 1114.024969
157 4336.843388
258 7702.003375
57 1114.024969
158 4336.843388
259 7702.003375
58 1114.024969
159 4336.843388
260 7702.003375
59 1114.024969
160 4336.843388
261 7702.003375
60 1114.024969
161 4336.843388
262 7702.003375
61 1248.564131
162 4336.843388
263 7702.003375
62 1248.564131
163 4336.843388
264 7702.003375
63 1248.564131
164 4336.843388
265 7702.003375
64 1248.564131
165 4336.843388
266 7702.003375
65 1248.564131
166 4336.843388
267 7702.003375
66 1248.564131
167 4336.843388
268 7702.003375
67 1248.564131
168 4336.843388
269 7702.003375
68 1248.564131
169 4336.843388
270 7702.003375
69 1248.564131
170 4336.843388
271 7702.003375
70 1248.564131
171 4336.843388
272 7702.003375
71 1248.564131
172 4336.843388
273 7702.003375
72 1248.564131
173 4336.843388
274 7702.003375
73 1248.564131
174 4336.843388
275 7702.003375
74 1248.564131
175 4336.843388
276 7702.003375
75 1248.564131
176 4336.843388
277 7702.003375
76 1248.564131
177 4336.843388
278 7702.003375
77 1248.564131
178 4336.843388
279 7702.003375
78 1248.564131
179 4336.843388
280 7702.003375
79 1248.564131
180 4336.843388
281 7702.003375
80 1248.564131
181 4336.843388
282 7702.003375
81 1248.564131
182 4336.843388
283 7702.003375
82 1248.564131
183 7702.003375
284 7702.003375
83 1248.564131
184 7702.003375
285 7702.003375
84 1248.564131
185 7702.003375
286 7702.003375
85 1248.564131
186 7702.003375
287 7702.003375
86 1248.564131
187 7702.003375
288 7702.003375
87 1248.564131
188 7702.003375
289 7702.003375
88 1248.564131
189 7702.003375
290 7702.003375
89 1248.564131
190 7702.003375
291 7702.003375
90 1248.564131
191 7702.003375
292 7702.003375
91 1248.564131
192 7702.003375
293 7702.003375
92 1248.564131
193 7702.003375
294 7702.003375
93 1248.564131
194 7702.003375
94 1248.564131
195 7702.003375
95 1248.564131
196 7702.003375
96 1248.564131
197 7702.003375
97 1248.564131
198 7702.003375
98 1248.564131
199 7702.003375
99 1248.564131
200 7702.003375
100 1248.564131
201 7702.003375
Table 2. DeJong Function 1 With Accelerator.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
5.2 DeJong Function 2
Shown below Figure 3 and Figure 4 are the graphical presentation of the result obtained
for DeJong Function 2, without and with the use of acceleration technique. The vertical
axis denotes the fitness level while the horizontal axis represents the number of
iterations. For the full results data, refer to Table 3 and Table 4 respectively.
200
180
160
140
120
100
Series1
80
60
40
20
0
0
100
200
300
400
Figure 3. DeJong Function 2 Without Accelerator.
200
180
160
140
120
100
80
Series1
60
40
20
0
0
50
100
150
200
250
Figure 4. DeJong Function 2 With Accelerator
For this function, it can be clearly seen that in Figure 4, with the aid of the accelerator,
optimisation was achieved in less than 50 iterations, whereas in Figure 3, without the
accelerator, it was only achieved after 200 iterations. Thus, it can be deduced that the
accelerator greatly speeds up the process.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
No. Generation
Best fitness
No. Generation Best fitness No. Generation Best fitness
0
1.286582
101 33.530739
202
70.806054
1
1.286582
102 33.530739
203
70.806054
2
1.441658
103 33.530739
204
70.806054
3
1.441658
104 33.530739
205
70.806054
4
2.381345
105 33.530739
206
70.806054
5
2.381345
106 33.530739
207
70.806054
6
2.381345
107 33.530739
208
70.806054
7
2.381345
108 33.530739
209 180.257135
8
2.381345
109 33.530739
210 180.257135
9
2.381345
110 33.530739
211 180.257135
10
2.381345
111 33.530739
212 180.257135
11
2.381345
112 33.530739
213 180.257135
12
2.381345
113 33.530739
214 180.257135
13
2.381345
114 33.530739
215 180.257135
14
2.381345
115 33.530739
216 180.257135
15
2.381345
116 33.530739
217 180.257135
16
2.381345
117 33.530739
218 180.257135
17
2.381345
118 33.530739
219 180.257135
18
2.381345
119 33.530739
220 180.257135
19
2.381345
120 33.530739
221 180.257135
20
2.381345
121 33.530739
222 180.257135
21
2.381345
122 33.530739
223 180.257135
22
2.381345
123 33.530739
224 180.257135
23
3.287491
124 33.530739
225 180.257135
24
3.287491
125 33.530739
226 180.257135
25
3.287491
126 33.530739
227 180.257135
26
3.287491
127 33.530739
228 180.257135
27
3.287491
128 33.530739
229 180.257135
28
3.287491
129 33.530739
230 180.257135
29
3.287491
130 33.530739
231 180.257135
30
13.131084
131 33.530739
232 180.257135
31
13.131084
132 33.530739
233 180.257135
32
13.131084
133 33.530739
234 180.257135
33
13.131084
134 33.530739
235 180.257135
34
13.131084
135 33.530739
236 180.257135
35
13.131084
136 33.530739
237 180.257135
36
13.131084
137 33.530739
238 180.257135
37
13.131084
138 33.530739
239 180.257135
38
13.131084
139 33.530739
240 180.257135
39
13.131084
140 33.530739
241 180.257135
40
13.131084
141 33.530739
242 180.257135
41
13.131084
142 33.530739
243 180.257135
42
13.131084
143 33.530739
244 180.257135
43
13.131084
144 33.530739
245 180.257135
44
13.131084
145 33.530739
246 180.257135
45
13.131084
146 33.530739
247 180.257135
46
13.131084
147 33.530739
248 180.257135
47
13.131084
148 33.530739
249 180.257135
48
13.131084
149 33.530739
250 180.257135
49
13.131084
150 33.530739
251 180.257135
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
50
13.131084
151 33.530739
252 180.257135
51
13.513353
152 33.530739
253 180.257135
52
13.513353
153 33.530739
254 180.257135
53
33.530739
154 33.530739
255 180.257135
54
33.530739
155 33.530739
256 180.257135
55
33.530739
156 33.530739
257 180.257135
56
33.530739
157 33.530739
258 180.257135
57
33.530739
158 33.530739
259 180.257135
58
33.530739
159 33.530739
260 180.257135
59
33.530739
160 33.530739
261 180.257135
60
33.530739
161 33.530739
262 180.257135
61
33.530739
162 33.530739
263 180.257135
62
33.530739
163 33.530739
264 180.257135
63
33.530739
164 33.530739
265 180.257135
64
33.530739
165 33.530739
266 180.257135
65
33.530739
166 33.530739
267 180.257135
66
33.530739
167 33.530739
268 180.257135
67
33.530739
168 33.530739
269 180.257135
68
33.530739
169 33.530739
270 180.257135
69
33.530739
170 33.530739
271 180.257135
70
33.530739
171 33.530739
272 180.257135
71
33.530739
172 33.530739
273 180.257135
72
33.530739
173 33.530739
274 180.257135
73
33.530739
174 33.530739
275 180.257135
74
33.530739
175 33.530739
276 180.257135
75
33.530739
176 33.530739
277 180.257135
76
33.530739
177 33.530739
278 180.257135
77
33.530739
178 33.530739
279 180.257135
78
33.530739
179 70.806054
280 180.257135
79
33.530739
180 70.806054
281 180.257135
80
33.530739
181 70.806054
282 180.257135
81
33.530739
182 70.806054
283 180.257135
82
33.530739
183 70.806054
284 180.257135
83
33.530739
184 70.806054
285 180.257135
84
33.530739
185 70.806054
286 180.257135
85
33.530739
186 70.806054
287 180.257135
86
33.530739
187 70.806054
288 180.257135
87
33.530739
188 70.806054
289 180.257135
88
33.530739
189 70.806054
290 180.257135
89
33.530739
190 70.806054
291 180.257135
90
33.530739
191 70.806054
292 180.257135
91
33.530739
192 70.806054
293 180.257135
92
33.530739
193 70.806054
294 180.257135
93
33.530739
194 70.806054
94
33.530739
195 70.806054
95
33.530739
196 70.806054
96
33.530739
197 70.806054
97
33.530739
198 70.806054
98
33.530739
199 70.806054
99
33.530739
200 70.806054
100
33.530739
201 70.806054
Table 3. DeJong Function 2 Without Accelerator.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
No. Generation
Best fitness
No. Generation
Best fitness No. Generation Best fitness
0
1.286582
101 187.474979
202 187.881577
1
1.794763
102 187.474979
203 187.881577
2
1.794763
103 187.474979
204 187.881577
3
1.794763
104 187.474979
205 650.559873
4
2.19656
105 187.474979
206 650.559873
5
2.19656
106 187.474979
207 650.559873
6
2.357204
107 187.766807
208 650.559873
7
2.357204
108 187.881577
209 650.559873
8
2.357204
109 187.881577
210 650.559873
9
2.357204
110 187.881577
211 650.559873
10
2.358387
111 187.881577
212 650.559873
11
2.358387
112 187.881577
213 650.559873
12
2.358387
113 187.881577
214 650.559873
13
2.358387
114 187.881577
215 650.559873
14
2.358387
115 187.881577
216 650.559873
15
2.358387
116 187.881577
217 650.559873
16
2.358387
117 187.881577
218 650.559873
17
2.358387
118 187.881577
219 650.559873
18
14.396213
119 187.881577
220 650.559873
19
14.396213
120 187.881577
221 650.559873
20
14.396213
121 187.881577
222 650.559873
21
14.396213
122 187.881577
223 650.559873
22
14.396213
123 187.881577
224 650.559873
23
14.396213
124 187.881577
225 650.559873
24
14.396213
125 187.881577
226 650.559873
25
14.396213
126 187.881577
227 650.559873
26
14.396213
127 187.881577
228 650.559873
27
14.396213
128 187.881577
229 650.559873
28
185.867507
129 187.881577
230 650.559873
29
185.867507
130 187.881577
231 650.559873
30
185.867507
131 187.881577
232 650.559873
31
185.867507
132 187.881577
233 650.559873
32
185.867507
133 187.881577
234 650.559873
33
185.867507
134 187.881577
235 650.559873
34
185.867507
135 187.881577
236 650.559873
35
185.867507
136 187.881577
237 650.559873
36
185.867507
137 187.881577
238 650.559873
37
185.867507
138 187.881577
239 650.559873
38
185.867507
139 187.881577
240 650.559873
39
185.867507
140 187.881577
241 650.559873
40
185.867507
141 187.881577
242 650.559873
41
185.867507
142 187.881577
243 650.559873
42
185.867507
143 187.881577
244 650.559873
43
185.867507
144 187.881577
245 650.559873
44
185.867507
145 187.881577
246 650.559873
45
185.867507
146 187.881577
247 676.825134
46
185.867507
147 187.881577
248 676.825134
47
185.867507
148 187.881577
249 676.825134
48
185.867507
149 187.881577
250 676.825134
49
185.867507
150 187.881577
251 676.825134
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
50
185.867507
151 187.881577
252 676.825134
51
185.867507
152 187.881577
253 676.825134
52
185.867507
153 187.881577
254 676.825134
53
185.867507
154 187.881577
255 676.825134
54
185.867507
155 187.881577
256 676.825134
55
185.867507
156 187.881577
257 676.825134
56
185.867507
157 187.881577
258 676.825134
57
187.474979
158 187.881577
259 676.825134
58
187.474979
159 187.881577
260 676.825134
59
187.474979
160 187.881577
261 676.825134
60
187.474979
161 187.881577
262 676.825134
61
187.474979
162 187.881577
263 676.825134
62
187.474979
163 187.881577
264 676.825134
63
187.474979
164 187.881577
265 676.825134
64
187.474979
165 187.881577
266 676.825134
65
187.474979
166 187.881577
267 676.825134
66
187.474979
167 187.881577
268 676.825134
67
187.474979
168 187.881577
269 676.825134
68
187.474979
169 187.881577
270 676.825134
69
187.474979
170 187.881577
271 676.825134
70
187.474979
171 187.881577
272 676.825134
71
187.474979
172 187.881577
273 676.825134
72
187.474979
173 187.881577
274 676.825134
73
187.474979
174 187.881577
275 676.825134
74
187.474979
175 187.881577
276 676.825134
75
187.474979
176 187.881577
277 676.825134
76
187.474979
177 187.881577
278 676.825134
77
187.474979
178 187.881577
279 676.825134
78
187.474979
179 187.881577
280 676.825134
79
187.474979
180 187.881577
281 676.825134
80
187.474979
181 187.881577
282 676.825134
81
187.474979
182 187.881577
283 676.825134
82
187.474979
183 187.881577
284 676.825134
83
187.474979
184 187.881577
285 676.825134
84
187.474979
185 187.881577
286 676.825134
85
187.474979
186 187.881577
287 676.825134
86
187.474979
187 187.881577
288 676.825134
87
187.474979
188 187.881577
289 676.825134
88
187.474979
189 187.881577
290 676.825134
89
187.474979
190 187.881577
291 676.825134
90
187.474979
191 187.881577
292 676.825134
91
187.474979
192 187.881577
293 676.825134
92
187.474979
193 187.881577
294 676.825134
93
187.474979
194 187.881577
94
187.474979
195 187.881577
95
187.474979
196 187.881577
96
187.474979
197 187.881577
97
187.474979
198 187.881577
98
187.474979
199 187.881577
99
187.474979
200 187.881577
100
187.474979
201 187.881577
Table 4. DeJong Function 2 With Accelerator.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
5.3 DeJong Function 3
Shown below Figure 5 and Figure 6 are the graphical presentation of the result obtained
for DeJong Function 3, without and with the use of acceleration technique. The vertical
axis denotes the fitness level while the horizontal axis represents the number of
iterations. For the full results data, refer to Table 5 and Table 6 respectively.
0.05
0.045
0.04
0.035
0.03
0.025
Series1
0.02
0.015
0.01
0.005
0
0
100
200
300
400
Figure 5. DeJong Function 3 Without Accelerator.
0.039
0.038
0.037
0.036
Series1
0.035
0.034
0.033
0
100
200
300
400
Figure 6. DeJong Function 3 With Accelerator.
For DeJong Function 3, due to different coding, the results are actually different from
the rest. For this case, the lower the fitness level, the better. In this case, the fitness level
obtained without accelerator at the end of the simulation is about 0.045 as illustrated in
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
Figure 1, whereas the fitness level obtain with accelerator is about 0.0385 as illustrated
in Figure 2, which is superior.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
No. Generation
Best fitness
No. Generation
Best fitness No. Generation Best fitness
0
0.033333
101
0.043478
202
0.043478
1
0.033333
102
0.043478
203
0.043478
2
0.033333
103
0.043478
204
0.043478
3
0.033333
104
0.043478
205
0.043478
4
0.033333
105
0.043478
206
0.043478
5
0.033333
106
0.043478
207
0.043478
6
0.033333
107
0.043478
208
0.043478
7
0.033333
108
0.043478
209
0.043478
8
0.033333
109
0.043478
210
0.043478
9
0.033333
110
0.043478
211
0.043478
10
0.033333
111
0.043478
212
0.043478
11
0.033333
112
0.043478
213
0.043478
12
0.033333
113
0.043478
214
0.043478
13
0.033333
114
0.043478
215
0.043478
14
0.033333
115
0.043478
216
0.043478
15
0.033333
116
0.043478
217
0.043478
16
0.033333
117
0.043478
218
0.043478
17
0.033333
118
0.043478
219
0.043478
18
0.033333
119
0.043478
220
0.043478
19
0.033333
120
0.043478
221
0.043478
20
0.033333
121
0.043478
222
0.043478
21
0.033333
122
0.043478
223
0.043478
22
0.033333
123
0.043478
224
0.043478
23
0.034483
124
0.043478
225
0.043478
24
0.035714
125
0.043478
226
0.043478
25
0.035714
126
0.043478
227
0.043478
26
0.035714
127
0.043478
228
0.043478
27
0.035714
128
0.043478
229
0.043478
28
0.035714
129
0.043478
230
0.043478
29
0.035714
130
0.043478
231
0.043478
30
0.035714
131
0.043478
232
0.043478
31
0.035714
132
0.043478
233
0.043478
32
0.035714
133
0.043478
234
0.043478
33
0.035714
134
0.043478
235
0.043478
34
0.035714
135
0.043478
236
0.043478
35
0.035714
136
0.043478
237
0.043478
36
0.035714
137
0.043478
238
0.043478
37
0.035714
138
0.043478
239
0.043478
38
0.035714
139
0.043478
240
0.043478
39
0.035714
140
0.043478
241
0.043478
40
0.035714
141
0.043478
242
0.043478
41
0.035714
142
0.043478
243
0.043478
42
0.035714
143
0.043478
244
0.043478
43
0.035714
144
0.043478
245
0.043478
44
0.035714
145
0.043478
246
0.043478
45
0.035714
146
0.043478
247
0.043478
46
0.035714
147
0.043478
248
0.043478
47
0.035714
148
0.043478
249
0.043478
48
0.035714
149
0.043478
250
0.043478
49
0.035714
150
0.043478
251
0.043478
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
50
0.035714
151
0.043478
252
0.043478
51
0.035714
152
0.043478
253
0.043478
52
0.035714
153
0.043478
254
0.043478
53
0.035714
154
0.043478
255
0.043478
54
0.035714
155
0.043478
256
0.043478
55
0.035714
156
0.043478
257
0.043478
56
0.035714
157
0.043478
258
0.043478
57
0.035714
158
0.043478
259
0.043478
58
0.035714
159
0.043478
260
0.043478
59
0.035714
160
0.043478
261
0.043478
60
0.035714
161
0.043478
262
0.043478
61
0.035714
162
0.043478
263
0.043478
62
0.035714
163
0.043478
264
0.043478
63
0.035714
164
0.043478
265
0.043478
64
0.035714
165
0.043478
266
0.043478
65
0.035714
166
0.043478
267
0.043478
66
0.035714
167
0.043478
268
0.043478
67
0.035714
168
0.043478
269
0.043478
68
0.035714
169
0.043478
270
0.043478
69
0.035714
170
0.043478
271
0.043478
70
0.035714
171
0.043478
272
0.043478
71
0.035714
172
0.043478
273
0.043478
72
0.035714
173
0.043478
274
0.043478
73
0.035714
174
0.043478
275
0.043478
74
0.035714
175
0.043478
276
0.043478
75
0.035714
176
0.043478
277
0.043478
76
0.035714
177
0.043478
278
0.043478
77
0.035714
178
0.043478
279
0.043478
78
0.035714
179
0.043478
280
0.043478
79
0.038462
180
0.043478
281
0.043478
80
0.038462
181
0.043478
282
0.043478
81
0.041667
182
0.043478
283
0.043478
82
0.041667
183
0.043478
284
0.043478
83
0.041667
184
0.043478
285
0.043478
84
0.041667
185
0.043478
286
0.043478
85
0.041667
186
0.043478
287
0.043478
86
0.041667
187
0.043478
288
0.043478
87
0.043478
188
0.043478
289
0.043478
88
0.043478
189
0.043478
290
0.043478
89
0.043478
190
0.043478
291
0.043478
90
0.043478
191
0.043478
292
0.043478
91
0.043478
192
0.043478
293
0.043478
92
0.043478
193
0.043478
294
0.043478
93
0.043478
194
0.043478
94
0.043478
195
0.043478
95
0.043478
196
0.043478
96
0.043478
197
0.043478
97
0.043478
198
0.043478
98
0.043478
199
0.043478
99
0.043478
200
0.043478
100
0.043478
201
0.043478
Table 5. DeJong Function 3 Without Accelerator.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
No. Generation
Best fitness
No. Generation
Best fitness No. Generation Best fitness
0
0.033333
101
0.038462
202
0.038462
1
0.033333
102
0.038462
203
0.038462
2
0.033333
103
0.038462
204
0.038462
3
0.034483
104
0.038462
205
0.038462
4
0.034483
105
0.038462
206
0.038462
5
0.034483
106
0.038462
207
0.038462
6
0.034483
107
0.038462
208
0.038462
7
0.034483
108
0.038462
209
0.038462
8
0.034483
109
0.038462
210
0.038462
9
0.034483
110
0.038462
211
0.038462
10
0.034483
111
0.038462
212
0.038462
11
0.034483
112
0.038462
213
0.038462
12
0.034483
113
0.038462
214
0.038462
13
0.034483
114
0.038462
215
0.038462
14
0.034483
115
0.038462
216
0.038462
15
0.034483
116
0.038462
217
0.038462
16
0.034483
117
0.038462
218
0.038462
17
0.034483
118
0.038462
219
0.038462
18
0.034483
119
0.038462
220
0.038462
19
0.034483
120
0.038462
221
0.038462
20
0.034483
121
0.038462
222
0.038462
21
0.034483
122
0.038462
223
0.038462
22
0.035714
123
0.038462
224
0.038462
23
0.035714
124
0.038462
225
0.038462
24
0.035714
125
0.038462
226
0.038462
25
0.035714
126
0.038462
227
0.038462
26
0.035714
127
0.038462
228
0.038462
27
0.035714
128
0.038462
229
0.038462
28
0.035714
129
0.038462
230
0.038462
29
0.035714
130
0.038462
231
0.038462
30
0.035714
131
0.038462
232
0.038462
31
0.035714
132
0.038462
233
0.038462
32
0.035714
133
0.038462
234
0.038462
33
0.035714
134
0.038462
235
0.038462
34
0.035714
135
0.038462
236
0.038462
35
0.035714
136
0.038462
237
0.038462
36
0.035714
137
0.038462
238
0.038462
37
0.035714
138
0.038462
239
0.038462
38
0.035714
139
0.038462
240
0.038462
39
0.035714
140
0.038462
241
0.038462
40
0.035714
141
0.038462
242
0.038462
41
0.035714
142
0.038462
243
0.038462
42
0.035714
143
0.038462
244
0.038462
43
0.035714
144
0.038462
245
0.038462
44
0.035714
145
0.038462
246
0.038462
45
0.035714
146
0.038462
247
0.038462
46
0.035714
147
0.038462
248
0.038462
47
0.035714
148
0.038462
249
0.038462
48
0.035714
149
0.038462
250
0.038462
49
0.035714
150
0.038462
251
0.038462
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
50
0.035714
151
0.038462
252
0.038462
51
0.037037
152
0.038462
253
0.038462
52
0.037037
153
0.038462
254
0.038462
53
0.037037
154
0.038462
255
0.038462
54
0.037037
155
0.038462
256
0.038462
55
0.037037
156
0.038462
257
0.038462
56
0.037037
157
0.038462
258
0.038462
57
0.037037
158
0.038462
259
0.038462
58
0.037037
159
0.038462
260
0.038462
59
0.037037
160
0.038462
261
0.038462
60
0.037037
161
0.038462
262
0.038462
61
0.037037
162
0.038462
263
0.038462
62
0.037037
163
0.038462
264
0.038462
63
0.037037
164
0.038462
265
0.038462
64
0.037037
165
0.038462
266
0.038462
65
0.037037
166
0.038462
267
0.038462
66
0.037037
167
0.038462
268
0.038462
67
0.037037
168
0.038462
269
0.038462
68
0.037037
169
0.038462
270
0.038462
69
0.037037
170
0.038462
271
0.038462
70
0.037037
171
0.038462
272
0.038462
71
0.037037
172
0.038462
273
0.038462
72
0.037037
173
0.038462
274
0.038462
73
0.037037
174
0.038462
275
0.038462
74
0.037037
175
0.038462
276
0.038462
75
0.037037
176
0.038462
277
0.038462
76
0.037037
177
0.038462
278
0.038462
77
0.037037
178
0.038462
279
0.038462
78
0.037037
179
0.038462
280
0.038462
79
0.037037
180
0.038462
281
0.038462
80
0.037037
181
0.038462
282
0.038462
81
0.037037
182
0.038462
283
0.038462
82
0.037037
183
0.038462
284
0.038462
83
0.037037
184
0.038462
285
0.038462
84
0.037037
185
0.038462
286
0.038462
85
0.037037
186
0.038462
287
0.038462
86
0.037037
187
0.038462
288
0.038462
87
0.037037
188
0.038462
289
0.038462
88
0.037037
189
0.038462
290
0.038462
89
0.037037
190
0.038462
291
0.038462
90
0.037037
191
0.038462
292
0.038462
91
0.037037
192
0.038462
293
0.038462
92
0.037037
193
0.038462
294
0.038462
93
0.037037
194
0.038462
94
0.037037
195
0.038462
95
0.037037
196
0.038462
96
0.037037
197
0.038462
97
0.037037
198
0.038462
98
0.037037
199
0.038462
99
0.037037
200
0.038462
100
0.03780035
201
0.038462
Table 6. DeJong Function 3 With Accelerator.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
5.4 DeJong Function 4
Shown below Figure 7 and Figure 8 are the graphical presentation of the result obtained
for DeJong Function 4, without and with the use of acceleration technique. The vertical
axis denotes the fitness level while the horizontal axis represents the number of
iterations. For the full results data, refer to Table 7 and Table 8 respectively.
3
2.5
2
1.5
Series1
1
0.5
0
0
100
200
300
400
Figure 7. DeJong Function 4 Without Accelerator.
800
700
600
500
400
Series1
300
200
100
0
0
50
100
150
200
Figure 8. DeJong Function 4 With Accelerator.
Similarly to the previous functions, the results obtained with the accelerator
demonstrates a higher fitness level, in a shorter number of iterations.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
No. Generation
Best fitness
No. Generation
Best fitness No. Generation Best fitness
0
0.462391
101
2.406461
202
2.406461
1
0.462391
102
2.406461
203
2.406461
2
0.462391
103
2.406461
204
2.406461
3
0.462391
104
2.406461
205
2.406461
4
0.462391
105
2.406461
206
2.406461
5
0.462391
106
2.406461
207
2.406461
6
0.462391
107
2.406461
208
2.406461
7
0.462391
108
2.406461
209
2.406461
8
0.462391
109
2.406461
210
2.406461
9
0.462391
110
2.406461
211
2.406461
10
0.713442
111
2.406461
212
2.406461
11
0.713442
112
2.406461
213
2.406461
12
0.713442
113
2.406461
214
2.406461
13
0.713442
114
2.406461
215
2.406461
14
0.713442
115
2.406461
216
2.406461
15
0.713442
116
2.406461
217
2.406461
16
0.713442
117
2.406461
218
2.406461
17
0.713442
118
2.406461
219
2.406461
18
0.713442
119
2.406461
220
2.406461
19
0.713442
120
2.406461
221
2.406461
20
0.713442
121
2.406461
222
2.406461
21
0.713442
122
2.406461
223
2.406461
22
0.713442
123
2.406461
224
2.406461
23
0.713442
124
2.406461
225
2.406461
24
0.713442
125
2.406461
226
2.406461
25
0.782321
126
2.406461
227
2.406461
26
0.782321
127
2.406461
228
2.406461
27
1.201005
128
2.406461
229
2.406461
28
1.201005
129
2.406461
230
2.406461
29
1.201005
130
2.406461
231
2.406461
30
1.201005
131
2.406461
232
2.406461
31
1.201005
132
2.406461
233
2.406461
32
1.201005
133
2.406461
234
2.406461
33
1.201005
134
2.406461
235
2.406461
34
1.201005
135
2.406461
236
2.406461
35
1.201005
136
2.406461
237
2.406461
36
1.201005
137
2.406461
238
2.406461
37
1.201005
138
2.406461
239
2.406461
38
1.201005
139
2.406461
240
2.406461
39
1.201005
140
2.406461
241
2.406461
40
1.201005
141
2.406461
242
2.406461
41
1.201005
142
2.406461
243
2.406461
42
1.201005
143
2.406461
244
2.406461
43
1.201005
144
2.406461
245
2.406461
44
1.201005
145
2.406461
246
2.406461
45
1.201005
146
2.406461
247
2.406461
46
1.201005
147
2.406461
248
2.406461
47
1.201005
148
2.406461
249
2.406461
48
1.201005
149
2.406461
250
2.406461
49
1.201005
150
2.406461
251
2.406461
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
50
1.201005
151
2.406461
252
2.406461
51
1.201005
152
2.406461
253
2.406461
52
1.201005
153
2.406461
254
2.406461
53
1.201005
154
2.406461
255
2.406461
54
1.201005
155
2.406461
256
2.406461
55
1.201005
156
2.406461
257
2.406461
56
1.201005
157
2.406461
258
2.406461
57
1.201005
158
2.406461
259
2.406461
58
1.201005
159
2.406461
260
2.406461
59
1.201005
160
2.406461
261
2.406461
60
1.201005
161
2.406461
262
2.406461
61
1.201005
162
2.406461
263
2.406461
62
1.201005
163
2.406461
264
2.406461
63
1.201005
164
2.406461
265
2.406461
64
1.201005
165
2.406461
266
2.406461
65
1.201005
166
2.406461
267
2.406461
66
1.715546
167
2.406461
268
2.406461
67
1.715546
168
2.406461
269
2.406461
68
1.715546
169
2.406461
270
2.406461
69
1.715546
170
2.406461
271
2.406461
70
1.715546
171
2.406461
272
2.406461
71
1.715546
172
2.406461
273
2.406461
72
1.715546
173
2.406461
274
2.406461
73
1.715546
174
2.406461
275
2.406461
74
1.715546
175
2.406461
276
2.406461
75
1.715546
176
2.406461
277
2.406461
76
1.715546
177
2.406461
278
2.406461
77
2.406461
178
2.406461
279
2.406461
78
2.406461
179
2.406461
280
2.406461
79
2.406461
180
2.406461
281
2.406461
80
2.406461
181
2.406461
282
2.406461
81
2.406461
182
2.406461
283
2.406461
82
2.406461
183
2.406461
284
2.406461
83
2.406461
184
2.406461
285
2.406461
84
2.406461
185
2.406461
286
2.406461
85
2.406461
186
2.406461
287
2.406461
86
2.406461
187
2.406461
288
2.406461
87
2.406461
188
2.406461
289
2.406461
88
2.406461
189
2.406461
290
2.406461
89
2.406461
190
2.406461
291
2.406461
90
2.406461
191
2.406461
292
2.406461
91
2.406461
192
2.406461
293
2.406461
92
2.406461
193
2.406461
294
2.406461
93
2.406461
194
2.406461
94
2.406461
195
2.406461
95
2.406461
196
2.406461
96
2.406461
197
2.406461
97
2.406461
198
2.406461
98
2.406461
199
2.406461
99
2.406461
200
2.406461
100
2.45784157
201
2.406461
Table 7. DeJong Function 4 Without Accelerator.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
No. Generation
Best fitness
No. Generation
Best fitness No. Generation Best fitness
0
0.462391
101 701.77589
202 773.871129
1
0.614305
102 701.77589
203 773.871129
2
1.7657
103 701.77589
204 773.871129
3
2.445316
104 701.77589
205 773.871129
4
3.145639
105 701.77589
206 773.871129
5
7.604484
106 701.77589
207 773.871129
6
7.67631
107 701.77589
208 773.871129
7
7.804999
108 701.77589
209 773.871129
8
20.172961
109 701.77589
210 773.871129
9
20.172961
110 701.77589
211 773.871129
10
20.172961
111 701.77589
212 773.871129
11
34.381798
112 701.77589
213 773.871129
12
34.381798
113 701.77589
214 773.871129
13
34.381798
114 701.77589
215 773.871129
14
34.381798
115 701.77589
216 773.871129
15
34.381798
116 701.77589
217 773.871129
16
34.381798
117 701.77589
218 773.871129
17
67.146247
118 701.77589
219 773.871129
18
67.146247
119 701.77589
220 773.871129
19
67.146247
120 701.77589
221 773.871129
20
67.146247
121 701.77589
222 773.871129
21
67.146247
122 701.77589
223 773.871129
22
67.146247
123 701.77589
224 773.871129
23
67.146247
124 701.77589
225 773.871129
24
67.146247
125 701.77589
226 773.871129
25
67.146247
126 701.77589
227 773.871129
26
67.146247
127 701.77589
228 773.871129
27
87.807857
128 701.77589
229 773.871129
28
87.807857
129 701.77589
230 773.871129
29
701.77589
130 701.77589
231 773.871129
30
701.77589
131 701.77589
232 773.871129
31
701.77589
132 701.77589
233 773.871129
32
701.77589
133 701.77589
234 773.871129
33
701.77589
134 701.77589
235 773.871129
34
701.77589
135 701.77589
236 773.871129
35
701.77589
136 701.77589
237 773.871129
36
701.77589
137 701.77589
238 773.871129
37
701.77589
138 701.77589
239 773.871129
38
701.77589
139 701.77589
240 773.871129
39
701.77589
140 701.77589
241 773.871129
40
701.77589
141 701.77589
242 773.871129
41
701.77589
142 701.77589
243 773.871129
42
701.77589
143 701.77589
244 773.871129
43
701.77589
144 701.77589
245 773.871129
44
701.77589
145 701.77589
246 773.871129
45
701.77589
146 701.77589
247 773.871129
46
701.77589
147 701.77589
248 773.871129
47
701.77589
148 701.77589
249 773.871129
48
701.77589
149 701.77589
250 773.871129
49
701.77589
150 701.77589
251 773.871129
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
50
701.77589
151 701.77589
252 773.871129
51
701.77589
152 701.77589
253 773.871129
52
701.77589
153 773.871129
254 773.871129
53
701.77589
154 773.871129
255 773.871129
54
701.77589
155 773.871129
256 773.871129
55
701.77589
156 773.871129
257 773.871129
56
701.77589
157 773.871129
258 773.871129
57
701.77589
158 773.871129
259 773.871129
58
701.77589
159 773.871129
260 773.871129
59
701.77589
160 773.871129
261 773.871129
60
701.77589
161 773.871129
262 773.871129
61
701.77589
162 773.871129
263 773.871129
62
701.77589
163 773.871129
264 773.871129
63
701.77589
164 773.871129
265 773.871129
64
701.77589
165 773.871129
266 773.871129
65
701.77589
166 773.871129
267 773.871129
66
701.77589
167 773.871129
268 773.871129
67
701.77589
168 773.871129
269 773.871129
68
701.77589
169 773.871129
270 773.871129
69
701.77589
170 773.871129
271 773.871129
70
701.77589
171 773.871129
272 773.871129
71
701.77589
172 773.871129
273 773.871129
72
701.77589
173 773.871129
274 773.871129
73
701.77589
174 773.871129
275 773.871129
74
701.77589
175 773.871129
276 773.871129
75
701.77589
176 773.871129
277 773.871129
76
701.77589
177 773.871129
278 773.871129
77
701.77589
178 773.871129
279 773.871129
78
701.77589
179 773.871129
280 773.871129
79
701.77589
180 773.871129
281 773.871129
80
701.77589
181 773.871129
282 773.871129
81
701.77589
182 773.871129
283 773.871129
82
701.77589
183 773.871129
284 773.871129
83
701.77589
184 773.871129
285 773.871129
84
701.77589
185 773.871129
286 773.871129
85
701.77589
186 773.871129
287 773.871129
86
701.77589
187 773.871129
288 773.871129
87
701.77589
188 773.871129
289 773.871129
88
701.77589
189 773.871129
290 773.871129
89
701.77589
190 773.871129
202 773.871129
90
701.77589
191 773.871129
203 773.871129
91
701.77589
192 773.871129
204 773.871129
92
701.77589
193 773.871129
205 773.871129
93
701.77589
194 773.871129
94
701.77589
195 773.871129
95
701.77589
196 773.871129
96
701.77589
197 773.871129
97
701.77589
198 773.871129
98
701.77589
199 773.871129
99
701.77589
200 773.871129
100
701.77589
201 773.871129
Table 8. DeJong Function 4 With Accelerator.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
6. Conclusion and Recommendations
In recent years genetic algorithm have been gaining popularity as a robust and efficient
form of search technique. Although it is highly effective, it is limited by the fact that it
does not know when optimisation has been achieved and thus, additional test functions
are required in order to determine when optimisation have been achieved.
The report introduced the concept of the genetic algorithm and the various reproduction
methods. It then went on to introduce the DeJong functions that were used to test for
optimisation, and the acceleration technique that was implemented to speed up the
simulation.
Simulations were carried out with and without accelerator and the results were collected
and tabulated. From the results, comparison between with and without the aid of the
accelerator can be drawn. It is clearly shown that the accelerator greatly increases
optimisation. This can be seen from the fact that less iterations were needed for the
process.
The acceleration technique that was implemented has been highly successful in
speeding up the optimisation of the genetic algorithm, but this is not the only available
acceleration technique. There are many other techniques that can be used. Due to time
constraints, only one technique was being implemented in this thesis. A
recommendation for any future research on this thesis would be to explore the other
acceleration techniques and compare the results with those obtained by the technique
that was used in this thesis and from there, a deduction can be drawn as to which are the
best acceleration techniques.
Improvements can also be made to the existing program that was created for this thesis.
One recommendation would be to try using other test functions instead of the DeJong
functions, for example, Newton-Raphson can also be used to test for convergence.
Another recommendation would be to alter the code such that the program terminates
once optimisation has been achieved, instead of generating for the full number of
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
generations. This way, it will shorten the simulation time greatly, and there will be a
clear indication of the number of iterations, which were being used. There are many
other recommendations that can be made to this thesis, as genetic algorithm and the uses
are varied and flexible.
Some of the more common uses of genetic algorithm are for machine learning, and
search optimisations. For example, it can be used for the tuning of PID controllers, as
well as optimisation of power control systems. With the results from this thesis,
hopefully it will be able to give a clear indication of the success of using acceleration
techniques in conjunction with genetic algorithm, and make genetic algorithm more
efficient and effective in it’s applications.
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
Appendix 1
/* This is a simple genetic algorithm implementation where the evaluation function
takes positive values only and the fitness of an individual is the same as the
value of the
objective function
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
/* Test parameters, which can be changed */
#define POPSIZE 100
// population size
#define MAXGENS 500
// max. number of generations
#define NVARSmax 50
// no. of problem variables
#define PXOVER 0.8
// probability of crossover
#define PMUTATION 0.15
// probability of mutation
#define TRUE 1
#define FALSE 0
#define DeJong1
#define DeJong2
#define DeJong3
#define DeJong4
1
2
3
4
// De Jong function F1
// De Jong function F2
// De Jong function F3
// De Jong function F4
char outputfilename[100]; // out put file name
char reply[3];
FILE * galog;
// used in case when file name exists
int ObjectiveF;
int NVARS;
int generation;
int cur_best;
long idum = (-13);
// index of De Jong functions
// no. of problem variables
// current generation number
// best individual
struct genotype
{
double gene[NVARSmax];
double fitness;
double upper[NVARSmax];
double lower[NVARSmax];
double rfitness;
double cfitness;
};
// genotype (GT), a member of the population
// a string of variables
// GT's fitness
// GT's variables upper bound
// GT's variables lower bound
// relative fitness
// cumulative fitness
struct genotype population[POPSIZE+1];
struct genotype newpopulation[POPSIZE+1];
/* replaces the old generation */
double OBJ_f[POPSIZE + 1];
// population
// new population
// objective function
/* Declaration of procedures used by this genetic algorithm */
void initialize(void);
double randval(double, double);
void evaluate(void);
void keep_the_best(void);
void accelerator(void);
void elitist(void);
void select(void);
void crossover(void);
void Xover(int, int);
void swap(double *, double *);
void mutate(void);
void report(void);
void Task_Selection(void);
/* Main function: Each generation involves selecting the best embers, performing
crossover & mutation and then valuating the resulting population, until the
terminating condition is satisfied */
void main(int argc, char *argv[])
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
{
int i, j;
char accel[3];
// for selection with or without accelerator
/* Allows user to select file to save results in and checks if file already exists. If
it does, it lets user decide if to proceed, or to save in an alternative filename */
do {
reply[0] = 'y';
printf("Pls enter output file name (eg output.txt): ");
gets(outputfilename);
galog = fopen(outputfilename, "r");
if(galog != NULL) {
fclose(galog);
printf("File exists, overwrite?(y/n): ");
gets(reply);
if(reply[0] != 'y' && reply[0] != 'n')
reply[0] = 'n';
}
} while (reply[0] == 'n');
galog = fopen(outputfilename, "w");
while(1) {
Task_Selection();
// Allows user to select with or without accelerator.
while(1) {
printf("\n");
printf("\tDo you wish to test with accelerator? (y/n) : ");
gets(accel);
if(accel[0] != 'n' && accel[0] != 'y')
printf("\n\tInvalid choice. Please re-enter.");
else
break;
}
fprintf(galog, "\n No. Generation Best fitness Average fitness Standard deviation\n\n");
initialize();
evaluate();
keep_the_best();
for(generation = 0; generation < MAXGENS; generation++) {
select();
crossover();
mutate();
if(accel[0] == 'y')
accelerator();
report();
evaluate();
elitist();
}
fprintf(galog, "\n\n Simulation completed\n");
fprintf(galog, "\n Best member: \n");
for (i = 0; i < NVARS; i++)
fprintf(galog, "\n var(%d) = %.6f", i, population[POPSIZE].gene[i]);
fprintf(galog, "\n\n Best fitness = %.6f", population[POPSIZE].fitness);
fprintf(galog, "\n Best objective = %.6f", OBJ_f[POPSIZE]);
printf("\n\n\tProcess Completed\n\n\n\n");
for(i = 0; i <= POPSIZE; i++) {
population[i].fitness = 0;
for(j = 0; j <= POPSIZE; j++)
population[i].gene[j] = 0;
}
}
} // End of main(void)
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
/* Initialization function: User can change the values of NVARS/lbound/ubound
from the files dj1, dj2, dj3 and dj4 respectively. */
void initialize(void)
{
FILE *infile;
int i, j;
double lbound, ubound;
switch(ObjectiveF) {
case 1:
if ((infile = fopen("dj1.txt", "r"))==NULL) {
fprintf(galog,"\nCannot open input file!\n");
fprintf(galog,"Pls check that 'dj1.txt' exists in directory.\n");
fprintf(galog,"If not pls create file and enter values for the following:\n");
fprintf(galog,"No. of problem variables\nLower bound\nUpper bound");
exit(1);
}
break;
case 2:
if ((infile = fopen("dj2.txt", "r"))==NULL) {
fprintf(galog,"\nCannot open input file!\n");
fprintf(galog,"Pls check that 'dj2.txt' exists in directory.\n");
fprintf(galog,"If not pls create file and enter values for the following:\n");
fprintf(galog,"No. of problem variables\nLower bound\nUpper bound");
exit(1);
}
break;
case 3:
if ((infile = fopen("dj3.txt", "r"))==NULL) {
fprintf(galog,"\nCannot open input file!\n");
fprintf(galog,"Pls check that 'dj3.txt' exists in directory.\n");
fprintf(galog,"If not pls create file and enter values for the following:\n");
fprintf(galog,"No. of problem variables\nLower bound\nUpper bound");
exit(1);
}
break;
case 4:
if ((infile = fopen("dj4.txt", "r"))==NULL) {
fprintf(galog,"\nCannot open input file!\n");
fprintf(galog,"Pls check that 'dj4.txt' exists in directory.\n");
fprintf(galog,"If not pls create file and enter values for the following:\n");
fprintf(galog,"No. of problem variables\nLower bound\nUpper bound");
exit(1);
}
break;
}
/* initialize variables within the bounds */
fscanf(infile, "%d", &NVARS);
if(NVARSmax < NVARS) {
printf("\n\tERROR: allowed number of variables is too small.\n");
exit(0);
}
for (i = 0; i < NVARS; i++) {
fscanf(infile, "%lf", &lbound);
fscanf(infile, "%lf", &ubound);
for (j = 0; j < POPSIZE; j++) {
population[j].fitness = 0;
population[j].rfitness = 0;
population[j].cfitness = 0;
population[j].lower[i] = lbound;
population[j].upper[i] = ubound;
population[j].gene[i] = randval(population[j].lower[i], population[j].upper[i]);
OBJ_f[j] = 0;
}
}
fclose(infile);
} // End of initialize()
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
// Random value generator: Generates a value within bounds
double randval(double low, double high)
{
double val;
val = ((double)(rand()%1000)/1000.0) * (high - low) + low;
return(val);
} // End of randval()
/* Evaluation function: Uses DeJong Functions */
void evaluate(void)
{
int i, mem;
double x[NVARSmax+1], temp = 0;
for (mem = 0; mem < POPSIZE; mem++) {
for (i = 0; i < NVARS; i++)
x[i+1] = population[mem].gene[i];
/* De Jong function F1: */
if(ObjectiveF == DeJong1)
OBJ_f[mem] = x[1] * x[1] + x[2] * x[2] + x[3] * x[3];
/* De Jong function F2: */
else if(ObjectiveF == DeJong2)
OBJ_f[mem] = 100.0*(x[1]*x[1]-x[2])*(x[1]*x[1]-x[2])+(1.0-x[1])*(1.0-x[1]);
/* De Jong function F3: */
else if(ObjectiveF == DeJong3) {
for(i = 0; i <= NVARS; i++) {
if(x[i] > 0.0)
temp += (int)x[i];
else
temp += (int)x[i] - 1;
}
OBJ_f[mem] = 25 - temp;
}
/* De Jong function F4: */
else if(ObjectiveF == DeJong4) {
OBJ_f[mem] = 0.0;
for(i = 1; i <= NVARS; i++)
OBJ_f[mem] += (double)i * pow(x[i], 4.0);
OBJ_f[mem] += randval(0, 1);
}
population[mem].fitness = (double)1.0/(0.0000001+fabs(OBJ_f[mem]));
/* De Jong function F5: */
else if(ObjectiveF == DeJong5) {
OBJ_f[mem] = 0.0;
for(i = 1; i <= 25; i++)
OBJ_f[mem] = OBJ_f[mem] + (1.0 / dj5(x[i], i));
population[mem].fitness = 500.0 - (1.0 / (OBJ_f[mem] + .002));
} */
/*
}
} // End of evaluate()
/* Keep_the_best function: This function keeps track of the best member of the population.
Note that the last entry in the array Population holds a copy of the best individual
*/
void keep_the_best(void)
{
int i, mem;
cur_best = 0;
// stores the index of the best individual
for (mem = 0; mem < POPSIZE; mem++) {
if (population[mem].fitness > population[POPSIZE].fitness) {
cur_best = mem;
population[POPSIZE].fitness = population[mem].fitness;
OBJ_f[POPSIZE] = OBJ_f[mem];
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
}
}
// once the best member in the population is found, copy the genes
for (i = 0; i < NVARS; i++)
population[POPSIZE].gene[i] = population[cur_best].gene[i];
} // End of keep_the_best()
/* Elitist function: The best member of the previous generation is stored as the last in
the array. If the best member of the current generation is worse than the best member
of the previous generation, the latter one would replace the worst member of the
current population */
void elitist(void)
{
int i;
double best, worst;
int best_mem, worst_mem;
// best and worst fitness values
// indexes of the best and worst member
best = population[0].fitness;
worst = population[0].fitness;
for (i = 0; i < POPSIZE - 1; ++i) {
if (population[i].fitness > population[i + 1].fitness) {
if (population[i].fitness >= best) {
best = population[i].fitness;
best_mem = i;
}
if (population[i + 1].fitness <= worst) {
worst = population[i+1].fitness;
worst_mem = i + 1;
}
}
else {
if (population[i].fitness <= worst){
worst = population[i].fitness;
worst_mem = i;
}
if (population[i + 1].fitness >= best) {
best = population[i + 1].fitness;
best_mem = i + 1;
}
}
}
/* if best individual from the new population is better than the best individual from the
previous population, then copy the best from the new population; else replace the
worst individual from the current population with the best one from the previous
generation */
if (best >= population[POPSIZE].fitness) {
for (i = 0; i < NVARS; i++)
population[POPSIZE].gene[i] = population[best_mem].gene[i];
population[POPSIZE].fitness = population[best_mem].fitness;
OBJ_f[POPSIZE] = OBJ_f[best_mem];
}
else {
for (i = 0; i < NVARS; i++)
population[worst_mem].gene[i] = population[POPSIZE].gene[i];
population[worst_mem].fitness = population[POPSIZE].fitness;
OBJ_f[worst_mem] = OBJ_f[POPSIZE];
}
} // End of elitist()
// accelerator()
void accelerator(void)
{
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
int i, j;
double H_Co=0.5;
for(i = 0; i < POPSIZE; i++)
for(j = 0; j < NVARS; j++)
population[i].gene[j]
H_Co*(population[i].gene[j]);
} // End of accelerator()
=
(1.0-H_Co)*(population[POPSIZE].gene[j])
+
/* select function: Standard proportional selection for maximumization problems
incorporating elitist model - makes sure that the best member survives */
void select(void)
{
int mem, i, j;
double sum = 0;
double p;
// find total fitness of the population
for (mem = 0; mem < POPSIZE; mem++) {
sum += population[mem].fitness;
}
// calculate relative fitness
for (mem = 0; mem < POPSIZE; mem++) {
population[mem].rfitness = population[mem].fitness/sum;
}
population[0].cfitness = population[mem - 1].cfitness + population[mem].rfitness;
// calculate cumulative fitness
for (mem = 1; mem <POPSIZE; mem++) {
population[mem].cfitness = population[mem - 1].cfitness + population[mem].rfitness;
}
// finally select survivors usingg cumulative fitness
for (i = 0; i < POPSIZE; i++) {
p = rand() % 1000 / 1000.0;
if (p < population[0].cfitness)
newpopulation[i] = population[0];
else {
for (j = 0; j < POPSIZE; j++)
if (p >= population[j].cfitness && p,population[j + 1].cfitness)
newpopulation[i] = population[j + 1];
}
}
// once a new population is created, copy it back
for (i = 0; i < POPSIZE; i++)
population[i] = newpopulation[i];
} // End of select(void)
/* Crossover selection: selects two parents that take part in the crossover. Implements
a single point crossover */
void crossover(void)
{
int mem, one;
int first = 0;
double x;
// count of the number of members chosen
for (mem = 0; mem < POPSIZE; ++mem) {
x = rand() % 1000 / 1000.0;
if (x < PXOVER) {
++first;
if (first % 2 == 0)
Xover(one, mem);
else
one = mem;
}
}
} // End of crossover(void)
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
/* Crossover: performs crossover of the two selected parents. */
void Xover(int one, int two)
{
int i;
int point;
// crossover point
// select crossover point
if(NVARS > 1) {
if(NVARS == 2)
point = 1;
else
point = (rand() % (NVARS - 1)) + 1;
for (i = 0; i < point; i++)
swap(&population[one].gene[i], &population[two].gene[i]);
}
} // End of Xover(int one, int two)
/* Swap: A swap procedure that helps in swapping 2 variables */
void swap(double *x, double *y)
{
double temp;
temp = *x;
*x = *y;
*y = temp;
} // End of swap(double *x, double *y)
/* Mutation: Random uniform mutation. A variable selected for mutation is replaced by a
random value between lower and upper bounds of this variable */
void mutate(void)
{
int i, j;
double lbound, hbound;
double x;
for (i = 0; i < POPSIZE; i++)
for (j = 0; j < NVARS; j++) {
x = rand() % 1000 / 1000.0;
if (x < PMUTATION) {
/* find the bounds on the variable to be mutated */
lbound = population[i].lower[j];
hbound = population[i].upper[j];
population[i].gene[j] = randval(lbound, hbound);
}
}
} // End of mutate(void)
/* Report function: Reports progress of the simulation. Data dumped into the output'
file are separated by commas */
void report(void)
{
int i;
double best_val;
// best population fitness
double avg;
// avg population fitness
double stddev;
// std. deviation of population fitness
double sum_square; // sum of square for std. calc
double square_sum; // square of sum for std. calc
double sum;
// total population fitness
sum = 0.0;
sum_square = 0.0;
for (i = 0; i < POPSIZE; i++) {
sum += population[i].fitness;
sum_square += population[i].fitness * population[i].fitness;
}
avg = sum / (double)POPSIZE;
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
square_sum = avg * avg * (double)POPSIZE;
if(floor((sum_square - square_sum) * 1000000.0) < 1.0)
stddev = 0.0;
else
stddev = sqrt((sum_square - square_sum) / (POPSIZE - 1));
best_val = population[POPSIZE].fitness;
fprintf(galog, "%5d %s %.6f %s %.6f %s %.6f \n",
generation,
"
",
best_val,
" ",
avg,
"
",
stddev);
} // End of report(void)
/* routine selectes a process */
void Task_Selection(void)
{
int Nfield;
char linebuffer[1024];
// For selection of which DeJong function to use
while(1) {
printf("\n\n");
printf("\t__________________________________________________________\n");
printf("\t_______________ Standard Genetic Algorithm _______________\n");
printf("\n\t\t\tOPTIONS:\n\n");
printf("\t\t\t 1 De Jong function F1\n");
printf("\t\t\t 2 De Jong function F2\n");
printf("\t\t\t 3 De Jong function F3\n");
printf("\t\t\t 4 De Jong function F4\n");
printf("\t\t\t 5 EXIT\n");
printf("\t__________________________________________________________\n");
do {
printf("\tMake A Selection (1-5): ");
gets(linebuffer);
Nfield = sscanf(linebuffer, "%d ", &ObjectiveF);
} while (Nfield != 1);
if(ObjectiveF < 1 || ObjectiveF > 5)
printf("\n\tInvalid choice, please re-enter.");
else
break;
}
if(ObjectiveF==5) {
fclose(galog);
printf("\n\n\t\t\tProcess Terminated.\n\n\n");
exit(0);
}
} // End of Task_Selection()
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
REFERENCES
[1] SCHWEFEL, HANS-PAUL, Evolution and Optimum Seeking. John Wiley & Sons,
Inc, 1995.
[2] SAIT, SADIQ & YOUSSEF HABIB, Iterative Computer Algorithms with
Applications in Engineering. The Institute of Electrical and Electronics Engineers,
Inc, 1999.
[3] GEN, M & CHENG, R., Genetic Algorithms and Engineering Optimisation. John
Wiley & Sons, Inc, 2000.
[4] GEN, M & CHENG, R., Genetic Algorithm and Engineering Design. John Wiley &
Sons, Inc, 1997.
[5] GOLDBERG, D., Genetic Algorithms in Search, Optimisation and Machine
Learning. Addison-Wesley, 1987.
[6] HOLLAND, J., Adaptation in Natural and Artificial Systems. Ann Arbor: University
of Michigan Press, 1975.
[7]
Marek
Obitko,
“Genetic
Algorithms,”
Visited
October
2002,
http://cs.felk.cvut.cz/~xobitko/ga/main.html.
[8] ADERSON, A & SIMPSON, A R., Genetic Algorithm Optimisation Software in
Fortran. Research Report No. R136, 1996.
[9] MICHALEWICS, Z., Genetic Algorithm + Data Structure = Evolution Programs,
3rd Edition. Springer-Verlag, 1996.
[10] K.A. De Jong, An Analysis of The Behavior of A Class of Genetic Adaptive
Systems. Ann Arbor: University of Michigan Press, 1975
Yeo Su Yuin Melinda
Genetic Algorithm and Acceleration Techniques
[11] University of Nevada, Reno, “DeJong Function Minimization,” Visited September
2002, http://www.cs.unr.edu/~gruber/ga/dejong.html.
[12] University of Nevada, Reno, “DeJong Function Minimization,” Visited September
2002, http://www.cs.unr.edu/~ekkasit/ga/dejong.html.
[13] Adam Fraser, “Genetic Programming in C++ FAQ,” Visited August 2002,
http://www.cs.ucl.ac.uk/research/genprog/gpfaq.html.
Yeo Su Yuin Melinda
Download