Grail (C#)  1.4.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
Grail.Evolution Namespace Reference

Classes

class  BaseEvoParam
 A class that represents a parameter that is modifiable (optimizable) by evolutionary algorithms.
Unless your parameter is only a positional index (represented by an integer from 0 to max), use a specialized version EvoParam<Type>.
These parameters form an encoding and are stored as member Fields or Properties in an Individual and set as optimizable using Individual.SetMemberParameterOptimizable.
Typically, the Individual.SetMemberParameterOptimizable function should be called in the constructor of an Individual-derived class. More...
 
class  Crossover
 The Crossover object that encapsulates the crossover operation and its configuration in the evolutionary algorithm. More...
 
class  EAOptimizer
 A class that serves as the main interface for evolutionary algorithms in Grail. More...
 
class  EvoParam
 A specialization of BaseEvoParam to hold a value of specific type. Use a generic version if the inner type of the parameter is not just an integer position from [0,n]. More...
 
class  FitnessRepository
 This class provides a functionality of assigning fitness values as averages from the previous evaluations.
It can be used to minimize the effects of variance when fitness calculation is non-deterministic.
Use AddSampleWithFitnessUpdate(Individual) method to store the current fitness and update it based on past evaluations.
More...
 
interface  IFitnessProvider
 Contains one property Fitness. This interface can be used for evolutionary algorithms and/or for RouletteSampler<T>. More...
 
class  Individual
 Represents an individual for evolutionary algorithms (EA).
It stores the encoding consisting of optimizable parameters (represented by BaseEvoParam and specialized EvoParam<Type>).
The members (fields or properties) should be registered for optimization using SetMemberParameterOptimizable methods in your implementation of the constructor.
In the optimization process, the EA will require assigning the fitness evaluation to the individual. Calculate it in your game environment based on the current values of Individual's parameters. More...
 
class  Mutation
 The Mutation object that encapsulates the mutation operation and its configuration in evolutionary algorithm. More...
 
class  RouletteSampler
 Provides a functionality of a fitness proportional roulette sampling of any objects that implement the IFitnessProvider interface.
Because the implementation is optimized for usage in EA, the sampled elements are removed unless the method ends with 'WithReturn'. More...
 
class  Selection
 The Selection class encapsulates the selection operation, i.e., how individuals are selected from the current population to the next generation, in the evolutionary algorithm.
See EAOptimizer. More...
 

Enumerations

enum  CrossoverSelectionType {
  CrossoverSelectionType.RANDOM, CrossoverSelectionType.ROULETTE, CrossoverSelectionType.TOP, CrossoverSelectionType.PSEUDO_ROULETTE,
  CrossoverSelectionType.CONSECUTIVE_PAIRS
}
 Predefined ways in which individuals are selected from the population for crossover. Please refer to enum values for details about each of them. More...
 
enum  ElitismType { ElitismType.NONE, ElitismType.FITNESS_RANKING, ElitismType.ROULETTE }
 Different types of handling elitism within evolutionary algorithm. More...
 
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...
 

Enumeration Type Documentation

◆ CrossoverSelectionType

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

Enumerator
RANDOM 

Each individual that undergoes crossover is selected using a uniform random distribution.

ROULETTE 

Individuals that will be recombined together are selected using weighted random distribution proportional to their fitness values.

TOP 

Only the top individuals as ranked by fitness are selected for crossover - without any randomization.

PSEUDO_ROULETTE 

A certain amount of individuals determined by Crossover.PseudoRouletteRandomPortion is chosen as in RANDOM, whereas the rest as in ROULETTE.

CONSECUTIVE_PAIRS 

In this method, an i-th individual will be recombined with the (i+1)-th individual according to the current ordering of the population. The ordering is arbitrary, not performed by fitness.

◆ ElitismType

Different types of handling elitism within evolutionary algorithm.

Enumerator
NONE 

NONE - there is no elitism in the algorithm.

FITNESS_RANKING 

FITNESS_RANKING - the most fit individuals are chosen as the elite individuals.

ROULETTE 

ROULETTE - elite individuals are chosen using fitness proportional roulette-sampling.

◆ 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 

A random test whether to mutate an individual will be performed for each individual in a loop.

SELECT_P_OF_N 

Upfront, the PopulationSize*MutationIndividualRate of individuals will be randomly chosen for mutation.
This ensures that the expected number of individuals will be mutated, regardless of RNG.