𝒙𝟐
Maximize 𝒇(𝒙) = − 3𝑥 , when x in [1 to 31]
𝟐
Binary Encoding – 5 digits
Initialization of Population
1. Selection
2. Crossover/Recombination
3. Mutation
4. Survival/Accept
Update Population
1. Selection (Let us take 6 chromosomes in initial population)
String Initial x 𝒙𝟐 Probability Bin
No Population 𝒇(𝒙) = − 𝟑𝒙
𝟐
1 [1,0,0,1,0] 18 108 0.211 0.001-0.211
2 [1,0,0,1,1] 19 123.5 0.242 0.212-0.453
3 [1,0,1,1,1] 23 195.5 0.383 0.454-0.836
4 [0,1,1,1,0] 14 56 0.110 0.837-0.946
5 [0,0,1,0,1] 5 0 [if negative] 0 ---
6 [0,1,0,1,1] 11 27.5 0.054 0.947-1.00
Total 510.5 1.00
Let us select 4 parents and perform 2. crossover and 3. mutation
Random Selected Chosen Offspring after Offspring after
Number Bin No. Parent Crossover at random point Mutation (1% chance)
0.54 3 [1,0,1,1,1] [1,0,1,1,0] [1,1,1,1,0]
0.88 4 [0,1,1,1,0] [0,1,1,1,1] [0,1,1,1,1]
0.45 2 [1,0,0,1,1] [1,0,0,1,0] [1,0,0,1,0]
0.20 1 [1,0,0,1,0] [1,0,0,1,1] [1,0,0,1,1]
4. Accept/Survival
Offspring x Fitness, f(x)
[1,1,1,1,0] 30 360
[0,1,1,1,1] 15 67.5
[1,0,0,1,0] 18 108
[1,0,0,1,1] 19 123.5
[Select survivors and add to population]
Updated Population:
String Initial
No Population
1 [1,0,0,1,0]
2 [1,0,0,1,1]
3 [1,0,1,1,1]
4 [0,1,1,1,0]
5 [0,0,1,0,1]
6 [0,1,0,1,1]
7 [1,1,1,1,0]
Check termination [Condition]
New Cycle: