Himmelblau's Function
So... there is this 2 dimensional function called Himmalblau's function that is easy to calculate and is a very easy task for an evolving system. Let's try then.
The function has four minima (places where its value is the smallest) and those are all having the same value (0 actually). One could say it doesn't matter which of these we find and that makes our life even easier. So we can write a fitness function that gets x and y, calculates the Himmelblau's function and returns a value that we want to maximize. We add some bells and whistles and we get this script:
#! /usr/bin/pev -f begin string description Himmelblau Function ----------------------------------------------------------------------------- This function has four equal local minimum at the following places: ( 3, 2) (-2.805118, 3.131312) (-3.779310, -3.283186) ( 3.584458, -1.848126) http://benchmarkfcns.xyz/benchmarkfcns/himmelblaufcn.html ----------------------------------------------------------------------------- end string default_population_size = 1600; min_population_size = 1000; default_genome_length = 64; function fitness(organism) { if (organism.doubleSize() < 2) return null; x = organism.getDouble(0); y = organism.getDouble(1); fxy = (x * x + y - 11) * (x * x + y - 11); fxy += (x + y * y - 7) * (x + y * y - 7);
# We maximize the fitness while searching for the minimum of f(xy) return 100.0 - fxy; } function Population::printDebug(population) { print(description); } function printDebug(organism) { printl(""); printl(" Organism:"); printl(" byteSize = ", organism.byteSize()); printl(" doubleSize = ", organism.doubleSize()); printl(" fitness = ", organism.fitness()); if (organism.doubleSize() < 2) return null; ch = organism.chromosome0(); printl(""); printl(" Chromosome0:"); printl(" express = ", ch.expressionFunction()); printl(" byteSize = ", ch.byteSize()); printl(" mutation factor = ", ch.mutationFactor()); x = organism.getDouble(0); y = organism.getDouble(1); printl(" x = ", x); printl(" y = ", y); ph = organism.phenome(); ch.printDebug(); ph.printDebug(); }
Here is a video showing how this script runs. It is interesting to watch, trying to figure out what happens, sometimes almost hypnotic as the bytes are jumping up and down. While starring on the screen we can come to the conclusion that this is just an evolving string again in disguise! One number is stored on 8 bytes, there are two numbers, that's 16 bytes similar to a string that is 16 characters long. The Himmelblau's function is so simple it doesn't complicate the evolving string case much. Well, it has four solutions, that's definitely new, but apart from that the whole thing is the same.