How tightly can a population settle on a peak while it keeps mutating? The scattered creatures converge on the bright peak at (15, 10) within about 20 ticks.
Try this With the run going, drag mutation-rate from 8 to 30. The cluster loosens and average-fitness drops to about 94. At 1, it tightens to almost a single point.
About this model Where it ends up The run doesn't stop. It settles with the population clustered on the peak, best-fitness near 100 and diversity low but not zero.
John Holland introduced genetic algorithms in Adaptation in Natural and Artificial Systems (1975): keep a population of candidate solutions and breed the better ones. David Goldberg's 1989 textbook made them a standard optimisation method. This is close to the smallest version that still shows all three operators at work.
A genome is two numbers between −24 and 24, used directly as the creature's (x, y) position, so the board is the search space. Fitness is 100 minus 2.5 times the distance to a single peak at (15, 10), shown by the shading. Every tick each creature picks the fittest of three random others. If that mate is fitter, then with probability crossover-rate% each gene is taken from the mate or kept, with even odds. Then each gene mutates with probability mutation-rate%, by adding Gaussian noise with a standard deviation of 3.
The landscape has one peak and no local optima, so the model shows convergence and the cost of mutation rather than a hard search. Editing fitness-peak in the code is the quickest way to make it harder.
Idea John H. Holland · David E. Goldberg
MathPets MathPets · org