27 #ifndef SINGLETONGENENGINE_H_
28 #define SINGLETONGENENGINE_H_
34 #include <selforg/randomgenerator.h>
35 #include <selforg/inspectableproxy.h>
199 void select(
bool createNextGeneration=
true);
211 void update(
double factor = 1.5);
259 virtual bool store(FILE* f)
const;
static void destroyGenEngine(bool cleanStrategies=false)
destroy the only existing engine.
Definition: SingletonGenEngine.h:274
Individual * getBestIndividual(void)
returns the best individual (where the fitness is next to zero) which the alg.
Definition: SingletonGenEngine.cpp:311
void generateFirstGeneration(int startSize, int numChildren, RandGen *random, bool withUpdate=true)
prepare the alg.
Definition: SingletonGenEngine.cpp:114
this interface is for a select strategy of the generation class.
Definition: ISelectStrategy.h:36
std::map< int, std::vector< int > > m_restoreIndividualInGeneration
Map for restoring the individual generation link from a run before.
Definition: SingletonGenEngine.h:340
void prepareNextGeneration(int size, int numChildren)
prepare the next generation.
Definition: SingletonGenEngine.cpp:170
void setSelectStrategy(ISelectStrategy *strategy)
decid the select strategy
Definition: SingletonGenEngine.h:217
void addGenPrototype(GenPrototype *prototype)
registered a GenPrototype in the engine.
Definition: SingletonGenEngine.h:114
std::string getIndividualRoot(bool withMutation=true) const
returns a complete list of the inheritance of all individual.
Definition: SingletonGenEngine.cpp:329
std::vector< Gen * > m_gen
management storage for all Gens
Definition: SingletonGenEngine.h:295
This interface gives the structur for the mutation of a gen.
Definition: IMutationStrategy.h:39
void setFitnessStrategy(IFitnessStrategy *strategy)
decide the fitness strategy.
Definition: SingletonGenEngine.h:229
std::vector< Generation * > m_generation
managment storage for all Generation
Definition: SingletonGenEngine.h:285
ISelectStrategy * m_selectStrategy
the select strategy of the alg.
Definition: SingletonGenEngine.h:305
The Gen class.
Definition: Gen.h:51
The GenContext class.
Definition: GenContext.h:51
Gen * getGen(int x) const
returns one gene
Definition: SingletonGenEngine.h:127
Definition: plotoptionengine.h:38
random generator with 48bit integer arithmentic
Definition: randomgenerator.h:34
void addGeneration(Generation *generation)
add a Generation to the alg.
Definition: SingletonGenEngine.h:139
This is a interface for a strategy, which is used by ValueMutationStrategy.
Definition: IMutationFactorStrategy.h:40
Generation * getGeneration(int x)
this function returns one Generation
Definition: SingletonGenEngine.h:83
void update(double factor=1.5)
this function makes a update on the statistical data of the gen.
Definition: SingletonGenEngine.cpp:299
Individual * getIndividual(int x) const
returns one individual
Definition: SingletonGenEngine.h:108
int getActualGenerationNumber(void) const
returns the actual generation number, on which the alg.
Definition: SingletonGenEngine.h:89
The interface for the fitness strategy of an individual.
Definition: IFitnessStrategy.h:36
virtual bool store(FILE *f) const
stores the object to the given file stream (binary).
Definition: SingletonGenEngine.cpp:349
std::map< int, std::string > m_restoreNameOfIndividuals
Map for restoring the names of the individuals.
Definition: SingletonGenEngine.h:350
std::map< int, std::vector< int > > m_restoreGeneInIndividual
Map for restoring the genes individual link from a run before.
Definition: SingletonGenEngine.h:345
std::vector< GenPrototype * > m_prototype
managment storage for all Genprototypes.
Definition: SingletonGenEngine.h:280
This is the engine of the gen.
Definition: SingletonGenEngine.h:64
IFitnessStrategy * m_fitnessStrategy
the fitness strategy of the alg.
Definition: SingletonGenEngine.h:310
bool m_cleanStrategies
flag for clean the seted strategies
Definition: SingletonGenEngine.h:325
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.
Definition: SingletonGenEngine.cpp:187
double getFitness(const Individual *individual)
calculate for a individual the fitness value.
Definition: SingletonGenEngine.cpp:307
this interface is to create a random IValue.
Definition: IRandomStrategy.h:36
This interface is to specify how big the next generation should be.
Definition: IGenerationSizeStrategy.h:36
std::vector< Individual * > m_individual
management storage for all Individual
Definition: SingletonGenEngine.h:290
The GenPrototype class.
Definition: GenPrototype.h:55
The Generation class.
Definition: Generation.h:53
void addGen(Gen *gen)
registered a Gen in the engine.
Definition: SingletonGenEngine.h:120
int getNumGeneration(void) const
this function return the number of Generation inside.
Definition: SingletonGenEngine.h:76
static SingletonGenEngine * m_engine
the one and only GenEngine.
Definition: SingletonGenEngine.h:320
int getNextGenerationSize()
return the size of the next generation.
Definition: SingletonGenEngine.cpp:217
IGenerationSizeStrategy * m_generationSizeStrategy
the generation size strategy of the alg.
Definition: SingletonGenEngine.h:315
This class is a interface for a value which is part of a gen.
Definition: IValue.h:38
int m_actualGeneration
the number of the actual generation
Definition: SingletonGenEngine.h:300
int getNumIndividual(void) const
returns the number of individual inside the alg.
Definition: SingletonGenEngine.h:101
virtual bool restore(FILE *f, InspectableProxy *&proxyGeneration, InspectableProxy *&proxyGene, PlotOptionEngine *plotEngine, PlotOptionEngine *plotEngineGenContext)
loads the object from the given file stream (binary).
Definition: SingletonGenEngine.cpp:396
void addIndividual(Individual *individual)
registered a individual in the engine.
Definition: SingletonGenEngine.h:133
void crossover(RandGen *random)
in the actual generation it will generate the children of the living individual
Definition: SingletonGenEngine.cpp:295
std::map< int, RESTORE_GA_GENERATION * > m_restoreGeneration
Map for restoring the generations from a run before.
Definition: SingletonGenEngine.h:330
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.
Definition: SingletonGenEngine.cpp:242
void setGenerationSizeStrategy(IGenerationSizeStrategy *strategy)
decide the generation size strategy.
Definition: SingletonGenEngine.h:223
void select(bool createNextGeneration=true)
make the select of the actual generation and transfer it to the next generation
Definition: SingletonGenEngine.cpp:264
This class is a proxy for the inspectable class.
Definition: inspectableproxy.h:35
This class represent one individual of the complete gen.
Definition: Individual.h:45
std::string getAllIndividualAsString(void) const
returns a list of all individual and there gens values.
Definition: SingletonGenEngine.cpp:339
Generation * getActualGeneration(void)
returns the actual Generation.
Definition: SingletonGenEngine.h:95
static SingletonGenEngine * getInstance(void)
returns the only existing engine.
Definition: SingletonGenEngine.h:269
void measureStep(double time, InspectableProxy *&proxyGeneration, InspectableProxy *&proxyGene, PlotOptionEngine *plotEngine=0, PlotOptionEngine *plotEngineGenContext=0)
makes a step in the measure
Definition: SingletonGenEngine.cpp:221
const std::vector< GenPrototype * > & getSetOfGenPrototyps(void) const
this function returns a set of all registered GenPrototypes.
Definition: SingletonGenEngine.h:70
std::map< int, RESTORE_GA_INDIVIDUAL * > m_restoreIndividual
Map for restoring the individuals from a run before.
Definition: SingletonGenEngine.h:335