Robot Simulator of the Robotics Group for Self-Organization of Control
0.8.0
|
This class represent one individual of the complete gen. More...
#include <Individual.h>
Public Member Functions | |
Individual (std::string name, int id, Individual *p1=0, Individual *p2=0) | |
constructor Create the individual with the name "name" More... | |
virtual | ~Individual () |
default destructor More... | |
int | getID (void) const |
return the ID of the individual More... | |
std::string | getName (void) const |
return the name of the individual More... | |
int | getSize (void) const |
return the size of the individual. More... | |
Gen * | getGen (int x) const |
return a gen of the individual More... | |
void | addGen (Gen *gen) |
add a gen to the individual. More... | |
const std::vector< Gen * > & | getGene (void) const |
returns all gens of the individual More... | |
void | removeGen (Gen *gen) |
remove a specified gen from the individual More... | |
void | removeGen (int x) |
remove a specified gen from the individual More... | |
double | getFitness () |
this function calculate the fitness value of the individual More... | |
double | getFitnessC () const |
this function calculate the fitness value of the individual (const) More... | |
void | setMutated (void) |
this select the individual as a product of mutation. More... | |
const Individual * | getParent1 (void) const |
returns parent 1 of the individual More... | |
const Individual * | getParent2 (void) const |
returns parent 2 of the individual More... | |
bool | isMutated (void) const |
test if the individual a product of mutation More... | |
std::string | IndividualToString (void) const |
returns a string, which repesent the individual (for logging) More... | |
std::string | RootToString (bool withMutation=true) const |
returns a string with the parents and a mark for mutation More... | |
bool | isFitnessCalculated () const |
returns the m_fitnessCalculated flag, which represent, that the fitness value was calculated before. More... | |
bool | store (FILE *f) const |
store the individual in a file More... | |
Static Public Member Functions | |
static bool | restore (int numberIndividuals, std::map< int, std::string > &nameSet, std::map< int, RESTORE_GA_INDIVIDUAL * > &individualSet, std::map< int, std::vector< int > > &linkSet, std::vector< Individual * > &storage) |
restore all individual from a restore structure More... | |
static bool | restoreParent (int numberIndividuals, std::map< int, RESTORE_GA_INDIVIDUAL * > &individualSet) |
restore the parent links from a restore structure More... | |
Protected Attributes | |
std::string | m_name |
the name of the individual More... | |
int | m_ID |
the ID of the individual More... | |
std::vector< Gen * > | m_gene |
the gens inside the individual More... | |
Individual * | m_parent1 |
parent 1 More... | |
Individual * | m_parent2 |
parent 2 More... | |
bool | m_mutated |
remember if the individual a product of mutation More... | |
bool | m_fitnessCalculated |
remember if the fitness value was calculated More... | |
double | m_fitness |
save the calculated fitness value More... | |
This class represent one individual of the complete gen.
alg. It have some gens and a fitness.
Individual | ( | std::string | name, |
int | id, | ||
Individual * | p1 = 0 , |
||
Individual * | p2 = 0 |
||
) |
constructor Create the individual with the name "name"
name | (sting) the name of the new individual |
id | (int) an unique ID |
p1 | (Individual*) parent 1 or zero if it random generate |
p2 | (Individual*) parent 2 or zero if it random generate |
|
virtual |
default destructor
|
inline |
add a gen to the individual.
gen | (Gen*) the new gen |
double getFitness | ( | ) |
this function calculate the fitness value of the individual
double getFitnessC | ( | ) | const |
this function calculate the fitness value of the individual (const)
|
inline |
return a gen of the individual
x | (the index of the gen |
|
inline |
returns all gens of the individual
|
inline |
return the ID of the individual
|
inline |
return the name of the individual
|
inline |
returns parent 1 of the individual
|
inline |
returns parent 2 of the individual
|
inline |
return the size of the individual.
This mean the number of gens inside the individual.
std::string IndividualToString | ( | void | ) | const |
returns a string, which repesent the individual (for logging)
|
inline |
returns the m_fitnessCalculated flag, which represent, that the fitness value was calculated before.
|
inline |
test if the individual a product of mutation
void removeGen | ( | Gen * | gen | ) |
remove a specified gen from the individual
gen | (Gen*) the gen which should removed from the individual |
void removeGen | ( | int | x | ) |
remove a specified gen from the individual
x | (the index of the gen, which should b removed. |
|
static |
restore all individual from a restore structure
numberIndividuals | (int) number of individuals which should be restored |
nameSet | (map<int,string>) names of the individuals |
individualSet | (map<int,RESTORE_GA_INDIVIDUAL*> the structures which should be restored |
linkSet | (map<int,vector<int>>) the linkings between the individual and the genes |
|
static |
restore the parent links from a restore structure
numberIndividuals | (int) number of individuals which should be restored |
individualSet | (map<int,RESTORE_GA_INDIVIDUAL*> the structures which should be restored |
std::string RootToString | ( | bool | withMutation = true | ) | const |
returns a string with the parents and a mark for mutation
withMutation | (bool) should mutation part of the string |
|
inline |
this select the individual as a product of mutation.
bool store | ( | FILE * | f | ) | const |
store the individual in a file
f | (FILE) the file to store in |
|
protected |
save the calculated fitness value
|
protected |
remember if the fitness value was calculated
|
protected |
the gens inside the individual
|
protected |
the ID of the individual
|
protected |
remember if the individual a product of mutation
|
protected |
the name of the individual
|
protected |
parent 1
|
protected |
parent 2