MTK++ Latest version: 0.2.0
Container for gaChromosomes. More...
#include <mtkpp/src/GA/gaIndividual.h>
Public Member Functions | |
gaIndividual (gaPopulation *parent=0) | |
gaIndividual Constructor | |
gaIndividual (gaIndividual *rhs, gaPopulation *parent) | |
gaIndividual Copy Constructor | |
virtual | ~gaIndividual () |
gaIndividual Destructor | |
gaChromosome * | addChromosome () |
Add gaChromosome to the gaIndividual. | |
gaChromosome * | addChromosome (gaChromosome *chr) |
Add chromosome of the individual. | |
void | delChromosome (gaChromosome *chr) |
Delete chromosome from individual. | |
gaChromosome * | getChromosome (int n, bool id, bool index) |
Get chromosome from individual. | |
void | initialize () |
Initialize gaIndividual. | |
double | getAbsValue () |
Get the absolute value of all the gaGenes summed up. | |
bool | compare (gaIndividual *rhs) |
Compare two gaIndividual with respect to its chromosomal make up. | |
void | printToScreen () |
Formatted print of the gaIndividual. | |
void | setId (int id) |
Set the individual id. | |
int | getId () |
Get gaIndividual id. | |
void | setName (std::string name) |
Set gaIndividual name. | |
std::string | getName () |
Get gaIndividual name. | |
void | setFitness (double f) |
Set the gaIndividual fitness value. | |
double | getFitness () |
Get fitness value. | |
void | setEvaluate (bool b) |
Set the gaIndividual evaluate value. | |
bool | getEvaluate () |
Get evaluate value. | |
gaPopulation * | getParent () |
Get gaPopulation which gaIndividual is a member of. | |
int | getNumChromosomes () |
Get number of gaChromosomes in gaIndividual. | |
std::vector< double > | getGeneticInformation () |
Get single vector of all genetic information of the gaIndividual. | |
void | setGene (int chr, int gen, gaIndividual *ind) |
Set gaGene. | |
void | mutateGene (int chr, int gen) |
Mutate gaGene. | |
void | averageGene (int chr, int gen, gaIndividual *ind) |
Average gaGene. | |
void | addParent (std::string p) |
Add parent gaIndividual. | |
std::vector< std::string > | getParents () |
Get parents. | |
void | addPartner (std::string partnerName) |
List of partner which gaIndividual has mated with. | |
std::vector< std::string > | getPartners () |
Get partners. | |
int | numPartners () |
Returns number of partners. | |
int | mated (std::string partnerName) |
Has it mated with a certain gaIndividual. | |
Static Public Member Functions | |
static bool | less (const gaIndividual *lhs, const gaIndividual *rhs) |
Compares two gaIndividuals based on fitness. | |
static bool | greater (const gaIndividual *lhs, const gaIndividual *rhs) |
Compares two gaIndividuals based on fitness. | |
Protected Types | |
typedef std::vector < gaChromosome * >::iterator | chromosomeIterator |
gaChromosome iterator | |
Protected Attributes | |
std::vector< gaChromosome * > | itsChromosomeList |
gaChromosome vector | |
gaPopulation * | pParent |
gaPopulation pointer | |
gaChromosome * | pGaChromosome |
gaChromosome pointer | |
int | itsId |
gaIndividual id in gaPopulation | |
std::string | itsName |
gaIndividual name | |
double | abs_value |
gaIndividual genetic absolute value | |
double | itsFitness |
gaIndividual fitness vales | |
bool | bEvaluate |
evaluate gaIndividual | |
std::vector< std::string > | itsPartners |
partners vector | |
std::vector< std::string > | itsParents |
partners vector |
Container for gaChromosomes.
typedef std::vector<gaChromosome*>::iterator MTKpp::gaIndividual::chromosomeIterator [protected] |
gaChromosome iterator
MTKpp::gaIndividual::gaIndividual | ( | gaPopulation * | parent = 0 | ) |
gaIndividual Constructor
parent | gaPopulation pointer |
References bEvaluate, itsFitness, itsName, and pParent.
MTKpp::gaIndividual::gaIndividual | ( | gaIndividual * | rhs, |
gaPopulation * | parent | ||
) |
gaIndividual Copy Constructor
rhs | gaIndividual pointer |
parent | gaPopulation pointer |
References addChromosome(), bEvaluate, getChromosome(), getFitness(), getName(), getNumChromosomes(), itsFitness, itsName, pGaChromosome, and pParent.
MTKpp::gaIndividual::~gaIndividual | ( | ) | [virtual] |
gaIndividual Destructor
gaChromosome * MTKpp::gaIndividual::addChromosome | ( | ) |
Add gaChromosome to the gaIndividual.
References itsChromosomeList, pGaChromosome, and MTKpp::gaChromosome::setId().
Referenced by gaIndividual().
gaChromosome * MTKpp::gaIndividual::addChromosome | ( | gaChromosome * | chr | ) |
Add chromosome of the individual.
chr | gaChromosome pointer |
References itsChromosomeList, and pGaChromosome.
void MTKpp::gaIndividual::delChromosome | ( | gaChromosome * | chr | ) |
Delete chromosome from individual.
chr | gaChromosome pointer |
References itsChromosomeList.
gaChromosome * MTKpp::gaIndividual::getChromosome | ( | int | n, |
bool | id, | ||
bool | index | ||
) |
Get chromosome from individual.
n | number of chromosome either id or index |
id | bool return by id |
index | bool return by index |
References MTKpp::gaChromosome::getId(), itsChromosomeList, and pGaChromosome.
Referenced by averageGene(), compare(), gaIndividual(), mutateGene(), MTKpp::gaOutput::prtWorld(), and setGene().
void MTKpp::gaIndividual::initialize | ( | ) |
Initialize gaIndividual.
References MTKpp::gaChromosome::initialize(), itsChromosomeList, and pGaChromosome.
Referenced by MTKpp::gaPopulation::initialize().
double MTKpp::gaIndividual::getAbsValue | ( | ) |
Get the absolute value of all the gaGenes summed up.
References abs_value, MTKpp::gaChromosome::getAbsValue(), itsChromosomeList, and pGaChromosome.
Referenced by MTKpp::gaPopulation::getAbsValues(), and MTKpp::gaOperators::removeRedundant().
bool MTKpp::gaIndividual::compare | ( | gaIndividual * | rhs | ) |
Compare two gaIndividual with respect to its chromosomal make up.
rhs | gaIndividual pointer |
References getChromosome(), and itsChromosomeList.
Referenced by MTKpp::gaOperators::removeRedundant().
static bool MTKpp::gaIndividual::less | ( | const gaIndividual * | lhs, |
const gaIndividual * | rhs | ||
) | [inline, static] |
Compares two gaIndividuals based on fitness.
lhs | first gaIndividual |
rhs | Second gaIndividual |
After this function is defined the STL sort() function in gaPopulation can be used
References itsFitness.
Referenced by MTKpp::gaPopulation::rank().
static bool MTKpp::gaIndividual::greater | ( | const gaIndividual * | lhs, |
const gaIndividual * | rhs | ||
) | [inline, static] |
Compares two gaIndividuals based on fitness.
lhs | first gaIndividual |
rhs | Second gaIndividual |
After this function is defined the STL sort() function in gaPopulation can be used
References itsFitness.
Referenced by MTKpp::gaPopulation::rank().
void MTKpp::gaIndividual::printToScreen | ( | ) |
Formatted print of the gaIndividual.
References itsFitness, and itsName.
void MTKpp::gaIndividual::setId | ( | int | id | ) |
Set the individual id.
id | individual int |
References itsId.
Referenced by MTKpp::gaPopulation::addIndividual(), and MTKpp::gaPopulation::initialize().
int MTKpp::gaIndividual::getId | ( | ) |
Get gaIndividual id.
References itsId.
Referenced by MTKpp::gaPopulation::getIndividual(), and MTKpp::gaOutput::prtWorld().
void MTKpp::gaIndividual::setName | ( | std::string | name | ) |
Set gaIndividual name.
name | gaIndividual name |
References itsName.
Referenced by MTKpp::gaAverage::average(), MTKpp::gaPopulation::initialize(), and MTKpp::gaCrossOver::reproduce().
std::string MTKpp::gaIndividual::getName | ( | ) |
Get gaIndividual name.
References itsName.
Referenced by MTKpp::gaAverage::average(), gaIndividual(), MTKpp::gaPopulation::getIndividual(), MTKpp::gaRegion::nextGeneration(), MTKpp::gaOutput::prtWorld(), MTKpp::gaPopulation::rank(), and MTKpp::gaCrossOver::reproduce().
void MTKpp::gaIndividual::setFitness | ( | double | f | ) |
double MTKpp::gaIndividual::getFitness | ( | ) |
Get fitness value.
References itsFitness.
Referenced by gaIndividual(), MTKpp::gaPopulation::getBestIndividual(), MTKpp::gaOutput::prtWorld(), and MTKpp::gaPopulation::rank().
void MTKpp::gaIndividual::setEvaluate | ( | bool | b | ) |
Set the gaIndividual evaluate value.
b | evaluate value |
References bEvaluate.
Referenced by MTKpp::gaAverage::average(), MTKpp::gaOperators::keep(), and MTKpp::gaCrossOver::reproduce().
bool MTKpp::gaIndividual::getEvaluate | ( | ) |
Get evaluate value.
References bEvaluate.
Referenced by MTKpp::gaOperators::removeRedundant().
gaPopulation * MTKpp::gaIndividual::getParent | ( | ) |
Get gaPopulation which gaIndividual is a member of.
References pParent.
Referenced by MTKpp::gaGene::gaGene().
int MTKpp::gaIndividual::getNumChromosomes | ( | ) |
Get number of gaChromosomes in gaIndividual.
References itsChromosomeList.
Referenced by MTKpp::gaChromosome::gaChromosome(), gaIndividual(), and MTKpp::gaOutput::prtWorld().
std::vector< double > MTKpp::gaIndividual::getGeneticInformation | ( | ) |
Get single vector of all genetic information of the gaIndividual.
References MTKpp::gaChromosome::getGeneticInformation(), itsChromosomeList, and pGaChromosome.
void MTKpp::gaIndividual::setGene | ( | int | chr, |
int | gen, | ||
gaIndividual * | ind | ||
) |
Set gaGene.
chr | gaChromosome index in gaIndividual |
gen | gaGene index in gaChromosome |
ind | gaIndividual that copied |
References getChromosome(), and MTKpp::gaChromosome::setGene().
Referenced by MTKpp::gaCrossOver::__multipleGene(), MTKpp::gaCrossOver::__randomLocus(), MTKpp::gaAverage::__singleGene(), and MTKpp::gaCrossOver::__singleGene().
void MTKpp::gaIndividual::mutateGene | ( | int | chr, |
int | gen | ||
) |
Mutate gaGene.
chr | gaChromosome index in gaIndividual |
gen | gaGene index in gaChromosome |
References getChromosome(), and MTKpp::gaChromosome::mutateGene().
Referenced by MTKpp::gaMutate::__multipleGene(), and MTKpp::gaMutate::__singleGene().
void MTKpp::gaIndividual::averageGene | ( | int | chr, |
int | gen, | ||
gaIndividual * | ind | ||
) |
Average gaGene.
chr | gaChromosome index in gaIndividual |
gen | gaGene index in gaChromosome |
ind | gaIndividual that copied |
References MTKpp::gaChromosome::averageGene(), and getChromosome().
void MTKpp::gaIndividual::addParent | ( | std::string | p | ) |
Add parent gaIndividual.
p | parent name |
References itsParents.
Referenced by MTKpp::gaOperators::keep(), and MTKpp::gaCrossOver::reproduce().
std::vector< std::string > MTKpp::gaIndividual::getParents | ( | ) |
void MTKpp::gaIndividual::addPartner | ( | std::string | partnerName | ) |
List of partner which gaIndividual has mated with.
partnerName | partner name |
References itsPartners.
Referenced by MTKpp::gaAverage::average(), MTKpp::gaOperators::keep(), and MTKpp::gaCrossOver::reproduce().
std::vector< std::string > MTKpp::gaIndividual::getPartners | ( | ) |
int MTKpp::gaIndividual::numPartners | ( | ) |
int MTKpp::gaIndividual::mated | ( | std::string | partnerName | ) |
Has it mated with a certain gaIndividual.
partnerName | partner name |
References itsPartners.
Referenced by MTKpp::gaAverage::average(), and MTKpp::gaCrossOver::reproduce().
std::vector<gaChromosome*> MTKpp::gaIndividual::itsChromosomeList [protected] |
gaChromosome vector
Referenced by addChromosome(), compare(), delChromosome(), getAbsValue(), getChromosome(), getGeneticInformation(), getNumChromosomes(), and initialize().
gaPopulation* MTKpp::gaIndividual::pParent [protected] |
gaPopulation pointer
Referenced by gaIndividual(), and getParent().
gaChromosome* MTKpp::gaIndividual::pGaChromosome [protected] |
gaChromosome pointer
Referenced by addChromosome(), gaIndividual(), getAbsValue(), getChromosome(), getGeneticInformation(), and initialize().
int MTKpp::gaIndividual::itsId [protected] |
gaIndividual id in gaPopulation
std::string MTKpp::gaIndividual::itsName [protected] |
gaIndividual name
Referenced by gaIndividual(), getName(), printToScreen(), and setName().
double MTKpp::gaIndividual::abs_value [protected] |
gaIndividual genetic absolute value
Referenced by getAbsValue().
double MTKpp::gaIndividual::itsFitness [protected] |
gaIndividual fitness vales
Referenced by gaIndividual(), getFitness(), greater(), less(), printToScreen(), and setFitness().
bool MTKpp::gaIndividual::bEvaluate [protected] |
evaluate gaIndividual
Referenced by gaIndividual(), getEvaluate(), and setEvaluate().
std::vector<std::string> MTKpp::gaIndividual::itsPartners [protected] |
partners vector
Referenced by addPartner(), getPartners(), mated(), and numPartners().
std::vector<std::string> MTKpp::gaIndividual::itsParents [protected] |
partners vector
Referenced by addParent(), and getParents().
Generated on Fri Dec 23 2011 09:28:55 for MTK++ by Doxygen 1.7.5.1