iPcEvolve Struct Reference
A property class implementing a genetic algorithm. More...
#include <propclass/evolve.h>

Public Member Functions | |
virtual void | FitnessCallback (float fitness)=0 |
Informs the property class that the fitness of a genome has been evaluated, as requested by the "pcevolve_fitness" message. | |
virtual void | Generate ()=0 |
Instructs the property class to begin the evolution of one generation. | |
virtual float | GetFitness (size_t index) const =0 |
Returns the fitness of the genome specified by the index parameter. | |
virtual size_t | GetPopulationSize () const =0 |
Returns the population size (number of individual genomes). | |
virtual iCelPropertyClass * | GetSubject ()=0 |
Returns the subject property class (the property class being evolved by this one. | |
virtual void | ResetPopulation ()=0 |
Resets the property class to its initial state before Generate() was first called. | |
virtual void | SelectGenome (size_t index)=0 |
Stored the genome specified by the index parameter into the subject property class. | |
virtual void | SetPopulationSize (size_t size)=0 |
Sets the population size (number of individual genomes). | |
virtual void | SetProbabilities (float select, float mutate)=0 |
Sets the probability parameters for the stochastic (non-deterministic) randomness of the genetic algorithm. | |
virtual void | SetSubject (iCelPropertyClass *pc)=0 |
Sets the subject property class (the property class that will be evolved by this one). |
Detailed Description
A property class implementing a genetic algorithm.
Currently the only thing that can be evolved using this is the celPcNeuralNet, but it would be fairly easy to extend it to support evolving other property classes where applicable.
The property class holds the following properties (add prefix "cel.property." to get a property ID):
- "population" (long) The size of the population (number of genomes).
- "subject" (propclass) The property class that will be evolved.
- "select_probability" (float) Parameter for stochastic selection.
- "mutate_probability" (float) Parameter for stochastic mutation.
And the following actions (add prefix "cel.action." or "cel.parameter." to get the ID of an action or parameter respectively):
- "Generate" Begins evolution of one generation.
- "ReturnFitness" The behaviour calls this after evaluating the fitness of the presently selected genome. Parameter: "fitness" (float).
- "GetFitness" Gets the fitness of a genome. Parameter: "index" (long).
- "Select" Stores a genome in subject. Parameter: "index" (long).
- "Reset" Resets the population to its state before "Generate" was called.
And sends the following message to the behaviour:
- "pcevolve_fitness" Tells the behaviour to evaluate the fitness of the genome currently stored in the subject propclass.
- "pcevolve_result" Signals completion of evolution of one generation. Parameters: "max_fitness", "min_fitness", "avg_fitness" (floats).
Definition at line 62 of file evolve.h.
Member Function Documentation
virtual void iPcEvolve::FitnessCallback | ( | float | fitness | ) | [pure virtual] |
Informs the property class that the fitness of a genome has been evaluated, as requested by the "pcevolve_fitness" message.
- Parameters:
-
fitness The fitness value. May not be less than zero.
virtual void iPcEvolve::Generate | ( | ) | [pure virtual] |
Instructs the property class to begin the evolution of one generation.
This will send the "pcevolve_fitness" message once for each individual genome in the population, to ask the behaviour to evaluate its fitness.
virtual float iPcEvolve::GetFitness | ( | size_t | index | ) | const [pure virtual] |
Returns the fitness of the genome specified by the index parameter.
This will be zero if its fitness has yet to be evaluated.
- Parameters:
-
index The index into the population array, which is sorted in descending order of fitness (0 being the fittest).
virtual size_t iPcEvolve::GetPopulationSize | ( | ) | const [pure virtual] |
Returns the population size (number of individual genomes).
virtual iCelPropertyClass* iPcEvolve::GetSubject | ( | ) | [pure virtual] |
Returns the subject property class (the property class being evolved by this one.
virtual void iPcEvolve::ResetPopulation | ( | ) | [pure virtual] |
Resets the property class to its initial state before Generate() was first called.
virtual void iPcEvolve::SelectGenome | ( | size_t | index | ) | [pure virtual] |
Stored the genome specified by the index parameter into the subject property class.
- Parameters:
-
index The index into the population array, which is sorted in descending order of fitness (0 being the fittest).
virtual void iPcEvolve::SetPopulationSize | ( | size_t | size | ) | [pure virtual] |
Sets the population size (number of individual genomes).
Sets the probability parameters for the stochastic (non-deterministic) randomness of the genetic algorithm.
- Parameters:
-
select Genomes will be selected for crossover with a probability of p(1-p)^r
, where p is this parameter and r is the genome's rank in descending order of fitness (0 being the fittest).mutate The average number of genes to mutate in each genome. For example, 3.0 means that an average of 3 genes will be mutated, while 0.5 means that one gene will be mutated in every 2 genomes, on average.
virtual void iPcEvolve::SetSubject | ( | iCelPropertyClass * | pc | ) | [pure virtual] |
Sets the subject property class (the property class that will be evolved by this one).
It must be of a type supported by the genetic algorithm.
The documentation for this struct was generated from the following file:
- propclass/evolve.h
Generated for CEL: Crystal Entity Layer 1.4.1 by doxygen 1.7.1