genetiK::gp::Individual Class Reference
[Genetic Programming framework]

Individual: GP-specific Individual. More...

#include <Individual.h>

Inheritance diagram for genetiK::gp::Individual:

Inheritance graph
[legend]
Collaboration diagram for genetiK::gp::Individual:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Individual (IndividualFactory *individualFactory)
 creates an Individual and generates its tree.
 Individual (const Individual &individual)
 creates a copy of an Individual
virtual ~Individual (void)
 destructor
virtual double fitness ()=0
 The fitness function.
virtual genetiK::Individual * copy () const =0
 Copy this individual.
virtual int mutate (const double mutationProbabilty)
 mutate the individual
virtual int crossOver (genetiK::Individual *i, genetiK::Individual **child1, genetiK::Individual **child2)
 Cross over.
virtual std::string toString () const
 outputs the individual.

Protected Member Functions

Gene * extract (const unsigned int label) const
 Extract a branch.
Gene * substituteBranch (const unsigned int label, Gene *newSubTree)
 Substitute a branch.
void setLabels ()
 Sets the labels to all the tree.
unsigned int getCardinality () const
 Return the cardinality of the tree.
IndividualFactory * getIndividualFactory () const
 Return the factory which generated this individual.
Gene * getRoot () const
 Return the root gene of the genetic programming tree.

Detailed Description

Individual: GP-specific Individual.

This class extends the generic genetiK::Individual. It represents an individual as a gene tree.


Constructor & Destructor Documentation

genetiK::gp::Individual::Individual (  IndividualFactory *  individualFactory  ) 
 

creates an Individual and generates its tree.

Parameters:
individualFactory specifies the individualFactory used to generate the tree
See also:
Individual(const Individual& individual)

genetiK::gp::Individual::Individual (  const Individual &  individual  ) 
 

creates a copy of an Individual

Parameters:
individual the Individual to be copied
See also:
Individual(const Individual& individual)


Member Function Documentation

virtual genetiK::Individual* genetiK::gp::Individual::copy (   )  const [pure virtual]
 

Copy this individual.

copy this Individual. You should override this function in your Individual implementation, and return the appropriate new Individual, possibly, using the copy constructor.

See also:
Individual(const Individual& individual)

Implements genetiK::Individual.

Implemented in genetiK::gp::st::Individual.

int genetiK::gp::Individual::crossOver (  genetiK::Individual *  i,
genetiK::Individual **  child1,
genetiK::Individual **  child2
)  [virtual]
 

Cross over.

Parameters:
i the partner of the cross over.
child1 the first child.
child2 the second child.

Implements genetiK::Individual.

Reimplemented in genetiK::gp::st::Individual.

Gene * genetiK::gp::Individual::extract (  const unsigned int  label  )  const [protected]
 

Extract a branch.

Try to find and extract a branch labelled label

Parameters:
label the label of the node to be extracted
Returns:
the extracted node
See also:
getLabel() gp::Gene::extract( const unsigned int label ) const

virtual double genetiK::gp::Individual::fitness (   )  [pure virtual]
 

The fitness function.

a function that quantifies the optimality of a solution. You should override this function in your Individual implementation, and evaluate your own fitness.

Implements genetiK::Individual.

Implemented in genetiK::gp::st::Individual.

unsigned int genetiK::gp::Individual::getCardinality (   )  const [protected]
 

Return the cardinality of the tree.

Return the cardinality of the tree. The cardinality of the tree is computed when you call setLabels(). You should call setLabels() before getCardinality().

Returns:
the number of all the genes in the tree
See also:
setLabels()

IndividualFactory * genetiK::gp::Individual::getIndividualFactory (   )  const [protected]
 

Return the factory which generated this individual.

This fuction is used to retrieve the IndividualFactory which generated this individual. The IndividualFactory is needed for the cross-over and mutation.

Returns:
the number of all the genes in the tree

Gene* genetiK::gp::Individual::getRoot (   )  const [inline, protected]
 

Return the root gene of the genetic programming tree.

Return the root gene of the genetic programming tree.

Returns:
the root gene

int genetiK::gp::Individual::mutate (  const double  mutationProbabilty  )  [virtual]
 

mutate the individual

Parameters:
mutationProbabilty the probability of the mutation, GP mutate each Individual with this probability. Note that GA mutate each bit with this probability.
See also:
crossOver( genetiK::Individual* i,genetiK::Individual** child1,genetiK::Individual** child2)

Implements genetiK::Individual.

Reimplemented in genetiK::gp::st::Individual.

void genetiK::gp::Individual::setLabels (   )  [protected]
 

Sets the labels to all the tree.

Sets the labels to all the tree, and compute the cardinality and the eight of each node.

See also:
gp::Gene::setLabel()

Gene * genetiK::gp::Individual::substituteBranch (  const unsigned int  label,
Gene *  newSubTree
)  [protected]
 

Substitute a branch.

Try to find, and substitute a branch.

Parameters:
label the label of the node to be extracted
newSubTree the new branch
Returns:
the old branch, be careful for possible memory leak.
See also:
getLabel() gp::Gene::substituteBranch( const unsigned int label, Gene* newSubTree )

std::string genetiK::gp::Individual::toString (   )  const [virtual]
 

outputs the individual.

Returns:
the representation of the individual.

Reimplemented from genetiK::Individual.


The documentation for this class was generated from the following files:
Generated on Thu Feb 23 12:22:27 2006 for GenetiK by  doxygen 1.4.6