Robot Simulator of the Robotics Group for Self-Organization of Control
0.8.0
|
The GenPrototype class. More...
#include <GenPrototype.h>
Public Member Functions | |
GenPrototype (std::string name, IRandomStrategy *randomStrategy, IMutationStrategy *mutationStrategy) | |
constructor to create a GenPrototype. More... | |
virtual | ~GenPrototype () |
destructor to delete a GenContext. More... | |
std::string | getName (void) const |
[inline], [const] This function gives the name of the prototype back. More... | |
IValue * | getRandomValue (void) const |
[inline], [const] This function gives a random value (IValue) which are with the randomStrategy is generated back. More... | |
void | insertContext (Generation *generation, GenContext *context) |
This function insert a GenContext in the GenPrototype. More... | |
GenContext * | getContext (Generation *generation) |
This function gives the context which is relatedto the Eneration "generation" back. More... | |
Gen * | mutate (GenContext *context, Individual *individual, Gen *oldGen, GenContext *oldContext) const |
[const] This function mutate the given gen. More... | |
int | getMutationProbability (void) const |
[const] This function gives the mutation probability back (from the mutation strategy) More... | |
bool | restoreGene (FILE *f, RESTORE_GA_GENE *gene, std::vector< Gen * > &storage) |
restore gene and the value More... | |
Protected Attributes | |
std::string | m_name |
(string) the name More... | |
std::map< Generation *, GenContext * > | m_context |
(map<Generation*, GenContext*>) The storage for the GenContexte. More... | |
IRandomStrategy * | m_randomStrategy |
(IRandomStrategy*) the random strategy More... | |
IMutationStrategy * | m_mutationStrategy |
(IMutationStrategy*) the mutation strategy More... | |
The GenPrototype class.
This class is used for group some gens and is needed from the genFactory. It saves all GenContexte which are use this prototype. The group of gens becomes whit it an name.
The prototypes inside the gen. alg. are saved in the GenContext, in the Gen and in the GenEngine (only here can be deleted!!!).
GenPrototype | ( | std::string | name, |
IRandomStrategy * | randomStrategy, | ||
IMutationStrategy * | mutationStrategy | ||
) |
constructor to create a GenPrototype.
Information which the class need are the name of the gen pool group, a strategy how can a Gen of this group be created (for the IValue) and a strategy how can a Gen mutate.
name | (string) Name of the group |
randomStrategy | (IRandomStrategy*) the strategy for creating a gen |
mutationStrategy | (IMutationStrategy*) the strategy for mutating a gen |
|
virtual |
destructor to delete a GenContext.
GenContext * getContext | ( | Generation * | generation | ) |
This function gives the context which is relatedto the Eneration "generation" back.
generation | (Generation*) the related generation |
int getMutationProbability | ( | void | ) | const |
[const] This function gives the mutation probability back (from the mutation strategy)
|
inline |
[inline], [const] This function gives the name of the prototype back.
|
inline |
[inline], [const] This function gives a random value (IValue) which are with the randomStrategy is generated back.
void insertContext | ( | Generation * | generation, |
GenContext * | context | ||
) |
This function insert a GenContext in the GenPrototype.
generation | (Generation*) to which Generation is the Context related. |
context | (GenContext*) the context which should be insert |
Gen * mutate | ( | GenContext * | context, |
Individual * | individual, | ||
Gen * | oldGen, | ||
GenContext * | oldContext | ||
) | const |
[const] This function mutate the given gen.
context | (GenContext*) param is needed by the mutationStrategy |
individual | (Individual*) param is needed by the mutationStrategy |
oldGen | (Gen*) the gen which should be mutate |
oldContext | (GenContext*) param is needed by the mutationStrategy |
bool restoreGene | ( | FILE * | f, |
RESTORE_GA_GENE * | gene, | ||
std::vector< Gen * > & | storage | ||
) |
restore gene and the value
f | (FILE*) here is the value inside |
gene | (RESTORE_GA_GENE*) this gene is to restore |
|
protected |
(map<Generation*, GenContext*>) The storage for the GenContexte.
It related the contexte to the generations.
|
protected |
(IMutationStrategy*) the mutation strategy
|
protected |
(string) the name
|
protected |
(IRandomStrategy*) the random strategy