1. Smith Dhumbumroong
  2. PyCGA



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:

python PyCGA.py

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


./PyCGA.py --help