Robot Simulator of the Robotics Group for Self-Organization of Control
0.8.0
|
This is a facade for the gen. More...
#include <SingletonGenAlgAPI.h>
Public Member Functions | |
void | select (bool createNextGeneration=true) |
starts the selection More... | |
void | crossover (RandGen *random) |
create the children from to fill up the next generation More... | |
void | update (double factor=1.5) |
update the internal statistical data More... | |
void | prepare (int startSize, int numChildren, RandGen *random, bool withUpdate=true) |
prepares the first generation and optional the enabled measure More... | |
void | prepare () |
prepares the next generation and optional the enabled measure More... | |
void | measureStep (double time) |
makes a step in the measure More... | |
void | runGenAlg (int startSize, int numChildren, int numGeneration, RandGen *random) |
start the sequenz of select, crossover, update in a automatically loop More... | |
void | enableMeasure (std::list< PlotOption > &plotOptions) |
enables data measure with more than one plotOption. More... | |
void | enableMeasure (PlotOption &plotOption) |
enables da : public Storableta measure. More... | |
PlotOptionEngine * | getPlotOptionEngine (void) const |
returns the active plotOptionEngine for data measure. More... | |
void | enableGenContextMeasure (std::list< PlotOption > &plotOptions) |
enable data measure inside the GenContexts with more than one plotOption More... | |
void | enableGenContextMeasure (PlotOption &plotOption) |
enable data measure inside the GenContexts. More... | |
PlotOptionEngine * | getPlotOptionEngineForGenContext (void) const |
returns the active plotOptionEngine for data measure inside the GenContexts. More... | |
void | setGenerationSizeStrategy (IGenerationSizeStrategy *strategy) |
set the generation size strategy More... | |
void | setFitnessStrategy (IFitnessStrategy *strategy) |
set the fitness strategy More... | |
void | setSelectStrategy (ISelectStrategy *strategy) |
set the select strategy More... | |
SingletonGenEngine * | getEngine (void) const |
returns the GenAlgEngine More... | |
IFitnessStrategy * | createSumFitnessStrategy () const |
creates a SumFitnessStrategy. More... | |
IFitnessStrategy * | createEuclidicDistanceFitnessStrategy () const |
creates a EuclidicFitnessStrategy. More... | |
IFitnessStrategy * | createExtreamTestFitnessStrategy (IFitnessStrategy *fitness) const |
creates a TestFitnessStrategy which is the hardest test for a gen. More... | |
IFitnessStrategy * | createTestFitnessStrategy () const |
creates the test function fitness strategy from the papper tp this alg. More... | |
IFitnessStrategy * | createInvertedFitnessStrategy (IFitnessStrategy *strategy) const |
returns a fitness strategy which calculate the inverse value from a other strategy. More... | |
IRandomStrategy * | createDoubleRandomStrategy (RandGen *random, double base=0.0, double factor=1.0, double epsilon=0.0) const |
creates a random strategy for double values. More... | |
IMutationStrategy * | createValueMutationStrategy (IMutationFactorStrategy *strategy, int mutationProbability) const |
creates mutation strategy which change the old values by add a other value More... | |
IMutationFactorStrategy * | createFixMutationFactorStrategy (IValue *value) const |
creates a mutation factor strategy with a fix value More... | |
IMutationFactorStrategy * | createStandartMutationFactorStrategy (void) const |
creates a mutation factor strategy with a optimized value (varianz about all existing gens) More... | |
IGenerationSizeStrategy * | createFixGenerationSizeStrategy (int value) const |
creates a generation size strategy with a fix value More... | |
IGenerationSizeStrategy * | createStandartGenerationSizeStrategy (int startSize, int numGeneration) const |
creates a generation size strategy with a optimized size for the generation (changing by speed of development) More... | |
ISelectStrategy * | createEliteSelectStrategy (void) const |
creates a elite select strategy More... | |
ISelectStrategy * | createTournamentSelectStrategy (RandGen *random) const |
creates a tournament SelctStrategy. More... | |
ISelectStrategy * | createRandomSelectStrategy (RandGen *random) const |
creates a random select strategy. More... | |
IValue * | createDoubleValue (double value) const |
creates a IValue (TemplateValue<double) from type double. More... | |
bool | storeGA (FILE *f) const |
stores the object to the given file stream (binary). More... | |
bool | restoreGA (FILE *f) const |
loads the object from the given file stream (binary). More... | |
void | insertGenPrototype (GenPrototype *prototype) |
add a GenPrototype to the alg. More... | |
GenPrototype * | createPrototype (std::string name, IRandomStrategy *randomStrategy, IMutationStrategy *mutationStrategy) const |
create a prototype. More... | |
Individual * | getBestIndividual (void) const |
returns the best individual which the alg. More... | |
Static Public Member Functions | |
static SingletonGenAlgAPI * | getInstance (void) |
returns the one and only API to the alg. More... | |
static void | destroyAPI (bool cleanStrategies=false) |
destroy the api More... | |
Protected Attributes | |
PlotOptionEngine * | m_plotEngine |
plot option engine for data measure More... | |
PlotOptionEngine * | m_plotEngineGenContext |
plot option engine for gen contexts More... | |
Static Protected Attributes | |
static SingletonGenAlgAPI * | m_api = 0 |
the api More... | |
This is a facade for the gen.
alg.
Over this is the class as singleton concepted. Only one API for a run.
IRandomStrategy * createDoubleRandomStrategy | ( | RandGen * | random, |
double | base = 0.0 , |
||
double | factor = 1.0 , |
||
double | epsilon = 0.0 |
||
) | const |
creates a random strategy for double values.
The values will be generated in the intervals [base-epsilon:-epsilon] or [epsilon:factor+base+epsilon]
This means a random value in the interval [0:1] will be mul. with factor => [0:factor] After this it will be shifted by base => [base:factor+base] And than divided at the point zero and moved away by epsilon from the point zero => [base-epsilon:-epsilon], [epsilon:factor+base+epsilon]
For example: We want values in the intervals [-10:-5] and [5:10]. ==> epsilon=5 ==> [-5:5] ==> base=-5 ==> [0:10] ==> factor=10
random | (RandGen*) random generator |
base | (double) normal=0.0 moves the ground interval |
factor | (double) normal=1.0 resize the interval |
epsilon | (double) normal=0.0 devided the interval at the point zero and move the values by epsilon away from point zero |
IValue * createDoubleValue | ( | double | value | ) | const |
creates a IValue (TemplateValue<double) from type double.
value | (double) the value |
ISelectStrategy * createEliteSelectStrategy | ( | void | ) | const |
creates a elite select strategy
IFitnessStrategy * createEuclidicDistanceFitnessStrategy | ( | ) | const |
creates a EuclidicFitnessStrategy.
This strategy calculate the euclidic distance of all gens with a double value.
IFitnessStrategy * createExtreamTestFitnessStrategy | ( | IFitnessStrategy * | fitness | ) | const |
creates a TestFitnessStrategy which is the hardest test for a gen.
alg. Only a smale area has a fitness. All other gives no information!
fitness | (IFitnessStrategy*) a other fitness strat* Over this is the class as singleton concepted. Only one engine for a run.egy which define the smal area. |
IGenerationSizeStrategy * createFixGenerationSizeStrategy | ( | int | value | ) | const |
creates a generation size strategy with a fix value
value | (int) the size of the generation |
IMutationFactorStrategy * createFixMutationFactorStrategy | ( | IValue * | value | ) | const |
creates a mutation factor strategy with a fix value
value | (IValue*) the fix value. |
IFitnessStrategy * createInvertedFitnessStrategy | ( | IFitnessStrategy * | strategy | ) | const |
returns a fitness strategy which calculate the inverse value from a other strategy.
strategy | (IFitnessStrategy*) the other strategy |
GenPrototype * createPrototype | ( | std::string | name, |
IRandomStrategy * | randomStrategy, | ||
IMutationStrategy * | mutationStrategy | ||
) | const |
create a prototype.
name | (STRING) THE NAME OF THE PROTOTYPE |
randomStrategy | (IRandomStrategy*) the random strategy to generate values of the type which the prototype represent |
mutationStrategy | (IMutationStrategy*) the mutation strategy to change a value (Gen) |
ISelectStrategy * createRandomSelectStrategy | ( | RandGen * | random | ) | const |
creates a random select strategy.
By this strategy will a random selected individual fight again a random number. If the random number higher than the fitness from the individual, than it will be die.
random | (RandGen*) ranom generator |
IGenerationSizeStrategy * createStandartGenerationSizeStrategy | ( | int | startSize, |
int | numGeneration | ||
) | const |
creates a generation size strategy with a optimized size for the generation (changing by speed of development)
startSize | (int) the size at the start time |
numGeneration | (int) number of generation. (needed for the speed calculation |
IMutationFactorStrategy * createStandartMutationFactorStrategy | ( | void | ) | const |
creates a mutation factor strategy with a optimized value (varianz about all existing gens)
IFitnessStrategy * createSumFitnessStrategy | ( | ) | const |
creates a SumFitnessStrategy.
This strategy make the sum of all gens with a double value.
IFitnessStrategy * createTestFitnessStrategy | ( | ) | const |
creates the test function fitness strategy from the papper tp this alg.
f(x,y) = 10.0 * (x² + 2.5y² - y) * exp(1 - (x² + y²)) + 2.4 + 0.1x² + 0.1y²
ISelectStrategy * createTournamentSelectStrategy | ( | RandGen * | random | ) | const |
creates a tournament SelctStrategy.
By this strategy will two individual fight again (the individual with the higher fitness lives longer).
random | (RandGen*) random generator |
IMutationStrategy * createValueMutationStrategy | ( | IMutationFactorStrategy * | strategy, |
int | mutationProbability | ||
) | const |
creates mutation strategy which change the old values by add a other value
strategy | (IMutationFactorStrategy*) this strategy define what the other value is. |
mutationProbability | (int) the probability of mutation in one per tausend (1/1000) |
void crossover | ( | RandGen * | random | ) |
create the children from to fill up the next generation
random | (RandGen*) random generator |
|
inlinestatic |
destroy the api
cleanStrategies | (bool) default = false set a flag to clean the strategies, which are seted. |
void enableGenContextMeasure | ( | std::list< PlotOption > & | plotOptions | ) |
enable data measure inside the GenContexts with more than one plotOption
plotOptions | (list<PlotOption>&) the list |
void enableGenContextMeasure | ( | PlotOption & | plotOption | ) |
enable data measure inside the GenContexts.
plotOption | (PlotOption&) the plot option |
void enableMeasure | ( | std::list< PlotOption > & | plotOptions | ) |
enables data measure with more than one plotOption.
plotOptions | (list |
&) the list
void enableMeasure | ( | PlotOption & | plotOption | ) |
enables da : public Storableta measure.
plotOption | (PlotOption&) the plot option |
|
inline |
returns the best individual which the alg.
have found
SingletonGenEngine * getEngine | ( | void | ) | const |
returns the GenAlgEngine
|
inlinestatic |
returns the one and only API to the alg.
|
inline |
returns the active plotOptionEngine for data measure.
|
inline |
returns the active plotOptionEngine for data measure inside the GenContexts.
void insertGenPrototype | ( | GenPrototype * | prototype | ) |
add a GenPrototype to the alg.
prototype | (GenPrototype*) the prototype |
void measureStep | ( | double | time | ) |
makes a step in the measure
time | (double) time stamp in the measure |
void prepare | ( | int | startSize, |
int | numChildren, | ||
RandGen * | random, | ||
bool | withUpdate = true |
||
) |
prepares the first generation and optional the enabled measure
startSize | (int) Number of individual at begin of the gen. alg. |
startChildren | (int) Number of individual which will be created by crossover |
random | (RandGen*) A random generator |
withUpdate | (bool) is needed for "generateFirstGeneration" |
void prepare | ( | ) |
prepares the next generation and optional the enabled measure
bool restoreGA | ( | FILE * | f | ) | const |
loads the object from the given file stream (binary).
void runGenAlg | ( | int | startSize, |
int | numChildren, | ||
int | numGeneration, | ||
RandGen * | random | ||
) |
start the sequenz of select, crossover, update in a automatically loop
startSize | (int) Number of individual at begin of the gen. alg. |
numChildren | (int) Number of individual which will be created by crossover |
numGeneration | (int) Number of generation which the alg. max. runs |
random | (RandGen*) random generator |
void select | ( | bool | createNextGeneration = true | ) |
starts the selection
createNextGeneration | (bool) normal=true should be the next generation be prepare? |
|
inline |
set the fitness strategy
strategy | (IFitnessStrategy*) the strategy |
|
inline |
set the generation size strategy
strategy | (IGenerationSizeStrategy*) the strategy |
|
inline |
set the select strategy
strategy | (ISelectStrategy*) the strategy |
bool storeGA | ( | FILE * | f | ) | const |
stores the object to the given file stream (binary).
void update | ( | double | factor = 1.5 | ) |
update the internal statistical data
factor | (double) normal=1.5 is needed for the whisker distance |
|
staticprotected |
the api
|
protected |
plot option engine for data measure
|
protected |
plot option engine for gen contexts