0% found this document useful (0 votes)
49 views116 pages

Ga 3

This document provides an introduction and overview of genetic algorithms. It discusses how genetic algorithms are inspired by biological evolution and natural selection. The key aspects of genetic algorithms covered include: - Representing potential solutions to an optimization problem as a population of chromosomes. - Using genetic operators like crossover and mutation to generate new populations from existing ones, selecting the fittest solutions to breed into the next generation. - Encoding problem variables into genetic representations like binary strings and using fitness functions to evaluate chromosomes based on the problem being solved. - Exploring the search space and converging toward optimal solutions through successive generations, similar to Darwinian evolution and survival of the fittest.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
49 views116 pages

Ga 3

This document provides an introduction and overview of genetic algorithms. It discusses how genetic algorithms are inspired by biological evolution and natural selection. The key aspects of genetic algorithms covered include: - Representing potential solutions to an optimization problem as a population of chromosomes. - Using genetic operators like crossover and mutation to generate new populations from existing ones, selecting the fittest solutions to breed into the next generation. - Encoding problem variables into genetic representations like binary strings and using fitness functions to evaluate chromosomes based on the problem being solved. - Exploring the search space and converging toward optimal solutions through successive generations, similar to Darwinian evolution and survival of the fittest.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 116

Genetic Algorithm

Introduction
In all fields of human activities we need to take
some decisions.
And during decision making process we are trying
to make the objective function optimum.
During decision making process the following
major questions arises:
– Does an optimal solution exist?
– Is it unique?
– What is the procedure?
– How sensitive the optimal solution is?
– How the solution behaves for small changes in
parameters?
Introduction
Since 1940, several optimization problems have
been tackled by classical procedures including:
– Linear programming
– Transportation
– Assignment
– Non-linear programming
– Dynamic programming
– Inventory
– Queuing
– Replacement
– Scheduling
Introduction
In recent past nontraditional search and
optimization methods have become popular
These algorithms includes
– Simulated annealing (Kirkpatrik, et al. 1983)
– Ant colony optimization method (Dorgio and
Caro,1999)
– Random cost (Kost and Baumann, 1999)
– Evolution strategy (Kost 1995)
– Genetic algorithms (Holland, 1975)
– Cellular automata (Wolfran, 1994)
Genetic Algorithm : History
The idea of evolutionary computing was introduced
on 1960 by I. Rechenberg in his work on
Evolutionary strategies.
Genetic algorithms are computerized search and
optimization algorithms based on the mechanics of
natural genetics and natural selection.
– Introduced by Prof. Holland of University of Michigan,
Ann Arbor
– Concept was published on 1975.
GA : Basic concepts

“Genetic Algorithms are good at


taking large, potentially huge
search spaces and navigating
them, looking for optimal
combinations of things,
solutions you might not
otherwise find in a lifetime.”

- Salvatore Mangano
Computer Design, May 1995
GA : Basic concepts
For each problem the GA needs design space to be
converted into genetic space.
– So variables are need to be coded to get a solution
– The main advantage of coding is that it discretizes the
search space even though the function may be continuous.
More important characteristics of the GA is that it
takes a population of points at a one time in contrast
to the single point.
– So it can be considered as a multi-objective optimization
algorithm
Biological Background
All living organisms consists of cells.
In each cell, there is a set of chromosomes
Strings of DNA
A chromosome consists of genes on blocks of
DNA
Each gene encodes a particular pattern called traits
– Ex. Colour of eyes, intelligence etc…
Each gene has its own position in the chromosome
search space called locus.
Complete set of all chromosomes is called genome
and a particular set of genes is in genome is called
genotype.
Biological Background
The genotype is based on organism’s
phenotype, its physical and mental
characteristics.
DNA & Chromosome
GA : Search space
To solve a problem we need to works towards
some solution which is the best among others.
– The space for all possible solution is called the search
space.
Each solution is marked by its value of the fitness
of the problem – the objective function
‘Looking for a solution’ means looking for
extrema in search space.
The search space can be known by the time of
solving a problem and we generate other points as
the process of finding the solution continues.
GA : Search space
Problem:
– Search space is extremely large.
– One does not know from which point start looking
solution.
This is done in GA very efficiently
– Based on the principle of Darwinian theory of the
survival of the fittest.
Drawin’s Observation
In “the Origin of Species”,
1. All the species have the potential for exponential
increase in numbers
2. Offspring tends to resemble their parents but not
identical to their parents
3. Slight variations of offspring significantly affect
the chance of survival
4. Individuals whose variations adapting themselves
better to the new conditions would have better
chance to survive (Natural selection)
Natural Selection (Darwin’s theory)
Genetic contents = survival capacity = features
Reproduction
– recombination (or crossover) first occurs. Genes from
parents combine to form a whole new chromosome.
– Newly created offspring mutated, elements of DNA are
changed. à Diversity
changes are caused by errors in copying genes from
parents.
“Survival of the fittest”
– Gene of the fittest survive, gene of weaker die out
– Elitism
Evolution = change of species’ feature to fit environment
Genetic Algorithm / Evolutionary
Strategy
Inspired by theory of biological evolution
– Search proceeds through maintenance of a population of solutions
– Reproduction biased in favor of better individuals
– Diversity obtained by mutation and recombination
– J. Holland, Adaptation in Natural and Artificial Systems, U of Michigan
Press, 1975
Evolutionary process for optimization
– Improves initial solutions
Stochastic Search
– High probability of locating global optimal solution
– Local minima escape
minimum value
GA: Search space exploration
Started with a set of initial solution (represented
by chromosome) called population.
Solution for one population are taken and used to
form a new population.
– This is motivated by the hope that new population
(offspring) will be better than the old one.
New populations are selected according to their
fitness.
– The more suitable they are, the more chances they have
to reproduce.
New populations are created until no further
improvement in best solution achieved for last few
generation.
Genetic Algorithms

