
 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 1
Lecture 9
Lecture 9
Evolutionary Computation:
Evolutionary Computation:
Genetic algorithms
Genetic algorithms
I
I Introduction, or
Introduction, or can
can evolution
evolution be
be
intelligent
intelligent?
?
I
I Simulation of
Simulation of natural
natural evolution
evolution
I
I Genetic
Genetic algorithms
algorithms
I
I Case
Case study
study:
: maintenance
maintenance scheduling
scheduling with
with
genetic
genetic algorithms
algorithms
I
I Summary
Summary

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 2
I
I Intelligence can be defined as the capability of a
Intelligence can be defined as the capability of a
system to adapt its behaviour to ever
system to adapt its behaviour to ever-
-changing
changing
environment. According to Alan Turing, the form
environment. According to Alan Turing, the form
or appearance of a system is irrelevant to its
or appearance of a system is irrelevant to its
intelligence.
intelligence.
I
I Evolutionary computation simulates evolution on a
Evolutionary computation simulates evolution on a
computer. The result of such a simulation is a
computer. The result of such a simulation is a
series of optimisation algorithms
series of optimisation algorithms, usually based on
, usually based on
a simple set of rules. Optimisation
a simple set of rules. Optimisation iteratively
iteratively
improves the quality of solutions until an optimal,
improves the quality of solutions until an optimal,
or at least feasible, solution is found.
or at least feasible, solution is found.
Can evolution be intelligent
Can evolution be intelligent?
?

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 3
I
I The behaviour of
The behaviour of an individual organism
an individual organism is
is an
an
inductive inference about some yet unknown
inductive inference about some yet unknown
aspects of its environment.
aspects of its environment. If,
If, over successive
over successive
generations, the organism survives, we can say
generations, the organism survives, we can say
that this organism is capable of learning to predict
that this organism is capable of learning to predict
changes in its environment.
changes in its environment.
I
I The evolutionary approach is based on
The evolutionary approach is based on
computational models of natural selection and
computational models of natural selection and
genetics. We call them
genetics. We call them evolutionary
evolutionary
computation
computation, an umbrella term that combines
, an umbrella term that combines
genetic algorithms
genetic algorithms,
, evolution strategies
evolution strategies and
and
genetic programming
genetic programming.
.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 4
I
I On 1 July 1858,
On 1 July 1858, Charles Darwin
Charles Darwin presented his
presented his
theory of evolution before the
theory of evolution before the Linnean
Linnean Society of
Society of
London. This day marks the beginning of a
London. This day marks the beginning of a
revolution in biology.
revolution in biology.
I
I Darwin
Darwin’
’s
s classical
classical theory of evolution
theory of evolution, together
, together
with
with Weismann
Weismann’
’s
s theory of natural selection
theory of natural selection and
and
Mendel
Mendel’
’s
s concept of
concept of genetics
genetics, now represent the
, now represent the
neo
neo-
-Darwinian paradigm.
Darwinian paradigm.
Simulation of
Simulation of natural
natural evolution
evolution

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 5
I
I Neo
Neo-
-Darwinism
Darwinism is based on processes of
is based on processes of
reproduction, mutation, competition and selection.
reproduction, mutation, competition and selection.
The power to reproduce appears to be an essential
The power to reproduce appears to be an essential
property of life. The power to mutate is also
property of life. The power to mutate is also
guaranteed in any living organism that reproduces
guaranteed in any living organism that reproduces
itself in a continuously changing environment.
itself in a continuously changing environment.
Processes of competition and selection normally
Processes of competition and selection normally
take place in the natural world, where expanding
take place in the natural world, where expanding
populations of different species are limited by a
populations of different species are limited by a
finite space.
finite space.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 6
I
I Evolution can be seen as a process leading to the
Evolution can be seen as a process leading to the
maintenance
maintenance of a population
of a population’
’s
s ability to survive
ability to survive
and reproduce in a specific environment. This
and reproduce in a specific environment. This
ability is called
ability is called evolutionary fitness
evolutionary fitness.
.
I
I Evolutionary fitness can also be viewed as a
Evolutionary fitness can also be viewed as a
measure of the organism
measure of the organism’
’s ability to anticipate
s ability to anticipate
changes in its environment.
changes in its environment.
I
I The
The fitness, or the quantitative measure of the
fitness, or the quantitative measure of the
ability to predict environmental changes and
ability to predict environmental changes and
respond adequately, can be considered as the
respond adequately, can be considered as the
quality that is
quality that is optimised
optimised in natural life.
in natural life.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 7
How is a population with increasing
How is a population with increasing
fitness generated?
fitness generated?
I
I Let us consider
Let us consider a population of rabbits. Some
a population of rabbits. Some
rabbits are faster than others, and we may say that
rabbits are faster than others, and we may say that
these rabbits possess superior fitness, because they
these rabbits possess superior fitness, because they
have a greater chance of avoiding foxes, surviving
have a greater chance of avoiding foxes, surviving
and then breeding
and then breeding.
.
I
I If two parents have superior fitness, there is a good
If two parents have superior fitness, there is a good
chance that a combination of their genes will
chance that a combination of their genes will
produce an offspring with even higher fitness.
produce an offspring with even higher fitness.
Over time the entire population of rabbits becomes
Over time the entire population of rabbits becomes
faster to meet their environmental challenges in the
faster to meet their environmental challenges in the
face of foxes.
face of foxes.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 8
I
I All methods of evolutionary computation simulate
All methods of evolutionary computation simulate
natural
natural evolution by creating
evolution by creating a population of
a population of
individuals, evaluating their fitness, generating a
individuals, evaluating their fitness, generating a
new population through genetic operations, and
new population through genetic operations, and
repeating this process a number of times
repeating this process a number of times.
.
I
I We will start with
We will start with Genetic Algorithms
Genetic Algorithms (GAs) as
(GAs) as
most of the other evolutionary
most of the other evolutionary algorithms can be
algorithms can be
viewed as variations of
viewed as variations of genetic algorithms
genetic algorithms.
.
Simulation of
Simulation of natural
natural evolution
evolution

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 9
I
I In the early 1970s, John
In the early 1970s, John Holland introduced the
Holland introduced the
concept of genetic algorithms.
concept of genetic algorithms.
I
I His
His aim was to make computers do what nature
aim was to make computers do what nature
does.
does. Holland was concerned with
Holland was concerned with algorithms
algorithms
that manipulate strings of binary digits
that manipulate strings of binary digits.
.
I
I Each artificial
Each artificial “
“chromosomes
chromosomes”
” consists of a
consists of a
number of
number of “
“genes
genes”
”, and each gene is represented
, and each gene is represented
by 0 or 1:
by 0 or 1:
Genetic Algorithms
Genetic Algorithms
1 1
0 1 0 1 0 0 0 0 0 1 0 1 1
0

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 10
I
I Nature has an ability to adapt and learn without
Nature has an ability to adapt and learn without
being told what to do. In other words, nature
being told what to do. In other words, nature
finds good chromosomes blindly.
finds good chromosomes blindly. GAs
GAs do the
do the
same. Two mechanisms link a GA to the problem
same. Two mechanisms link a GA to the problem
it is solving:
it is solving: encoding
encoding and
and evaluation
evaluation.
.
I
I The GA uses a measure of fitness of individual
The GA uses a measure of fitness of individual
chromosomes to carry out reproduction. As
chromosomes to carry out reproduction. As
reproduction takes place, the crossover operator
reproduction takes place, the crossover operator
exchanges parts of two single chromosomes, and
exchanges parts of two single chromosomes, and
the mutation operator changes the gene value in
the mutation operator changes the gene value in
some randomly chosen location of the
some randomly chosen location of the
chromosome.
chromosome.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 11
Step 1
Step 1:
: Represent the problem variable domain as
Represent the problem variable domain as
a chromosome of a fixed length, choose the size
a chromosome of a fixed length, choose the size
of a chromosome population
of a chromosome population N
N, the crossover
, the crossover
probability
probability p
pc
c and the mutation probability
and the mutation probability p
pm
m.
.
Step
Step 2
2:
: Define
Define a fitness function to measure the
a fitness function to measure the
performance, or fitness, of an individual
performance, or fitness, of an individual
chromosome in the problem domain. The fitness
chromosome in the problem domain. The fitness
function establishes the basis for selecting
function establishes the basis for selecting
chromosomes that will be mated during
chromosomes that will be mated during
reproduction.
reproduction.
Basic
Basic genetic
genetic algorithms
algorithms

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 12
Step 3
Step 3:
: Randomly generate an initial population of
Randomly generate an initial population of
chromosomes of size
chromosomes of size N
N:
:
x
x1
1,
, x
x2
2, . . . ,
, . . . , x
xN
N
Step 4
Step 4:
: Calculate the fitness of each individual
Calculate the fitness of each individual
chromosome:
chromosome:
f
f (
(x
x1
1),
), f
f (
(x
x2
2), . . . ,
), . . . , f
f (
(x
xN
N)
)
Step 5
Step 5:
: Select a pair of chromosomes for mating
Select a pair of chromosomes for mating
from the current population. Parent
from the current population. Parent
chromosomes are selected with a probability
chromosomes are selected with a probability
related to their fitness.
related to their fitness.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 13
Step 6
Step 6:
: Create a pair of offspring chromosomes by
Create a pair of offspring chromosomes by
applying the genetic operators
applying the genetic operators −
− crossover
crossover and
and
mutation
mutation.
.
Step 7
Step 7:
: Place the created offspring chromosomes
Place the created offspring chromosomes
in the new population.
in the new population.
Step 8
Step 8:
: Repeat
Repeat Step 5
Step 5 until the size of the new
until the size of the new
chromosome population becomes
chromosome population becomes equal to the
equal to the
size of the
size of the initial population,
initial population, N
N.
.
Step 9
Step 9:
: Replace
Replace the initial (parent) chromosome
the initial (parent) chromosome
population with the new (offspring) population.
population with the new (offspring) population.
Step
Step 10
10:
: Go to
Go to Step 4
Step 4, and repeat the process until
, and repeat the process until
the termination criterion is satisfied.
the termination criterion is satisfied.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 14
I
I GA represents an iterative process. Each iteration is
GA represents an iterative process. Each iteration is
called a
called a generation
generation. A typical number of generations
. A typical number of generations
for a simple GA can range from 50 to over
for a simple GA can range from 50 to over 500. The
500. The
entire set
entire set of generations is called a
of generations is called a run
run.
.
I
I Because GAs use a stochastic search method, the
Because GAs use a stochastic search method, the
fitness of a population may
fitness of a population may remain stable for a
remain stable for a
number of generations before a superior chromosome
number of generations before a superior chromosome
appears.
appears.
I
I A common practice is to terminate a GA after a
A common practice is to terminate a GA after a
specified number of generations and then examine
specified number of generations and then examine
the best chromosomes in the population. If no
the best chromosomes in the population. If no
satisfactory solution is found, the GA is restarted.
satisfactory solution is found, the GA is restarted.
Genetic
Genetic algorithms
algorithms

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 15
A simple example will help us to understand how
A simple example will help us to understand how
a GA works. Let us find the maximum value of
a GA works. Let us find the maximum value of
the function (15
the function (15x
x −
− x
x2
2
) where parameter
) where parameter x
x varies
varies
between 0 and 15. For simplicity, we may
between 0 and 15. For simplicity, we may
assume that
assume that x
x takes only integer values. Thus,
takes only integer values. Thus,
chromosomes can be built with only four
chromosomes can be built with only four genes:
genes:
Genetic
Genetic algorithms
algorithms:
: case
case study
study
Integer Binary code Integer Binary code Integer Binary code
1 0 0 0 1 6 0 1 1 0 11 1 0 1 1
2 0 0 1 0 7 0 1 1 1 12 1 1 0 0
3 0 0 1 1 8 1 0 0 0 13 1 1 0 1
4 0 1 0 0 9 1 0 0 1 14 1 1 1 0
5 0 1 0 1 10 1 0 1 0 15 1 1 1 1

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 16
Suppose that the size of the chromosome population
Suppose that the size of the chromosome population
N
N is 6, the crossover probability
is 6, the crossover probability p
pc
c equals 0.7, and
equals 0.7, and
the mutation probability
the mutation probability p
pm
m equals 0.001. The
equals 0.001. The
fitness function in our example is defined
fitness function in our example is defined by
by
f
f(
(x
x) =
) = 15
15 x
x −
−
−
−
−
−
−
− x
x2
2

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 17
The fitness function and chromosome locations
The fitness function and chromosome locations
Chromosome
label
Chromosome
string
Decoded
integer
Chromosome
fitness
Fitness
ratio, %
X1 1 1 0 0 12 36 16.5
X2 0 1 0 0 4 44 20.2
X3 0 0 0 1 1 14 6.4
X4 1 1 1 0 14 14 6.4
X5 0 1 1 1 7 56 25.7
X6 1 0 0 1 9 54 24.8
x
50
40
30
20
60
10
0
0 5 10 15
f(x)
(a) Chromosome initial locations.
x
50
40
30
20
60
10
0
0 5 10 15
(b) Chromosome final locations.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 18
I
I In natural selection, only the fittest species can
In natural selection, only the fittest species can
survive, breed, and thereby pass their genes on to
survive, breed, and thereby pass their genes on to
the next generation.
the next generation. GAs
GAs use a similar approach,
use a similar approach,
but unlike nature, the size of the chromosome
but unlike nature, the size of the chromosome
population remains unchanged from one
population remains unchanged from one
generation to the next.
generation to the next.
I
I The last column in Table shows the ratio of the
The last column in Table shows the ratio of the
individual chromosome
individual chromosome’
’s fitness to the
s fitness to the
population
population’
’s total fitness. This ratio determines
s total fitness. This ratio determines
the chromosome
the chromosome’
’s chance of being selected for
s chance of being selected for
mating.
mating. The chromosome
The chromosome’
’s average fitness
s average fitness
improves from one generation to the next.
improves from one generation to the next.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 19
Roulette
Roulette wheel
wheel selection
selection
The most commonly used chromosome selection
The most commonly used chromosome selection
techniques is the
techniques is the roulette wheel selection
roulette wheel selection.
.
100 0
16.5
36.7
43.1
49.5
75.2
X1: 16.5%
X2: 20.2%
X3: 6.4%
X4: 6.4%
X5: 25.3%
X6: 24.8%

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 20
Crossover operator
Crossover operator
I
I In our example, we have an initial population of 6
In our example, we have an initial population of 6
chromosomes. Thus, to establish the same
chromosomes. Thus, to establish the same
population in the next generation, the roulette
population in the next generation, the roulette
wheel would be spun six times
wheel would be spun six times.
.
I
I Once a pair of parent chromosomes is selected,
Once a pair of parent chromosomes is selected,
the
the crossover
crossover operator is applied.
operator is applied.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 21
I
I First, the crossover operator randomly chooses a
First, the crossover operator randomly chooses a
crossover point where two parent chromosomes
crossover point where two parent chromosomes
“
“break
break”
”, and then exchanges the chromosome
, and then exchanges the chromosome
parts after that point. As a result, two new
parts after that point. As a result, two new
offspring are created.
offspring are created.
I
I If a pair of chromosomes does not cross over,
If a pair of chromosomes does not cross over,
then
then the chromosome cloning takes place, and the
the chromosome cloning takes place, and the
offspring are created as exact copies of each
offspring are created as exact copies of each
parent.
parent.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 22
X6i 1 0
0 0 0
1 0 X2i
0 0
1 0
X2i 0 1
1 1 X5i
0
X1i 0 1
1 1 X5i
1 0
1 0
0 1
0 0
1
1 1
0
1 0
Crossover
Crossover

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 23
I
I Mutation represents a change in
Mutation represents a change in the gene.
the gene.
I
I Mutation is a background operator. Its role is to
Mutation is a background operator. Its role is to
provide a guarantee that
provide a guarantee that the search algorithm is
the search algorithm is
not trapped on a local optimum.
not trapped on a local optimum.
I
I The mutation operator flips a randomly selected
The mutation operator flips a randomly selected
gene in a chromosome.
gene in a chromosome.
I
I The mutation probability is quite small in nature,
The mutation probability is quite small in nature,
and is kept low for
and is kept low for GAs
GAs, typically in the range
, typically in the range
between 0.001 and 0.01.
between 0.001 and 0.01.
Mutation operator
Mutation operator

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 24
Mutation
Mutation
0 1
1 1
X5'i 0
1 0
X6'i 1 0
0
0 0
1 0
X2'i 0 1
0 0
0 1 1
1
1
X5i
1 1 1 X1"i
1 1
X2"i
0 1 0
0
X1'i 1 1 1
0 1 0
X2i

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 25
The
The genetic algorithm cycle
genetic algorithm cycle
1 0
1 0
X1i
Generation i
0 0
1 0
X2i
0 0
0 1
X3i
1 1
1 0
X4i
0 1
1 1
X5i f = 56
1 0
0 1
X6i f = 54
f = 36
f = 44
f = 14
f = 14
1 0
0 0
X1i+1
Generation (i + 1)
0 0
1 1
X2i+1
1 1
0 1
X3i+1
0 0
1 0
X4i+1
0 1
1 0
X5i+1 f = 54
0 1
1 1
X6i+1 f = 56
f = 56
f = 50
f = 44
f = 44
Crossover
X6i 1 0
0 0 0
1 0 X2i
0 0
1 0
X2i 0 1
1 1 X5i
0
X1i 0 1
1 1 X5i
1 0
1 0
0 1
0 0
1
1 1
0
1 0
Mutation
0 1
1 1
X5'i 0
1 0
X6'i 1 0
0
0 0
1 0
X2'i 0 1
0 0
0 1 1
1
1
X5i
1 1 1 X1"i
1 1
X2"i
0 1 0
0
X1'i 1 1 1
0 1 0
X2i

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 26
Genetic
Genetic algorithms
algorithms:
: case
case study
study
I
I Suppose it is desired to find the maximum of the
Suppose it is desired to find the maximum of the
“
“peak
peak”
” function of two variables:
function of two variables:
where parameters
where parameters x
x and
and y
y vary between
vary between −
−3 and 3.
3 and 3.
I
I The first step is to represent the problem variables
The first step is to represent the problem variables
as a
as a chromosome
chromosome −
− parameters
parameters x
x and
and y
y as a
as a
concatenated binary string:
concatenated binary string:
2
2
2
2
)
(
)
1
(
)
,
( 3
3
)
1
(
2 y
x
y
x
e
y
x
x
e
x
y
x
f −
−
+
−
−
−
−
−
−
=
1 0
0 0 1 1
0 0 0 1
0 1 1 1
0 1
y
x

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 27
I
I We also choose
We also choose the size of the chromosome
the size of the chromosome
population, for instance 6, and randomly generate
population, for instance 6, and randomly generate
an initial population.
an initial population.
I
I The next step is to calculate the fitness of each
The next step is to calculate the fitness of each
chromosome. This is done in two stages.
chromosome. This is done in two stages.
I
I First, a chromosome, that is a string of 16 bits, is
First, a chromosome, that is a string of 16 bits, is
partitioned into two 8
partitioned into two 8-
-bit strings:
bit strings:
10
0
1
2
3
4
5
6
7
2 )
138
(
2
0
2
1
2
0
2
1
2
0
2
0
2
0
2
1
)
10001010
( =
×
+
×
+
×
+
×
+
×
+
×
+
×
+
×
=
and
10
0
1
2
3
4
5
6
7
2 )
59
(
2
1
2
1
2
0
2
1
2
1
2
1
2
0
2
0
)
00111011
( =
×
+
×
+
×
+
×
+
×
+
×
+
×
+
×
=
I
I Then these strings are converted from binary
Then these strings are converted from binary
(base 2) to decimal (base 10):
(base 2) to decimal (base 10):
1 0
0 0 1 1
0 0 0 1
0 1 1 1
0 1
and

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 28
I
I Now the range of integers that can be handled by
Now the range of integers that can be handled by
8
8-
-bits, that is the range from 0 to (2
bits, that is the range from 0 to (28
8
−
− 1), is
1), is
mapped to the actual range of parameters
mapped to the actual range of parameters x
x and
and y
y,
,
that is the range from
that is the range from −
−3 to 3:
3 to 3:
I
I To
To obtain the actual values of
obtain the actual values of x
x and
and y
y, we multiply
, we multiply
their decimal values by 0.0235294 and subtract 3
their decimal values by 0.0235294 and subtract 3
from the results:
from the results:
0235294
.
0
1
256
6
=
−
2470588
.
0
3
0235294
.
0
)
138
( 10 =
−
×
=
x
and
6117647
.
1
3
0235294
.
0
)
59
( 10 −
=
−
×
=
y

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 29
I
I Using decoded values of
Using decoded values of x
x and
and y
y as inputs in the
as inputs in the
mathematical function, the GA calculates the
mathematical function, the GA calculates the
fitness of each chromosome.
fitness of each chromosome.
I
I To
To find the maximum of the
find the maximum of the “
“peak
peak”
” function, we
function, we
will use crossover with the probability equal to 0.7
will use crossover with the probability equal to 0.7
and mutation with the probability equal to 0.001.
and mutation with the probability equal to 0.001.
As we mentioned earlier, a common practice in
As we mentioned earlier, a common practice in
GAs
GAs is to specify the number of generations.
is to specify the number of generations.
Suppose the desired number of generations is 100.
Suppose the desired number of generations is 100.
That is, the GA will create 100 generations of 6
That is, the GA will create 100 generations of 6
chromosomes before stopping.
chromosomes before stopping.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 30
Chromosome locations on the surface of the
Chromosome locations on the surface of the
“
“peak
peak”
” function: initial population
function: initial population

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 31
Chromosome locations on the surface of the
Chromosome locations on the surface of the
“
“peak
peak”
” function: first generation
function: first generation

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 32
Chromosome locations on the surface of the
Chromosome locations on the surface of the
“
“peak
peak”
” function: local maximum
function: local maximum

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 33
Chromosome locations on the surface of the
Chromosome locations on the surface of the
“
“peak
peak”
” function: global maximum
function: global maximum

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 34
Performance graphs for 100 generations of 6
Performance graphs for 100 generations of 6
chromosomes
chromosomes:
: local maximum
local maximum
pc = 0.7, pm = 0.001
G e n e r a t i o n s
Best
Average
80 90 100
60 70
40 50
20 30
10
0
-0.1
0.5
0.6
0.7
F
i
t
n
e
s
s
0
0.1
0.2
0.3
0.4

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 35
Performance graphs for 100 generations of 6
Performance graphs for 100 generations of 6
chromosomes
chromosomes:
: global maximum
global maximum
Best
Average
100
G e n e r a t i o n s
80 90
60 70
40 50
20 30
10
pc = 0.7, pm = 0.01
1.8
F
i
t
n
e
s
s
0
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 36
pc = 0.7, pm = 0.001
Best
Average
20
G e n e r a t i o n s
16 18
12 14
8 10
4 6
2
0
F
i
t
n
e
s
s
0.2
0.4
0.6
0.8
1.0
1.2
1.4
1.6
1.8
Performance graphs for
Performance graphs for 20
20 generations of
generations of
60
60 chromosomes
chromosomes

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 37
Case
Case study
study:
: maintenance
maintenance scheduling
scheduling
I
I Maintenance scheduling problems are usually
Maintenance scheduling problems are usually
solved using a combination of search techniques
solved using a combination of search techniques
and
and heuristics.
heuristics.
I
I These problems are complex and difficult to
These problems are complex and difficult to
solve.
solve.
I
I They are NP
They are NP-
-complete and cannot be solved by
complete and cannot be solved by
combinatorial search
combinatorial search techniques.
techniques.
I
I Scheduling involves competition for limited
Scheduling involves competition for limited
resources, and is complicated by a great number
resources, and is complicated by a great number
of badly formalised constraints.
of badly formalised constraints.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 38
Steps in the GA development
Steps in the GA development
1. Specify
1. Specify the problem, define constraints
the problem, define constraints and
and
optimum
optimum criteria;
criteria;
2
2. Represent
. Represent the problem domain as
the problem domain as a
a
chromosome
chromosome;
;
3.
3. Define
Define a fitness function to evaluate the
a fitness function to evaluate the
chromosome
chromosome performance;
performance;
4. Construct
4. Construct the genetic
the genetic operators;
operators;
5. Run
5. Run the GA and tune its
the GA and tune its parameters.
parameters.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 39
Case
Case study
study
Scheduling of 7 units in 4 equal intervals
Scheduling of 7 units in 4 equal intervals
The problem constraints:
The problem constraints:
I
I The maximum loads expected during four intervals are
The maximum loads expected during four intervals are
80, 90, 65 and 70 MW;
80, 90, 65 and 70 MW;
I
I Maintenance of any unit starts at the beginning of an
Maintenance of any unit starts at the beginning of an
interval and finishes at the end of the same or adjacent
interval and finishes at the end of the same or adjacent
interval. The maintenance cannot be aborted or finished
interval. The maintenance cannot be aborted or finished
earlier than scheduled;
earlier than scheduled;
I
I The net reserve of the power system must be greater or
The net reserve of the power system must be greater or
equal to zero at any interval.
equal to zero at any interval.
The optimum criterion is the maximum of the net
The optimum criterion is the maximum of the net
reserve at any maintenance period.
reserve at any maintenance period.

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 40
Case
Case study
study
Unit data and maintenance requirements
Unit data and maintenance requirements
Unit
number
Unit capacity,
MW
Number of intervals required
for unit maintenance
1 20 2
2 15 2
3 35 1
4 40 1
5 15 1
6 15 1
7 10 1

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 41
Case
Case study
study
Unit gene pools
Unit gene pools
Unit 1: 1 0
1 0 0 1
1 0 0 1
0 1
Unit 2: 1 0
1 0 0 1
1 0 0 1
0 1
Unit 3: 1 0
0 0 0 0
1 0 0 1
0 0 0 0
0 1
Unit 4: 1 0
0 0 0 0
1 0 0 1
0 0 0 0
0 1
Unit 5: 1 0
0 0 0 0
1 0 0 1
0 0 0 0
0 1
Unit 6: 1 0
0 0 0 0
1 0 0 1
0 0 0 0
0 1
Unit 7: 1 0
0 0 0 0
1 0 0 1
0 0 0 0
0 1
Chromosome for the scheduling problem
Chromosome for the scheduling problem
0 1
1 0 0 1
0 1 0 0
0 1 1 0
0 0 0 0
1 0 0 1
0 0 1 0
0 0
Unit 1 Unit 3
Unit 2 Unit 4 Unit 6
Unit 5 Unit 7

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 42
Case
Case study
study
The crossover operator
The crossover operator
0 1
1 0 0 1
0 1 0 0
0 1 1 0
0 0 0 0
1 0 0 1
0 0 1 0
0 0
Parent 1
1 0
1 0 0 1
1 0 0 0
1 0 0 0
0 1 0 1
0 0 1 0
0 0 0 0
1 0
Parent 2
0 1
1 0 0 1
0 1 0 0
0 1 1 0
0 0 0 1
0 0 1 0
0 0 0 0
1 0
Child 1
1 0
1 0 0 1
1 0 0 0
1 0 0 0
0 1 0 0
1 0 0 1
0 0 1 0
0 0
Child 2

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 43
Case
Case study
study
The mutation operator
The mutation operator
1 0
1 0 0 1
1 0 0 0
1 0 0 0
0 1 0 0
1 0 0 1
0 0 1 0
0 0
0 0
1 0
1 0
1 0 0 1
1 0 0 0
1 0 0 0
0 1 0 0
1 0 0 1
0 0 1 0
0 0
0 0
0 1

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 44
Performance
Performance graphs and the best maintenance
graphs and the best maintenance
schedules created in a population of 20 chromosomes
schedules created in a population of 20 chromosomes
G e n e r a t i o n s
0
30
60
90
120
150
Unit 2 Unit 2
Unit 7
Unit 1
Unit 6
Unit 1
Unit 3
Unit 5
Unit 4
1 2 3 4
T i m e i n t e r v a l
M
W
N e t r e s e r v e s:
15 35 35 25
N = 20, pc = 0.7, pm = 0.001
Best
Average
5 15 25 35
10 30
20 40 45 50
G e n e r a t i o n s
0
F
i
t
n
e
s
s
-10
-5
0
5
10
15
(
(a
a) 50
) 50 generations
generations

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 45
Performance
Performance graphs and the best maintenance
graphs and the best maintenance
schedules created in a population of 20 chromosomes
schedules created in a population of 20 chromosomes
G e n e r a t i o n s
0
30
60
1 2 3 4
T i m e i n t e r v a l
M
W
N e t r e s e r v e s :
40 25 20 25
Unit 2
Unit 2
Unit 7
Unit 1
Unit 6
Unit 1
Unit 3
Unit 5
Unit 4
90
120
150
N = 20, pc = 0.7, pm = 0.001
Best
Average
10 30 50 70
20
0 60
40 80 90 100
F
i
t
n
e
s
s
-10
0
10
20
G e n e r a t i o n s
(
(b
b)
) 100
100 generations
generations

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 46
Performance
Performance graphs and the best maintenance
graphs and the best maintenance
schedules created in a population of
schedules created in a population of 100
100 chromosomes
chromosomes
(
(a
a)
) Mutation rate is 0.001
Mutation rate is 0.001
1 2 3 4
T i m e i n t e r v a l
35 25 25 25
Unit 2 Unit 2
Unit 7
Unit 1
Unit 6
Unit 1
Unit 3
Unit 5
Unit 4
0
30
60
M
W
90
120
150
N = 100, pc = 0.7, pm = 0.001
G e n e r a t i o n s
N e t r e s e r v e s :
Best
Average
10 30 50 70
20
0 60
40 80 90 100
-10
F
i
t
n
e
s
s
0
10
20
30

 Negnevitsky, Pearson Education, 2011
Negnevitsky, Pearson Education, 2011 47
Performance
Performance graphs and the best maintenance
graphs and the best maintenance
schedules created in a population of
schedules created in a population of 100
100 chromosomes
chromosomes
(
(b
b)
) Mutation rate is 0.01
Mutation rate is 0.01
1 2 3 4
T i m e i n t e r v a l
N e t r e s e r v e s :
25 25 30 30
Unit 2
Unit 2
Unit 7
Unit 6
Unit 1
Unit 3
Unit 5
Unit 4
0
30
60
M
W
90
120
150
Unit 1
N = 100, pc = 0.7, pm = 0.01
G e n e r a t i o n s
10 30 50 70
20
0 60
40 80 90 100
Best
Average
F
i
t
n
e
s
s
-20
-10
0
10
30
20

lecture-09-evolutionary-computation-genetic-algorithms.pdf

  • 1.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 1 Lecture 9 Lecture 9 Evolutionary Computation: Evolutionary Computation: Genetic algorithms Genetic algorithms I I Introduction, or Introduction, or can can evolution evolution be be intelligent intelligent? ? I I Simulation of Simulation of natural natural evolution evolution I I Genetic Genetic algorithms algorithms I I Case Case study study: : maintenance maintenance scheduling scheduling with with genetic genetic algorithms algorithms I I Summary Summary
  • 2.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 2 I I Intelligence can be defined as the capability of a Intelligence can be defined as the capability of a system to adapt its behaviour to ever system to adapt its behaviour to ever- -changing changing environment. According to Alan Turing, the form environment. According to Alan Turing, the form or appearance of a system is irrelevant to its or appearance of a system is irrelevant to its intelligence. intelligence. I I Evolutionary computation simulates evolution on a Evolutionary computation simulates evolution on a computer. The result of such a simulation is a computer. The result of such a simulation is a series of optimisation algorithms series of optimisation algorithms, usually based on , usually based on a simple set of rules. Optimisation a simple set of rules. Optimisation iteratively iteratively improves the quality of solutions until an optimal, improves the quality of solutions until an optimal, or at least feasible, solution is found. or at least feasible, solution is found. Can evolution be intelligent Can evolution be intelligent? ?
  • 3.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 3 I I The behaviour of The behaviour of an individual organism an individual organism is is an an inductive inference about some yet unknown inductive inference about some yet unknown aspects of its environment. aspects of its environment. If, If, over successive over successive generations, the organism survives, we can say generations, the organism survives, we can say that this organism is capable of learning to predict that this organism is capable of learning to predict changes in its environment. changes in its environment. I I The evolutionary approach is based on The evolutionary approach is based on computational models of natural selection and computational models of natural selection and genetics. We call them genetics. We call them evolutionary evolutionary computation computation, an umbrella term that combines , an umbrella term that combines genetic algorithms genetic algorithms, , evolution strategies evolution strategies and and genetic programming genetic programming. .
  • 4.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 4 I I On 1 July 1858, On 1 July 1858, Charles Darwin Charles Darwin presented his presented his theory of evolution before the theory of evolution before the Linnean Linnean Society of Society of London. This day marks the beginning of a London. This day marks the beginning of a revolution in biology. revolution in biology. I I Darwin Darwin’ ’s s classical classical theory of evolution theory of evolution, together , together with with Weismann Weismann’ ’s s theory of natural selection theory of natural selection and and Mendel Mendel’ ’s s concept of concept of genetics genetics, now represent the , now represent the neo neo- -Darwinian paradigm. Darwinian paradigm. Simulation of Simulation of natural natural evolution evolution
  • 5.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 5 I I Neo Neo- -Darwinism Darwinism is based on processes of is based on processes of reproduction, mutation, competition and selection. reproduction, mutation, competition and selection. The power to reproduce appears to be an essential The power to reproduce appears to be an essential property of life. The power to mutate is also property of life. The power to mutate is also guaranteed in any living organism that reproduces guaranteed in any living organism that reproduces itself in a continuously changing environment. itself in a continuously changing environment. Processes of competition and selection normally Processes of competition and selection normally take place in the natural world, where expanding take place in the natural world, where expanding populations of different species are limited by a populations of different species are limited by a finite space. finite space.
  • 6.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 6 I I Evolution can be seen as a process leading to the Evolution can be seen as a process leading to the maintenance maintenance of a population of a population’ ’s s ability to survive ability to survive and reproduce in a specific environment. This and reproduce in a specific environment. This ability is called ability is called evolutionary fitness evolutionary fitness. . I I Evolutionary fitness can also be viewed as a Evolutionary fitness can also be viewed as a measure of the organism measure of the organism’ ’s ability to anticipate s ability to anticipate changes in its environment. changes in its environment. I I The The fitness, or the quantitative measure of the fitness, or the quantitative measure of the ability to predict environmental changes and ability to predict environmental changes and respond adequately, can be considered as the respond adequately, can be considered as the quality that is quality that is optimised optimised in natural life. in natural life.
  • 7.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 7 How is a population with increasing How is a population with increasing fitness generated? fitness generated? I I Let us consider Let us consider a population of rabbits. Some a population of rabbits. Some rabbits are faster than others, and we may say that rabbits are faster than others, and we may say that these rabbits possess superior fitness, because they these rabbits possess superior fitness, because they have a greater chance of avoiding foxes, surviving have a greater chance of avoiding foxes, surviving and then breeding and then breeding. . I I If two parents have superior fitness, there is a good If two parents have superior fitness, there is a good chance that a combination of their genes will chance that a combination of their genes will produce an offspring with even higher fitness. produce an offspring with even higher fitness. Over time the entire population of rabbits becomes Over time the entire population of rabbits becomes faster to meet their environmental challenges in the faster to meet their environmental challenges in the face of foxes. face of foxes.
  • 8.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 8 I I All methods of evolutionary computation simulate All methods of evolutionary computation simulate natural natural evolution by creating evolution by creating a population of a population of individuals, evaluating their fitness, generating a individuals, evaluating their fitness, generating a new population through genetic operations, and new population through genetic operations, and repeating this process a number of times repeating this process a number of times. . I I We will start with We will start with Genetic Algorithms Genetic Algorithms (GAs) as (GAs) as most of the other evolutionary most of the other evolutionary algorithms can be algorithms can be viewed as variations of viewed as variations of genetic algorithms genetic algorithms. . Simulation of Simulation of natural natural evolution evolution
  • 9.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 9 I I In the early 1970s, John In the early 1970s, John Holland introduced the Holland introduced the concept of genetic algorithms. concept of genetic algorithms. I I His His aim was to make computers do what nature aim was to make computers do what nature does. does. Holland was concerned with Holland was concerned with algorithms algorithms that manipulate strings of binary digits that manipulate strings of binary digits. . I I Each artificial Each artificial “ “chromosomes chromosomes” ” consists of a consists of a number of number of “ “genes genes” ”, and each gene is represented , and each gene is represented by 0 or 1: by 0 or 1: Genetic Algorithms Genetic Algorithms 1 1 0 1 0 1 0 0 0 0 0 1 0 1 1 0
  • 10.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 10 I I Nature has an ability to adapt and learn without Nature has an ability to adapt and learn without being told what to do. In other words, nature being told what to do. In other words, nature finds good chromosomes blindly. finds good chromosomes blindly. GAs GAs do the do the same. Two mechanisms link a GA to the problem same. Two mechanisms link a GA to the problem it is solving: it is solving: encoding encoding and and evaluation evaluation. . I I The GA uses a measure of fitness of individual The GA uses a measure of fitness of individual chromosomes to carry out reproduction. As chromosomes to carry out reproduction. As reproduction takes place, the crossover operator reproduction takes place, the crossover operator exchanges parts of two single chromosomes, and exchanges parts of two single chromosomes, and the mutation operator changes the gene value in the mutation operator changes the gene value in some randomly chosen location of the some randomly chosen location of the chromosome. chromosome.
  • 11.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 11 Step 1 Step 1: : Represent the problem variable domain as Represent the problem variable domain as a chromosome of a fixed length, choose the size a chromosome of a fixed length, choose the size of a chromosome population of a chromosome population N N, the crossover , the crossover probability probability p pc c and the mutation probability and the mutation probability p pm m. . Step Step 2 2: : Define Define a fitness function to measure the a fitness function to measure the performance, or fitness, of an individual performance, or fitness, of an individual chromosome in the problem domain. The fitness chromosome in the problem domain. The fitness function establishes the basis for selecting function establishes the basis for selecting chromosomes that will be mated during chromosomes that will be mated during reproduction. reproduction. Basic Basic genetic genetic algorithms algorithms
  • 12.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 12 Step 3 Step 3: : Randomly generate an initial population of Randomly generate an initial population of chromosomes of size chromosomes of size N N: : x x1 1, , x x2 2, . . . , , . . . , x xN N Step 4 Step 4: : Calculate the fitness of each individual Calculate the fitness of each individual chromosome: chromosome: f f ( (x x1 1), ), f f ( (x x2 2), . . . , ), . . . , f f ( (x xN N) ) Step 5 Step 5: : Select a pair of chromosomes for mating Select a pair of chromosomes for mating from the current population. Parent from the current population. Parent chromosomes are selected with a probability chromosomes are selected with a probability related to their fitness. related to their fitness.
  • 13.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 13 Step 6 Step 6: : Create a pair of offspring chromosomes by Create a pair of offspring chromosomes by applying the genetic operators applying the genetic operators − − crossover crossover and and mutation mutation. . Step 7 Step 7: : Place the created offspring chromosomes Place the created offspring chromosomes in the new population. in the new population. Step 8 Step 8: : Repeat Repeat Step 5 Step 5 until the size of the new until the size of the new chromosome population becomes chromosome population becomes equal to the equal to the size of the size of the initial population, initial population, N N. . Step 9 Step 9: : Replace Replace the initial (parent) chromosome the initial (parent) chromosome population with the new (offspring) population. population with the new (offspring) population. Step Step 10 10: : Go to Go to Step 4 Step 4, and repeat the process until , and repeat the process until the termination criterion is satisfied. the termination criterion is satisfied.
  • 14.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 14 I I GA represents an iterative process. Each iteration is GA represents an iterative process. Each iteration is called a called a generation generation. A typical number of generations . A typical number of generations for a simple GA can range from 50 to over for a simple GA can range from 50 to over 500. The 500. The entire set entire set of generations is called a of generations is called a run run. . I I Because GAs use a stochastic search method, the Because GAs use a stochastic search method, the fitness of a population may fitness of a population may remain stable for a remain stable for a number of generations before a superior chromosome number of generations before a superior chromosome appears. appears. I I A common practice is to terminate a GA after a A common practice is to terminate a GA after a specified number of generations and then examine specified number of generations and then examine the best chromosomes in the population. If no the best chromosomes in the population. If no satisfactory solution is found, the GA is restarted. satisfactory solution is found, the GA is restarted. Genetic Genetic algorithms algorithms
  • 15.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 15 A simple example will help us to understand how A simple example will help us to understand how a GA works. Let us find the maximum value of a GA works. Let us find the maximum value of the function (15 the function (15x x − − x x2 2 ) where parameter ) where parameter x x varies varies between 0 and 15. For simplicity, we may between 0 and 15. For simplicity, we may assume that assume that x x takes only integer values. Thus, takes only integer values. Thus, chromosomes can be built with only four chromosomes can be built with only four genes: genes: Genetic Genetic algorithms algorithms: : case case study study Integer Binary code Integer Binary code Integer Binary code 1 0 0 0 1 6 0 1 1 0 11 1 0 1 1 2 0 0 1 0 7 0 1 1 1 12 1 1 0 0 3 0 0 1 1 8 1 0 0 0 13 1 1 0 1 4 0 1 0 0 9 1 0 0 1 14 1 1 1 0 5 0 1 0 1 10 1 0 1 0 15 1 1 1 1
  • 16.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 16 Suppose that the size of the chromosome population Suppose that the size of the chromosome population N N is 6, the crossover probability is 6, the crossover probability p pc c equals 0.7, and equals 0.7, and the mutation probability the mutation probability p pm m equals 0.001. The equals 0.001. The fitness function in our example is defined fitness function in our example is defined by by f f( (x x) = ) = 15 15 x x − − − − − − − − x x2 2
  • 17.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 17 The fitness function and chromosome locations The fitness function and chromosome locations Chromosome label Chromosome string Decoded integer Chromosome fitness Fitness ratio, % X1 1 1 0 0 12 36 16.5 X2 0 1 0 0 4 44 20.2 X3 0 0 0 1 1 14 6.4 X4 1 1 1 0 14 14 6.4 X5 0 1 1 1 7 56 25.7 X6 1 0 0 1 9 54 24.8 x 50 40 30 20 60 10 0 0 5 10 15 f(x) (a) Chromosome initial locations. x 50 40 30 20 60 10 0 0 5 10 15 (b) Chromosome final locations.
  • 18.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 18 I I In natural selection, only the fittest species can In natural selection, only the fittest species can survive, breed, and thereby pass their genes on to survive, breed, and thereby pass their genes on to the next generation. the next generation. GAs GAs use a similar approach, use a similar approach, but unlike nature, the size of the chromosome but unlike nature, the size of the chromosome population remains unchanged from one population remains unchanged from one generation to the next. generation to the next. I I The last column in Table shows the ratio of the The last column in Table shows the ratio of the individual chromosome individual chromosome’ ’s fitness to the s fitness to the population population’ ’s total fitness. This ratio determines s total fitness. This ratio determines the chromosome the chromosome’ ’s chance of being selected for s chance of being selected for mating. mating. The chromosome The chromosome’ ’s average fitness s average fitness improves from one generation to the next. improves from one generation to the next.
  • 19.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 19 Roulette Roulette wheel wheel selection selection The most commonly used chromosome selection The most commonly used chromosome selection techniques is the techniques is the roulette wheel selection roulette wheel selection. . 100 0 16.5 36.7 43.1 49.5 75.2 X1: 16.5% X2: 20.2% X3: 6.4% X4: 6.4% X5: 25.3% X6: 24.8%
  • 20.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 20 Crossover operator Crossover operator I I In our example, we have an initial population of 6 In our example, we have an initial population of 6 chromosomes. Thus, to establish the same chromosomes. Thus, to establish the same population in the next generation, the roulette population in the next generation, the roulette wheel would be spun six times wheel would be spun six times. . I I Once a pair of parent chromosomes is selected, Once a pair of parent chromosomes is selected, the the crossover crossover operator is applied. operator is applied.
  • 21.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 21 I I First, the crossover operator randomly chooses a First, the crossover operator randomly chooses a crossover point where two parent chromosomes crossover point where two parent chromosomes “ “break break” ”, and then exchanges the chromosome , and then exchanges the chromosome parts after that point. As a result, two new parts after that point. As a result, two new offspring are created. offspring are created. I I If a pair of chromosomes does not cross over, If a pair of chromosomes does not cross over, then then the chromosome cloning takes place, and the the chromosome cloning takes place, and the offspring are created as exact copies of each offspring are created as exact copies of each parent. parent.
  • 22.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 22 X6i 1 0 0 0 0 1 0 X2i 0 0 1 0 X2i 0 1 1 1 X5i 0 X1i 0 1 1 1 X5i 1 0 1 0 0 1 0 0 1 1 1 0 1 0 Crossover Crossover
  • 23.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 23 I I Mutation represents a change in Mutation represents a change in the gene. the gene. I I Mutation is a background operator. Its role is to Mutation is a background operator. Its role is to provide a guarantee that provide a guarantee that the search algorithm is the search algorithm is not trapped on a local optimum. not trapped on a local optimum. I I The mutation operator flips a randomly selected The mutation operator flips a randomly selected gene in a chromosome. gene in a chromosome. I I The mutation probability is quite small in nature, The mutation probability is quite small in nature, and is kept low for and is kept low for GAs GAs, typically in the range , typically in the range between 0.001 and 0.01. between 0.001 and 0.01. Mutation operator Mutation operator
  • 24.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 24 Mutation Mutation 0 1 1 1 X5'i 0 1 0 X6'i 1 0 0 0 0 1 0 X2'i 0 1 0 0 0 1 1 1 1 X5i 1 1 1 X1"i 1 1 X2"i 0 1 0 0 X1'i 1 1 1 0 1 0 X2i
  • 25.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 25 The The genetic algorithm cycle genetic algorithm cycle 1 0 1 0 X1i Generation i 0 0 1 0 X2i 0 0 0 1 X3i 1 1 1 0 X4i 0 1 1 1 X5i f = 56 1 0 0 1 X6i f = 54 f = 36 f = 44 f = 14 f = 14 1 0 0 0 X1i+1 Generation (i + 1) 0 0 1 1 X2i+1 1 1 0 1 X3i+1 0 0 1 0 X4i+1 0 1 1 0 X5i+1 f = 54 0 1 1 1 X6i+1 f = 56 f = 56 f = 50 f = 44 f = 44 Crossover X6i 1 0 0 0 0 1 0 X2i 0 0 1 0 X2i 0 1 1 1 X5i 0 X1i 0 1 1 1 X5i 1 0 1 0 0 1 0 0 1 1 1 0 1 0 Mutation 0 1 1 1 X5'i 0 1 0 X6'i 1 0 0 0 0 1 0 X2'i 0 1 0 0 0 1 1 1 1 X5i 1 1 1 X1"i 1 1 X2"i 0 1 0 0 X1'i 1 1 1 0 1 0 X2i
  • 26.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 26 Genetic Genetic algorithms algorithms: : case case study study I I Suppose it is desired to find the maximum of the Suppose it is desired to find the maximum of the “ “peak peak” ” function of two variables: function of two variables: where parameters where parameters x x and and y y vary between vary between − −3 and 3. 3 and 3. I I The first step is to represent the problem variables The first step is to represent the problem variables as a as a chromosome chromosome − − parameters parameters x x and and y y as a as a concatenated binary string: concatenated binary string: 2 2 2 2 ) ( ) 1 ( ) , ( 3 3 ) 1 ( 2 y x y x e y x x e x y x f − − + − − − − − − = 1 0 0 0 1 1 0 0 0 1 0 1 1 1 0 1 y x
  • 27.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 27 I I We also choose We also choose the size of the chromosome the size of the chromosome population, for instance 6, and randomly generate population, for instance 6, and randomly generate an initial population. an initial population. I I The next step is to calculate the fitness of each The next step is to calculate the fitness of each chromosome. This is done in two stages. chromosome. This is done in two stages. I I First, a chromosome, that is a string of 16 bits, is First, a chromosome, that is a string of 16 bits, is partitioned into two 8 partitioned into two 8- -bit strings: bit strings: 10 0 1 2 3 4 5 6 7 2 ) 138 ( 2 0 2 1 2 0 2 1 2 0 2 0 2 0 2 1 ) 10001010 ( = × + × + × + × + × + × + × + × = and 10 0 1 2 3 4 5 6 7 2 ) 59 ( 2 1 2 1 2 0 2 1 2 1 2 1 2 0 2 0 ) 00111011 ( = × + × + × + × + × + × + × + × = I I Then these strings are converted from binary Then these strings are converted from binary (base 2) to decimal (base 10): (base 2) to decimal (base 10): 1 0 0 0 1 1 0 0 0 1 0 1 1 1 0 1 and
  • 28.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 28 I I Now the range of integers that can be handled by Now the range of integers that can be handled by 8 8- -bits, that is the range from 0 to (2 bits, that is the range from 0 to (28 8 − − 1), is 1), is mapped to the actual range of parameters mapped to the actual range of parameters x x and and y y, , that is the range from that is the range from − −3 to 3: 3 to 3: I I To To obtain the actual values of obtain the actual values of x x and and y y, we multiply , we multiply their decimal values by 0.0235294 and subtract 3 their decimal values by 0.0235294 and subtract 3 from the results: from the results: 0235294 . 0 1 256 6 = − 2470588 . 0 3 0235294 . 0 ) 138 ( 10 = − × = x and 6117647 . 1 3 0235294 . 0 ) 59 ( 10 − = − × = y
  • 29.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 29 I I Using decoded values of Using decoded values of x x and and y y as inputs in the as inputs in the mathematical function, the GA calculates the mathematical function, the GA calculates the fitness of each chromosome. fitness of each chromosome. I I To To find the maximum of the find the maximum of the “ “peak peak” ” function, we function, we will use crossover with the probability equal to 0.7 will use crossover with the probability equal to 0.7 and mutation with the probability equal to 0.001. and mutation with the probability equal to 0.001. As we mentioned earlier, a common practice in As we mentioned earlier, a common practice in GAs GAs is to specify the number of generations. is to specify the number of generations. Suppose the desired number of generations is 100. Suppose the desired number of generations is 100. That is, the GA will create 100 generations of 6 That is, the GA will create 100 generations of 6 chromosomes before stopping. chromosomes before stopping.
  • 30.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 30 Chromosome locations on the surface of the Chromosome locations on the surface of the “ “peak peak” ” function: initial population function: initial population
  • 31.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 31 Chromosome locations on the surface of the Chromosome locations on the surface of the “ “peak peak” ” function: first generation function: first generation
  • 32.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 32 Chromosome locations on the surface of the Chromosome locations on the surface of the “ “peak peak” ” function: local maximum function: local maximum
  • 33.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 33 Chromosome locations on the surface of the Chromosome locations on the surface of the “ “peak peak” ” function: global maximum function: global maximum
  • 34.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 34 Performance graphs for 100 generations of 6 Performance graphs for 100 generations of 6 chromosomes chromosomes: : local maximum local maximum pc = 0.7, pm = 0.001 G e n e r a t i o n s Best Average 80 90 100 60 70 40 50 20 30 10 0 -0.1 0.5 0.6 0.7 F i t n e s s 0 0.1 0.2 0.3 0.4
  • 35.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 35 Performance graphs for 100 generations of 6 Performance graphs for 100 generations of 6 chromosomes chromosomes: : global maximum global maximum Best Average 100 G e n e r a t i o n s 80 90 60 70 40 50 20 30 10 pc = 0.7, pm = 0.01 1.8 F i t n e s s 0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6
  • 36.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 36 pc = 0.7, pm = 0.001 Best Average 20 G e n e r a t i o n s 16 18 12 14 8 10 4 6 2 0 F i t n e s s 0.2 0.4 0.6 0.8 1.0 1.2 1.4 1.6 1.8 Performance graphs for Performance graphs for 20 20 generations of generations of 60 60 chromosomes chromosomes
  • 37.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 37 Case Case study study: : maintenance maintenance scheduling scheduling I I Maintenance scheduling problems are usually Maintenance scheduling problems are usually solved using a combination of search techniques solved using a combination of search techniques and and heuristics. heuristics. I I These problems are complex and difficult to These problems are complex and difficult to solve. solve. I I They are NP They are NP- -complete and cannot be solved by complete and cannot be solved by combinatorial search combinatorial search techniques. techniques. I I Scheduling involves competition for limited Scheduling involves competition for limited resources, and is complicated by a great number resources, and is complicated by a great number of badly formalised constraints. of badly formalised constraints.
  • 38.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 38 Steps in the GA development Steps in the GA development 1. Specify 1. Specify the problem, define constraints the problem, define constraints and and optimum optimum criteria; criteria; 2 2. Represent . Represent the problem domain as the problem domain as a a chromosome chromosome; ; 3. 3. Define Define a fitness function to evaluate the a fitness function to evaluate the chromosome chromosome performance; performance; 4. Construct 4. Construct the genetic the genetic operators; operators; 5. Run 5. Run the GA and tune its the GA and tune its parameters. parameters.
  • 39.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 39 Case Case study study Scheduling of 7 units in 4 equal intervals Scheduling of 7 units in 4 equal intervals The problem constraints: The problem constraints: I I The maximum loads expected during four intervals are The maximum loads expected during four intervals are 80, 90, 65 and 70 MW; 80, 90, 65 and 70 MW; I I Maintenance of any unit starts at the beginning of an Maintenance of any unit starts at the beginning of an interval and finishes at the end of the same or adjacent interval and finishes at the end of the same or adjacent interval. The maintenance cannot be aborted or finished interval. The maintenance cannot be aborted or finished earlier than scheduled; earlier than scheduled; I I The net reserve of the power system must be greater or The net reserve of the power system must be greater or equal to zero at any interval. equal to zero at any interval. The optimum criterion is the maximum of the net The optimum criterion is the maximum of the net reserve at any maintenance period. reserve at any maintenance period.
  • 40.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 40 Case Case study study Unit data and maintenance requirements Unit data and maintenance requirements Unit number Unit capacity, MW Number of intervals required for unit maintenance 1 20 2 2 15 2 3 35 1 4 40 1 5 15 1 6 15 1 7 10 1
  • 41.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 41 Case Case study study Unit gene pools Unit gene pools Unit 1: 1 0 1 0 0 1 1 0 0 1 0 1 Unit 2: 1 0 1 0 0 1 1 0 0 1 0 1 Unit 3: 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 Unit 4: 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 Unit 5: 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 Unit 6: 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 Unit 7: 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 Chromosome for the scheduling problem Chromosome for the scheduling problem 0 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 Unit 1 Unit 3 Unit 2 Unit 4 Unit 6 Unit 5 Unit 7
  • 42.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 42 Case Case study study The crossover operator The crossover operator 0 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 0 1 0 0 1 0 0 1 0 0 0 Parent 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 0 1 0 0 1 0 0 0 0 0 1 0 Parent 2 0 1 1 0 0 1 0 1 0 0 0 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 Child 1 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 Child 2
  • 43.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 43 Case Case study study The mutation operator The mutation operator 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 1 0 1 0 1 0 0 1 1 0 0 0 1 0 0 0 0 1 0 0 1 0 0 1 0 0 1 0 0 0 0 0 0 1
  • 44.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 44 Performance Performance graphs and the best maintenance graphs and the best maintenance schedules created in a population of 20 chromosomes schedules created in a population of 20 chromosomes G e n e r a t i o n s 0 30 60 90 120 150 Unit 2 Unit 2 Unit 7 Unit 1 Unit 6 Unit 1 Unit 3 Unit 5 Unit 4 1 2 3 4 T i m e i n t e r v a l M W N e t r e s e r v e s: 15 35 35 25 N = 20, pc = 0.7, pm = 0.001 Best Average 5 15 25 35 10 30 20 40 45 50 G e n e r a t i o n s 0 F i t n e s s -10 -5 0 5 10 15 ( (a a) 50 ) 50 generations generations
  • 45.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 45 Performance Performance graphs and the best maintenance graphs and the best maintenance schedules created in a population of 20 chromosomes schedules created in a population of 20 chromosomes G e n e r a t i o n s 0 30 60 1 2 3 4 T i m e i n t e r v a l M W N e t r e s e r v e s : 40 25 20 25 Unit 2 Unit 2 Unit 7 Unit 1 Unit 6 Unit 1 Unit 3 Unit 5 Unit 4 90 120 150 N = 20, pc = 0.7, pm = 0.001 Best Average 10 30 50 70 20 0 60 40 80 90 100 F i t n e s s -10 0 10 20 G e n e r a t i o n s ( (b b) ) 100 100 generations generations
  • 46.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 46 Performance Performance graphs and the best maintenance graphs and the best maintenance schedules created in a population of schedules created in a population of 100 100 chromosomes chromosomes ( (a a) ) Mutation rate is 0.001 Mutation rate is 0.001 1 2 3 4 T i m e i n t e r v a l 35 25 25 25 Unit 2 Unit 2 Unit 7 Unit 1 Unit 6 Unit 1 Unit 3 Unit 5 Unit 4 0 30 60 M W 90 120 150 N = 100, pc = 0.7, pm = 0.001 G e n e r a t i o n s N e t r e s e r v e s : Best Average 10 30 50 70 20 0 60 40 80 90 100 -10 F i t n e s s 0 10 20 30
  • 47.
      Negnevitsky, PearsonEducation, 2011 Negnevitsky, Pearson Education, 2011 47 Performance Performance graphs and the best maintenance graphs and the best maintenance schedules created in a population of schedules created in a population of 100 100 chromosomes chromosomes ( (b b) ) Mutation rate is 0.01 Mutation rate is 0.01 1 2 3 4 T i m e i n t e r v a l N e t r e s e r v e s : 25 25 30 30 Unit 2 Unit 2 Unit 7 Unit 6 Unit 1 Unit 3 Unit 5 Unit 4 0 30 60 M W 90 120 150 Unit 1 N = 100, pc = 0.7, pm = 0.01 G e n e r a t i o n s 10 30 50 70 20 0 60 40 80 90 100 Best Average F i t n e s s -20 -10 0 10 30 20