ECF 1.7
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).
void execute (void *result, Tree &tree)
 Execute the primitive.
void setValue (void *value)
 Set terminal's value.
void getValue (void *value)
 Get terminal's value.
PrimitiveP copyWithNode (PrimitiveP primitive)
 Copy primitive (when copying a node, e.g. in crossover). The default behaviour just returns the same pointer (common primitives). (ERCs should override and make a new copy of the original object).
PrimitiveP assignToNode (PrimitiveP primitive)
 Create (or choose) new unique ERC value and assign to tree node.
Public Member Functions inherited from Tree::Primitives::Primitive
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

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).

ERCs 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.

Reimplemented in Tree::Primitives::ERCD.

Definition at line 160 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). (ERCs should override and make a new copy of the original object).

Parameters
sptrto this primitive

Reimplemented from Tree::Primitives::Primitive.

Definition at line 151 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 124 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 145 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.

Reimplemented in Tree::Primitives::ERCD.

Definition at line 103 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 135 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 176 of file Terminal.h.


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