Show HN: Evolve expressions that evaluate to a target number
github.com
github.com
Each individual in the population is encoded as a binary string representing an infix expression, with 0...9 becoming their binary representations (0001 through 1001) and the operators `+`, `-`, * , `/` and `* * ` (exponentiation) represented as 1010 through 1110.
Since I'm on a phone (again): how do you deal with malformed expressions, and changing the length of the genome?
In my current scheme, malformed expressions just get a fitness of 0 (where fitness is between 0 and 1; 1 when the expression evaluates to the given target).
Varying lengths are achieved by randomly picking a length for each individual at the beginning. Thereafter, every generation gets varied length genomes automatically because of crossover. Not sure if this is the best approach, though.