A Simple Genetic Algorithm

Implementation of a function evaluation object
void createInitialPop( Pop& _pop, unsigned _numChrom, unsigned _numBits )
Function that creates the initial population
void getParams( int _argc, char** _argv, bool& _verbose, unsigned& _p, unsigned& _nb, unsigned& _ngen, float& _x, float& _m )
Parses the programīs command line, by creating a parsing object
This is probably the easiest way to start with EO. Itīs a simple Genetic Algorithm as especified by Goldberg: Binary Chromosome (Chrom, that is, EOBin<float>), Lottery selection, Random Reproduction, generational termination( it ends after a fixed number of generations and mutation and 2 point crossover as genetic operators. It optimizes a simple function: add the number of ones in the chromosome. All the operators are hidden inside the SGA class.

The only thing the user has to define is, obviously, the fitness function, which in EO becomes a fitness function class, the initial population, which in this case is created randomly, and the parameters for mutation and crossover.

If you want a more powerful way of defining the GA, and more control over it, use other algorithm (EOAlgo class, like EasyGA).

See Also:

alphabetic index hierarchy of classes