Grail (C++)  1.3.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< EvoScript >> &inputPopulation)
 Perform - the function that performs the crossover phase. More...
 

Public Attributes

std::vector< std::unique_ptr< EvoScript > > populationAfter {}
 Population after the crossover operation is performed. More...
 
double crossoverIndividualRate = 0.0
 Average rate of crossover. If N is the population.size(), then around (N*crossoverIndividualRate) children will be produced.
 
CrossoverSelectionType selectionType = CrossoverSelectionType::RANDOM
 The method that chooses parents to be recombined.
 
double pseudoRouletteRandomPortion = 0.0
 Pseudoroullete selects pseudoRouletteRandomPortion individuals at random and 1-pseudoRouletteRandomPortion according to roulette.
 
double crossoverPhaseRate = 0.0
 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 (EvoScript &individual1, EvoScript &individual2)
 
virtual void CrossoverFunctionMultiPoint (EvoScript &individual1, EvoScript &individual2, size_t length)
 
virtual void CrossoverIndividuals (EvoScript &individual1, EvoScript &individual2)
 

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- average rate of crossover. If N is the population.size(), then around (N*crossoverIndividualRate) children will be produced.
selectionType- the method that chooses parents to be recombined. See CrossoverSelectionType.
pseudoRouletteRandomPortion- pseudoroullete selects pseudoRouletteRandomPortion individuals at random and 1-pseudoRouletteRandomPortion according to roulette.
crossoverPhaseRate- 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- initial seed for random numbers generator.

Member Function Documentation

◆ Perform()

void grail::evolution::Crossover::Perform ( const std::vector< std::unique_ptr< EvoScript >> &  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<EvoScript> > grail::evolution::Crossover::populationAfter {}

Population after the crossover operation is performed.


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