Main Page   Class Hierarchy   Alphabetical List   Compound List   Compound Members  

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

#include <GeneticEngine.h>

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

prapi::ga::Breeder< T > List of all members.

Detailed Description

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

CrossingOverBreeder randomly takes some individuals from a population, mates them using crossing over, and produces two offspring for each pair of parents.


Public Methods

 CrossingOverBreeder (double selectionProbability=0.25, double rate=0.8)
 Create a new CrossingOverBreeder with the given parent selection probability and selection rate.

virtual void createChildren (const util::List< Individual< T > > &from, util::List< Individual< T > > &to)
 Select parentSelectionRate/2*from.getLength() pairs of parents and breed them producing two children for each pair.

virtual util::List< Individual<
T > > 
mate (const Individual< T > &parent1, const Individual< T > &parent2)
 Mate two individuals and produce some offspring.


Public Attributes

double parentSelectionProbability
 A value in the range [0,1] that tells how probable it is for the fittest individual to get selected for mating first.

double parentSelectionRate
 A value in the range [0,1] that tells how large fraction of the population is selected for mating.


Constructor & Destructor Documentation

template<class T = double>
prapi::ga::CrossingOverBreeder< T >::CrossingOverBreeder double    selectionProbability = 0.25,
double    rate = 0.8
[inline]
 

Create a new CrossingOverBreeder with the given parent selection probability and selection rate.

If you are using a RankSelector or similar, you need to make sure that the selection rates of these objects sum up to unity. Otherwise your population will either shrink or grow.


Member Function Documentation

template<class T>
void prapi::ga::CrossingOverBreeder< T >::createChildren const util::List< Individual< T > > &    from,
util::List< Individual< T > > &    to
[virtual]
 

Select parentSelectionRate/2*from.getLength() pairs of parents and breed them producing two children for each pair.

Parents are selected using a rank selection method.

Parameters:
from  the list from which individuals are to be selected. createNextGeneration always sorts from prior to calling this method (ascending fitness order).
to  the list that stores the selected individuals

Implements prapi::ga::Breeder< T >.

template<class T>
util::List< Individual< T > > prapi::ga::CrossingOverBreeder< T >::mate const Individual< T > &    parent1,
const Individual< T > &    parent2
[virtual]
 

Mate two individuals and produce some offspring.

This implementation makes a random number of crossing overs to the genes of the parents and returns a list containing two new individuals. You may want to override this method to produce different mating schemes.

Parameters:
parent1  the first parent
parent2  the second parent
Returns:
a list containing the children bred


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.