ECF 1.5
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Tree::Primitives::Primitive Class Referenceabstract

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

#include <Primitive.h>

Inheritance diagram for Tree::Primitives::Primitive:
Tree::Primitives::ERC< double > And And2 BoolV If IfFoodAhead Mod Mod MoveAhead Nand Nor Not Or Prog2 Prog3 Sqrt Sqrt Tree::MyFunc Tree::MyTerminal Tree::Primitives::AddT< T > Tree::Primitives::Cos Tree::Primitives::DivT< T > Tree::Primitives::ERC< T > Tree::Primitives::Log 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::Sqrt Tree::Primitives::SubT< T > Tree::Primitives::TerminalT< T > TurnLeft TurnRight XNor Xor

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_
 

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.

Constructor & Destructor Documentation

◆ Primitive()

Tree::Primitives::Primitive::Primitive ( )

Definition at line 9 of file Primitive.cpp.

◆ ~Primitive()

Tree::Primitives::Primitive::~Primitive ( )
virtual

Definition at line 16 of file Primitive.cpp.

Member Function Documentation

◆ assignToNode()

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
sptrto this primitive

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

Definition at line 36 of file Primitive.cpp.

◆ copyWithNode()

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
sptrto this primitive

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

Definition at line 60 of file Primitive.cpp.

◆ execute()

virtual void Tree::Primitives::Primitive::execute ( void *  result,
Tree tree 
)
pure virtual

◆ getComplementName()

std::string Tree::Primitives::Primitive::getComplementName ( )

Get complement's name.

Definition at line 118 of file Primitive.cpp.

◆ getName()

std::string Tree::Primitives::Primitive::getName ( )

Get primitive's name.

Definition at line 109 of file Primitive.cpp.

◆ getNextArgument()

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

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

Parameters
resultresult of the operation
treereference to current tree

Definition at line 71 of file Primitive.cpp.

◆ getNumberOfArguments()

int Tree::Primitives::Primitive::getNumberOfArguments ( )

Return primitive's number of arguments.

Definition at line 91 of file Primitive.cpp.

◆ getValue()

void Tree::Primitives::Primitive::getValue ( void *  value)
virtual

◆ initialize()

bool Tree::Primitives::Primitive::initialize ( StateP  state)
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.

◆ setName()

void Tree::Primitives::Primitive::setName ( std::string  name)

Set primitive's name.

Definition at line 100 of file Primitive.cpp.

◆ setValue()

void Tree::Primitives::Primitive::setValue ( void *  value)
virtual

◆ skipNextArgument()

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

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

Parameters
treereference to current tree

Definition at line 82 of file Primitive.cpp.

Member Data Documentation

◆ complementName_

std::string Tree::Primitives::Primitive::complementName_
protected

Definition at line 65 of file Primitive.h.

◆ name_

std::string Tree::Primitives::Primitive::name_
protected

Definition at line 63 of file Primitive.h.

◆ nArguments_

int Tree::Primitives::Primitive::nArguments_
protected

Definition at line 64 of file Primitive.h.

◆ state_

StateP Tree::Primitives::Primitive::state_

Definition at line 60 of file Primitive.h.


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