PyCGA is a simple implementation of Compact Genetic Algorithm (cGA) written in Python for educational purposes. It implements a simple OneMax fitness function and a trap-5, as well as a (very simple and very biased) method of solving the said trap. PyCGA can also plot simple graphs showing how the fitness score and the state of each member inside the probability vector change as our algorithm "evolves" through generations.
- Python version 2.7.3 or any later version in the Python 2.7 series
- matplotlib (optional) for graph plotting
Just run PyCGA in your favorite terminal emulator, like the following examples:
or (if the PyCGA.py script has execute permission)
Which should be more than enough to start PyCGA with the default parameters.
For more information, such as how to enable graph plotting or change various parameters of PyCGA, please consult PyCGA's help, which can be invoke using the following commands:
python PyCGA.py --help
- The Compact Genetic Algorithm (1999), by Georges R. Harik, Fernando G. Lobo, and David E. Goldberg
- Compact Genetic Algorithm section from the book: Clever Algorithms: Nature-Inspired Programming Recipes (2011), by Jason Brownlee PhD