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

Gene: The node of the genetic programming tree. More...

#include <Gene.h>

Inheritance diagram for genetiK::gp::Gene:

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

Collaboration graph
[legend]
List of all members.

Public Member Functions

 Gene (unsigned char arity)
 creates a Gene
virtual ~Gene ()
 destructor
virtual util::Variant evaluate ()=0
 Evaluate the tree.
virtual std::string toString () const
 outputs the children.
unsigned char getArity () const
 Arity.
GenegetArgument (unsigned char i)
 Return children.
void setArgument (unsigned char i, Gene *newArgument)
 Sets a child.
unsigned int getCardinality () const
 Cardinality of the node.
unsigned int getLabel () const
 Label of the node.
unsigned char getHeight () const
 Height of the node.
void setHeight (unsigned char height)
 Set the current height of the node.
unsigned char getBranchDepth () const
 Branch depth.
Geneextract (unsigned int label)
 Extract a branch.
GenesubstituteBranch (unsigned int label, Gene *newSubTree)
 Substitute a branch.
unsigned int setLabels (unsigned int label)
 Sets the labels to all the tree.
virtual GenecopyBranch () const
 Copy the branch.
virtual Genecopy () const =0
 Copy the Gene.

Detailed Description

Gene: The node of the genetic programming tree.

This class represents the node of the genetic programming tree.


Constructor & Destructor Documentation

genetiK::gp::Gene::Gene unsigned char  arity  ) 
 

creates a Gene

Gene default contructor

Todo:
add the copy constructor
Parameters:
arity specifies the arity of the node

genetiK::gp::Gene::~Gene  )  [virtual]
 

destructor

Destroys this gene and all its child, recursively

Reimplemented in genetiK::gp::st::Gene.


Member Function Documentation

virtual Gene* genetiK::gp::Gene::copy  )  const [pure virtual]
 

Copy the Gene.

Copy this node.

Returns:
the copyed node.

Gene * genetiK::gp::Gene::copyBranch  )  const [virtual]
 

Copy the branch.

Copy the node and his children, recursively

Returns:
the copyed branch.

virtual util::Variant genetiK::gp::Gene::evaluate  )  [pure virtual]
 

Evaluate the tree.

The cardinality of the node is the number of all descendant plus one (itself).

Returns:
the evaluated expression
See also:
Variant

Gene * genetiK::gp::Gene::extract unsigned int  label  ) 
 

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()

Gene * genetiK::gp::Gene::getArgument unsigned char  i  ) 
 

Return children.

Returns:
The index of the child

unsigned char genetiK::gp::Gene::getArity  )  const [inline]
 

Arity.

The number of children of the node.

Returns:
the arity

unsigned char genetiK::gp::Gene::getBranchDepth  )  const [inline]
 

Branch depth.

The branch depth is

Returns:
the height

unsigned int genetiK::gp::Gene::getCardinality  )  const [inline]
 

Cardinality of the node.

The cardinality of the node is the number of all descendant plus one (itself). The cardinality of the root is exactly the number of the node in the tree.

Returns:
the cardinality

unsigned char genetiK::gp::Gene::getHeight  )  const [inline]
 

Height of the node.

The height of the node in the tree, starting from 0. The root has an height of 0, his children of 1, and so on...

Returns:
the height
See also:
setHeight

unsigned int genetiK::gp::Gene::getLabel  )  const [inline]
 

Label of the node.

The label of the node is an ID used to perform crossover.

Returns:
the label
See also:
setLabels

void genetiK::gp::Gene::setArgument unsigned char  i,
Gene newArgument
 

Sets a child.

Parameters:
i The index of the child
newArgument The child to be set

void genetiK::gp::Gene::setHeight unsigned char  height  )  [inline]
 

Set the current height of the node.

See also:
getHeight

unsigned int genetiK::gp::Gene::setLabels unsigned int  label  ) 
 

Sets the labels to all the tree.

Sets the labels to all the tree

Parameters:
label the next free label to be set to
Returns:
the next free label.
See also:
getLabel()

Gene * genetiK::gp::Gene::substituteBranch unsigned int  label,
Gene newSubTree
 

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()

string genetiK::gp::Gene::toString  )  const [virtual]
 

outputs the children.

Returns:
.string containing all the children toString() strings.


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