Robot Simulator of the Robotics Group for Self-Organization of Control  0.8.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Generation Class Reference

The Generation class. More...

#include <Generation.h>

Inheritance diagram for Generation:
Collaboration diagram for Generation:

Public Member Functions

 Generation (int generationNumber, int size, int numChildren)
 constructor to create a Generation. More...
 
virtual ~Generation ()
 destructor to delete a GenContext. More...
 
int getGenerationNumber (void) const
 [inline], [const] This function gives the ID (number) of the generation back. More...
 
int getSize (void) const
 [inline], [const] This function gives the size which is planed for this generation back. More...
 
int getCurrentSize (void) const
 [inline], [const] This function gives the actual size (number of individuals inside the generation) back. More...
 
int getNumChildren (void) const
 [inline], [const] This function gives the number of children back, which will be created by crossover. More...
 
IndividualgetIndividual (int x) const
 [individual], [const] This function gives one individual from this generation back. More...
 
const std::vector< Individual * > & getAllIndividual (void) const
 [inline], [const] This function gives all individual back. More...
 
std::vector< Individual * > * getAllUnCalculatedIndividuals (void) const
 [inline], [const] This function gives all individual back which aren't have the fitness value calculated. More...
 
void addIndividual (Individual *individual)
 This function insert an individual in the generation. More...
 
void crossover (RandGen *random)
 This function makes an crossOver whit the existing individuals to become from the current size the planed size. More...
 
std::string getAllIndividualAsString (void) const
 returns a string which represent all individual in this generation. More...
 
std::vector< double > * getAllFitness (void) const
 returns all fitness values from the individuals. More...
 
void update (double factor=1.5)
 This function updates the statistical values. More...
 
bool store (FILE *f) const
 store a generation in a file More...
 
- Public Member Functions inherited from Inspectable
 Inspectable (const iparamkey &name="")
 TYPEDEFS END. More...
 
virtual ~Inspectable ()
 
virtual iparamkeylist getInternalParamNames () const
 The list of the names of all internal parameters given by getInternalParams(). More...
 
virtual iparamvallist getInternalParams () const
 
virtual iparamvalptrlist getInternalParamsPtr () const
 be careful: matrices will be ignored More...
 
virtual ilayerlist getStructuralLayers () const
 Specifies which parameter vector forms a structural layer (in terms of a neural network) The ordering is important. More...
 
virtual iconnectionlist getStructuralConnections () const
 Specifies which parameter matrix forms a connection between layers (in terms of a neural network) The orderning is not important. More...
 
virtual void addInspectableValue (const iparamkey &key, iparamval const *val, const std::string &descr=std::string())
 This is the new style for adding inspectable values. More...
 
virtual void addInspectableMatrix (const iparamkey &key, const matrix::Matrix *m, bool only4x4AndDiag=true, const std::string &descr=std::string())
 This is the new style for adding inspectable values. More...
 
virtual void addInspectableDescription (const iparamkey &key, const std::string &descr)
 adds a description for the given parameter using info-lines The line will start (appart from the #I) with a D for description followed by the key end then followed by the string. More...
 
virtual void addInfoLine (std::string infoLine)
 Adds an info line to this inspectable instance. More...
 
virtual void addInfoLines (std::list< std::string > infoLineList)
 Adds a bunch of infolines with addInfoLine to this inspectable instance. More...
 
virtual void removeInfoLines ()
 Removes all infolines from this inspectable instance. More...
 
virtual const infoLinesListgetInfoLines () const
 Returns all infolines added to this inspectable instance. More...
 
virtual void addInspectable (Inspectable *insp)
 Adds an inspectable as a child object. More...
 
virtual void removeInspectable (Inspectable *insp)
 Removes an inspectable as a child object. More...
 
virtual void setNameOfInspectable (const iparamkey &name)
 set the name of the inspectable More...
 
virtual const iparamkey getNameOfInspectable () const
 return the name of the inspectable, getName() would conflict with Configurable::getName() too often More...
 
virtual const inspectableListgetInspectables () const
 Returns the list containing all inspectable children. More...
 

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

Protected Attributes

int m_generationNumber
 (int) The generation number (ID) More...
 
std::vector< Individual * > m_individual
 (vector<Individual*>) The storage for the individuals, which are part of this generation. More...
 
int m_size
 (int) The planed size of the generation. More...
 
int m_numChildren
 (int) The number of children More...
 
- Protected Attributes inherited from Inspectable
iparamkey name
 
iparampairlist mapOfValues
 
imatrixpairlist mapOfMatrices
 
infoLinesList infoLineStringList
 

Additional Inherited Members

- Public Types inherited from Inspectable
typedef std::string iparamkey
 
typedef double iparamval
 
typedef std::pair< iparamkey,
iparamval const * > 
iparampair
 
typedef std::pair< iparamkey,
std::pair< const
matrix::Matrix *, bool > > 
imatrixpair
 
typedef std::list< iparamkeyiparamkeylist
 
typedef std::list< std::string > infoLinesList
 
typedef std::list< iparamvaliparamvallist
 
typedef std::list< iparamval
const * > 
iparamvalptrlist
 
typedef std::list< iparampairiparampairlist
 
typedef std::list< imatrixpairimatrixpairlist
 
typedef struct Inspectable::ILayer ILayer
 
typedef struct
Inspectable::IConnection 
IConnection
 
typedef std::list< ILayerilayerlist
 
typedef std::list< IConnectioniconnectionlist
 
typedef std::list< const
Inspectable * > 
inspectableList
 

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: