MTK++ Latest version: 0.2.0

Public Member Functions | Static Public Member Functions | Protected Types | Protected Attributes
MTKpp::gaIndividual Class Reference

Container for gaChromosomes. More...

#include <mtkpp/src/GA/gaIndividual.h>

Collaboration diagram for MTKpp::gaIndividual:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 gaIndividual (gaPopulation *parent=0)
 gaIndividual Constructor
 gaIndividual (gaIndividual *rhs, gaPopulation *parent)
 gaIndividual Copy Constructor
virtual ~gaIndividual ()
 gaIndividual Destructor
gaChromosomeaddChromosome ()
 Add gaChromosome to the gaIndividual.
gaChromosomeaddChromosome (gaChromosome *chr)
 Add chromosome of the individual.
void delChromosome (gaChromosome *chr)
 Delete chromosome from individual.
gaChromosomegetChromosome (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.
gaPopulationgetParent ()
 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
gaPopulationpParent
 gaPopulation pointer
gaChromosomepGaChromosome
 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

Detailed Description

Container for gaChromosomes.

Author:
Martin Peters
Version:
0.1
Date:
2005

Member Typedef Documentation

typedef std::vector<gaChromosome*>::iterator MTKpp::gaIndividual::chromosomeIterator [protected]

gaChromosome iterator


Constructor & Destructor Documentation

MTKpp::gaIndividual::gaIndividual ( gaPopulation parent = 0)

gaIndividual Constructor

Parameters:
parentgaPopulation pointer

References bEvaluate, itsFitness, itsName, and pParent.

MTKpp::gaIndividual::gaIndividual ( gaIndividual rhs,
gaPopulation parent 
)
MTKpp::gaIndividual::~gaIndividual ( ) [virtual]

gaIndividual Destructor


Member Function Documentation

gaChromosome * MTKpp::gaIndividual::addChromosome ( )
gaChromosome * MTKpp::gaIndividual::addChromosome ( gaChromosome chr)

Add chromosome of the individual.

Parameters:
chrgaChromosome pointer
Returns:
gaChromosome pointer

References itsChromosomeList, and pGaChromosome.

void MTKpp::gaIndividual::delChromosome ( gaChromosome chr)

Delete chromosome from individual.

Parameters:
chrgaChromosome pointer

References itsChromosomeList.

gaChromosome * MTKpp::gaIndividual::getChromosome ( int  n,
bool  id,
bool  index 
)

Get chromosome from individual.

Parameters:
nnumber of chromosome either id or index
idbool return by id
indexbool return by index
Returns:
gaChromosome pointer

References MTKpp::gaChromosome::getId(), itsChromosomeList, and pGaChromosome.

Referenced by averageGene(), compare(), gaIndividual(), mutateGene(), MTKpp::gaOutput::prtWorld(), and setGene().

void MTKpp::gaIndividual::initialize ( )
double MTKpp::gaIndividual::getAbsValue ( )

Get the absolute value of all the gaGenes summed up.

Returns:
Absolute value

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.

Parameters:
rhsgaIndividual pointer
Returns:
true/false

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.

Parameters:
lhsfirst gaIndividual
rhsSecond gaIndividual
Returns:
boolean

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.

Parameters:
lhsfirst gaIndividual
rhsSecond gaIndividual
Returns:
boolean

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.

Parameters:
idindividual int

References itsId.

Referenced by MTKpp::gaPopulation::addIndividual(), and MTKpp::gaPopulation::initialize().

int MTKpp::gaIndividual::getId ( )
void MTKpp::gaIndividual::setName ( std::string  name)
std::string MTKpp::gaIndividual::getName ( )
void MTKpp::gaIndividual::setFitness ( double  f)

Set the gaIndividual fitness value.

Parameters:
ffitness value

References itsFitness.

double MTKpp::gaIndividual::getFitness ( )
void MTKpp::gaIndividual::setEvaluate ( bool  b)

Set the gaIndividual evaluate value.

Parameters:
bevaluate value

References bEvaluate.

Referenced by MTKpp::gaAverage::average(), MTKpp::gaOperators::keep(), and MTKpp::gaCrossOver::reproduce().

bool MTKpp::gaIndividual::getEvaluate ( )

Get evaluate value.

Returns:
gaIndividual evaluate value

References bEvaluate.

Referenced by MTKpp::gaOperators::removeRedundant().

gaPopulation * MTKpp::gaIndividual::getParent ( )

Get gaPopulation which gaIndividual is a member of.

Returns:
gaPopulation pointer

References pParent.

Referenced by MTKpp::gaGene::gaGene().

int MTKpp::gaIndividual::getNumChromosomes ( )

Get number of gaChromosomes in gaIndividual.

Returns:
number of gaChromosomes

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.

Returns:
genetic info

References MTKpp::gaChromosome::getGeneticInformation(), itsChromosomeList, and pGaChromosome.

void MTKpp::gaIndividual::setGene ( int  chr,
int  gen,
gaIndividual ind 
)
void MTKpp::gaIndividual::mutateGene ( int  chr,
int  gen 
)
void MTKpp::gaIndividual::averageGene ( int  chr,
int  gen,
gaIndividual ind 
)

Average gaGene.

Parameters:
chrgaChromosome index in gaIndividual
gengaGene index in gaChromosome
indgaIndividual that copied

References MTKpp::gaChromosome::averageGene(), and getChromosome().

void MTKpp::gaIndividual::addParent ( std::string  p)

Add parent gaIndividual.

Parameters:
pparent name

References itsParents.

Referenced by MTKpp::gaOperators::keep(), and MTKpp::gaCrossOver::reproduce().

std::vector< std::string > MTKpp::gaIndividual::getParents ( )

Get parents.

Returns:
parents

References itsParents.

Referenced by MTKpp::gaOperators::keep().

void MTKpp::gaIndividual::addPartner ( std::string  partnerName)

List of partner which gaIndividual has mated with.

Parameters:
partnerNamepartner name

References itsPartners.

Referenced by MTKpp::gaAverage::average(), MTKpp::gaOperators::keep(), and MTKpp::gaCrossOver::reproduce().

std::vector< std::string > MTKpp::gaIndividual::getPartners ( )

Get partners.

Returns:
partners

References itsPartners.

Referenced by MTKpp::gaOperators::keep().

int MTKpp::gaIndividual::numPartners ( )

Returns number of partners.

Returns:
number of partners

References itsPartners.

int MTKpp::gaIndividual::mated ( std::string  partnerName)

Has it mated with a certain gaIndividual.

Parameters:
partnerNamepartner name
Returns:
number of times it has mated with partnerName

References itsPartners.

Referenced by MTKpp::gaAverage::average(), and MTKpp::gaCrossOver::reproduce().


Member Data Documentation

gaPopulation pointer

Referenced by gaIndividual(), and getParent().

int MTKpp::gaIndividual::itsId [protected]

gaIndividual id in gaPopulation

Referenced by getId(), and setId().

std::string MTKpp::gaIndividual::itsName [protected]
double MTKpp::gaIndividual::abs_value [protected]

gaIndividual genetic absolute value

Referenced by getAbsValue().

double MTKpp::gaIndividual::itsFitness [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().


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

Generated on Fri Dec 23 2011 09:28:55 for MTK++ by Doxygen 1.7.5.1