#include <GenPrototype.h>
Collaboration diagram for GenPrototype:
Public Member Functions | |
GenPrototype (std::string name, IRandomStrategy *randomStrategy, IMutationStrategy *mutationStrategy) | |
constructor to create a GenPrototype. | |
virtual | ~GenPrototype () |
destructor to delete a GenContext. | |
std::string | getName (void) const |
[inline], [const] This function gives the name of the prototype back. | |
IValue * | getRandomValue (void) const |
[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. | |
GenContext * | getContext (Generation *generation) |
This function gives the context which is relatedto the Eneration "generation" back. | |
Gen * | mutate (GenContext *context, Individual *individual, Gen *oldGen, GenContext *oldContext) const |
[const] This function mutate the given gen. | |
int | getMutationProbability (void) const |
[const] This function gives the mutation probability back (from the mutation strategy) | |
bool | restoreGene (FILE *f, RESTORE_GA_GENE *gene) |
restore gene and the value | |
Protected Attributes | |
std::string | m_name |
(string) the name | |
std::map< Generation *, GenContext * > | m_context |
(map<Generation*, GenContext*>) The storage for the GenContexte. | |
IRandomStrategy * | m_randomStrategy |
(IRandomStrategy*) the random strategy | |
IMutationStrategy * | m_mutationStrategy |
(IMutationStrategy*) the mutation strategy |
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 |
~GenPrototype | ( | ) | [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)
std::string getName | ( | void | ) | const [inline] |
[inline], [const] This function gives the name of the prototype back.
IValue* getRandomValue | ( | void | ) | const [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 | |||
) |
restore gene and the value
f | (FILE*) here is the value inside | |
gene | (RESTORE_GA_GENE*) this gene is to restore |
std::map<Generation*,GenContext*> m_context [protected] |
(map<Generation*, GenContext*>) The storage for the GenContexte.
It related the contexte to the generations.
IMutationStrategy* m_mutationStrategy [protected] |
(IMutationStrategy*) the mutation strategy
std::string m_name [protected] |
(string) the name
IRandomStrategy* m_randomStrategy [protected] |
(IRandomStrategy*) the random strategy