Steps

children
reproduction modification

parents modified
evaluated children
children
population evaluation

deleted
members

discard
Simple GA
Simple_Genetic_Algorithm()
{
Initialize the Population;

Calculate Fitness Function;

While(Fitness Value != Optimal)


{
Selection; //Natural Selection, Survival Of Fittest

Crossover; //Propagate favorable characteristics

Mutation; //Mutation
Calculate Fitness Function;
}
}
GA : Main aspects
To improve the search direction different
randomized operators are used that
improves the search space in adaptive
manner.
Three main aspects of using GA are:
– Definition and implementation of genetic
representation
– Definition of objective function
– Definition and implementation of genetic
operators
GA’s Five Decision Points
Encoding technique (“chromosome structure”)
– Mechanism to encode solution
Evaluation function (“environment”)
– Fitness function
Selection procedure (“creation”)
Generating Chromosome diversity (“evolution”)
– Crossover, mutation
Parameter settings (practice and art)
– Termination condition
– (Random) Initialization of population
Encoding mechanisms
Many ways to represent individual genes.
– Binary encoding
– Octal encoding
– Hexadecimal encoding
– Permutation encoding
– Value encoding
– Tree encoding
The type of encoding technique used for a
chromosome depends on the type of problem it suits
more.
Binary encoding
Here chromosome is represented by a binary
string.
– Ex: Chromosome A 101101100011
Chromosome B 010011001100
Binary encoding gives many possible
chromosomes even with small variables.
Binary encoding
Suppose the objective function is a two variable
function f(x1,x2)
– we want to code a two variable function assuming four
bits are used for each variable.
– Every variable has both upper and lower limit as xiL£ xi £
xiU
– So a chromosome can be represented as
1011 0110 (4-bit for each variable)
– Knowing xiL and xiU , the equivalent value for any string
can be obtained as
xi = xiL + (xiU – xiL)/(2ni –1) ´ (decoded value of the string)
Binary encoding
Example: Let xiL=2 and xiU=17
– Then for the chromosome 1011 0110 the value of
the variable x1 can be obtained as 2+(17-2)/15 x 11
= 13.
– Hence cost function can be calculated accordingly
based on the function f(x1,x2).
Binary Encoding : Some points
It is not necessary to code all the variables in
equal substring length.
Length depends on the desired accuracy in that
variable.
– For n-bit length coding of a variable the obtainable
accuracy or precision is e=(xiU – xiL)/2n
Again it is not always necessary for coding of
the variables.
– It depends on the type of problems we are trying to
solve.
Octal encoding
In this case instead of using binary string
hexadecimal value is used.
So a four bit octal string can give more
accuracy than the equal length binary string
The obtainable accuracy in this variable
encoding is (xiU – xiL)/8ni
Hexadecimal encoding
Similar to the binary and octal encoding each variable
is encoded with hexadecimal form
So the accuracy is better than the previous ones and it
is (xiU – xiL)/16ni

It is noted that encoding can be done for any base b


and bits of ni length.
– So obtainable accuracy will be then (xiU – xiL)/bni
Permutation encoding

This is generally used for ordering


problems.
– Example: Traveling sales man problem.
Chromosome A: 1 5 3 2 4 7 9 8 6
Chromosome B: 8 5 6 7 2 3 1 4 9
In this encoding mechanism every
chromosome is represented by a string of
numbers
– String of numbers representing the sequence.
Value encoding
In this coding scheme every chromosome is
represented by a string of some values.
The values can be anything connected to the
problem.
Example:
– Chromosome A: 1.234 5.345 6.125 7.341
– Chromosome B: (back) (right) (forward) (left)
Fitness function
GAs mimic the Darwinian theory of survival
of the fittest and principle of nature to make a
search process.
Fitness function is derived from objective
function.
The fitness function quantifies the optimality
of a solution.
Using this fitness value chromosome can be
ranked against all other chromosomes.
Example : fitness function
Example:
– Representation of a path through a
square maze:
F(p) called Objective
Function :Shortest legal path
to goal
– F(pn) = S(steps)

