|
Grail (C++)
1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
|
3 #ifndef GRAIL_CROSSOVER_H
4 #define GRAIL_CROSSOVER_H
19 enum class CrossoverSelectionType
52 CrossoverSelectionType
selectionType = CrossoverSelectionType::PSEUDO_ROULETTE,
55 std::mt19937_64::result_type seed = std::random_device{}());
63 void Perform(
const std::vector<std::unique_ptr<Individual>>& inputPopulation);
74 CrossoverSelectionType
selectionType = CrossoverSelectionType::PSEUDO_ROULETTE;
99 std::mt19937_64 randGen;
102 void PerformRandomCrossover(
const std::vector<std::unique_ptr<Individual>>& inputPopulation);
103 void PerformRouletteCrossover(
const std::vector<std::unique_ptr<Individual>>& inputPopulation);
104 void PerformTopCrossover(
const std::vector<std::unique_ptr<Individual>>& inputPopulation);
105 void PerformPseudoRouletteCrossover(
const std::vector<std::unique_ptr<Individual>>& inputPopulation);
106 void PerformConsecutivePairsCrossover(
const std::vector<std::unique_ptr<Individual>>& inputPopulation);
110 #endif // GRAIL_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.
Definition: Crossover.cpp:13
virtual void CrossoverFunctionOnePoint(Individual &individual1, Individual &individual2)
Implementation of the standard one-point crossover operation.
Definition: Crossover.cpp:77
double pseudoRouletteRandomPortion
Used only with pseudo-roulette. This method selects pseudoRouletteRandomPortion*100% of individuals a...
Definition: Crossover.hh:77
void Perform(const std::vector< std::unique_ptr< Individual >> &inputPopulation)
Perform - the function that performs the crossover phase.
Definition: Crossover.cpp:30
The Crossover structure that encapsulates the crossover operation and its configuration in evolutiona...
Definition: Crossover.hh:40
double crossoverPhaseRate
The probability of a crossover phase to happen (globally). If a crossover is included in the algorith...
Definition: Crossover.hh:80
virtual void CrossoverFunctionMultiPoint(Individual &individual1, Individual &individual2, size_t length)
Implementation of the standard k-point (multi-point) crossover operation.
Definition: Crossover.cpp:83
Represents an individual for evolutionary algorithms (EA). It stores the encoding consisting of opti...
Definition: Individual.hh:23
std::vector< std::unique_ptr< Individual > > populationAfter
The population of children, i.e., after the crossover operation has been performed.
Definition: Crossover.hh:68
CrossoverSelectionType selectionType
The method that chooses parents to be recombined.
Definition: Crossover.hh:74
virtual void CrossoverIndividuals(Individual &individual1, Individual &individual2)
The function that performs a single crossover operation between two individuals.
Definition: Crossover.cpp:90
double crossoverIndividualRate
The average rate of crossover. The expected number of children is: populationSize*crossoverIndividual...
Definition: Crossover.hh:71