NetLogo banner

 Contact Us

 Modeling Commons

 User Manuals:


NetLogo User Community Models

(back to the NetLogo User Community Models)


by Thomas Hills (Submitted: 10/09/2003)

[screen shot]

Download BinaryGA
If clicking does not initiate a download, try right clicking or control clicking and choosing "Save" or "Download".

(You can also run this model in your browser, but we don't recommend it; details here.)

Elementary Genetic Algorithm

This uses the basic features of genetic algorithms to solve a simple binary matching task. The 'target-size' sets the length of the binary sequence (zeros and ones) that must be found. This sequence can be thought of as the optimal genetic information (genome) for a particular environment. The 'population-size' sets the number of individuals that can try out their own genomes in that environment. Each generation the genetic algorithm runs through the following sequence of events, much like the process of evolution takes place in a typical ecosystem.

1. The individuals test their genomes against the environment ('compare-genomes' in the procedures).
2. Individuals with better genomes are more likely to become part of the mating pool for future generations ('mate-recombine' procedure).
3. Individuals in the mating pool then randomly recombine their genomes with their partners to generate new offspring genomes (called seed-genomes in 'mate-recombine')
4. Once the seed-genomes are constructed, they undergo mutation at a rate set by the 'mutation-rate' ('mutation' procedure).
5. Finally, the newly constructed and mutated seed-genomes are assigned to individuals in the next generation who start the process over again.

In this simulation, the fitness is assigned by counting the number of genes (individual zeros or ones in the genome) that match the target genome. After ranking the fitnesses, the half of the population with higher fitness are then chosen to reproduce. These individual genomes are then randomly chosen in pairs, who then randomly decide which parent gives their gene at each locus (i.e., the location of an individual gene). Mutation occurs by choosing a random number at each locus for each genome. If the random number is lower than the mutation rate, then the gene is switched to its opposite state.

This was created as a preliminary excercise for the ARS-Genetic, by Thomas Hills.

(back to the NetLogo User Community Models)