Representation: N=00, E=10,


S=11,W=01
00 10 10 00 10 11 10 10 00 00 10 00 10 10 00 01 00 10 00 10
Reproduction
Reproduction is usually the first operator applied on
the population
Chromosomes are selected in the population to be
parents to cross over and produce offspring.
– This operator is sometimes called selection operator.
There exist a number of reproduction operators in GA
literature.
– Roulette-wheel selection
– Tournament selection
– Rank selection
– Steady-state selection
– Elitism
Roulette-wheel selection
A string is selected from the mating pool with a
probability proportional to the fitness.
– Thus i-th string in the population is selected with a
probability proportional to Fi, where Fi is the fitness value
for that string.
– Since the population size is fixed so sum of the
probabilities of each string being selected for the mating
pool must be one.
Fi
p
– The probability of the i-th selected string is i = n
– n is the population size åF
j =1
j
Roulette-wheel selection
Example:
Population Population F Probability pi
No.
1 0000 0000 1 0.0429
2 0010 0001 2.1 0.090
3 0001 0101 3.11 0.1336
4 0010 1000 4.01 0.1723
5 0110 1010 4.66 0.200
6 1110 1000 1.91 0.028
7 1110 1101 1.93 0.0829
8 0111 1100 4.55 0.1955
Roulette-wheel selection
One way to implement this Roulette-Wheel marked for eight individuals according to
fitness

selection scheme by using a


1
Roulette-wheel 20
5
9 2
3
The circumference of Roulette- 3 4

wheel for each string marked 5


6
8
proportionate to string’s fitness. 17 7
8
So more the probability of a 8

chromosome, high chances of 20

selecting that chromosome for


mating.
Roulette-wheel selection :Simulation
Simulation of Roulette-wheel can be done by
calculating cumulative probability of each
chromosome.
So the i-th chromosome has the cumulative
probability from Pi-1 to Pi.
So for selecting a chromosome for mating generate a
random number between 0 to 1.
The chromosome that represents the chosen random
number in the cumulative probability range is copied
to the mating pool.
Roulette-wheel selection :Simulation
Example:
Sl. Population F Probability Cumulative Random Selected String count Expected
No pi probability number from String in mating pool Count
. 0-1 (True count)
1 0000 0000 1 0.0429 0.0429 0.259 3 1 0.34=0
2 0010 0001 2.1 0.090 0.1329 0.038 1 1 0.72=1
3 0001 0101 3.11 0.1336 0.266 0.486 5 1 1.068=1
4 0010 1000 4.01 0.1723 0.438 0.428 4 2 1.38=1
5 0110 1010 4.66 0.200 0.638 0.095 2 2 1.6=2
6 1110 1000 1.91 0.028 0.720 0.3 4 0 0.224=0
7 1110 1101 1.93 0.0829 0.809 0.616 5 0 0.663=1
8 0111 1100 4.55 0.1955 1.0 0.897 8 1 1.564=2

If a random number of 0.428 is created then the fourth string gets a copy in
the mating pool.
Some important issues in genetic
search
There are two important issues (Whitely 1989) in
genetic search
– Population diversity:
Genes from the already discovered good individuals are exploited
while promising the new areas of the search space continue to be
explored.
– Selective pressure:
The degree which the better individuals are favored.
So higher the selective pressure, the better individuals
are favored.
– Improve population fitness over succeeding generations
Some important issues in genetic
search
Again the convergence rate of the GA is largely
determined by the selective pressure and population
diversity.
– Higher selective pressure results in higher convergence
rate.
– But if it is too high it is expected that it will terminate
prematurely in a local minima as exploitation of population
diversity is lost.
– If it is too low then convergence will take much time to get
the solution.
So we need to adjust (fine tuning) these two things
such that GA perform correctly.
Problem in Roulette-wheel selection
Whitely identified two main problems are
– Stagnation of search because it lacks selection pressure
– Premature convergence of the search because it causes the
search to narrow down too quickly.
Example:
– Suppose the best chromosome fitness is 90%.
– So other chromosomes will have very less chances to be
selected.
So convergence will be too quickly and
Search will stagnant

Improved Version of this method also exist: Stochastic Remainder selection


