How long does evolution sit on a flat line before it finds the cubic?
A plateau with best-fitness at about 7.26: the champion is a 3-node formula that is always zero, drawn as a flat red line.
Try thisSet size-penalty to 0 while it runs. Nothing discourages bloat any more, and average-size climbs from about 9 to about 25. Set it back to 5 and the formulas shrink again.
About this model
Where it ends up
The run doesn't stop. Once the red curve lies on the grey one, best-fitness sits near 99.5 and the printed formula is the target, possibly rearranged.
John Koza's Genetic Programming (1992) evolves programs instead of parameter vectors. Here each critter carries a formula tree up to 5 levels deep, built from add, sub and mul, the input v, and the constants 1 and 2. The target is v³ − 2v, drawn in grey.
A formula's error is its summed absolute difference from the target at nine points, v = −2, −1.5, …, 2. Fitness is 100 / (1 + error) minus size-penalty/100 per node. Every tick each critter picks the fittest of three random others. If that one is fitter, the critter either splices in one of its subtrees (probability crossover-rate%) or copies it outright. Then, with probability mutation-rate%, a random branch is regrown. The red curve plots the current champion, with its formula printed above.
IdeaJohn R. Koza
MathPetsMathPets · org