- Consider the sin function over 0-15 (radians)
- Optima are at pi/2 + N * 2 * pi, for N = 1 .. 4
- 0-15 is represented by four bits, to form a solution
- Initial (toy size) population
1001 = 9 sin = 0.41 fraction of total = 0.46 cumulative = 0.46
0011 = 3 sin = 0.14 fraction of total = 0.37 cumulative = 0.83
1010 = 10 sin = -0.54 fraction of total = 0.15 cumulative = 0.98
0101 = 5 sin = -0.96 fraction of total = 0.02 cumulative = 1.00
Total 3.05 (taking -1 as the base)
- Chance of breeding is proportional to fraction of total, e.g.,
random numbers 0.56 and 0.38 select 0011 and 1001.
- Two random pairs are selected, and four new solutions are bred
using a randomly selected single crossover point.
- Example of one generation:
1001 + 0011 @ 2 = 1011 & 0001
1001 + 1010 @ 3 = 1000 & 1011
- The new generation is
1000 = 8 sin = 0.99 fraction of total = 0.52 cumulative = 0.52
0001 = 1 sin = 0.84 fraction of total = 0.48 cumulative = 1.00
1011 = 11 sin = -1.00 fraction of total = 0.00 cumulative = 0.00
1011 = 11 sin = -1.00 fraction of total = 0.00 cumulative = 0.00