A class that serves as the main interface for evolutionary algorithms in Grail.
More...
|
| | EAOptimizer (List< Individual > initialPopulation, uint maxEpochCount, Crossover crossover=null, Mutation mutation=null, Selection selection=null) |
| | Constructor. The EA algorithm will maintain the size of the initial population after the selection phase. More...
|
| |
|
List< Individual > | GetPopulation () |
| | - Returns
- A list, sorted by fitness, that contains deep clones of the current population evolved by the algorithm.
|
| |
| Individual | GetBestIndividual () |
| | Returns the individual with the highest fitness value from the population. More...
|
| |
| void | SerializeState (string filename) |
| | Serializes the inner state of the evolutionary algorithm, including the current population.
You can load the serialized state again by calling the DeserializeState(string) method. More...
|
| |
| bool | DeserializeState (string filename) |
| | Loads a previously serialized state of the evolutionary algorithm.
You can, for instance, get the results or continue calculations. More...
|
| |
|
float | CalculatePopulationDiversity () |
| | - Returns
- The diversity ratio as a number [0,1]. The lower the value, the population is more homogeneous
|
| |
| int | CalculatePopulationIdenticalFrontCount () |
| | Finds the most frequent individuals (which are identical to each other) and returns the number of them. More...
|
| |
|
float | CalculatePopulationIdenticalFrontRatio () |
| | - Returns
- The number of the most frequent identical individuals divided by the population size.
|
| |
| void | RunInteractive (System.Action< Individual > onEvaluateNeeded, System.Action onFinished=null, System.Action onNewEpoch=null) |
| | Advances the computations of the evolutionary algorithm (EA). This is the main method to run it. This method will call provided functions on specific events. More...
|
| |
|
| int | PopulationSize => corePopulation.Count |
| | Returns the number of individuals in the current population. More...
|
| |
A class that serves as the main interface for evolutionary algorithms in Grail.
◆ EAOptimizer()
| Grail.Evolution.EAOptimizer.EAOptimizer |
( |
List< Individual > |
initialPopulation, |
|
|
uint |
maxEpochCount, |
|
|
Crossover |
crossover = null, |
|
|
Mutation |
mutation = null, |
|
|
Selection |
selection = null |
|
) |
| |
|
inline |
Constructor. The EA algorithm will maintain the size of the initial population after the selection phase.
- Parameters
-
| initialPopulation | The initial population to the EA algorithm. For example, you can create one individual and call GetRandomRealizations() on it. |
| maxEpochCount | The maximum number of full iterations after which the algorithm will stop making any further optimizations. |
| crossover | The Crossover instance that encapsulates the crossover (recombination) procedure of evolutionary algorithm. |
| mutation | The Mutation instance that encapsulates the mutation procedure of evolutionary algorithm. |
| selection | The Selection instance that encapsulates the selection procedure of evolutionary algorithm. |
◆ CalculatePopulationIdenticalFrontCount()
| int Grail.Evolution.EAOptimizer.CalculatePopulationIdenticalFrontCount |
( |
| ) |
|
|
inline |
Finds the most frequent individuals (which are identical to each other) and returns the number of them.
- Returns
- The number of the most frequent identical individuals.
◆ DeserializeState()
| bool Grail.Evolution.EAOptimizer.DeserializeState |
( |
string |
filename | ) |
|
|
inline |
Loads a previously serialized state of the evolutionary algorithm.
You can, for instance, get the results or continue calculations.
- Parameters
-
| filename | The path where the state has been saved. |
- Returns
- A boolean value that tells if the deserialization was successful.
◆ GetBestIndividual()
| Individual Grail.Evolution.EAOptimizer.GetBestIndividual |
( |
| ) |
|
|
inline |
Returns the individual with the highest fitness value from the population.
- Returns
- The individual with the highest fitness value from the population.
◆ RunInteractive()
| void Grail.Evolution.EAOptimizer.RunInteractive |
( |
System.Action< Individual > |
onEvaluateNeeded, |
|
|
System.Action |
onFinished = null, |
|
|
System.Action |
onNewEpoch = null |
|
) |
| |
|
inline |
Advances the computations of the evolutionary algorithm (EA). This is the main method to run it. This method will call provided functions on specific events.
- Parameters
-
| onEvaluateNeeded | When EA needs an individual to have it fitness evaluated, it will invoke this callback function with this individual as a parameter. |
| onFinished | This callback will be invoked when the algorithm has reached its maximum number of iterations. |
| onNewEpoch | This callback will be invoked when a new epoch (iteration) starts. An epoch is one round of evaluating a population and applying genetic operators on it. |
◆ SerializeState()
| void Grail.Evolution.EAOptimizer.SerializeState |
( |
string |
filename | ) |
|
|
inline |
Serializes the inner state of the evolutionary algorithm, including the current population.
You can load the serialized state again by calling the DeserializeState(string) method.
- Parameters
-
| filename | The path where the state will be saved. If the file exists, it will be overridden. |
◆ PopulationSize
| int Grail.Evolution.EAOptimizer.PopulationSize => corePopulation.Count |
Returns the number of individuals in the current population.
◆ ElitismRate
| double Grail.Evolution.EAOptimizer.ElitismRate |
|
getset |
Percent of most fit individuals in a population that will be considered for the next population without any change.
◆ ElitismType
| ElitismType Grail.Evolution.EAOptimizer.ElitismType = 0.2 |
|
getset |
Determines if and how the elitism is enabled in the evolutionary algorithm. See ElitismType.
◆ EpochNumber
| uint Grail.Evolution.EAOptimizer.EpochNumber = 0 |
|
get |
The current epoch (iteration) number.
◆ MaxEpochCount
The number of epochs (iterations) of EA, after which the algorithm will stop.
The documentation for this class was generated from the following file:
- GrailEvolution/source/EAOptimizer.cs