Tournament selection
The tournament selection strategy provides selective
pressure by holding a tournament competition among
Nu individuals
The chromosome having highest fitness F is the
winner of Nu.
The tournament competitors and the winner then
inserted into the mating pool.
The tournament competition is repeated until the
mating pool for generating new offspring is filled.
Tournament selection : Example
Population No. Population F
1 0000 0000 1
2 0010 0001 2.1
3 0001 0101 3.11
4 0010 1000 4.01
5 0110 1010 4.66
6 1110 1000 1.91
7 1110 1101 1.93
8 0111 1100 4.55
Step 1: Select chromosome 2 and 4 randomly
– Winner 4 (0010 10000)
Step 2: Select chromosome 3 and 8 randomly
– Winner 8 (0111 1100)
Step 3: Select chromosome 1 and 3 randomly
– Winner 3 (0001 0101)
Tournament selection : Example
Similarly other populations are selected from mating
pool as
Individuals Selected
4 and 5 5
1 and 6 6
1 and 2 2
4 and 2 4
8 and 3 8
So winners are 4, 8, 3, 5, 6, 2, 4, 8
– 2, 3, 5, 6 winner one time
– 4, 8 chosen twice
– 1 and 7 not chosen
Rank selection
Ranks the chromosomes according to fitness and get the
ranking.
The worst will have fitness 1, the next 2 and the best will have
fitness N (number of chromosome in population).
Let r(i) denotes the rank of the chromosome i.
– So r(imost_fit_individual)=N and r(ileast_fit_individual)=1.
Let N -1
be the sum of the rankings of all individuals.
rsum = å r (i )
i =0

Then the probability that an individual will be selected as


Ps(i)=r(i)/rsum
This method can lead to slow convergence
– as the best chromosome does not differ so much from the other
Rank Selection : Example
i Fitness F Rank Ps(i) Ps(i)
r(i) (Proportional) (Rank)
1 8 2 8/132=0.06 2/10=0.2
2 19 3 19/132=0.14 3/10=0.3
3 5 1 5/132=0.04 1/10=0.1
4 100 4 100/132=0.76 4/10=0.4
FSum=132 rsum=10

• Behaviorally, rank selection differs from proportional selection is


that it tends to exact weaker selection pressure in diverse
populations.
Steady-state selection
This is not a particular method of selecting parents
The main idea is that bigger part of the population
should survive to next generation.
In every generation a few ( good individuals with
highest fitness) chromosomes are selected for
creating new offspring.
Some (bad with low fitness) chromosomes are
removed and new offspring is placed in that place
The rest of population survives a new generation.
Steady-state selection
This is often used in evolving rule-based
systems in which
– incremental learning (and remembering what has
already been learned) is important.
– In which members of the population collectively
(rather than individually) solve the problem at
hand.
Elitism (Jong 1975)
In this method, first the best chromosome, or few best
chromosomes are copied to new population.
The rest is done in classic way.
Elitism can very rapidly increase the performance of
GA
– As it prevents loosing the best found solution
Goldberg(1989) suggests that
– if F, the fitness is +ve and for minimization problem
Change fitness to fi = (Fmax – Fmin) – Fi so that all fitness values are
non-negative.
– If F is +ve and for maximization problem then fi = Fi
Generation Gap and Steady-state
replacement
The generation gap is defined as the proportion
of the individuals which are replaced in each
generation.
More recent trends has favored steady-state
replacement and in each generation a few
(typically two) are replaced.
Evolution
GA makes use of the Darwinian survival of the
fittest procedure.
Search method is based on the mechanics of
natural genetics and natural selection.
GA derives power from the genetic operators.
A simple GA largely uses three basic operators
– Reproduction
– Cross over
– Mutation
Cross over
After the reproduction phase population is
enriched with better individuals.
Reproduction makes clones of good strings,
but does not create any new ones.
Using cross over operator we can create new
and better strings.
Cross over operation
Cross over is a recombination operator.
This operation is proceed in three steps:
– Selection of the parents (two chromosome for
mating)
– Selection of cross-site
– Swapping of the positional values of the
chromosomes following the cross sites.
Cross over operation: Example
Let the two selected chromosomes for mating
are A=11111 and B=00000
Let the random selection of a cross site is 2
Then the new chromosomes following the
cross site is A*=11000 and B*=00111
A 1 1 1 1 1 A* 1 1 0 0 0

B 0 0 0 0 0 B* 0 0 1 1 1

Cross site
Cross over operation
Though these operator looks very simple their
combined action is responsible for much
power of GA’s.
For computer implementation they involve
only random number generation, copying and
value swapping.
Types of cross over
There exists many types of cross over
operations in GA
– Single-site cross over
– Two-point cross over
– Multi-point cross over
– Uniform cross over
– Half Uniform Crossover
– Shuffle Crossover
– Matrix Crossover (2- Dimensional)
– Three Parent Crossover
Single-site cross over
In a single-site cross over, a cross site is
selected randomly along the length of the
mated chromosomes.
The values next to the cross-sites are
exchanged.
If an appropriate site is chosen, better children
can be obtained by combining good substances
of parents.
Single-site cross over
Since the knowledge of appropriate site is unknown it
is selected randomly.
– This random selection may produce better children
or
– May severely hamper the quality.
If better children are produced then they will continue
in the next generation
Otherwise they will not survive beyond next
generation
– As they will not be selected for the next mating pool.
Two-point cross over
In this case two random sites are chosen.
Example:
2 4

