Home Download Help Forum Resources Extensions FAQ NetLogo Publications Contact Us Donate Models: Library Community Modeling Commons Beginners Interactive NetLogo Dictionary (BIND) NetLogo Dictionary User Manuals: Web Printable Chinese Czech Farsi / Persian Japanese Spanish

NetLogo User Community Models(back to the NetLogo User Community Models)
## WHAT IS IT?
Genetic algorithms try to solve a computational problem following some principles of organic evolution. This model has didactic purposes; it is able to give us an answer to the simple arithmetic problem on how to find the highest number composed by a given number of digits. We approach the task using a genetic algorithm, where the possible answers to the problem are represented by agents that in logo programming environment are usually named "turtles".
## HOW IT WORKS
Every turtle owns a “chromosome” made up by a string of digits each one representing a "gene"; chromosomes can mutate on a single gene and can exchange fragments (sequence of genes) with the chromosome carried by other turtles: we can see the mechanism as a mixture of eukaryotic crossingover and prokaryotic conjugation, here we will refer to it as a geneticshuffling. The total sequence of genes in a chromosome can be read as a number and its value can be considered the turtles “phenotype” as well as a candidate solution to the problem. A turtle will be as fit as the value expressed by its chromosome will be high. The best theoretical fitness can be easily mathematically established as the nearest to the result of a simple formula. If n is the number of digits in a string, the higher number having n digits is:
## HOW TO USE IT
SETUP button creates the selected number of turtles having a chromosome constituted by a string long till 20 genes (digits), as chosen by the user. Initially, all chromosomes show the lowest suitability.
## THINGS TO NOTICE
1. During geneticshuffling, the replaced chromosomal fragment can have random length, so sometimes it can have a null extension or it could cover the entire chromosome but a gene (the fragment's final digit).
## THINGS TO TRY
Search a possible statistical relationship between the number of cycles required to obtain the right answer to the problem and the single parameters adjustable by sliders. Particularly interesting could be the relationship between mutation rate and the average of cycles' number required to reach the right answer to the problem.
## EXTENDING THE MODEL
Minimal Genetic Algorithm can be furtherly extended by adding new routines and plots: e.g. it would be interesting to introduce a block evaluating the genotypes diversity dynamic during the search process.
## NETLOGO FEATURES
In this model, chromosomes have two features: as a string and as a number. To switch them each other, two NetLogo commands are very useful: "readfromstring" interprets the given chromosome and reports the resulting numerical value; on the contrary "word" command allows to revert a number into a string (because it requires two inputs, the second one could be double quotation marks: "")
## RELATED MODELS
 Stonedahl, F. and Wilensky, U. (2008). NetLogo Simple Genetic Algorithm model. http://ccl.northwestern.edu/netlogo/models/SimpleGeneticAlgorithm. Center for Connected Learning and ComputerBased Modeling, Northwestern Institute on Complex Systems, Northwestern University, Evanston, IL.
## CREDITS AND REFERENCES
A nice introduction to genetic algorithms could be the chapter nine of the book "Complexity  A guided tour" by Melanie Mitchel (2009  Oxford University Press) where the GA "Robby the Robot" is described; see also Mitchell, M., Tisue, S. and Wilensky, U. (2012). NetLogo Robby the Robot model http://ccl.northwestern.edu/netlogo/models/RobbytheRobot. Center for Connected Learning and ComputerBased Modeling, Northwestern University, Evanston, IL.
## COPYRIGHT AND LICENSE
Copyright 2018 Cosimo Leuci.
This work is licensed under the Creative Commons AttributionNonCommercialShareAlike 3.0 International License. To view a copy of this license, visit http://creativecommons.org/licenses/byncsa/3.0/ or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA. 
(back to the NetLogo User Community Models)