![Page 1: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/1.jpg)
1
Basic frame of Genetic algorithm
Initialise a population
Evaluate a population
While (termination condition not met) do
Select sub-population based on fitness
Produce offspring of the population using crossover
Mutate offspring stochastically
![Page 2: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/2.jpg)
2
Evolution Runs Until:
A perfect individual appears (if you know what the goal is),
Or: improvement appears to be stalled,
Or: you give up (your computing budget is exhausted).
![Page 3: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/3.jpg)
3
Simple GA Simulation
Optimisation problemmaximise the function f(x)=x2
x: integer between 0 and 31objective function as the fitness function
code using binary representation110112 = 1910
1*24+0*23+0*22+1*21+1*20
0 is then 0000031 is then 11111
![Page 4: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/4.jpg)
4
Simple GA Simulation: Initial Population
Lets assume that we want to create a initial population of 4
random flip coin 20 times (4 population size * string of 5)
String InitialNo. Population1 011012 110003 010004 10011
![Page 5: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/5.jpg)
5
Simple GA Simulation: Fitness Function
String Initial f(x) Prob. = fi/Sum
No. Population
1 01101 169 0.142 11000 576 0.493 01000 64 0.064 10011 361 0.31 Sum 1170
Average 293 Max 576
![Page 6: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/6.jpg)
6
Simple GA Simulation: Roulette Wheel
String Initial f(x) Prob Roulette.No. Population Wheel
1 01101 169 0.14 12 11000 576 0.49 23 01000 64 0.06 04 10011 361 0.31 1
Sum 1170 Average 293 Max 576
![Page 7: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/7.jpg)
7
Simple GA Simulation: Mating Pool
String Initial f(x) Prob Roulette. MatingNo. Population Wheel Pool
1 01101 169 0.14 1 011012 11000 576 0.49 2 110003 01000 64 0.06 0 110004 10011 361 0.31 1 10011
Sum 1170 Average 293 Max 576
![Page 8: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/8.jpg)
8
Simple GA Simulation: Mate
String Initial f(x) Prob Roulette. Mating MateNo. Population Wheel Pool
1 01101 169 0.14 1 01101 22 11000 576 0.49 2 11000 13 01000 64 0.06 0 11000 44 10011 361 0.31 1 10011 3
Sum 1170 Average 293 Mate is Randomly
selected Max 576
![Page 9: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/9.jpg)
9
Simple GA Simulation: Crossover
String Initial f(x) Prob R. Mating Mate Crossover No. Population W Pool1 01101 169 0.14 1 01101 2 42 11000 576 0.49 2 11000 1 43 01000 64 0.06 0 11000 4
24 10011 361 0.31 1 10011 3
2 Sum 1170 Average 293 Crossover is Randomly selected Max 576
![Page 10: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/10.jpg)
10
Simple GA Simulation: New Population
String Initial f(x) Prob R. Mating Mate Cross New No. Population W Pool over Pop.1 01101 169 0.14 1 01101 2 4 011002 11000 576 0.49 2 11000 1 4 110013 01000 64 0.06 0 11000 4 2 110114 10011 361 0.31 1 10011 3 2 10000
Sum 1170 Average 293 Max 576
![Page 11: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/11.jpg)
11
Simple GA Simulation: Mutation
String Initial f(x) Prob R. Mating Mate Cross New No. Population W Pool over Pop.1 01101 169 0.14 1 01101 2 4 011002 11000 576 0.49 2 11000 1 4 110013 01000 64 0.06 0 11000 4 2 110114 10011 361 0.31 1 10011 3 2 10000
Sum 1170 Average 293 Max 576
![Page 12: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/12.jpg)
12
Simple GA Simulation: Mutation
String Initial f(x) Prob R. Mating Mate Cross New No. Population W Pool over Pop.1 01101 169 0.14 1 01101 2 4 011002 11000 576 0.49 2 11000 1 4 100013 01000 64 0.06 0 11000 4 2 110114 10011 361 0.31 1 10011 3 2 10000
Sum 1170 Average 293 Max 576
![Page 13: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/13.jpg)
13
Simple GA Simulation: Evaluation New Population
String Initial f(x) Prob R. Mating Mate C New f(x)No. Population W Pool o Pop.1 01101 169 0.14 1 01101 2 4 01100
1442 11000 576 0.49 2 11000 1 4 10001
2893 01000 64 0.06 0 11000 4 2 11011
7294 10011 361 0.31 1 10011 3 2 10000
256 Sum 1170 1418
Average 293 354 Max 576 729
![Page 14: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/14.jpg)
14
Problem & Representations
Chromosomes represent problems' solutions as genotypes
They should be amenable to:
Creation (spontaneous generation)
Evaluation (fitness) via development of phenotypes
Modification (mutation)
Crossover (recombination)
![Page 15: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/15.jpg)
15
How GAs Represent Problems' Solutions: Genotypes
Bit strings -- this is the most common method
Strings on small alphabets (e.g., C, G, A, T)
Permutations (Queens, Salesmen)
Trees (Lisp programs).
Genotypes must allow for: creation, modification, and crossover.
![Page 16: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/16.jpg)
16
Binary-Encoding for Genetic Algorithms
The original formulation of genetic algorithms relied on a binary encoding of solutions, i.e., the chromosomes consist of a string of 0’s and 1’s.
No restriction on the phenotype so long as a good method for encoding/decoding exists.
Other methods of encoding will come later.
![Page 17: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/17.jpg)
17
Genetic Binary Encoding/Decoding of Integers
Initially, single parameters
Integer parameters: p is an integer parameter to be encoded. 3 distinct cases to consider:
Case 1
p takes values from {0, 1, 2, …..2^N-1} for some N. In this case, p can be encoded by its equivalent binary representation.
![Page 18: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/18.jpg)
18
Genetic Binary Encoding/Decoding of Integers
Case 2p takes values from {M, M+1, …., M+2^N-1} for
some M, N. In this case (p-M) can be encoded directly by its equivalent binary representation.
Case 3p takes values from {0, 1, .., L-1} for some L such
that there exist no N for which L=2^N. There are two possibilities. Clipping and Scaling
![Page 19: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/19.jpg)
19
Clipping
Take N = log(L)+1 and encode all parameter values 0<= p <= L-2 by their equivalent binary representation, letting all other n-bit strings serve as encodings of p = L-1.
Example: p from {0,1,2,3,4,5}, i.e., L=6. Then N=log(6)+1= 3 p 0 1 2 3 4 5 5 5Code 000 001 010 011 100 101 110 111
Advantages: Easy to implementDisadvantages: Strong representational bias. All parameter
values between 0 and L-2 have a single encoding, but the single value L-1 has 2^N-L+1 encodings
![Page 20: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/20.jpg)
20
Scaling
Take N=log(L)+1 and encode p by the binary representation of the integer e such that p = e(L-1)/(2^N-1)
Example: p from {0,1,2,3,4,5} i.e. L=6, N=log(6)+1=3. p 0 0 1 2 2 3 4 5Code 000 001 010 011 100 101 110 111
Advantages: Easy to implement. Smaller representational bias than clipping (at most double representations)
Disadvantages: Small representational bias. More computation than clipping.
![Page 21: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/21.jpg)
21
Gray Coding
Desired: points close to each other in representation space also close to each other in problem space
This is not the case when binary numbers represent floating point values
Binary gray code 000 000 001 001 010 011 011 010 100 110 101 111 110 101 111 100
![Page 22: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/22.jpg)
22
Gray Coding
m is number of bits in representation
Binary number b = (b1; b2; ; bm)
Gray code number g = (g1; g2; ; gm)
![Page 23: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/23.jpg)
23
Gray Coding
PROCEDURE Binary-To-Gray
g1=b1
for k=2 to m do
gk=b k-1 XOR bk
endfor
![Page 24: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/24.jpg)
24
Gray Coding
PROCEDURE Gray-To-Binary
value = g1
b1 = value for k = 2 to m do if gk = 1 then
value = NOT value end if bk =value
end for
![Page 25: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/25.jpg)
25
Binary Encoding and Decoding of Real-valued parameters
Can be encoded as:
fixed-point numbers
integers using scaling and quantisation
If p ranges over [min,max]
encode p using N bits by using the binary representation of the integer part of (2^N-1)(p-min)/(max - min)
![Page 26: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/26.jpg)
26
Multiple parameters
Vectors of parameters are encoded on multi-gene chromosomes by combining the encodings of each individual parameter.
Let e_i =[b_i0,….b_iN] be the encoding of the ith of M parameters. There are two ways of combining the e_i’s into a chromosome.
Concatenating: Individual encodings simply follow one another in some predefined order e.g. [b_10,…b_1N,..,b_M0,…b_MN]
Interleaving: the bits of each individual encoding are interleaved e.g. [b_10,…,b_M0,b_11,…,b_MN]
The order of parameters in the vector (i.e. genes in the chromosome) is important, especially for concatenated encodings.
![Page 27: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/27.jpg)
27
Initialization
Initialise a population
Evaluate a population
While (termination condition not met) do
Select sub-population based on fitness
Produce offspring of the population using crossover
Mutate offspring stochastically
![Page 28: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/28.jpg)
28
Initialization
init( ){ for( i = 0; i < POP_SIZE; i++ ) for( j = 0; j < N; j++ ) p[i][j] = random_int( 2 );}
![Page 29: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/29.jpg)
29
GA Main Program
Initialise a population
Evaluate a population
While (termination condition not met) do
Select sub-population based on fitness
Produce offspring of the population using crossover
Mutate offspring stochastically
![Page 30: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/30.jpg)
30
GA Main Program
for( trial = 0; trial < LOOPS; trial++ ){ selection( ) crossover( ) mutation( ) for( who = 0; who < POP_SIZE; who++ ) fitness[who] = fv(who);}
![Page 31: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/31.jpg)
31
Selection
Initialise a population
Evaluate a population
While (termination condition not met) do
Select sub-population based on fitness
Produce offspring of the population using crossover
Mutate offspring stochastically
![Page 32: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/32.jpg)
32
Selection
Selects individuals for reproduction– randomly with a probability depending on the
relative fitness of the individuals so that the best ones are more often chosen for reproduction rather than poor ones
– Proportionate-based selectionpicks out individuals based upon their fitness
values relative to the fitness of the other individuals in the population
– Ordinal-based selectionselects individuals based upon their rank within the
population; independent of the fitness distribution
![Page 33: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/33.jpg)
33
Roulette Wheel Selection
Here is a common technique: let F = j=1 to popsizefitnessj
Select individual k with probability fitnessk/F
![Page 34: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/34.jpg)
34
Roulette Wheel Selectionassigns to each solution a sector of a roulette wheel
whose size is proportional to the appropriate fitness measure
chooses a random position on the wheel (spin the wheel)Fitnessa:1b:3c:5d:3e:2f:2g:8
c
d
e
fg
a
b
![Page 35: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/35.jpg)
35
Roulette Wheel Realization
For each chromosome evaluate the fitness and the cumulative fitness
For N times create a random number
Select the chromosome where its cumulative fitness is the first value greater than the generated random number
Individual Chromosome Fitness Cumulative x1 101100 20 20 x2 111000 7 27 x3 001110 6 33 x4 101010 10 43 x5 100011 12 55 x6 011011 9 64
![Page 36: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/36.jpg)
36
Roulette Wheel Example
Individual Chromosome Fitness Cumulative Random Individual
x1 101100 20 20 42.8
x2 111000 7 27 x3 001110 6 33 x4 101010 10 43 x5 100011 12 55 x6 011011 9 64
![Page 37: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/37.jpg)
37
Roulette Wheel Example
Individual Chromosome Fitness Cumulative Random Individual
x1 101100 20 20 42.8 x4
x2 111000 7 27 x3 001110 6 33 x4 101010 10 43 x5 100011 12 55 x6 011011 9 64
![Page 38: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/38.jpg)
38
Roulette Wheel Example
Individual Chromosome Fitness Cumulative Random Individual
x1 101100 20 20 42.8 x4
x2 111000 7 27 19.78
x3 001110 6 33 x4 101010 10 43 x5 100011 12 55 x6 011011 9 64
![Page 39: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/39.jpg)
39
Roulette Wheel Example
Individual Chromosome Fitness Cumulative Random Individual
x1 101100 20 20 42.8 x4
x2 111000 7 27 19.78 x1
x3 001110 6 33 x4 101010 10 43 x5 100011 12 55 x6 011011 9 64
![Page 40: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/40.jpg)
40
Roulette Wheel Example
Individual Chromosome Fitness Cumulative Random Individual x1 101100 20 20 42.8 x4 x2 111000 7 27 19.78 x1 x3 001110 6 33 42.73 ? x4 101010 10 43 58.44 ? x5 100011 12 55 27.31 ? x6 011011 9 64 28.31 ?
![Page 41: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/41.jpg)
41
Roulette Wheel Example
Individual Chromosome Fitness Cumulative Random Individual x1 101100 20 20 42.8 x4 x2 111000 7 27 19.78 x1 x3 001110 6 33 42.73 x4 x4 101010 10 43 58.44 x6 x5 100011 12 55 27.31 x3 x6 011011 9 64 28.31 x3
![Page 42: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/42.jpg)
42
Roulette Wheel Selection
There are some problems here:
fitnesses shouldn't be negative
only useful for max problem
probabilities should be “right” avoid skewing by super heros.
![Page 43: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/43.jpg)
43
Parent Selection: Rank
Here is another technique.
Order the individuals by fitness rank
Worst individual has rank 1. Best individual has rank POPSIZE
Let F = 1 + 2 + 3 + + POP_SIZE
Select individual k to be a parent with probability rankk/F
Benefits of rank selection: the probabilities are all positive can be used for max and min problems the probability distribution is “even”
![Page 44: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/44.jpg)
44
Parent Selection: Rank Power
Yet another technique.
Order the individuals by fitness rankWorst individual has rank 1. Best individual has rank POP_SIZE
Let F = 1s + 2s + 3s + + POP_SIZEs
Select individual k to be a parent with probability rankks/F
benefits: the probabilities are all positive can be used for max and min problems the probabilities can be skewed to use more “elitist” selection
![Page 45: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/45.jpg)
45
Tournament Selection
Pick k members of the population at randomselect one of them in some manner that depends on
fitness
![Page 46: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/46.jpg)
46
Tournament Selection
void tournament(int *winner){ int size = tournament_size, i, winfit; for( i = 0; i < size; i++ ) { int j = random_int( POP_SIZE );; if( j==0 || fitness[j] > winfit ) winfit = fitness[j],*winner = j; }}
![Page 47: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/47.jpg)
47
Truncation selection
Choose the best k individuals as the offspringThere is no randomnessIf the population size is N, some researchers suggest
k/N=0.3
![Page 48: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/48.jpg)
48
Crossover Methods
Initialise a population
Evaluate a population
While (termination condition not met) do
Select sub-population based on fitness
Produce offspring of the population using crossover
Mutate offspring stochastically
![Page 49: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/49.jpg)
49
Crossover Methods
Crossover is a primary tool of a GA. (The other main tool is selection.)
CROSS_RATE: determine if the chromosome attend the crossover
Common techniques for bit string representations:
One-point crossover: Parents exchange a random prefix
Two-point crossover: Parents exchange a random substring
Uniform crossover: Each child bit comes arbitrarily from either parent
(We need more clever methods for permutations & trees.)
![Page 50: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/50.jpg)
50
1-point Crossover
Suppose we have 2 strings a and b, each consisting of 6 variablesa1, a2, a3, a4, a5, a6b1, b2, b3, b4, b5, b6representing two solutions to a problem
a crossover point is chosen at random and a new solution is produced by combining the pieces of the original solutionsif crossover point was 2a1, a2, b3, b4, b5, b6b1, b2, a3, a4, a5, a6
![Page 51: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/51.jpg)
51
1-point Crossover
Parents Children
![Page 52: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/52.jpg)
52
2-point Crossover
With one-point crossover the head and the tail of one chromosome cannot be passed together to the offspring
If both the head and the tail of a chromosome conatin good generic information, none of the offsprings obtained directly with one-point crossover will share the two good features
A 2-point crossover avoids such a drawback
Parents Children
![Page 53: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/53.jpg)
53
Uniform Crossover
Each gene in the offspring is created by copying the corresponding gene from one or the other parentchosen according to a random generated binary
crossover mask of the same length as the chromosomeswhere there is a 1 in the crossover mask the
gene is copied from the first parent and where there is a 0 in the mask the gene is copied from the second parent
a new crossover mask is randomly generated for each pair of parents
![Page 54: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/54.jpg)
54
Uniform Crossover
Parents Child
1 0 0 1 0 1 1 0CrossoverMask
![Page 55: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/55.jpg)
55
Uniform Crossover
make_children(int p1, p2, c1, c2)
{
int i, j;
for( i = 0; i < N; i++ ) {
if( random_int(2) )
p[c1][i] = p[p1][i],p[c2][i] = p[p2][i];
else
p[c1][i] = p[p2][i],p[c2][i] = p[p1][i];
}
}
![Page 56: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/56.jpg)
56
Another Clever CrossoverSelect three individuals, A, B, and C.Suppose A has the highest fitness and C the lowest.
Create a child like this.
for(i = 0; i < length; i++ ) { if( A[i] == B[i] ) child[i] = A[i]; else child[i] = 1 - C[i]; }
We just suppose C is a “bad example.”
![Page 57: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/57.jpg)
57
Crossover Methods & Schemas
Crossovers try to combine good schemas in the good parents.
The schemas are the good genes, building blocks to gather.
The simplest schemas are substrings.
1-point & 2-point crossovers preserve short substring schemas.
Uniform crossover is uniformly hostile to all kinds of schemas.
![Page 58: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/58.jpg)
58
Limit Consistency of Crossover Operator
)()()(lim 00 11 mm iiiikk
xPxPxxP
![Page 59: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/59.jpg)
59
Crossover for Permutations (A Tricky Issue)
Small-alphabet techniques fail. Some common methods are:
OX: ordered crossover
PMX: partially matched crossover
CX: cycle crossover
We will address these and others later.
![Page 60: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/60.jpg)
60
Crossover for Trees
These trees often represent computer programs.
Think Lisp
Interchange randomly chosen subtrees of parents.
![Page 61: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/61.jpg)
61
Mutation: Preserve Genetic Diversity
Initialise a population
Evaluate a population
While (termination condition not met) do
Select sub-population based on fitness
Produce offspring of the population using crossover
Mutate offspring stochastically
![Page 62: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/62.jpg)
62
Mutation: Preserve Genetic Diversity
Mutation is a minor GA tool .
Provides the opportunity to reach parts of the search space which perhaps cannot be reached by crossover alone. Without mutation we may get premature convergence to a population of identical clones– mutation helps for the exploration of the whole search space by
maintaining genetic diversity in the population– each gene of a string is examined in turn and with a small
probability its current value is changed– 011001 could become 010011
• if the 3rd and 5th genes are mutated
![Page 63: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/63.jpg)
63
Mutate Strings & Permutations
Bit strings (or small alphabets)
Flip some bits
Reverse a substring (nature does this)
Permutations
Transpose some pairs
Reverse a substring
Trees . . .
![Page 64: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/64.jpg)
64
Mutation
Mutate each bit with probability MUT_ RATEmutate(int who){ int i,j; for(i=0;i<Population_size;i++) for( j = 0; j < N; j++ ) { if( MUT_RATE > random_float( ) ) p[who][j] = 1-p[who][j]; }}
![Page 65: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/65.jpg)
65
Mutation
Mutation rate determines the probability that a mutation will occur.
Mutation is employed to give new information to the population
and also prevents the population from becoming saturated with similar chromosomes
Large mutation rates increase the probability that good schemata will be destroyed, but increase population diversity.
The best mutation rate is application dependent but for most applications is between 0.001 and 0.1.
![Page 66: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/66.jpg)
66
Mutation
Some researchers have published "rules of thumb" for choosing the best mutation rate based on the length of the chromosome and the population size.
DeJong suggested that the mutation rate be inversely proportional to the population size. (1/L)
Hessner and Manner suggest that the optimal mutation rate is approximately
(M * L1/2)-1
where M is the population size and L is the length of the chromosome.
![Page 67: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/67.jpg)
67
Crossover vs Mutation
Crossover
modifications depend on the whole population
decreasing effects with convergence
exploitation operator
GA emphasize crossover
Mutation
mandatory to escape local optima
exploration operator
ES and EP emphasize mutation
![Page 68: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/68.jpg)
68
Replacement
A method to determine which of the current members of the population, if any, should be replaced by the new solutions.
Generational updatesSteady state updates
![Page 69: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/69.jpg)
69
Generational Updates Replacement
• produce N children from a population of size N to form the population at the next time step and this new population of children completely replaces the parent selection
• a derived generational update scheme can also be used– (+)-update and (, )-update
is the parent population is the number of children produced of size
– the best individuals from either the offspring population or the combined parent and offspring populations form the next generation
![Page 70: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/70.jpg)
70
Steady state replacement
• New individuals are inserted in the population as soon as they are created by replacing an existing member of the population– the worst or the oldest member– tournament replacement
• as tournament selection but this time the less good solutions are picked more often than the good ones
– the most similar member– elitism
• never replace the best individuals in the population with inferior solution, so best solution is always available for reproduction
– harder to escape from a local optimum
![Page 71: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/71.jpg)
71
Basic frame of Genetic algorithm
Initialise a population
Evaluate a population
While (termination condition not met) do
Select sub-population based on fitness
Produce offspring of the population using crossover
Mutate offspring stochastically
![Page 72: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/72.jpg)
72
Another Function to Optimize
Find the max. of the “peaks” functionz = f(x, y) = 3*(1-x)^2*exp(-(x^2) - (y+1)^2) - 10*(x/5 - x^3 - y^5)*exp(-x^2-
y^2) -1/3*exp(-(x+1)^2 - y^2).
![Page 73: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/73.jpg)
73
Derivatives of the “peaks” functiondz/dx = -6*(1-x)*exp(-x^2-(y+1)^2) - 6*(1-x)^2*x*exp(-x^2-(y+1)^2) -
10*(1/5-3*x^2)*exp(-x^2-y^2) + 20*(1/5*x-x^3-y^5)*x*exp(-x^2-y^2) - 1/3*(-2*x-2)*exp(-(x+1)^2-y^2)
dz/dy = 3*(1-x)^2*(-2*y-2)*exp(-x^2-(y+1)^2) + 50*y^4*exp(-x^2-y^2) + 20*(1/5*x-x^3-y^5)*y*exp(-x^2-y^2) + 2/3*y*exp(-(x+1)^2-y^2)
d(dz/dx)/dx = 36*x*exp(-x^2-(y+1)^2) - 18*x^2*exp(-x^2-(y+1)^2) - 24*x^3*exp(-x^2-(y+1)^2) + 12*x^4*exp(-x^2-(y+1)^2) + 72*x*exp(-x^2-y^2) - 148*x^3*exp(-x^2-y^2) - 20*y^5*exp(-x^2-y^2) + 40*x^5*exp(-x^2-y^2) + 40*x^2*exp(-x^2-y^2)*y^5 -2/3*exp(-(x+1)^2-y^2) - 4/3*exp(-(x+1)^2-y^2)*x^2 -8/3*exp(-(x+1)^2-y^2)*x
d(dz/dy)/dy = -6*(1-x)^2*exp(-x^2-(y+1)^2) + 3*(1-x)^2*(-2*y-2)^2*exp(-x^2-(y+1)^2) + 200*y^3*exp(-x^2-y^2)-200*y^5*exp(-x^2-y^2) + 20*(1/5*x-x^3-y^5)*exp(-x^2-y^2) - 40*(1/5*x-x^3-y^5)*y^2*exp(-x^2-y^2) + 2/3*exp(-(x+1)^2-y^2)-4/3*y^2*exp(-(x+1)^2-y^2)
![Page 74: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/74.jpg)
74
GA process
10th generation5th generationInitial population
![Page 75: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/75.jpg)
75
Performance profile
![Page 76: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/76.jpg)
76
Setting the Parameters
How do we choose the “params”?
There is a statistical discipline: experimental design
For the present, we will treat this issue informally.
Try different setting and get a problem to work.
Then systematically try various settings.
![Page 77: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/77.jpg)
77
Probability of applying operations
Probability of Crossover (Pc)
Pc is normally chosen from range {0.5,…0.8}
This means that Crossover is applied to individuals with a probability of Pc and cloning with a probability of 1- Pc
Probability of Mutation (Pm)
This is the probability of flipping any individual bit
In GA’s Pm is normally kept very low, generally in the range {0.001,0.1}
![Page 78: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/78.jpg)
78
Pop Sizes 5, 10, 100, 300, 1000 For Problem 1
5: too much exploitation. 1000: too much exploration.
![Page 79: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/79.jpg)
79
Mutation Rates 0.001, 0.005, 0.007, 0.01 For Problem 1
0.01: too much exploration
![Page 80: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/80.jpg)
80
Improving Performance
Although GAs are conceptually simple, to the newcomer the number of configuration choices can be overwhelming.
Once the scientist using a GA for the first time receives less than satisfactory results there are several steps which can be taken to improve search performance.
![Page 81: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/81.jpg)
81
Improving Performance
The first approach to improving search performance is to simply use different values for mutation rates, population size, etc..
Many times, search performance can be improved by making the optimization more stochastic or becoming more hill-climbing in nature.
This trial and error approach, although time-consuming, will usually result in improved search performance.
If changing the configuration parameters has no effect on search performance a more fundamental problem may be the cause.
![Page 82: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/82.jpg)
82
Mapping Quality Functions to Fitness Functions
So far, we have assumed that there exists a known quality measure Q >= 0 for the solutions of the problem and that finding a solution can be achieved by maximising Q.
Under this assumption, a chromosome's fitness is taken to be the quality measure of the individual it encodes.
When this assumption is not valid, adjustments must be made for fitness-proportionate selection to be used. Of course, one may use a different selection mechanism. `
We will look at some of the problems that may arise with quality measures and suggest ways how these can be mapped into fitness functions that allow FPS to be applied.
![Page 83: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/83.jpg)
83
Negative-valued Quality Measure
In some problems, Q may take on negative values for some of the solutions, hence cannot be used directly as a fitness function with FPS (it would produce negative probabilities!).
One solution is to use an offset and a threshold
We can do this by defining fitness as follows:
f(s) = Q(s) - C_min if Q(s) - C_min > 0, and 0 otherwise
C_min (the offset) is taken to be one of the following:
1) The minimum value Q may take (when known)
2) The minimum value of Q in the current and/or last k generations
3) A function of the variance of Q in the current population, e.g. Mean(Q)- 2Sqrt(Variance(Q))
![Page 84: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/84.jpg)
84
Cost-based or Error-based Quality Measure
In some problems, the natural measure of quality is actually a cost or an error E, and finding a solution consists of minimising E (rather than maximising Q).
In this case, there is a straightforward solution, which consists of taking -E as the raw fitness, and then using an offset and a threshold (as before) to avoid negative values, if FPS is to be applied.
f(s) = C_max - E(s) if C_max > E(s) and 0 otherwise
C_max (the offset) is taken to be one of the following:
1) The maximum value E may take (when known)
2) The maximum value of E in the current and/or last k generations
3) A function of the variance of Q in the current population e.g. Mean(E)+2 Sqrt(Variance(E))
![Page 85: 1 Basic frame of Genetic algorithm Initialise a population Evaluate a population While (termination condition not met) do Select sub-population based on](https://reader035.vdocument.in/reader035/viewer/2022062423/5697bf791a28abf838c826f5/html5/thumbnails/85.jpg)
85
Stagnation-prone Quality Measure
If Q ranges over [Q_min, Q_max] where Q_min >> 0 and Q_max - Q_min !>> 0 then FPS can lead to stagnation even at the beginning of a run.
In this case, one solution is to use an offset and threshold as follows:
f(s) = Q(s) - C_min if Q(s) - C_min > 0 and 0 otherwise,
where C_min = Q_min, so that f ranges over [0, Q_max - Q_min]