Grail (C++)  1.1.1
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::evolution::EAOptimizer Class Referencefinal

Public Member Functions

 EAOptimizer (std::vector< std::unique_ptr< EvoScript >> &initialPopulation, std::unique_ptr< Arena > arenaEvaluation, std::unique_ptr< Crossover > crossover=std::make_unique< Crossover >(), std::unique_ptr< Mutation > mutation=std::make_unique< Mutation >(), std::unique_ptr< Selection > selection=std::make_unique< Selection >(), std::mt19937_64::result_type seed=std::random_device{}())
 The EA algorithm will maintain the size of the initial population after the selection phase. More...
 
size_t PopulationSize () const
 
void Run (int maxEpochCount=1)
 
void SetElitism (double rate, ElitismType type)
 
float CalculatePopulationDiversity () const
 
size_t CalculatePopulationIdenticalFront () const
 
EvoScriptGetBestIndividual () const
 
void SetOnEpochEndedCallback (std::function< void(EAOptimizer &eaOptimizer)> function)
 
CrossoverGetCrossover () const
 
MutationGetMutation () const
 

Friends

std::ostream & operator<< (std::ostream &out, const EAOptimizer &eaOptimizer)
 

Constructor & Destructor Documentation

◆ EAOptimizer()

grail::evolution::EAOptimizer::EAOptimizer ( std::vector< std::unique_ptr< EvoScript >> &  initialPopulation,
std::unique_ptr< Arena arenaEvaluation,
std::unique_ptr< Crossover crossover = std::make_unique<Crossover>(),
std::unique_ptr< Mutation mutation = std::make_unique<Mutation>(),
std::unique_ptr< Selection selection = std::make_unique<Selection>(),
std::mt19937_64::result_type  seed = std::random_device{}() 
)

The EA algorithm will maintain the size of the initial population after the selection phase.

Parameters
initialPopulationInitial population to the EA algorithm.
arenaEvaluation
mutation
crossover
selection

Member Function Documentation

◆ CalculatePopulationDiversity()

float grail::evolution::EAOptimizer::CalculatePopulationDiversity ( ) const

Returns the diversity ratio as a number [0,1]. The lower the value, the population is more homogeneous

◆ CalculatePopulationIdenticalFront()

size_t grail::evolution::EAOptimizer::CalculatePopulationIdenticalFront ( ) const

Finds the most frequent individuals (which are identical to each other) and returns the number of them.

◆ Run()

void grail::evolution::EAOptimizer::Run ( int  maxEpochCount = 1)

Runs the EA algorithm for a given number of evolutionary epochs. The main method of the algorithm.


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