ECF 1.5
Primitive.cpp
1#include "../ECF_base.h"
2#include "Tree_c.h"
3#include <iostream>
4
5
6namespace Tree {
7namespace Primitives {
8
9Primitive::Primitive()
10{
11 // default: no complement
12 complementName_ = "";
13}
14
15
16Primitive::~Primitive()
17{ }
18
19
23bool Primitive::initialize(StateP state)
24{
25 state_ = state;
26 return true;
27}
28
29
36PrimitiveP Primitive::assignToNode(PrimitiveP primitive)
37{
38 return primitive;
39}
40
41
42void Primitive::setValue(void* value)
43{
44 return;
45}
46
47
48void Primitive::getValue(void* value)
49{
50 return;
51}
52
53
60PrimitiveP Primitive::copyWithNode(PrimitiveP primitive)
61{
62 return primitive;
63}
64
65
71void Primitive::getNextArgument(void* result, Tree& tree)
72{
73 tree.iNode_++;
74 tree[tree.iNode_]->primitive_->execute(result, tree);
75}
76
77
83{
84 tree.iNode_ += tree[tree.iNode_ + 1]->size_;
85}
86
87
92{
93 return nArguments_;
94}
95
96
100void Primitive::setName(std::string name)
101{
102 name_ = name;
103}
104
105
110{
111 return name_;
112}
113
114
119{
120 return complementName_;
121}
122
123}
124}
virtual PrimitiveP copyWithNode(PrimitiveP)
Copy primitive (when copying a node, e.g. in crossover). The default behaviour just returns the same ...
Definition: Primitive.cpp:60
std::string getName()
Get primitive's name.
Definition: Primitive.cpp:109
int getNumberOfArguments()
Return primitive's number of arguments.
Definition: Primitive.cpp:91
void skipNextArgument(Tree &tree)
Skip next child subtree (doesn't execute the subtree).
Definition: Primitive.cpp:82
std::string getComplementName()
Get complement's name.
Definition: Primitive.cpp:118
void getNextArgument(void *result, Tree &tree)
Execute next child node's primitive (execute next subtree).
Definition: Primitive.cpp:71
virtual bool initialize(StateP state)
Initialize the primitive (default just sets the StateP pointer).
Definition: Primitive.cpp:23
void setName(std::string name)
Set primitive's name.
Definition: Primitive.cpp:100
virtual PrimitiveP assignToNode(PrimitiveP)
Assign primitive to node (when building a tree). The default behaviour just returns the same pointer ...
Definition: Primitive.cpp:36
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29