00001 #ifndef Tree_c_h
00002 #define Tree_c_h
00003 #include "Node.h"
00004 #include "../Genotype.h"
00005 #include <vector>
00006 #define MAX_ARGS 10
00007
00008
00009 namespace Tree
00010 {
00011
00017 class PrimitiveSet;
00018 typedef boost::shared_ptr<PrimitiveSet> PrimitiveSetP;
00019
00028 class Tree : public std::vector<NodeP>, public Genotype
00029 {
00030 protected:
00031 uint growBuild(PrimitiveSetP primitiveSet, int myDepth);
00032 uint fullBuild(PrimitiveSetP primitiveSet, int myDepth);
00033 uint setSize(int);
00034 void setDepth(int myDepth);
00035 void initializeFirst(Tree* hometree);
00036
00037 std::vector<PrimitiveP> userFunctions_;
00038 std::vector<PrimitiveP> userTerminals_;
00039 StateP state_;
00040
00041 public:
00042 Tree();
00043 ~Tree();
00044 Tree* copy();
00045
00046 void growBuild(PrimitiveSetP primitiveSet);
00047 void fullBuild(PrimitiveSetP primitiveSet);
00048 void update();
00049 void execute(void*);
00050 void addNode(Node* node);
00051 void addNode(NodeP node);
00052 void setTerminalValue(std::string, void*);
00053 void getTerminalValue(std::string, void*);
00054 void write(XMLNode&);
00055 void read(XMLNode&);
00056 void registerParameters(StateP);
00057 bool initialize (StateP state);
00058
00059 std::vector<MutationOpP> getMutationOp();
00060 std::vector<CrossoverOpP> getCrossoverOp();
00061
00062 bool addFunction(PrimitiveP);
00063 bool addTerminal(PrimitiveP);
00064
00065 uint getMaxDepth()
00066 { return maxDepth_; }
00067
00068 uint getMinDepth()
00069 { return minDepth_; }
00070
00071 uint getStartDepth()
00072 { return startDepth_; }
00073
00074 PrimitiveSetP primitiveSet_;
00075 uint iNode_;
00076 uint startDepth_;
00077 uint maxDepth_;
00078 uint minDepth_;
00079 uint initMaxDepth_;
00080 uint initMinDepth_;
00081 };
00082 }
00083 typedef boost::shared_ptr<Tree::Tree> TreeP;
00084
00085 #endif
00086