Public Member Functions | Public Attributes | Protected Attributes

Tree::Primitives::Primitive Class Reference
[TreeGenotypesTree Primitives]

Base primitive class (Tree genotype). More...

#include <Primitive.h>

Inheritance diagram for Tree::Primitives::Primitive:
Tree::Primitives::ERC< double > IfFoodAhead MoveAhead Prog2 Prog3 Tree::MyFunc Tree::MyTerminal Tree::Primitives::AddT< T > Tree::Primitives::Cos Tree::Primitives::DivT< T > Tree::Primitives::ERC< T > Tree::Primitives::MaxT< T > Tree::Primitives::MinT< T > Tree::Primitives::MulT< T > Tree::Primitives::NegT< T > Tree::Primitives::PosT< T > Tree::Primitives::Sin Tree::Primitives::SubT< T > Tree::Primitives::TerminalT< T > TurnLeft TurnRight

List of all members.

Public Member Functions

virtual void execute (void *result, Tree &tree)=0
 Execute the primitive.
virtual bool initialize (StateP state)
 Initialize the primitive (default just sets the StateP pointer).
virtual void setValue (void *value)
virtual void getValue (void *value)
virtual PrimitiveP copyWithNode (PrimitiveP)
 Copy primitive (when copying a node, e.g. in crossover). The default behaviour just returns the same pointer (common primitives). (ERC's should override and make a new copy of the original object).
virtual PrimitiveP assignToNode (PrimitiveP)
 Assign primitive to node (when building a tree). The default behaviour just returns the same pointer (common primitives). ERC's should override and generate a new object with a new value.
void getNextArgument (void *result, Tree &tree)
 Execute next child node's primitive (execute next subtree).
void skipNextArgument (Tree &tree)
 Skip next child subtree (doesn't execute the subtree).
int getNumberOfArguments ()
 Return primitive's number of arguments.
void setName (std::string name)
 Set primitive's name.
std::string getName ()
 Get primitive's name.
std::string getComplementName ()
 Get complement's name.

Public Attributes

StateP state_

Protected Attributes

std::string name_
int nArguments_
std::string complementName_

Detailed Description

Base primitive class (Tree genotype).

Each node of a tree points to a single primitive, which may be a function or a variable (of Terminal class). Some primitives are shared among all the trees (i.e. have the same value and functionality), but some (like ERC) are owned by a single Tree.

Definition at line 36 of file Primitive.h.


Member Function Documentation

PrimitiveP Tree::Primitives::Primitive::assignToNode ( PrimitiveP  primitive  )  [virtual]

Assign primitive to node (when building a tree). The default behaviour just returns the same pointer (common primitives). ERC's should override and generate a new object with a new value.

Parameters:
sptr to this primitive

Reimplemented in Tree::Primitives::ERC< T >, Tree::Primitives::ERCD, and Tree::Primitives::ERC< double >.

Definition at line 36 of file Primitive.cpp.

PrimitiveP Tree::Primitives::Primitive::copyWithNode ( PrimitiveP  primitive  )  [virtual]

Copy primitive (when copying a node, e.g. in crossover). The default behaviour just returns the same pointer (common primitives). (ERC's should override and make a new copy of the original object).

Parameters:
sptr to this primitive

Reimplemented in Tree::Primitives::ERC< T >, and Tree::Primitives::ERC< double >.

Definition at line 60 of file Primitive.cpp.

void Tree::Primitives::Primitive::getNextArgument ( void *  result,
Tree tree 
)

Execute next child node's primitive (execute next subtree).

Parameters:
result result of the operation
tree reference to current tree

Definition at line 71 of file Primitive.cpp.

void Tree::Primitives::Primitive::skipNextArgument ( Tree tree  ) 

Skip next child subtree (doesn't execute the subtree).

Parameters:
tree reference to current tree

Definition at line 82 of file Primitive.cpp.


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