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

# Generation Class Reference

The Generation class. More...

`#include <Generation.h>`

Inherits Inspectable.

Collaboration diagram for Generation:
[legend]

List of all members.

## Public Member Functions
| Generation (int generationNumber, int size, int numChildren)
| constructor to create a Generation.
virtual | ~Generation ()
| destructor to delete a GenContext.
int | getGenerationNumber (void) const
| [inline], [const] This function gives the ID (number) of the generation back.
int | getSize (void) const
| [inline], [const] This function gives the size which is planed for this generation back.
int | getCurrentSize (void) const
| [inline], [const] This function gives the actual size (number of individuals inside the generation) back.
int | getNumChildren (void) const
| [inline], [const] This function gives the number of children back, which will be created by crossover.
Individual * | getIndividual (int x) const
| [individual], [const] This function gives one individual from this generation back.
const std::vector< Individual * > & | getAllIndividual (void) const
| [inline], [const] This function gives all individual back.
std::vector< Individual * > * | getAllUnCalculatedIndividuals (void) const
| [inline], [const] This function gives all individual back which aren't have the fitness value calculated.
void | addIndividual (Individual *individual)
| This function insert an individual in the generation.
void | crossover (RandGen *random)
| This function makes an crossOver whit the existing individuals to become from the current size the planed size.
std::string | getAllIndividualAsString (void) const
| returns a string which represent all individual in this generation.
std::vector< double > * | getAllFitness (void) const
| returns all fitness values from the individuals.
void | update (double factor=1.5)
| This function updates the statistical values.
bool | store (FILE *f) const
| store a generation in a file
## Static Public Member Functions
static bool | restore (int numberGeneration, std::map< int, RESTORE_GA_GENERATION * > &generationSet, std::map< int, std::vector< int > > &linkSet)
| restore all generation from a restore structure
## Protected Attributes
int | m_generationNumber
| (int) The generation number (ID)
std::vector< Individual * > | m_individual
| (vector<Individual*>) The storage for the individuals, which are part of this generation.
int | m_size
| (int) The planed size of the generation.
int | m_numChildren
| (int) The number of children

## Detailed Description

The Generation class.

This class is used for grouping some individuals which representing one step in the gen. alg. (called generation). For this it save all individual which are part of this generation. Also it have an Number like a ID, which make this generation individual.

All Generations inside the gen.alg. are only saved in the GenEngine.

## Constructor & Destructor Documentation

Generation | ( | int | generationNumber,
|  | int | size,
|  | int | numChildren |
| ) |  |  |

constructor to create a Generation.

Information which the class need are the generation number, the size of it and how many individual don t come in the next generation (killRate).

Parameters:

  | generationNumber | (int) The ID of the Generation.
  | size | (int) The Size of this Generation. Means how many individual are lives in this generation
  | numChildren | (int) Number of individual which will be created by crossover

~Generation | ( |  | ) | `[virtual]`

destructor to delete a GenContext.

## Member Function Documentation

void addIndividual | ( | Individual * | individual | ) |

This function insert an individual in the generation.

Parameters:

  | individual | (Individual*) the individual which should be insert in the generation

void crossover | ( | RandGen * | random | ) |

This function makes an crossOver whit the existing individuals to become from the current size the planed size.

Parameters:

  | random | (RandGen*) a pseudo number generator.

std::vector< double > * getAllFitness | ( | void |  | ) | const

returns all fitness values from the individuals.

Returns:
  (vector<double> the fitness values.

const std::vector<Individual*>& getAllIndividual | ( | void |  | ) | const`[inline]`

[inline], [const] This function gives all individual back.

Returns:
  (vector<Individual*>&) all individual inside the generation

std::string getAllIndividualAsString | ( | void |  | ) | const

returns a string which represent all individual in this generation.

Returns:
  (string) the string

std::vector< Individual * > * getAllUnCalculatedIndividuals | ( | void |  | ) | const

[inline], [const] This function gives all individual back which aren't have the fitness value calculated.

Returns:
  (vector<Individual*>&) all individual inside the generation

int getCurrentSize | ( | void |  | ) | const`[inline]`

[inline], [const] This function gives the actual size (number of individuals inside the generation) back.

Returns:
  (int) current size

int getGenerationNumber | ( | void |  | ) | const`[inline]`

[inline], [const] This function gives the ID (number) of the generation back.

Returns:
  (int) The ID

Individual* getIndividual | ( | int | x | ) | const`[inline]`

[individual], [const] This function gives one individual from this generation back.

Parameters:

  | x | (int) the index of the searched individual

Returns:
  (Individual*) The individual. If 0, if the param x is not inside the index range

int getNumChildren | ( | void |  | ) | const`[inline]`

[inline], [const] This function gives the number of children back, which will be created by crossover.

Returns:
  (int) the number of children

int getSize | ( | void |  | ) | const`[inline]`

[inline], [const] This function gives the size which is planed for this generation back.

Returns:
  (int) The planed size

bool restore | ( | int | numberGeneration,
|  | std::map< int, RESTORE_GA_GENERATION * > & | generationSet,
|  | std::map< int, std::vector< int > > & | linkSet |
| ) |  |  | `[static]`

restore all generation from a restore structure

remember the individuals must be restored before

Parameters:

  | numberGeneration | (int) number of generations which should be restored
  | generationSet | (map<int,RESTORE_GA_GENERATION*>) the structures which should be restored
  | linkSet | (map<int,vector<int>>) the linkings between the generation and the individuals

Returns:
  (bool) true if all ok

bool store | ( | FILE * | f | ) | const

store a generation in a file

Parameters:

  | f | (FILE*) the file in which should be stored

Returns:
  (bool) true if all ok

void update | ( | double | factor = `1.5` | ) |

This function updates the statistical values.

Parameters:

  | factor | (double) normal 1.5 Is needed for the data analysation

## Member Data Documentation

int m_generationNumber`[protected]`

(int) The generation number (ID)

std::vector<Individual*> m_individual`[protected]`

(vector<Individual*>) The storage for the individuals, which are part of this generation.

(NO deleting)

int m_numChildren`[protected]`

(int) The number of children

int m_size`[protected]`

(int) The planed size of the generation.

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

- Generation.h
- Generation.cpp