#include <SingletonGenEngine.h>
Collaboration diagram for SingletonGenEngine:

Public Member Functions | |
| const std::vector< GenPrototype * > & | getSetOfGenPrototyps (void) const |
| this function returns a set of all registered GenPrototypes. | |
| int | getNumGeneration (void) const |
| this function return the number of Generation inside. | |
| Generation * | getGeneration (int x) |
| this function returns one Generation | |
| int | getActualGenerationNumber (void) const |
| returns the actual generation number, on which the alg. | |
| Generation * | getActualGeneration (void) |
| returns the actual Generation. | |
| int | getNumIndividual (void) const |
| returns the number of individual inside the alg. | |
| Individual * | getIndividual (int x) const |
| returns one individual | |
| void | addGenPrototype (GenPrototype *prototype) |
| registered a GenPrototype in the engine. | |
| void | addGen (Gen *gen) |
| registered a Gen in the engine. | |
| Gen * | getGen (int x) const |
| returns one gene | |
| void | addIndividual (Individual *individual) |
| registered a individual in the engine. | |
| void | addGeneration (Generation *generation) |
| add a Generation to the alg. | |
| void | generateFirstGeneration (int startSize, int numChildren, RandGen *random, bool withUpdate=true) |
| prepare the alg. | |
| void | prepareNextGeneration (int size, int numChildren) |
| prepare the next generation. | |
| 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. | |
| int | getNextGenerationSize () |
| return the size of the next generation. | |
| void | measureStep (double time, InspectableProxy *&proxyGeneration, InspectableProxy *&proxyGene, PlotOptionEngine *plotEngine=0, PlotOptionEngine *plotEngineGenContext=0) |
| makes a step in the measure | |
| 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. | |
| void | select (bool createNextGeneration=true) |
| make the select of the actual generation and transfer it to the next generation | |
| void | crossover (RandGen *random) |
| in the actual generation it will generate the children of the living individual | |
| void | update (double factor=1.5) |
| this function makes a update on the statistical data of the gen. | |
| void | setSelectStrategy (ISelectStrategy *strategy) |
| decid the select strategy | |
| void | setGenerationSizeStrategy (IGenerationSizeStrategy *strategy) |
| decide the generation size strategy. | |
| void | setFitnessStrategy (IFitnessStrategy *strategy) |
| decide the fitness strategy. | |
| double | getFitness (const Individual *individual) |
| calculate for a individual the fitness value. | |
| Individual * | getBestIndividual (void) |
| returns the best individual (where the fitness is next to zero) which the alg. | |
| std::string | getIndividualRoot (bool withMutation=true) const |
| returns a complete list of the inheritance of all individual. | |
| std::string | getAllIndividualAsString (void) const |
| returns a list of all individual and there gens values. | |
| virtual bool | store (FILE *f) const |
| stores the object to the given file stream (binary). | |
| virtual bool | restore (FILE *f, InspectableProxy *&proxyGeneration, InspectableProxy *&proxyGene, PlotOptionEngine *plotEngine, PlotOptionEngine *plotEngineGenContext) |
| loads the object from the given file stream (binary). | |
Static Public Member Functions | |
| static SingletonGenEngine * | getInstance (void) |
| returns the only existing engine. | |
| static void | destroyGenEngine (bool cleanStrategies=false) |
| destroy the only existing engine. | |
Protected Attributes | |
| std::vector< GenPrototype * > | m_prototype |
| managment storage for all Genprototypes. | |
| std::vector< Generation * > | m_generation |
| managment storage for all Generation | |
| std::vector< Individual * > | m_individual |
| management storage for all Individual | |
| std::vector< Gen * > | m_gen |
| management storage for all Gens | |
| int | m_actualGeneration |
| the number of the actual generation | |
| ISelectStrategy * | m_selectStrategy |
| the select strategy of the alg. | |
| IFitnessStrategy * | m_fitnessStrategy |
| the fitness strategy of the alg. | |
| IGenerationSizeStrategy * | m_generationSizeStrategy |
| the generation size strategy of the alg. | |
| bool | m_cleanStrategies |
| flag for clean the seted strategies | |
| std::map< int, RESTORE_GA_GENERATION * > | m_restoreGeneration |
| Map for restoring the generations from a run before. | |
| std::map< int, RESTORE_GA_INDIVIDUAL * > | m_restoreIndividual |
| Map for restoring the individuals from a run before. | |
| std::map< int, std::vector< int > > | m_restoreIndividualInGeneration |
| Map for restoring the individual generation link from a run before. | |
| std::map< int, std::vector< int > > | m_restoreGeneInIndividual |
| Map for restoring the genes individual link from a run before. | |
| std::map< int, std::string > | m_restoreNameOfIndividuals |
| Map for restoring the names of the individuals. | |
Static Protected Attributes | |
| static SingletonGenEngine * | m_engine = 0 |
| the one and only GenEngine. | |
alg.
Over this is the class as singleton concepted. Only one engine for a run.
| void addGen | ( | Gen * | gen | ) | [inline] |
| void addGeneration | ( | Generation * | generation | ) | [inline] |
add a Generation to the alg.
Normal only used by the alg. self.
| generation | (Generation*) the generation |
| void addGenPrototype | ( | GenPrototype * | prototype | ) | [inline] |
registered a GenPrototype in the engine.
| prototype | (GenPrototype*) the prototype which should be registered. |
| void addIndividual | ( | Individual * | individual | ) | [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 |
| static void destroyGenEngine | ( | bool | cleanStrategies = false |
) | [inline, static] |
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. |
| Generation* getActualGeneration | ( | void | ) | [inline] |
| int getActualGenerationNumber | ( | void | ) | const [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 |
| Gen* getGen | ( | int | x | ) | const [inline] |
returns one gene
| x | (int) index of the gene which is searched |
| Generation* getGeneration | ( | int | x | ) | [inline] |
this function returns one Generation
| x | (int) the index of the Generation which is searched |
| Individual* getIndividual | ( | int | x | ) | const [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. |
| static SingletonGenEngine* getInstance | ( | void | ) | [inline, static] |
returns the only existing engine.
| int getNextGenerationSize | ( | ) |
return the size of the next generation.
| int getNumGeneration | ( | void | ) | const [inline] |
this function return the number of Generation inside.
| int getNumIndividual | ( | void | ) | const [inline] |
returns the number of individual inside the alg.
| const std::vector<GenPrototype*>& getSetOfGenPrototyps | ( | void | ) | const [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 |
| bool restore | ( | FILE * | f, | |
| InspectableProxy *& | proxyGeneration, | |||
| InspectableProxy *& | proxyGene, | |||
| PlotOptionEngine * | plotEngine, | |||
| PlotOptionEngine * | plotEngineGenContext | |||
| ) | [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 |
| void setFitnessStrategy | ( | IFitnessStrategy * | strategy | ) | [inline] |
decide the fitness strategy.
| strategy | (IFitnessStrategy*) the fitness strategy of the alg. |
| void setGenerationSizeStrategy | ( | IGenerationSizeStrategy * | strategy | ) | [inline] |
decide the generation size strategy.
| strategy | (IGenerationSizeStrategy*) the generation size strategy of the alg. |
| void setSelectStrategy | ( | ISelectStrategy * | strategy | ) | [inline] |
decid the select strategy
| strategy | (ISelectStrategy*) the select strategy of the alg. |
| bool store | ( | FILE * | f | ) | const [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 |
int m_actualGeneration [protected] |
the number of the actual generation
bool m_cleanStrategies [protected] |
flag for clean the seted strategies
SingletonGenEngine * m_engine = 0 [static, protected] |
the one and only GenEngine.
IFitnessStrategy* m_fitnessStrategy [protected] |
the fitness strategy of the alg.
std::vector<Generation*> m_generation [protected] |
managment storage for all Generation
IGenerationSizeStrategy* m_generationSizeStrategy [protected] |
the generation size strategy of the alg.
std::vector<Individual*> m_individual [protected] |
management storage for all Individual
std::vector<GenPrototype*> m_prototype [protected] |
managment storage for all Genprototypes.
std::map<int,std::vector<int> > m_restoreGeneInIndividual [protected] |
Map for restoring the genes individual link from a run before.
std::map<int,RESTORE_GA_GENERATION*> m_restoreGeneration [protected] |
Map for restoring the generations from a run before.
std::map<int,RESTORE_GA_INDIVIDUAL*> m_restoreIndividual [protected] |
Map for restoring the individuals from a run before.
std::map<int,std::vector<int> > m_restoreIndividualInGeneration [protected] |
Map for restoring the individual generation link from a run before.
std::map<int,std::string> m_restoreNameOfIndividuals [protected] |
Map for restoring the names of the individuals.
ISelectStrategy* m_selectStrategy [protected] |
the select strategy of the alg.
1.4.7