Skip to content

vrettasm/PyGeneticAlgorithms

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

Genetic Algorithms in Python

"Genetic Algorithms (GA), are metaheuristic algorithms inspired by the process of natural selection and belong to a larger class of evolutionary algorithms (EA)."

-- (From Wikipedia, the free encyclopedia)

This repository implements a GA in Python3 programming language (using only Numpy as additional library). The initial approach offers a "StandardGA" class, where the whole population is replaced by another one of offsprings at the end of each iteration (or epoch).

NOTE: For computationally expensive fitness functions the StandardGA class provides the option of parallel evaluation, by setting in the method run(..., parallel=True). However, for fast fitness functions this might actually cause the evolution to converge slower. So the default setting here is "parallel=False".

NEWS: The IslandModelGA is now available! For the moment there is only one migration policy as implemented by the Clockwise Migrator. Any new migration policies can be easily added by inheriting directly from the Migration Operator (base) class.

The current implementation offers a variety of genetic operators including:

Note that incorporating additional genetic operators is easily facilitated by inheriting from the base classes:

and implement the basic interface as described in these classes. In the examples below I show how one can use this code to run a GA for optimization problems (maximization/minimization) with and without constraints. The project is ongoing so new things might come along the way.

Examples

Some optimization examples on how to use this algorithm:

  1. Minimization
  2. Maximization
  3. Minimization with constrains

Constraint optimization problems can be easily addressed using the Penalty Method as described in the link above.

To Do:

  • Add more examples

Contact

For any questions/comments (regarding this code) please contact me at: [email protected]