Grail (C++)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::evolution::Crossover Struct Reference

The Crossover structure that encapsulates the crossover operation and its configuration in evolutionary algorithm. More...

#include <Crossover.hh>

Public Member Functions

 Crossover (double crossoverIndividualRate=0.45, CrossoverSelectionType selectionType=CrossoverSelectionType::PSEUDO_ROULETTE, double pseudoRouletteRandomPortion=0.3, double crossoverPhaseRate=1.0, std::mt19937_64::result_type seed=std::random_device{}())
 Crossover - Constructor. More...
 
void Perform (const std::vector< std::unique_ptr< Individual >> &inputPopulation)
 Perform - the function that performs the crossover phase. More...
 

Public Attributes

std::vector< std::unique_ptr< Individual > > populationAfter {}
 The population of children, i.e., after the crossover operation has been performed. More...
 
double crossoverIndividualRate = 0.45
 The average rate of crossover. The expected number of children is: populationSize*crossoverIndividualRate.
 
CrossoverSelectionType selectionType = CrossoverSelectionType::PSEUDO_ROULETTE
 The method that chooses parents to be recombined.
 
double pseudoRouletteRandomPortion = 0.3
 Used only with pseudo-roulette. This method selects pseudoRouletteRandomPortion*100% of individuals at random and (1-pseudoRouletteRandomPortion)*100% according to roulette.
 
double crossoverPhaseRate = 1.0
 The probability of a crossover phase to happen (globally). If a crossover is included in the algorithm, this value should most likely be equal to 1.0.
 

Protected Member Functions

virtual void CrossoverFunctionOnePoint (Individual &individual1, Individual &individual2)
 Implementation of the standard one-point crossover operation. More...
 
virtual void CrossoverFunctionMultiPoint (Individual &individual1, Individual &individual2, size_t length)
 Implementation of the standard k-point (multi-point) crossover operation. More...
 
virtual void CrossoverIndividuals (Individual &individual1, Individual &individual2)
 The function that performs a single crossover operation between two individuals. More...
 

Protected Attributes

std::mt19937_64 randGen
 

Detailed Description

The Crossover structure that encapsulates the crossover operation and its configuration in evolutionary algorithm.

Constructor & Destructor Documentation

◆ Crossover()

grail::evolution::Crossover::Crossover ( double  crossoverIndividualRate = 0.45,
CrossoverSelectionType  selectionType = CrossoverSelectionType::PSEUDO_ROULETTE,
double  pseudoRouletteRandomPortion = 0.3,
double  crossoverPhaseRate = 1.0,
std::mt19937_64::result_type  seed = std::random_device{}() 
)

Crossover - Constructor.

Parameters
crossoverIndividualRate- the average rate of crossover. The expected number of children is: populationSize*crossoverIndividualRate.
selectionType- the method that chooses parents to be recombined. See the CrossoverSelectionType enum.
pseudoRouletteRandomPortion- used only with pseudo-roulette. This method selects pseudoRouletteRandomPortion*100% of individuals at random and (1-pseudoRouletteRandomPortion)*100% according to roulette.
crossoverPhaseRate- the probability of a crossover phase to happen (globally). If a crossover is included in the algorithm, this value should most likely be equal to 1.0.
seed- the initial seed for random numbers generator.

Member Function Documentation

◆ CrossoverFunctionMultiPoint()

void grail::evolution::Crossover::CrossoverFunctionMultiPoint ( Individual individual1,
Individual individual2,
size_t  length 
)
protectedvirtual

Implementation of the standard k-point (multi-point) crossover operation.

Parameters
individual1- the first parent to produce offspring.
individual2- the second parent to produce offspring.

◆ CrossoverFunctionOnePoint()

void grail::evolution::Crossover::CrossoverFunctionOnePoint ( Individual individual1,
Individual individual2 
)
protectedvirtual

Implementation of the standard one-point crossover operation.

Parameters
individual1- the first parent to produce offspring.
individual2- the second parent to produce offspring.

◆ CrossoverIndividuals()

void grail::evolution::Crossover::CrossoverIndividuals ( Individual individual1,
Individual individual2 
)
protectedvirtual

The function that performs a single crossover operation between two individuals.

Parameters
individual1- the first parent to produce offspring.
individual2- the second parent to produce offspring.

◆ Perform()

void grail::evolution::Crossover::Perform ( const std::vector< std::unique_ptr< Individual >> &  inputPopulation)

Perform - the function that performs the crossover phase.

Parameters
inputPopulation- the population containing individuals that are candidates for the crossover. Please note that the crossover might not choose all individuals depending on its configuration.

Member Data Documentation

◆ populationAfter

std::vector<std::unique_ptr<Individual> > grail::evolution::Crossover::populationAfter {}

The population of children, i.e., after the crossover operation has been performed.


The documentation for this struct was generated from the following files: