Professional Documents
Culture Documents
Slides GA
Slides GA
Slides GA
• To find a global minimum, users normally try a heuristic approach where several local
minima are found by repeated trials with different starting values or by using different
techniques
• The smallest of all known local minima is then assumed to be global minima. Certainly not
very reliable.
maximize 𝑓 𝑥
where 𝑥𝑖𝑚𝑖𝑛 ≤ 𝑥𝑖 ≤ 𝑥𝑖𝑚𝑎𝑥 𝑖 = 1,2, … 𝑛
i.e. 𝑥 ∈ Ω ⊂ ℛ𝑛
Initialization
Encoding
Fitness Evaluation
Selection Iteration
Crossover
Mutation
Decoding
i) Initialization
• A population size N is chosen and then N random points are picked from
the phenotype space (search space) Ω
• N is even and usually a few 10’s to a few 100’s (not too high!)
ii) Encoding
𝑥𝑖𝑚𝑎𝑥 −𝑥𝑖𝑚𝑖𝑛
• 𝜖𝑖 =
2𝑙𝑖 −1
𝑥𝑖𝑚𝑎𝑥 −𝑥𝑖𝑚𝑖𝑛
• 𝑙𝑖 = 𝑐𝑒𝑖𝑙𝑖𝑛𝑔 [ 𝑙𝑜𝑔2 1 + ]
𝜖𝑖
• Mapping from the range 𝑥𝑖𝑚𝑖𝑛 , 𝑥𝑖𝑚𝑎𝑥 to 0, 2𝑙𝑖 − 1 is done as
follows:
𝑥𝑖 −𝑥𝑖𝑚𝑖𝑛
𝑥𝑖𝑑 = 𝑟𝑜𝑢𝑛𝑑 2𝑙𝑖 − 1 or 𝑥𝑖 = 𝑥𝑖𝑚𝑖𝑛 + 𝜖𝑖′ . 𝑥𝑖𝑑
𝑥𝑖𝑚𝑎𝑥 −𝑥𝑖𝑚𝑖𝑛
−0.85
• To represent x= as a binary string or chromosome.
4.21
resolution for x1 ,
similarly,
solving for
Now, 𝑥1 = 𝑥1𝑚𝑖𝑛 + 𝑥1𝑑 . ∈1′ where ∈1′ is the actual resolution of 𝑥1
𝑥1𝑚𝑎𝑥 − 𝑥1𝑚𝑖𝑛
∈1′ = = 0.13
2𝑙1 −1
𝑥2𝑚𝑎𝑥 − 𝑥2𝑚𝑖𝑛
∈′2 = = 0.1746
2𝑙2 −1
• Next the fitness values at all the N points in the genotype space are
computed
• Extract the decimal integer 𝑥𝑖𝑑 from the GA string and then
1.03
Answer:
−0.55
iv) Selection
fi
f1
fN Pi N
f
i 1
i
f2
f4 f1
f1 10%
40%
80% f3
20% f2
3% f 3 f2
30%
7% 10%
Proportionate selection Ranking selection
(c) Tournament Selection
• With some crossover probability (𝑝𝑐 close to 1.0), the parent chromosomes
swap some portions of themselves to produce two children chromosomes
0101101011 1110100101
Children
0011010010 1001101001
•Two-point Crossover
101011 10011 010010100 Parents
010010 11101 000110011
10110000111001101110
Parents
01110110001100010100
Let us assume that 2-nd, 4-th, 5-th, 8-th, 9-th,12-th, 18-th and 20-th
bit positions are selected for swapping
11110000011101001110
00110110101000110100 Children
• What if all the new offspring are worse? To avoid such situations, go for
an ELITIST selection
vi) Mutation
• Each bit of all the N chromosomes are flipped with the mutation
probability 𝑝𝑚 (bit-wise mutation)
1) 0101101011 1001101001
2) 0011010010 1110100101
3) 0101101011 1110100101
4) 0011010010 1001101001
– Objective is to speed up convergence (best solutions are not lost from the population)
– A few best chromosomes of the present generation (Elite Count (EC) = 2, say) are
directly sent to the next generation; others go through the normal process of selection,
crossover and mutation
Example:
maximize f(x1, x2) = x1x2 where 1.0 ≤ x1, x2 ≤ 10.0
(2, 8); (5, 5); (9.5, 7.5); (3, 2); (10, 3); (4, 7)
Compute the next generation with the fitness values. Assume the following:
mating pairs as 1st and 4th members; 2nd and 5th members etc.
10 − 1
∈′ = 4 = 0.6
2 −1
2 = 1 + 0.6 ∗ 𝑥1𝑑
176.25
GEN #1 GEN #1 Fitness Select. Mating
(Phenotype (Genotype Value Prob. Pool
Space) Space) (f=x1.x2)
176.25
Mating GEN #2
Pool (Genotype
Space)
= 1 + 15 ∗ 0.6
= 10.0
= 1 + 3 ∗ 0.6
= 2.8
Mating GEN #2 GEN #2 Fitness
Pool (Genotype (Phenotype Value
Space) Space) (f=x1.x2)
238.80
𝑥1 −1 2
Example: − + 𝑥2 −2 2
𝑓 = −10 cos 𝑥1 cos 𝑥2 𝑒 4
2.51 (2.49)
𝑥∗ = 𝑓 ∗ = −2.8613 (−2.8733)
2.48 (2.43)
• N=20 (40) 4
• Pc=0.9
2
• Pm=0.09
x1(blue), x2(red)
1
• EC=0
-1
-3
• Uniform crossover
0 5 10 15 20 25 30
Gen
3
-1
-2
-3
-4
-5
-5
0
-6
-5 -4 -3 -2 -1 0 1 2 5
3 4 5
Schema Theorem for Binary Coded GA
110011
010100
110111
110000
f (H )
E [ m( H , t 1)] m( H , t )
f
L = String length
(H )
Probability of destruction = p L 1
c
(H )
Probability of survival = 1 pc
L 1
• Effect of Mutation (Bit–wise Mutation):
Building-Block Hypothesis:
The schemata having low order, short defining length and fitness considerably more
than average fitness of the population will have more and more representations in
future generations
Limitations of Binary Coded GA
14 : 01110 1 change
15 : 01111
5 changes
16 : 10000
Real Coded GA:
x1 x2 x3 x4 x5 x6
Chromosome:
Linear Crossover
Ch1 = 0.5*Pr1+0.5*Pr2
Best
Ch2 = 1.5*Pr1-0.5*Pr2 Two
Ch3 = -0.5*Pr1+1.5*Pr2
x2
c3
p2
c1
p1
c2
x1
𝑃1 + 𝑃2
𝐶2, 𝐶3 = ± (𝑃1 − 𝑃2)
2
Blend Crossover
Answer:
optimize f(𝑥)
subject to
gj(𝑥) ≤ 0 , j = 1,2,….,m
hk(𝑥) = 0 , k = 1,2,….,p
𝑥 = [x1 x2 …. xn]T
𝑥min ≤ 𝑥 ≤ 𝑥max
Let m+p = q
Functional constraints
Φk(𝑥) , k = 1,2,….,q
Penalty Function Approach
k 1
k 1
q
Fitness Fi ( X ) fi ( X ) (C.t ) ik ( X )
k 1
t = number of generations
q
Fi ( X ) f i ( X ) (t ) ik ( X )
2
Fitness
k 1
1
. (t ), if best soln. of last Nf GEN were feasible
λ(t+1) = 1
. (t ) , if infeasible
2