MTK++ Latest version: 0.2.0

Public Member Functions | Protected Attributes | Friends
MTKpp::gaGene Class Reference

Class to handle genes. More...

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

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

List of all members.

Public Member Functions

 gaGene (gaChromosome *parent=0)
 gaGene Constructor
 gaGene (gaGene *)
 gaGene Copy Constructor
virtual ~gaGene ()
 gaIndividual Destructor
void setGene (gaGene *rhs)
 Set gene equal to rhs.
void addBit (double b)
 Add bit to gene.
double getBit (const int &i)
 Get bit from gene.
void initialize ()
 Initialize gaGene.
double getAbsValue ()
 Get the absolute value of all bits summed together.
bool compare (gaGene *rhs)
 Compare two gaGenes.
void mutate ()
 Mutate gaGene.
void average (gaGene *rhs)
 Average gaGene, updates this gaGene.
void printToScreen ()
 Formatted print of the gaGene.
void setId (int id)
 Set id of gaGene.
int getId ()
 Get id of gaGene.
void setName (std::string name)
 Set name of gaGene.
std::string getName ()
 Get name of gaGene.
gaChromosomegetParent ()
 Get gaChromosome which gaGene is a member of.
int getNumBits ()
 Get number of bits in gaGene.
std::vector< double > getGeneticInformation ()
 Get genetic information of the gaGene.

Protected Attributes

gaRegioncurRegion
 gaRegion pointer
gaChromosomepParent
 gaChromosome pointer
std::vector< double > itsBits
 gaGene bits
int itsId
 gaGene id
std::string itsName
 gaGene name

Friends

std::ostream & operator<< (std::ostream &os, const gaGene &g)

Detailed Description

Class to handle genes.

Author:
Martin Peters
Version:
0.1
Date:
2005

Constructor & Destructor Documentation

MTKpp::gaGene::gaGene ( gaChromosome parent = 0)
MTKpp::gaGene::gaGene ( gaGene rhs)
MTKpp::gaGene::~gaGene ( ) [virtual]

gaIndividual Destructor


Member Function Documentation

void MTKpp::gaGene::setGene ( gaGene rhs)

Set gene equal to rhs.

Parameters:
rhsgaGene pointer

References getBit(), getNumBits(), and itsBits.

Referenced by MTKpp::gaChromosome::setGene().

void MTKpp::gaGene::addBit ( double  b)

Add bit to gene.

Parameters:
bbit to be added

References itsBits.

double MTKpp::gaGene::getBit ( const int &  i)

Get bit from gene.

Parameters:
iindex of bit in gene
Returns:
bit

References itsBits.

Referenced by average(), compare(), gaGene(), printToScreen(), and setGene().

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

Get the absolute value of all bits summed together.

Returns:
absolute vales

References itsBits.

Referenced by MTKpp::gaChromosome::getAbsValue().

bool MTKpp::gaGene::compare ( gaGene rhs)

Compare two gaGenes.

Parameters:
rhsSecond gaGene
Returns:
true/false

References MTKpp::gaRegion::chreDiff, curRegion, getBit(), and itsBits.

Referenced by MTKpp::gaChromosome::compare().

void MTKpp::gaGene::mutate ( )
void MTKpp::gaGene::average ( gaGene rhs)

Average gaGene, updates this gaGene.

Parameters:
rhsSecond gaGene

References getBit(), getNumBits(), and itsBits.

Referenced by MTKpp::gaChromosome::averageGene().

void MTKpp::gaGene::printToScreen ( )

Formatted print of the gaGene.

References getBit(), and getNumBits().

void MTKpp::gaGene::setId ( int  id)

Set id of gaGene.

Parameters:
idgaGene id

References itsId.

Referenced by MTKpp::gaChromosome::addGene().

int MTKpp::gaGene::getId ( )
void MTKpp::gaGene::setName ( std::string  name)

Set name of gaGene.

Parameters:
namegaGene name

References itsName.

std::string MTKpp::gaGene::getName ( )

Get name of gaGene.

Returns:
name of gaGene

References itsName.

Referenced by gaGene(), and MTKpp::gaOutput::prtWorld().

gaChromosome * MTKpp::gaGene::getParent ( )

Get gaChromosome which gaGene is a member of.

Returns:
gaChromosome pointer

References pParent.

Referenced by gaGene(), initialize(), and mutate().

int MTKpp::gaGene::getNumBits ( )

Get number of bits in gaGene.

Returns:
number of bits in gaGene

References itsBits.

Referenced by average(), gaGene(), printToScreen(), and setGene().

std::vector< double > MTKpp::gaGene::getGeneticInformation ( )

Get genetic information of the gaGene.

Returns:
genetic info

References itsBits.

Referenced by MTKpp::gaChromosome::getGeneticInformation().


Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  os,
const gaGene g 
) [friend]

Member Data Documentation

gaRegion pointer

Referenced by compare(), gaGene(), initialize(), and mutate().

gaChromosome pointer

Referenced by gaGene(), and getParent().

std::vector<double> MTKpp::gaGene::itsBits [protected]
int MTKpp::gaGene::itsId [protected]

gaGene id

Referenced by gaGene(), getId(), initialize(), mutate(), and setId().

std::string MTKpp::gaGene::itsName [protected]

gaGene name

Referenced by gaGene(), getName(), and setName().


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