Robot Simulator of the Robotics Group for Self-Organization of Control
0.8.0
|
This is the engine of the gen. More...
#include <SingletonGenEngine.h>
Public Member Functions | |
const std::vector < GenPrototype * > & | getSetOfGenPrototyps (void) const |
this function returns a set of all registered GenPrototypes. More... | |
int | getNumGeneration (void) const |
this function return the number of Generation inside. More... | |
Generation * | getGeneration (int x) |
this function returns one Generation More... | |
int | getActualGenerationNumber (void) const |
returns the actual generation number, on which the alg. More... | |
Generation * | getActualGeneration (void) |
returns the actual Generation. More... | |
int | getNumIndividual (void) const |
returns the number of individual inside the alg. More... | |
Individual * | getIndividual (int x) const |
returns one individual More... | |
void | addGenPrototype (GenPrototype *prototype) |
registered a GenPrototype in the engine. More... | |
void | addGen (Gen *gen) |
registered a Gen in the engine. More... | |
Gen * | getGen (int x) const |
returns one gene More... | |
void | addIndividual (Individual *individual) |
registered a individual in the engine. More... | |
void | addGeneration (Generation *generation) |
add a Generation to the alg. More... | |
void | generateFirstGeneration (int startSize, int numChildren, RandGen *random, bool withUpdate=true) |
prepare the alg. More... | |
void | prepareNextGeneration (int size, int numChildren) |
prepare the next generation. More... | |
void | prepare (int startSize, int numChildren, InspectableProxy *&proxyGeneration, InspectableProxy *&proxyGene, RandGen *random, PlotOptionEngine *plotEngine=0, PlotOptionEngine *plotEngineGenContext=0, bool withUpdate=true) |
prepare the first generation with "generateFirstGeneration" and init the measures. More... | |
int | getNextGenerationSize () |
return the size of the next generation. More... | |
void | measureStep (double time, InspectableProxy *&proxyGeneration, InspectableProxy *&proxyGene, PlotOptionEngine *plotEngine=0, PlotOptionEngine *plotEngineGenContext=0) |
makes a step in the measure More... | |
void | runGenAlg (int startSize, int numChildren, int numGeneration, RandGen *random, PlotOptionEngine *plotEngine=0, PlotOptionEngine *plotEngineGenContext=0) |
this function is for a automatically run of the gen. More... | |
void | select (bool createNextGeneration=true) |
make the select of the actual generation and transfer it to the next generation More... | |
void | crossover (RandGen *random) |
in the actual generation it will generate the children of the living individual More... | |
void | update (double factor=1.5) |
this function makes a update on the statistical data of the gen. More... | |
void | setSelectStrategy (ISelectStrategy *strategy) |
decid the select strategy More... | |
void | setGenerationSizeStrategy (IGenerationSizeStrategy *strategy) |
decide the generation size strategy. More... | |
void | setFitnessStrategy (IFitnessStrategy *strategy) |
decide the fitness strategy. More... | |
double | getFitness (const Individual *individual) |
calculate for a individual the fitness value. More... | |
Individual * | getBestIndividual (void) |
returns the best individual (where the fitness is next to zero) which the alg. More... | |
std::string | getIndividualRoot (bool withMutation=true) const |
returns a complete list of the inheritance of all individual. More... | |
std::string | getAllIndividualAsString (void) const |
returns a list of all individual and there gens values. More... | |
virtual bool | store (FILE *f) const |
stores the object to the given file stream (binary). More... | |
virtual bool | restore (FILE *f, InspectableProxy *&proxyGeneration, InspectableProxy *&proxyGene, PlotOptionEngine *plotEngine, PlotOptionEngine *plotEngineGenContext) |
loads the object from the given file stream (binary). More... | |
Static Public Member Functions | |
static SingletonGenEngine * | getInstance (void) |
returns the only existing engine. More... | |
static void | destroyGenEngine (bool cleanStrategies=false) |
destroy the only existing engine. More... | |
Protected Attributes | |
std::vector< GenPrototype * > | m_prototype |
managment storage for all Genprototypes. More... | |
std::vector< Generation * > | m_generation |
managment storage for all Generation More... | |
std::vector< Individual * > | m_individual |
management storage for all Individual More... | |
std::vector< Gen * > | m_gen |
management storage for all Gens More... | |
int | m_actualGeneration |
the number of the actual generation More... | |
ISelectStrategy * | m_selectStrategy |
the select strategy of the alg. More... | |
IFitnessStrategy * | m_fitnessStrategy |
the fitness strategy of the alg. More... | |
IGenerationSizeStrategy * | m_generationSizeStrategy |
the generation size strategy of the alg. More... | |
bool | m_cleanStrategies |
flag for clean the seted strategies More... | |
std::map< int, RESTORE_GA_GENERATION * > | m_restoreGeneration |
Map for restoring the generations from a run before. More... | |
std::map< int, RESTORE_GA_INDIVIDUAL * > | m_restoreIndividual |
Map for restoring the individuals from a run before. More... | |
std::map< int, std::vector< int > > | m_restoreIndividualInGeneration |
Map for restoring the individual generation link from a run before. More... | |
std::map< int, std::vector< int > > | m_restoreGeneInIndividual |
Map for restoring the genes individual link from a run before. More... | |
std::map< int, std::string > | m_restoreNameOfIndividuals |
Map for restoring the names of the individuals. More... | |
Static Protected Attributes | |
static SingletonGenEngine * | m_engine = 0 |
the one and only GenEngine. More... | |
This is the engine of the gen.
alg.
Over this is the class as singleton concepted. Only one engine for a run.
|
inline |
|
inline |
add a Generation to the alg.
Normal only used by the alg. self.
generation | (Generation*) the generation |
|
inline |
registered a GenPrototype in the engine.
prototype | (GenPrototype*) the prototype which should be registered. |
|
inline |
registered a individual in the engine.
Normal only used by the alg. self.
individual | (Individual*) the individual |
void crossover | ( | RandGen * | random | ) |
in the actual generation it will generate the children of the living individual
random | (RanGen*) random generator |
|
inlinestatic |
destroy the only existing engine.
void generateFirstGeneration | ( | int | startSize, |
int | numChildren, | ||
RandGen * | random, | ||
bool | withUpdate = true |
||
) |
prepare the alg.
and create his fisrt generation.
startSize | (int) Number of individual with which the alg. will be start. |
numChildren | (int) Number of individual which will be created by crossover. |
random | (RandGen*) A random generator |
withUpdate | (bool) if true, than makes this function on the end a update. |
|
inline |
returns the actual Generation.
|
inline |
returns the actual generation number, on which the alg.
work
std::string getAllIndividualAsString | ( | void | ) | const |
returns a list of all individual and there gens values.
Individual * getBestIndividual | ( | void | ) |
returns the best individual (where the fitness is next to zero) which the alg.
have found.
double getFitness | ( | const Individual * | individual | ) |
calculate for a individual the fitness value.
individual | (Individual*) the individual for which the fitness should be calculated |
|
inline |
returns one gene
x | (int) index of the gene which is searched |
|
inline |
this function returns one Generation
x | (int) the index of the Generation which is searched |
|
inline |
returns one individual
x | (int) index of the individual which is searched. |
std::string getIndividualRoot | ( | bool | withMutation = true | ) | const |
returns a complete list of the inheritance of all individual.
withMutation | (bool) normal=true. if every individual should be marked if it mutated. |
|
inlinestatic |
returns the only existing engine.
int getNextGenerationSize | ( | ) |
return the size of the next generation.
|
inline |
this function return the number of Generation inside.
|
inline |
returns the number of individual inside the alg.
|
inline |
this function returns a set of all registered GenPrototypes.
void measureStep | ( | double | time, |
InspectableProxy *& | proxyGeneration, | ||
InspectableProxy *& | proxyGene, | ||
PlotOptionEngine * | plotEngine = 0 , |
||
PlotOptionEngine * | plotEngineGenContext = 0 |
||
) |
makes a step in the measure
time | (double) the time stamp in the measure |
proxyGeneration | (InspectableProxy*&) the generation which is controlled by measures |
proxyGene | (InspectableProxy*&) the proxy for control measure |
void prepare | ( | int | startSize, |
int | numChildren, | ||
InspectableProxy *& | proxyGeneration, | ||
InspectableProxy *& | proxyGene, | ||
RandGen * | random, | ||
PlotOptionEngine * | plotEngine = 0 , |
||
PlotOptionEngine * | plotEngineGenContext = 0 , |
||
bool | withUpdate = true |
||
) |
prepare the first generation with "generateFirstGeneration" and init the measures.
startSize | (int) Number of individual with which the alg. will be start. |
numChildren | (int) Number of individual which will be created by crossover |
proxyGeneration | (InspectableProxy*&) the generation which is controlled by measures |
proxyGene | (InspectableProxy*&) the proxy for control measure |
random | (RandGen*) A random generator |
plotEngine | (PlotOptionEngine*) logging the data for later control |
plotEngineGenContext | (PlotOptionEngine*) logging the data of the GenContext for later control |
withUpdate | (bool) is needed for the function "generateFirstGeneration" |
void prepareNextGeneration | ( | int | size, |
int | numChildren | ||
) |
prepare the next generation.
Mean create the GenContext for every GenPrototype.
size | (int) size of the next generation |
numChildren | (int) Number of individual which will be created by crossover |
|
virtual |
loads the object from the given file stream (binary).
void runGenAlg | ( | int | startSize, |
int | numChildren, | ||
int | numGeneration, | ||
RandGen * | random, | ||
PlotOptionEngine * | plotEngine = 0 , |
||
PlotOptionEngine * | plotEngineGenContext = 0 |
||
) |
this function is for a automatically run of the gen.
alg.
startSize | (int) Number of individual with which the alg. will be start. |
numChildren | (int) Number of individual which will be created by crossover. |
numGeneration | (int) Number of generation after this the alg. will end. |
random | (RandGen*) a random generator |
plotEngine | (PlotOptionEngine*) logging the data for later control |
plotEngineGenContext | (PlotOptionEngine*) logging the data of the GenContext for later control |
void select | ( | bool | createNextGeneration = true | ) |
make the select of the actual generation and transfer it to the next generation
createNextGeneration | (bool) normal=true. should be the next generation prepare |
|
inline |
decide the fitness strategy.
strategy | (IFitnessStrategy*) the fitness strategy of the alg. |
|
inline |
decide the generation size strategy.
strategy | (IGenerationSizeStrategy*) the generation size strategy of the alg. |
|
inline |
decid the select strategy
strategy | (ISelectStrategy*) the select strategy of the alg. |
|
virtual |
stores the object to the given file stream (binary).
void update | ( | double | factor = 1.5 | ) |
this function makes a update on the statistical data of the gen.
alg.
factor | (double) the factor is for the whisker distance |
|
protected |
the number of the actual generation
|
protected |
flag for clean the seted strategies
|
staticprotected |
the one and only GenEngine.
|
protected |
the fitness strategy of the alg.
|
protected |
management storage for all Gens
|
protected |
managment storage for all Generation
|
protected |
the generation size strategy of the alg.
|
protected |
management storage for all Individual
|
protected |
managment storage for all Genprototypes.
|
protected |
Map for restoring the genes individual link from a run before.
|
protected |
Map for restoring the generations from a run before.
|
protected |
Map for restoring the individuals from a run before.
|
protected |
Map for restoring the individual generation link from a run before.
|
protected |
Map for restoring the names of the individuals.
|
protected |
the select strategy of the alg.