Javascript Genetic Algorithm

Each mathamatical number and symbol is a 'gene'. Choose the target number and the length of the chromosome (the number of genes), and the program will attempt to find a solution.

Certain target/chromosome-length combinations work better than others. At this time, the larger the number, the harder it is to find a solution.

Find a Solution

How It Works

Each chromosome is a series of binary numbers. Every 4 numbers is a 'gene' that codes to a certain mathematical symbol. For instance 0000 is '+', 0001 is '-', 0101 is 1, 0110 is 2, etc...

Two families of 10 chromosomes are psudo-randomly generated. The fittest chromosomes are allowed to reproduce producing a new generation of chromsomes. These two families evolve independantly, occationaly swapping their fittest individuals. The weakest Chromosomes are killed off.

The fitness of a Chromosome is determined by the solution to its equation, and how many operaters it has. The more operators the chromosome has, the more fit is. The closer the solution is to the target, the more fit it is.

Reproduction results in two offspring by a one-point crossover between the parent chromosomes.

There is a 0.6% chance that any number in the offspring's chromosome will mutate. (0 changes to 1 or 1 changes to 0)

You'll notice that the length of the chromosome doesn't always result in an equally long equation. 'Junk Genes' are ignored (for instance double operators ++ or double numbers).