A 1 1 1 1 1 A* 1 1 0 0 1

B 0 0 0 0 0 B* 0 0 1 1 0

Two Cross sites


Multi-point cross over
In this two different scenarios can occur
– Even number of cross-sites.
– Odd number of cross-sites.
Even number cross-sites:
– The chromosome is treated as a ring with no beginning or
end.
– The cross sites are selected around the circle uniformly.
– Then information between the alternate pair of sites is
interchanged.

Parent 1 Parent 2 Child 1 Child 2


Multi-point cross over
Odd number of cross-sites:
– In this case a different cross point is always
assumed at the beginning.
– The information between alternate pairs is
exchanged.
Cross- Cross- Cross-
site 1 site 2 site 3
Parent 1 Child 1

Parent 2 Child 2
Uniform cross over
An extreme of multipoint cross over is called
uniform cross over operator.
In this case each bit is from either parent is
selected with a probability of 0.5 and then
interchanged.
The number of effective crossing point is not
fixed but averages to L/2 (L is the
chromosome length).
Uniform cross over : Example
Parent 1 1 0 1 1 0 0 1 1 0 1 0 1

Parent 2 0 0 0 1 1 0 1 0 1 1 0 1

Child 1 1 0 0 1 1 0 1 0 1 1 0 1
Child 2 0 0 1 1 0 0 1 1 1 1 0 1

Interchanges
Uniform cross over : Other method
Sometimes gene in the offspring can be created using
cross over mask.
– When there is a 1 in the mask, the gene is copied fro the
first parent.
– When there is a 0 in the mask, the gene is copied from the
second parent.
The process is repeated with the parents exchanged to
produce the second offspring.
A new cross over mask is randomly generated for
each pair of parents.
Uniform cross over : Other method
Example

Cross over mask 1 0 0 1 0 1 1 1 0 0 1

Parent 1 1 0 1 0 0 0 1 1 1 0 1

Offspring 1 1 1 0 0 0 0 1 1 1 1 1

Parent 2 0 1 0 1 0 1 0 0 1 1 0

Offspring 2 0 0 1 1 0 1 0 0 1 0 0

Parent 1 1 0 1 0 0 0 1 1 1 0 1
Half-Uniform Crossover
In the half uniform crossover scheme, exactly half of
the non-matching bits are swapped.
– Calculate the Hamming distance (the number of differing
bits) between the given parents.
– This number is then divided by two.
– The resulting number is how many of the bits that do not
match between the two parents will be swapped but
probabilistically.
– Choose the locations of these half numbers (with some
strategies, say coin tossing) and swap them.
Example
Parent 1: 1 1 0 0 0 0 1 0 Here Hamming
distance is 4
Parent 2: 1 0 0 1 1 0 1 1

If toss is 1,
then swap the
Tossing 1 0 1 0 bits else
remain as it is

Offspring 1: 1 0 0 0 1 0 1 1

Offspring 2: 1 1 0 1 0 0 1 0

After Crossover
Shuffle Crossover
A single crossover point is selected. It divides
a chromosome into two parts called schema.
In both parents, genes are shuffled in each
schema. Follow some strategy for shuflling
bits
Schemas are exchanged to create offspring (as
in single crossover)
Example
P1 : 1 1 0 0 0 1 0 1
P2 : 1 0 0 1 1 0 1 1

K-point

P1’ : 0 0 1 0 1 1 1 0
After shuffling bits
P2’ : 0 1 1 1 0 1 0 1

Offspring 1: 0 0 1 0 1 1 0 1
Single point
Offspring 2: 0 1 1 1 0 1 1 0 crossover

After crossover
Matrix Crossover
The matrix crossover strategy is explained with the following
illustration.

l1 r11 r12 r13 r14 r15 r16 r17 … … r1n

l2 r21 r22 r23 r24 r25 r26 r27 … … r2n

P1: Two
r11 r12 r13 r14 P2: r21 r22 r23 r24
r25 r26 r27 r28 dimensional
r15 r16 r17 r18 representation
--- ---- ---- ---
--- ---- ---- --- of the
r2n-3 r2n-2 r2n-1 r2n
r1n-3 r1n-2 r1n-1 r1n chromosomes

Two matrices
Then matrices are divided into a number of non-overlapping zones are divided
into a number
of non-overlapping
zones and
shuffle
between them
Three parent Crossover
In this techniques, three parents are randomly
chosen.
Each bit of the first parent is compared with
the bit of the second parent.
If both are the same, the bit is taken for the
offspring.
Otherwise, the bit from the third parent is
taken for the offspring.
Example
P1: 1 1 0 1 0 0 0 1

P2: 0 1 1 0 1 0 0 1

P3: 0 1 1 0 1 1 0 1

C1: 0 1 1 0 1 0 0 1

Note: Sometime, the third parent can be taken as the crossover mask.
Drawbacks of Binary Coded GAs
Hamming Cliffs:
– Moving to a neighbouring solution requires
changing many bits which introduces encumbrance
to the gradual search in the continuous search
space.
Difficulty in achieving arbitrary precision
– Fixed string length limits the precision of the
solution
– Appropriate length of the string is not known
apriori
Hamming cliff
•Hamming distance = number of bit-wise differences
E.g.
a) the Hamming distance of 1000 and 0111 is 4
b) the Hamming distance of 0000 and 1000 is 1
In a), the distance between phenotypes is 1 (1000=8, 0111=7) but the
Hamming distance is 4
In b), the distance between phenotypes is 8 (0000=0, 1000=8) but the
Hamming distance is 1.

So, a one-bit mutation can make a large (or a small) jump; a multi-bit
mutation can make a small (or large) jump. This is known as the hamming
cliff problem.
Crossover operators for Real Coded
GAs
Single point crossover
Linear Crossover
Blend crossover
Simulated binary crossover
Single Point Crossover
Similar to the crossover operators used in the
binary-coded Gas

According to the number of crossover points,


there are also two-point, three-point and n-
point crossover
Linear Crossover
This scheme uses some linear functions of the parent
chromosomes to produce the new children
For example:
– Suppose P1k and P2k are the two parameter values in
position k of two parents, then the corresponding offspring
values in position k of the child chromosomes can be
obtained as
Cik = α*P1k + β*P2k
where i = 1, 2, … n (number of children).
α and β are some constants.
Example: Linear Crossover
P1: 15.65 12.76 13.47

P2: 18.83 19.41 16.28

K-th gene

α1 : 0.5, β1 = 0.5
α2 : 1.5, β2 =- 0.5
α3 : -0.5, β3 = 1.5

Modify the k-th gene of the P1 using Cik = αi*P1k + βi*P2k


C1k = α1*P1k + β1*P2k =16.08
C2k = α2*P1k + β2*P2k= 9.43
C3k = α3*P1k + β3*P2k= 22.73

C1: 15.65 16.08 13.47

C2: 15.65 9.43 13.47

C3: 15.65 22.73 13.47


Advantages and limitations
Advantages
– It is simple to calculate and hence faster in computation
– Can allow to generate a large set of offspring from two parent values
– Controls are possible to choose a wide-range of variations
Limitations
– Needs to be decided the values of αi and βi
– It is difficult for the inexperienced users to decide the right values for αi
and βi
– If αi and βi values are not chosen properly, the solution may stuck into
a local optima.
Blend Crossover in Real-Coded GA
This scheme can be stated as follows.
– Let x1 and x2 are the two parameter’s values in two
parent’s chromosomes, such that x1 < x2
– Then the blend crossover scheme creates the
children solution lying in the range
< {x1 – α (x2 – x1)} …. {x2 – α(x2 – x1)}>
– where α is a constant to be decided so that children
solution do not come out of the range of domain of
the said parameter.
Blend Crossover
Another parameter γ has to be identified by
utilizing the α and a random number r in the
range of (0.0, 1.0) both exclusive like the
following:
– γ = (1+2 α )r – α
The children solutions x1’ and x2’ are
determined from the parents as follows,
x1’ = (1 – γ) x1 + γ x2
x2’ = (1 – γ) x2 + γ x1
Example
Let x1 = 15.65 and x2 = 18.83
γ = 0.6 and α = 0.5

So, x1’ = 16.60 and x2’= 17.88


