ECF 1.5
Tree_c.h
1#ifndef Tree_c_h
2#define Tree_c_h
3#include "Node.h"
4#include "../Genotype.h"
5#include <vector>
6#define MAX_ARGS 10
7
8
9namespace Tree
10{
11
17class PrimitiveSet;
18typedef boost::shared_ptr<PrimitiveSet> PrimitiveSetP;
19
28class Tree : public std::vector<NodeP>, public Genotype
29{
30protected:
31 uint growBuild(PrimitiveSetP primitiveSet, uint myDepth);
32 uint fullBuild(PrimitiveSetP primitiveSet, uint myDepth);
33 uint setSize(uint);
34 void setDepth(uint myDepth);
35 virtual void initializeFirst(Tree* hometree);
36
37 std::vector<PrimitiveP> userFunctions_; // programatically added functions
38 std::vector<PrimitiveP> userTerminals_; // programatically added terminals
39 StateP state_;
40
41public:
42 Tree();
43 ~Tree();
44 Tree* copy();
45
46 void growBuild(PrimitiveSetP primitiveSet);
47 void fullBuild(PrimitiveSetP primitiveSet);
48 void update();
49 void execute(void*);
50 void addNode(Node* node);
51 void addNode(NodeP node);
52 void setTerminalValue(std::string, void*);
53 void getTerminalValue(std::string, void*);
54 void write(XMLNode&);
55 void read(XMLNode&);
56 void registerParameters(StateP);
57 bool initialize (StateP state);
58
59 std::vector<MutationOpP> getMutationOp();
60 std::vector<CrossoverOpP> getCrossoverOp();
61
62 bool addFunction(PrimitiveP);
63 bool addTerminal(PrimitiveP);
64
65 uint getMaxDepth()
66 { return maxDepth_; }
67
68 uint getMinDepth()
69 { return minDepth_; }
70
71 uint getStartDepth()
72 { return startDepth_; }
73
74 PrimitiveSetP primitiveSet_;
75 uint iNode_;
77 uint maxDepth_;
78 uint minDepth_;
81};
82}
83typedef boost::shared_ptr<Tree::Tree> TreeP;
84
85#endif
86
Genotype base class.
Definition: Genotype.h:36
Node base class (Tree genotype)
Definition: Node.h:20
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29
uint startDepth_
start depth of the first node (0 by default)
Definition: Tree_c.h:76
uint minDepth_
min allowed Tree depth
Definition: Tree_c.h:78
uint initMinDepth_
min allowed Tree depth at initialization (minDepth_ used if not defined)
Definition: Tree_c.h:80
uint iNode_
current node index (when parsing the tree)
Definition: Tree_c.h:75
uint initMaxDepth_
max allowed Tree depth at initialization (maxDepth_ used if not defined)
Definition: Tree_c.h:79
uint maxDepth_
max allowed Tree depth
Definition: Tree_c.h:77
Definition: nodes.h:92