ECF 1.5
Public Member Functions | Public Attributes | Protected Attributes | List of all members
Tree::Primitives::ERC< T > Class Template Reference

Ephemereal random constant (ERC) node class (Tree genotype). More...

#include <Terminal.h>

Inheritance diagram for Tree::Primitives::ERC< T >:
Tree::Primitives::Primitive

Public Member Functions

bool initialize (StateP state)
 Initialize ERC value(s). More...
 
void execute (void *result, Tree &tree)
 Execute the primitive. More...
 
void setValue (void *value)
 Set terminal's value. More...
 
void getValue (void *value)
 Get terminal's value. More...
 
PrimitiveP copyWithNode (PrimitiveP primitive)
 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...
 
PrimitiveP assignToNode (PrimitiveP primitive)
 Create (or choose) new unique ERC value and assign to tree node. More...
 
- Public Member Functions inherited from Tree::Primitives::Primitive
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

std::string baseName_
 
value_
 
- Public Attributes inherited from Tree::Primitives::Primitive
StateP state_
 

Protected Attributes

std::vector< T > * values_
 
- Protected Attributes inherited from Tree::Primitives::Primitive
std::string name_
 
int nArguments_
 
std::string complementName_
 

Detailed Description

template<class T>
class Tree::Primitives::ERC< T >

Ephemereal random constant (ERC) node class (Tree genotype).

ERC is a Primitive that represents a single value (of type double by default) that can assume values from the interval or from the set. Value of an ERC instance is defined once - when assigning to a node in a new tree. Only double-typed ERC instances may change value (with Gaussian mutation).

ERC's are distinguished from regular terminals by the prefix denoting their type, e.g.: D_3.14, I_5, B_true, C_a

Definition at line 85 of file Terminal.h.

Constructor & Destructor Documentation

◆ ERC()

template<class T >
Tree::Primitives::ERC< T >::ERC ( )
inline

Definition at line 91 of file Terminal.h.

Member Function Documentation

◆ assignToNode()

template<class T >
PrimitiveP Tree::Primitives::ERC< T >::assignToNode ( PrimitiveP  primitive)
inlinevirtual

Create (or choose) new unique ERC value and assign to tree node.

Parameters
pointerto destination

Reimplemented from Tree::Primitives::Primitive.

Definition at line 161 of file Terminal.h.

◆ copyWithNode()

template<class T >
PrimitiveP Tree::Primitives::ERC< T >::copyWithNode ( PrimitiveP  primitive)
inlinevirtual

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 from Tree::Primitives::Primitive.

Definition at line 152 of file Terminal.h.

◆ execute()

template<class T >
void Tree::Primitives::ERC< T >::execute ( void *  result,
Tree tree 
)
inlinevirtual

Execute the primitive.

Function primitives gather arguments and return a value; terminal primitives return current value.

Implements Tree::Primitives::Primitive.

Definition at line 125 of file Terminal.h.

◆ getValue()

template<class T >
void Tree::Primitives::ERC< T >::getValue ( void *  value)
inlinevirtual

Get terminal's value.

Parameters
pointerto destination

Reimplemented from Tree::Primitives::Primitive.

Definition at line 146 of file Terminal.h.

◆ initialize()

template<class T >
bool Tree::Primitives::ERC< T >::initialize ( StateP  state)
inlinevirtual

Initialize ERC value(s).

Read given values from config and store in vector.

Reimplemented from Tree::Primitives::Primitive.

Definition at line 104 of file Terminal.h.

◆ setValue()

template<class T >
void Tree::Primitives::ERC< T >::setValue ( void *  value)
inlinevirtual

Set terminal's value.

Parameters
valuepointer to new value

Reimplemented from Tree::Primitives::Primitive.

Definition at line 136 of file Terminal.h.

Member Data Documentation

◆ baseName_

template<class T >
std::string Tree::Primitives::ERC< T >::baseName_

Definition at line 88 of file Terminal.h.

◆ value_

template<class T >
T Tree::Primitives::ERC< T >::value_

Definition at line 89 of file Terminal.h.

◆ values_

template<class T >
std::vector<T>* Tree::Primitives::ERC< T >::values_
protected

Placeholder for predefined values that this type of ERC may assume. Each ERC instance holds only a single value.

Definition at line 177 of file Terminal.h.


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