#include <Generation.h>
Inherits Inspectable.
Inheritance diagram for Generation:
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 |
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.
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).
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.
void addIndividual | ( | Individual * | individual | ) |
This function insert an individual in the generation.
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.
random | (RandGen*) a pseudo number generator. |
std::vector< double > * getAllFitness | ( | void | ) | const |
returns all fitness values from the individuals.
const std::vector<Individual*>& getAllIndividual | ( | void | ) | const [inline] |
[inline], [const] This function gives all individual back.
std::string getAllIndividualAsString | ( | void | ) | const |
returns a string which represent all individual in this generation.
std::vector< Individual * > * getAllUnCalculatedIndividuals | ( | void | ) | const |
[inline], [const] This function gives all individual back which aren't have the fitness value calculated.
int getCurrentSize | ( | void | ) | const [inline] |
[inline], [const] This function gives the actual size (number of individuals inside the generation) back.
int getGenerationNumber | ( | void | ) | const [inline] |
[inline], [const] This function gives the ID (number) of the generation back.
Individual* getIndividual | ( | int | x | ) | const [inline] |
[individual], [const] This function gives one individual from this generation back.
x | (int) the index of the searched individual |
int getNumChildren | ( | void | ) | const [inline] |
[inline], [const] This function gives the number of children back, which will be created by crossover.
int getSize | ( | void | ) | const [inline] |
[inline], [const] This function gives the size which is planed for this generation back.
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
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 |
bool store | ( | FILE * | f | ) | const |
store a generation in a file
f | (FILE*) the file in which should be stored |
void update | ( | double | factor = 1.5 |
) |
This function updates the statistical values.
factor | (double) normal 1.5 Is needed for the data analysation |
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.