Simulated Binary Crossover
This scheme is based on the probability distribution
of generated children solution from the given parents.
A spread factor is used to represent the spread of the
children solutions with respect to that of the parents,
as given below.
α = | (x1’ – x2’)/(x1 – x2)|
Here x1 and x2 represent the parent points and x1’
and x2’ are two children solutions.
Simulated Binary Crossover
Three different cases may occurs:
– Case 1: α < 1 (Contracting Crossover)
The spread of children is less than the parents.
Case 2: α > 1 (Expanding Crossover)
The spread of children is more than the parents.
Case 3: α = 1 (Stationary Crossover)
The spread of children is same as that of the parents.
Simulated Binary Crossover
Probability Distribution:
–Case 1: For Contracting Crossover
C(α) = 0.5(q+1) α2
–Case 2: For Expanding Crossover
E(α) = 0.5(q+1) 1/(αq+2)
Simulated Binary Crossover
Following steps are used to create two children solutions x1’
and x2’ from the parents x1 and x2.
– Create a random number r {0:0 …1:0}
– Determine α’ such that
"!
∫! 𝐶 𝛼 𝑑𝛼 = 𝑟, 𝑖𝑓 𝑟 < 0.5
and
"!
– ∫# 𝐸 𝛼 𝑑𝛼 = 𝑟, 𝑖𝑓 > 0.5
Using the value of 0 obtain two children solution as follows
– x1’= 0.5 [(x1 + x2) - α’ (x2 – x1) ]
– x2’= 0.5 [(x1 + x2) + α’ (x2 – x1)]
Example
Let x1 = 15.65 and x2 = 18.83
q = 2 and α’ = 1.0772
Assuming expanding crossover with r > 0.5
– x1’ = 15.52 and x2’ = 18.95
Advantages and Limitations
Advantages:
– We can generate a large number of offspring from two parents.
– More explorations with diverse offspring.
– Results are accurate and usually terminated with global optima.
– Termination with a less number of iterations.
– Crossover techniques are independent of the length of the chromosome.
Limitations:
– Computationally expensive compared to binary crossover.
– If proper values of parameters involved in the crossover techniques are
not chosen judiciously, then it may lead to premature convergence with
not necessarily optimum solutions.
Crossover Techniques in Order GA
Some important crossover techniques in Order-coded
GAs are:
Single-point order crossover
Two-point order crossover
Position based crossover
Precedence-preservation crossover (PPX)
Edge recombination crossover
Assumptions
For all crossover techniques, we assume the
following:
– Let L be the length of the chromosome.
– P1 and P2 are two parents (are selected from the
mating pool).
– C1 and C2 denote offspring (initially empty).
Single Point Crossover
Given two parameters P1 and P2 with chromosome length ,
say L,
Steps:
– Randomly generate a crossover point K such that (1<K<L).
– Copy the left schema of P1 into C1 (initially empty) and
left schema of P2 to C2 (also initially empty).
– For the schema in the right side of C1, copy the gene value
from P2 in the same order as they appear but not already
present in the left schema.
– Repeat the same procedure to compute C2 from P1.
Example
K

P1: A C D E B F G H J I

P2: E D C J I H B A F G

C1: A C D E J I H B F G

C2: E D C J A B F G H I
Two-point order crossover
It is similar to the single point crossover, but
with two K-points.
Steps:
– Randomly generate two crossover points K1 and K2, 1<K1
<K2 <L.
– The schema in middle of P1 and P2 are copied into C1 and
C2 (initially both are empty), respectively in the same
location as well as in the same order.
– The remaining schema in C1 and C2 are copied from P2
and P1 respectively, so that an element already in child
solution does not appear again.
Example
K1 K2

P1: A C D E B F G H J I

P2: E D C J I H B A F G

C1: E D C J B F G I H A

C2: A C D E I H B F G J
Precedence preservation order
crossover
Let the parent chromosomes be P1 and P2 and the length of
chromosomes be L.
Steps:
– Create a vector V of length L randomly filled with elements from the
set {1, 2}.
– This vector defines the order in which genes are successfully drawn
from P1 and P2 as follows.
We scan the vector V from left to right.
Let the current position in the vector V be i (where i = 1,
2,…, L).
Let j (where j = 1, 2, …,L) and k (where j = 1, 2, …, L)
denotes the jth and kth gene of P1 and P2, respectively.
Initially j = k = 1.
Precedence preservation order
crossover
If i-th value is 1 then
– Delete jth gene value from P1 and as well as from P2
and append it to the offspring (which is initially
empty).
Else
– Delete kth gene value from P2 and as well as from P1
and append it to the offspring.
Repeat Step 2 until both P1 and P2 are empty
and the offspring contains all gene values.
Example
Random
Vector 2 1 1 2 1 1 2 2 1 2

P1: A C D E B F G H J I

P2: E D C J I H B A F G

C1: E C D J B F H A I G

C2: ?

Note: We can create another offspring following the alternative rule for 1 and 2
Position-based order crossover
Steps :
Choose n crossover points K1, K2, …Kn such that n << L, the
length of chromosome.
The gene values at K1th , K2th .. Knth positions in P1 are
directly copied into offspring C1 (Keeping their position
information intact).
The remaining gene values in C1 will be obtained from P2 in
the same order as they appear there except they are already not
copied from P1.
We can reverse the role of P1 and P2 to get another offspring
C2.
Example
K1 K2 K3

P1: A C D E B F G H J I

P2: E D C J I H B A F G

C1: E C D J B I A H F G

