MOGAL
Public Member Functions

mogal::GeneticAlgorithmParams Class Reference

Generic parameters for a genetic algorithm. More...

#include <geneticalgorithm.h>

List of all members.

Public Member Functions

 GeneticAlgorithmParams ()
 Construct an instance with default parameter values.
 GeneticAlgorithmParams (double beta, bool elitism, bool includeBest, double crossoverRate)
 Construct an instance with specific parameter values.
double getBeta () const
 Returns the current selection pressure value.
bool useElitism () const
 Returns a flag indicating if elitism should be used.
bool alwaysIncludeBestGenome () const
 If this flag is true, the best genomes of a generation are copied to the next generation, but are still allowed to be mutated.
double getCrossOverRate () const
 Returns the currently set cross-over rate.

Detailed Description

Generic parameters for a genetic algorithm.

The selection pressure is specified by the parameter 'beta'. In the default implementations, genomes are sorted according to their fitness; the best genomes get low indices in the population array, the worst genomes get high index numbers. When selecting genomes from this sorted population, genomes are picked according to the following probability distribution:

\[ p(x) = \frac{1+\beta}{s}\left(1-\frac{x}{s}\right)^\beta \]

where s is the population size. The default 'beta' value is 2.5; for a population size of one hundred, the above function is shown below. This probability function then clearly favors genomes with low index numbers, which are the genomes which are deemed more fit.

beta.png

The best setting for the selection pressure will depend on the problem at hand. If the global optimum can be reached relatively easily, a high setting of this parameter will cause the algorithm to converge quickly. For a more difficult problem however, a high selection pressure may cause the algorithm to get stuck in a local optimum. A better exploration of the solution space can be obtained by using a lower selection pressure. Note that if this value becomes too small, all the genomes will appear equally good, and little progress will be made.

If the 'elitism' flag is set, the default implementations will copy the best genome(s) to the next generation and these will not be mutated. The same thing will happen if the 'includeBest' flag is set, but then mutations are indeed allowed. By default, both of these flags are set to true.

The 'crossoverRate' parameter is used by the default implementations to select which fraction of the genomes in the new population should be created by combining two parent genomes. The rest of the new population is created by cloning.


Constructor & Destructor Documentation

mogal::GeneticAlgorithmParams::GeneticAlgorithmParams ( )
mogal::GeneticAlgorithmParams::GeneticAlgorithmParams ( double  beta,
bool  elitism,
bool  includeBest,
double  crossoverRate 
)

Construct an instance with specific parameter values. The meaning of these parameters is described in the class documentation of GeneticAlgorithmParams.


Member Function Documentation

double mogal::GeneticAlgorithmParams::getBeta ( ) const [inline]
double mogal::GeneticAlgorithmParams::getCrossOverRate ( ) const [inline]
bool mogal::GeneticAlgorithmParams::useElitism ( ) const [inline]

The documentation for this class was generated from the following file: