Ga 3
Ga 3
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
- 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;
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
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
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
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
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.
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
K-th gene
α1 : 0.5, β1 = 0.5
α2 : 1.5, β2 =- 0.5
α3 : -0.5, β3 = 1.5
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.