C2: C D E B I F G A H J
Edge recombination order
crossover
This crossover technique is used to solve TSP
problem when the cities are not completely
connected to each other.
In this technique, an edge table which contains
the adjacency information (but not the order).
In the other words, edge table provides
connectivity information.
Example
Let us consider a problem instance of a TSP with 9
cities.
Assume any two chromosome P1 and P2 for the
mating.
P1: 1 2 4 6 8 7 5 3

P2: 4 3 5 7 8 6 2 1

1 2
Connectivity 6
Graph 3 4
8
5
7
Edge Recombination Order
Crossover
Edge Table for the connectivity Graph

City Connectivity
1 2 1 2, 4, 3
6
4 2 1, 4, 7, 6
3
8 3 1, 7
5
4 1, 2, 6, 7
7
5 3, 7, 8
6 2, 4, 8
7 2, 5, 8
8 5, 6, 7
Edge recombination order crossover:
Illustration
Steps:
Let the child chromosome be C1 (initially empty).
– Start the child tour with the starting city of P1. Let this city be X.
– Append city X to C.
– Delete all occurrences of X from the connectivity list of all cities
(right-hand column).
– From city X choose the next city say Y, which is in the list of
minimum (or any one, if there is no choice) connectivity links.
– Make X = Y [ i.e. new city Y becomes city X].
– Repeat Steps 2-5 until the tour is complete.
End
Cross over rate
This term is denoted as PC , the probability of cross
over.
This is calculated in GA by finding out the ratio of
the number of pairs to be crossed to some fixed
population.
– Typically for a population size of 30 to 200, cross over
rates are ranged from 0.5 to 1.
So for a cross over probability of PC , only 100PC
percent strings in the population are used in the cross
over population
Mutation Operation in GAs
Like different crossover techniques in different
GAs there are many variations in mutation
operations.
Binary Coded GA :
– Flipping
– Interchanging
– Reversing
Real Coded GA :
– Random mutation
Mutation in Binary-coded GA :
Flipping
Here, a mutation chromosome of the same
length as the individual’s chromosome is
created with a probability p of 1/0s in the bit.
For a 1 in mutation chromosome, the
corresponding bit in the parent chromosome is
flipped ( 0 to 1 or 1 to 0) and mutated
chromosome is produced.
Example
1 0 1 1 0 0 1 0

Offspring

1 0 0 0 1 0 0 1

Mutation chromosome

0 0 1 1 1 1 0 1

Mutated offspring
Binary-coded GA :
Interchanging
Two positions of a child’s chromosome are
chosen randomly and the bits corresponding to
those position are interchanged.

1 0 1 1 0 1 0 0

Child chromosome

1 1 1 1 0 0 0 0

Mutated chromosome
Mutation in Binary-coded GA :
Reversing
A positions is chosen at random and the bit
next to that position are reversed and mutated
child is produced.

0 1 1 0 0 1 0 1

Child chromosome

0 1 1 0 0 1 1 1

Mutated chromosome
Mutation operation in Real-
coded GA
Here, mutated solution is obtained from the
original solution using the following rule.
– Pmutated = Poriginal + (r – 0.5) x delta
– Where r is a random number lying between 0.0 and
1.0 and delta is the maximum value of the
perturbation decided by the user.
Example
Poriginal = 15.6
r = 0.7
delta = 2.5
Then, Pmutated = 15.6 + (0.7 – 0.5) x 2.5 = 16.1
Mutation operator
After cross over, mutation operations are done on the
chromosomes.
Mutation of a value (a bit for example) involves
changing (or flipping) it with a small mutation
probability Pm .
A number between 0 to 1 is chosen at random.
– If the number is smaller than Pm then the flip the bit, else
do not.
Values of the chromosomes are individually mutated.
So this operator is mainly used as
– A secondary operation for restoring lost genetic materials.
– Also to maintain diversity in the population.
Mutation rate
Mutation rate is the probability of mutation
which is used to calculate number of bits to be
muted.
Mutation probabilities are smaller in natural
populations
– Typically for the population size of 30 to 200 with
the mutation rates varying from 0.001 to 0.5.
Revisiting the flow in GA
Start

Initial Population

Fitness evaluation

Selection
Converge No
Select Mate
?

Yes

Reproduction
Crossover
Stop Mutation
Fitness evaluation
Some Points
Multi-objective optimization:
– There are many objective functions in multi-objective
optimization.
– The usual practice is to convert multiple objectives into one
objective function as
f = w1 f1 + w2 f2+ w3 f3+…+ wn fn
wi’s are the weights and fi’s are the multi-objective functions.
– This is one way of converting a multi-objective function
into a single-objective optimization problem.
Example
Benefits of GA
Easy to understand
Modular, separate from application
Supports multi-objective optimization
Good for noisy environment.
Inherently parallel
Always give the answer and the answer gets
better with time.
Easy to exploit the alternate solutions.

You might also like