SingletonGenEngine Class Reference

This is the engine of the gen. More...

#include <SingletonGenEngine.h>

Collaboration diagram for SingletonGenEngine:

Collaboration graph
[legend]
List of all members.

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.
GenerationgetGeneration (int x)
 this function returns one Generation
int getActualGenerationNumber (void) const
 returns the actual generation number, on which the alg.
GenerationgetActualGeneration (void)
 returns the actual Generation.
int getNumIndividual (void) const
 returns the number of individual inside the alg.
IndividualgetIndividual (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.
GengetGen (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.
IndividualgetBestIndividual (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 SingletonGenEnginegetInstance (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
ISelectStrategym_selectStrategy
 the select strategy of the alg.
IFitnessStrategym_fitnessStrategy
 the fitness strategy of the alg.
IGenerationSizeStrategym_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 SingletonGenEnginem_engine = 0
 the one and only GenEngine.

Detailed Description

This is the engine of the gen.

alg.

Over this is the class as singleton concepted. Only one engine for a run.


Member Function Documentation

void addGen ( Gen gen  )  [inline]

registered a Gen in the engine.

Normal only used by the alg. self.

Parameters:
gen (Gen*) the Gen which should be registered.

void addGeneration ( Generation generation  )  [inline]

add a Generation to the alg.

Normal only used by the alg. self.

Parameters:
generation (Generation*) the generation

void addGenPrototype ( GenPrototype prototype  )  [inline]

registered a GenPrototype in the engine.

Parameters:
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.

Parameters:
individual (Individual*) the individual

void crossover ( RandGen random  ) 

in the actual generation it will generate the children of the living individual

Parameters:
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.

Parameters:
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]

returns the actual Generation.

Returns:
(Generation*) the actual generation

int getActualGenerationNumber ( void   )  const [inline]

returns the actual generation number, on which the alg.

work

Returns:
(int) the actual generation number

std::string getAllIndividualAsString ( void   )  const

returns a list of all individual and there gens values.

Returns:
(string) the list

Individual * getBestIndividual ( void   ) 

returns the best individual (where the fitness is next to zero) which the alg.

have found.

Returns:
(Individual*) the best.

double getFitness ( const Individual individual  ) 

calculate for a individual the fitness value.

Parameters:
individual (Individual*) the individual for which the fitness should be calculated
Returns:
(double) the fitness value.

Gen* getGen ( int  x  )  const [inline]

returns one gene

Parameters:
x (int) index of the gene which is searched
Returns:
(Gen*) the searched gene

Generation* getGeneration ( int  x  )  [inline]

this function returns one Generation

Parameters:
x (int) the index of the Generation which is searched
Returns:
(Generation*) the searched Generation. If x not a right index, than the result is zero.

Individual* getIndividual ( int  x  )  const [inline]

returns one individual

Parameters:
x (int) index of the individual which is searched.
Returns:
(Individual*) the searched individual

std::string getIndividualRoot ( bool  withMutation = true  )  const

returns a complete list of the inheritance of all individual.

Parameters:
withMutation (bool) normal=true. if every individual should be marked if it mutated.
Returns:
(string) the list

static SingletonGenEngine* getInstance ( void   )  [inline, static]

returns the only existing engine.

Returns:
(SingletonGenEngine*) the engine

int getNextGenerationSize (  ) 

return the size of the next generation.

Returns:
(int) the size

int getNumGeneration ( void   )  const [inline]

this function return the number of Generation inside.

Returns:
(int) the number of Generation in the storage

int getNumIndividual ( void   )  const [inline]

returns the number of individual inside the alg.

Returns:
(int) number of individual

const std::vector<GenPrototype*>& getSetOfGenPrototyps ( void   )  const [inline]

this function returns a set of all registered GenPrototypes.

Returns:
(vector<GenPrototype*>&) the set

void measureStep ( double  time,
InspectableProxy *&  proxyGeneration,
InspectableProxy *&  proxyGene,
PlotOptionEngine plotEngine = 0,
PlotOptionEngine plotEngineGenContext = 0 
)

makes a step in the measure

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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

Parameters:
createNextGeneration (bool) normal=true. should be the next generation prepare

void setFitnessStrategy ( IFitnessStrategy strategy  )  [inline]

decide the fitness strategy.

Parameters:
strategy (IFitnessStrategy*) the fitness strategy of the alg.

void setGenerationSizeStrategy ( IGenerationSizeStrategy strategy  )  [inline]

decide the generation size strategy.

Parameters:
strategy (IGenerationSizeStrategy*) the generation size strategy of the alg.

void setSelectStrategy ( ISelectStrategy strategy  )  [inline]

decid the select strategy

Parameters:
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.

Parameters:
factor (double) the factor is for the whisker distance


Member Data Documentation

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<Gen*> m_gen [protected]

management storage for all Gens

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.


The documentation for this class was generated from the following files:
Generated on Fri Oct 30 16:29:02 2009 for Robot Simulator of the Robotics Group for Self-Organization of Control by  doxygen 1.4.7