|
Grail (C++)
1.3.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
58 CrossoverSelectionType
selectionType = CrossoverSelectionType::PSEUDO_ROULETTE,
61 std::mt19937_64::result_type seed = std::random_device{}());
69 void Perform(
const std::vector<std::unique_ptr<EvoScript>>& inputPopulation);
89 virtual void CrossoverFunctionOnePoint(
EvoScript& individual1,
EvoScript& individual2);
90 virtual void CrossoverFunctionMultiPoint(
EvoScript& individual1,
EvoScript& individual2,
size_t length);
94 std::mt19937_64 randGen;
97 void PerformRandomCrossover(
const std::vector<std::unique_ptr<EvoScript>>& inputPopulation);
98 void PerformRouletteCrossover(
const std::vector<std::unique_ptr<EvoScript>>& inputPopulation);
99 void PerformTopCrossover(
const std::vector<std::unique_ptr<EvoScript>>& inputPopulation);
100 void PerformPseudoRouletteCrossover(
const std::vector<std::unique_ptr<EvoScript>>& inputPopulation);
101 void PerformConsecutivePairsCrossover(
const std::vector<std::unique_ptr<EvoScript>>& inputPopulation);
105 #endif // GRAIL_CROSSOVER
std::vector< std::unique_ptr< EvoScript > > populationAfter
Population after the crossover operation is performed.
Definition: Crossover.hh:74
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
double pseudoRouletteRandomPortion
Pseudoroullete selects pseudoRouletteRandomPortion individuals at random and 1-pseudoRouletteRandomPo...
Definition: Crossover.hh:83
The Crossover structure that encapsulates the crossover operation and its configuration in evolutiona...
Definition: Crossover.hh:46
double crossoverPhaseRate
Probability of a crossover phase to happen (globally). If a crossover is included in the algorithm,...
Definition: Crossover.hh:86
EvoScript - a class that holds a collection of EvoParams (through them) is optimizable....
Definition: EvoScript.hh:18
void Perform(const std::vector< std::unique_ptr< EvoScript >> &inputPopulation)
Perform - the function that performs the crossover phase.
Definition: Crossover.cpp:30
CrossoverSelectionType selectionType
The method that chooses parents to be recombined.
Definition: Crossover.hh:80
double crossoverIndividualRate
Average rate of crossover. If N is the population.size(), then around (N*crossoverIndividualRate) chi...
Definition: Crossover.hh:77