Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes

Tree::Tree Class Reference

Tree class - implements genotype as a tree. More...

#include <Tree_c.h>

Inheritance diagram for Tree::Tree:
Genotype

List of all members.

Public Member Functions

Treecopy ()
void growBuild (PrimitiveSetP primitiveSet)
 Build tree with grow method.
void fullBuild (PrimitiveSetP primitiveSet)
 Build tree with full method.
void update ()
 Calculate depth and subtree sizes of each node in the tree.
void execute (void *)
 Execute current tree.
void addNode (Node *node)
void addNode (NodeP node)
void setTerminalValue (std::string, void *)
 Set a terminal's value.
void write (XMLNode &)
void read (XMLNode &)
void registerParameters (StateP)
bool initialize (StateP state)
std::vector< MutationOpP > getMutationOp ()
std::vector< CrossoverOpP > getCrossoverOp ()
bool addFunction (PrimitiveP)
 Add user defined function primitive.
bool addTerminal (PrimitiveP)
 Add user defined terminal primitive.
uint getMaxDepth ()
uint getMinDepth ()
uint getStartDepth ()

Public Attributes

PrimitiveSetP primitiveSet_
uint iNode_
uint startDepth_
uint maxDepth_
uint minDepth_
uint initMaxDepth_
uint initMinDepth_

Protected Member Functions

uint growBuild (PrimitiveSetP primitiveSet, int myDepth)
uint fullBuild (PrimitiveSetP primitiveSet, int myDepth)
uint setSize (int)
 Calculate subtree sizes of each node in the tree.
void setDepth (int myDepth)
 Calculate depth of each node in the tree.
void initializeFirst (Tree *hometree)
 Performs the first Tree initialization. Constructs the primitive set and performs parameter checks.

Protected Attributes

std::vector< PrimitiveP > userFunctions_
std::vector< PrimitiveP > userTerminals_
StateP state_

Detailed Description

Tree class - implements genotype as a tree.

Definition at line 18 of file Tree_c.h.


Member Function Documentation

bool Tree::Tree::addFunction ( PrimitiveP  func  ) 

Add user defined function primitive.

Must be called prior to initialization (no impact otherwise).

Definition at line 81 of file Tree.cpp.

bool Tree::Tree::addTerminal ( PrimitiveP  term  ) 

Add user defined terminal primitive.

Must be called prior to initialization (no impact otherwise).

Definition at line 93 of file Tree.cpp.

Tree * Tree::Tree::copy (  )  [virtual]

Create an identical copy of the genotype object

Implements Genotype.

Definition at line 37 of file Tree.cpp.

void Tree::Tree::execute ( void *  result  ) 

Execute current tree.

Evaluates the function embodied in the tree (or executes the represented program).

Parameters:
result the resulting tree value (of the first node)

Definition at line 347 of file Tree.cpp.

std::vector< CrossoverOpP > Tree::Tree::getCrossoverOp (  )  [virtual]

Create and return a vector of crossover operators

Reimplemented from Genotype.

Definition at line 49 of file Tree.cpp.

std::vector< MutationOpP > Tree::Tree::getMutationOp (  )  [virtual]

Create and return a vector of mutation operators

Reimplemented from Genotype.

Definition at line 61 of file Tree.cpp.

bool Tree::Tree::initialize ( StateP  state  )  [virtual]

Initialize a genotype object (read parameters, perform sanity check, build data)

Implements Genotype.

Definition at line 111 of file Tree.cpp.

void Tree::Tree::read ( XMLNode &   )  [virtual]

Read genotype data from XMLNode

Implements Genotype.

Definition at line 520 of file Tree.cpp.

void Tree::Tree::registerParameters ( StateP   )  [virtual]

Register genotype's parameters (called before Genotype::initialize)

Reimplemented from Genotype.

Definition at line 100 of file Tree.cpp.

void Tree::Tree::setTerminalValue ( std::string  name,
void *  value 
)

Set a terminal's value.

Parameters:
name terminal's name
value terminal's value

Definition at line 487 of file Tree.cpp.

void Tree::Tree::update ( void   ) 

Calculate depth and subtree sizes of each node in the tree.

Uses recursive depth-first tree processing.

Definition at line 418 of file Tree.cpp.

void Tree::Tree::write ( XMLNode &   )  [virtual]

Write genotype data to XMLNode

Implements Genotype.

Definition at line 505 of file Tree.cpp.


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