ECF 1.5
|
Base primitive class (Tree genotype). More...
#include <Primitive.h>
Public Member Functions | |
virtual void | execute (void *result, Tree &tree)=0 |
Execute the primitive. More... | |
virtual bool | initialize (StateP state) |
Initialize the primitive (default just sets the StateP pointer). More... | |
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). More... | |
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. More... | |
void | getNextArgument (void *result, Tree &tree) |
Execute next child node's primitive (execute next subtree). More... | |
void | skipNextArgument (Tree &tree) |
Skip next child subtree (doesn't execute the subtree). More... | |
int | getNumberOfArguments () |
Return primitive's number of arguments. More... | |
void | setName (std::string name) |
Set primitive's name. More... | |
std::string | getName () |
Get primitive's name. More... | |
std::string | getComplementName () |
Get complement's name. More... | |
Public Attributes | |
StateP | state_ |
Protected Attributes | |
std::string | name_ |
int | nArguments_ |
std::string | complementName_ |
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.
Tree::Primitives::Primitive::Primitive | ( | ) |
Definition at line 9 of file Primitive.cpp.
|
virtual |
Definition at line 16 of file Primitive.cpp.
|
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.
sptr | to this primitive |
Reimplemented in Tree::Primitives::ERC< T >, Tree::Primitives::ERC< double >, and Tree::Primitives::ERCD.
Definition at line 36 of file Primitive.cpp.
|
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).
sptr | to this primitive |
Reimplemented in Tree::Primitives::ERC< T >, and Tree::Primitives::ERC< double >.
Definition at line 60 of file Primitive.cpp.
|
pure virtual |
Execute the primitive.
Function primitives gather arguments and return a value; terminal primitives return current value.
Implemented in IfFoodAhead, MoveAhead, Prog2, Prog3, TurnLeft, TurnRight, Tree::MyTerminal, Tree::MyFunc, Tree::Primitives::AddT< T >, Tree::Primitives::Cos, Tree::Primitives::DivT< 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 >, Tree::Primitives::ERC< T >, Tree::Primitives::ERC< double >, Tree::Primitives::Log, Tree::Primitives::Sqrt, BoolV, Or, Nor, Xor, XNor, And, Nand, And2, Not, If, DivInt, Sqrt, Mod, DivInt, Sqrt, Mod, IAAdd, IAConstTerminal, IACos, IADiv, IAERCD, IALog, IAMul, IASin, IASqrt, IASub, and IATerminal.
std::string Tree::Primitives::Primitive::getComplementName | ( | ) |
Get complement's name.
Definition at line 118 of file Primitive.cpp.
std::string Tree::Primitives::Primitive::getName | ( | ) |
Get primitive's name.
Definition at line 109 of file Primitive.cpp.
void Tree::Primitives::Primitive::getNextArgument | ( | void * | result, |
Tree & | tree | ||
) |
Execute next child node's primitive (execute next subtree).
result | result of the operation |
tree | reference to current tree |
Definition at line 71 of file Primitive.cpp.
int Tree::Primitives::Primitive::getNumberOfArguments | ( | ) |
Return primitive's number of arguments.
Definition at line 91 of file Primitive.cpp.
|
virtual |
Reimplemented in Tree::Primitives::TerminalT< T >, Tree::Primitives::ERC< T >, and Tree::Primitives::ERC< double >.
Definition at line 48 of file Primitive.cpp.
|
virtual |
Initialize the primitive (default just sets the StateP pointer).
Reimplemented in Tree::Primitives::ERC< T >, Tree::Primitives::ERC< double >, and Tree::Primitives::ERCD.
Definition at line 23 of file Primitive.cpp.
void Tree::Primitives::Primitive::setName | ( | std::string | name | ) |
Set primitive's name.
Definition at line 100 of file Primitive.cpp.
|
virtual |
Reimplemented in Tree::Primitives::TerminalT< T >, Tree::Primitives::ERC< T >, and Tree::Primitives::ERC< double >.
Definition at line 42 of file Primitive.cpp.
void Tree::Primitives::Primitive::skipNextArgument | ( | Tree & | tree | ) |
Skip next child subtree (doesn't execute the subtree).
tree | reference to current tree |
Definition at line 82 of file Primitive.cpp.
|
protected |
Definition at line 65 of file Primitive.h.
|
protected |
Definition at line 63 of file Primitive.h.
|
protected |
Definition at line 64 of file Primitive.h.
StateP Tree::Primitives::Primitive::state_ |
Definition at line 60 of file Primitive.h.