Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

prapi::ga::GeneticEngine< T > Class Template Reference

#include <GeneticEngine.h>

Inheritance diagram for prapi::ga::GeneticEngine< T >:

EventSource< EvolutionEvent< T > > Object List of all members.

Detailed Description

template<class T = double>
class prapi::ga::GeneticEngine< T >

GeneticEngine loops through a predefined number of evolution cycles by creating a new population from an old one.


Public Methods

 GeneticEngine (int generations, FitnessCalculator< T > &calculator, Mutator< T > &mutator, SurvivorSelector< T > &selector, Breeder< T > &breeder)
 Create a new genetic engine with the given number of generations and a set of pluggable behaviors.

virtual ~GeneticEngine ()
void start (util::List< Individual< T > > &population)
 Start the evolution.

virtual void createNextGeneration (util::List< Individual< T > > &population, int index)
 Create a new generation of individuals by replacing the current contents of the population by new individuals.

void stop (void)
 Stop the evolution.


Constructor & Destructor Documentation

template<class T = double>
prapi::ga::GeneticEngine< T >::GeneticEngine int    generations,
FitnessCalculator< T > &    calculator,
Mutator< T > &    mutator,
SurvivorSelector< T > &    selector,
Breeder< T > &    breeder
[inline]
 

Create a new genetic engine with the given number of generations and a set of pluggable behaviors.

If generations is -1, the engine will run forever unless explicitly stopped.


Member Function Documentation

template<class T>
void prapi::ga::GeneticEngine< T >::createNextGeneration util::List< Individual< T > > &    population,
int    index
[virtual]
 

Create a new generation of individuals by replacing the current contents of the population by new individuals.

The default implementation first sorts the population in ascending fitness order and calls the selectSurvivors method in the internal SurvivorSelector. Second, the age of each individual is incremented by one. Finally, the internal Breeder is required to produce some new offspring.

Parameters:
population  the population that is to be converted to a new generation
index  the index of the generation

template<class T>
void prapi::ga::GeneticEngine< T >::start util::List< Individual< T > > &    population
 

Start the evolution.

Until the maximum generation count is reached or the evolution is explicitly stopped, the engine will create new generations as follows.

  1. Calculate the fitness of each individual by calling the calculateFitness method of the internal fitness calculator.
  2. Fire an evolution event that informs interested listeners about the state of the evolution
  3. Ff the evolution is not stopped and the generations is not the last one, create a new generation, mutate it and proceed to a new cycle.
    Parameters:
    population  the population to evolve. Note that the contents of this population change for each generation.

template<class T = double>
void prapi::ga::GeneticEngine< T >::stop void    [inline]
 

Stop the evolution.

The evolution will stop after the currently generating population has finished.


The documentation for this class was generated from the following file:
Documentation generated on 11.09.2003 with Doxygen.
The documentation is copyrighted material.
Copyright © Topi Mäenpää 2003. All rights reserved.