Genetic Algorithm Solution
y = x^2 +
Function 2*x-1
Binary Values
Random
Chromosomes 8 01000
13 01101
19 10011
23 10111
Table Construction
Initial Value of % Expected Actual
Population X Fitness Probability Probability Count Count
String number
0.06345381
1 01000 8 79 5 6.345381526 0.253815261 0
0.15582329
2 01101 13 194 3 15.58232932 0.623293173 1
0.31967871
3 10011 19 398 5 31.96787149 1.278714859 1
0.46104417
4 10111 23 574 7 46.10441767 1.844176707 2
Sum 1245 1 100 4 4
Average 311.25 0.25 25 1 1
0.46104417
Maximum 574 7 46.10441767 1.844176707 2
less than 0.5 will be considered as ZERO
greater than 0.5 will round off to 1
Select Mating Pool
Offspring
After
Cross over Cross Value of
String No Mating Pool Point over X Fitness
1 10111 4 10111 23 574 10111 Consider it twice
2 01101 4 01101 13 194
3 10111 2 10011 19 398
4 10011 2 10111 23 574
Sum 1740
Average 435
Maximum 574
Mutation
Mutation Offspring
Offspring After Chromosom after Value of
String No Crossover e for flipping mutation X Fitness
1 10111 0 10111 23 574
only least value’s chromosome’s bit 3
will be changed from 1 to 0
2 01101 00100 01001 09 98
3 10011 0 10011 19 398
4 10111 0 10111 23 574
Sum 1644
Average 411
Maximum 574
Solution is diverging as the mutation is only performed on the least value chromosome and one the point 3 so it will change from one to ZERO.
The total value of SUM is decreased from the previous value.