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

The Mutation structure that encapsulates the mutation operation and its configuration in evolutionary algorithm. More...

#include <Mutation.hh>

Public Types

enum  MutationSelectionType { MutationSelectionType::ITERATE_AND_TEST_P, MutationSelectionType::SELECT_P_OF_N }
 Predefined ways in which individuals are selected from the population for mutation. Please refer to enum values for details about each of them. More...
 

Public Member Functions

 Mutation (double mutationPhaseRate=1.0, double mutateIndividualRate=0.09, double mutateChromosomeRate=0.5, bool mutateBothParentsAndChildren=true, std::mt19937_64::result_type seed=std::random_device{}())
 Mutation - Constructor. More...
 
virtual void Perform (const std::vector< std::unique_ptr< EvoScript >> &parentPopulation, const std::vector< std::unique_ptr< EvoScript >> &childrenPopulation)
 Perform - Attempts to mutate the entire population. The umber of individuals mutates is based on mutation phase rate and mutate individual rate. More...
 

Public Attributes

std::vector< std::unique_ptr< EvoScript > > populationAfter {}
 
double MutationPhaseRate = 0.0
 Probability of a mutation phase to happen (globally). If a mutation is included in the algorithm, this value should most likely be equal to 1.0.
 
double MutateIndividualRate = 0.0
 Probability that an individual will be considered for mutation (randomResolutionTypeForIndividual == ITERATE_AND_TEST_P); or the portion of individuals chosen for mutation (randomResolutionTypeForIndividual == SELECT_P_OF_N).
 
double MutateChromosomeRate = 0.0
 Probability that a chromosome of an individual will be considered for mutation (randomResolutionTypeForChromosome == ITERATE_AND_TEST_P); or the portion of chromosomes within an individual chosen for mutation (randomResolutionTypeForChromosome == SELECT_P_OF_N).
 
bool MutateBothParentsAndChildren = false
 If true: both the previous population and children can be mutated; if false: only the individuals after crossover can be mutated.
 

Protected Member Functions

virtual void MutateIndividual (EvoScript &individual)
 
virtual void MutateChromosome (EvoScript &individual, EvoParam &chromosome)
 

Protected Attributes

std::mt19937_64 randGen
 
MutationSelectionType RandomResolutionTypeForIndividual = MutationSelectionType::SELECT_P_OF_N
 
MutationSelectionType RandomResolutionTypeForChromosome = MutationSelectionType::SELECT_P_OF_N
 

Detailed Description

The Mutation structure that encapsulates the mutation operation and its configuration in evolutionary algorithm.

Member Enumeration Documentation

◆ MutationSelectionType

Predefined ways in which individuals are selected from the population for mutation. Please refer to enum values for details about each of them.

Enumerator
ITERATE_AND_TEST_P 

ITERATE_AND_TEST_P -

SELECT_P_OF_N 

SELECT_P_OF_N -

Constructor & Destructor Documentation

◆ Mutation()

grail::evolution::Mutation::Mutation ( double  mutationPhaseRate = 1.0,
double  mutateIndividualRate = 0.09,
double  mutateChromosomeRate = 0.5,
bool  mutateBothParentsAndChildren = true,
std::mt19937_64::result_type  seed = std::random_device{}() 
)

Mutation - Constructor.

Parameters
mutationPhaseRate- probability of a mutation phase to happen (globally). If a mutation is included in the algorithm, this value should most likely be equal to 1.0.
mutateIndividualRate-Probability that an individual will be considered for mutation (randomResolutionTypeForIndividual == ITERATE_AND_TEST_P); or the portion of individuals chosen for mutation (randomResolutionTypeForIndividual == SELECT_P_OF_N).
mutateChromosomeRate- probability that a chromosome of an individual will be considered for mutation (randomResolutionTypeForChromosome == ITERATE_AND_TEST_P); or the portion of chromosomes within an individual chosen for mutation (randomResolutionTypeForChromosome == SELECT_P_OF_N).
mutateBothParentsAndChildren- if true: both the previous population and children can be mutated; if false: only the individuals after crossover can be mutated.
seed- initial seed for random numbers generator.

Member Function Documentation

◆ Perform()

void grail::evolution::Mutation::Perform ( const std::vector< std::unique_ptr< EvoScript >> &  parentPopulation,
const std::vector< std::unique_ptr< EvoScript >> &  childrenPopulation 
)
virtual

Perform - Attempts to mutate the entire population. The umber of individuals mutates is based on mutation phase rate and mutate individual rate.

Parameters
parentPopulationParent population - before the mutation.
childrenPopulationChildren population - after the mutation.

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