Robot Simulator of the Robotics Group for Self-Organization of Control: GenPrototype Class Reference

# GenPrototype Class Reference

The GenPrototype class. More...

`#include <GenPrototype.h>`

Collaboration diagram for GenPrototype:
[legend]

List of all members.

## 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, std::vector< Gen * > &storage)
| 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

## Detailed Description

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!!!).

## Constructor & Destructor Documentation

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.

Parameters:

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

## Member Function Documentation

GenContext * getContext | ( | Generation * | generation | ) |

This function gives the context which is relatedto the Eneration "generation" back.

Parameters:

  | generation | (Generation*) the related generation

Returns:
  (GenContext*) the searched context

int getMutationProbability | ( | void |  | ) | const

[const] This function gives the mutation probability back (from the mutation strategy)

Returns:
  (int) The mutation probability. Maybe the Typ int will be changed.

std::string getName | ( | void |  | ) | const`[inline]`

[inline], [const] This function gives the name of the prototype back.

Returns:
  (string) the name

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.

Parameters:

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

Parameters:

  | 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

Returns:
  (Gen*) The new mutated gen

bool restoreGene | ( | FILE * | f,
|  | RESTORE_GA_GENE * | gene,
|  | std::vector< Gen * > & | storage |
| ) |  |  |

restore gene and the value

Parameters:

  | f | (FILE*) here is the value inside
  | gene | (RESTORE_GA_GENE*) this gene is to restore

Returns:
  (bool) true if all ok

## Member Data Documentation

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

The documentation for this class was generated from the following files:

- GenPrototype.h
- GenPrototype.cpp