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 write(XMLNode&);
00054 void read(XMLNode&);
00055 void registerParameters(StateP);
00056 bool initialize (StateP state);
00057
00058 std::vector<MutationOpP> getMutationOp();
00059 std::vector<CrossoverOpP> getCrossoverOp();
00060
00061 bool addFunction(PrimitiveP);
00062 bool addTerminal(PrimitiveP);
00063
00064 uint getMaxDepth()
00065 { return maxDepth_; }
00066
00067 uint getMinDepth()
00068 { return minDepth_; }
00069
00070 uint getStartDepth()
00071 { return startDepth_; }
00072
00073 PrimitiveSetP primitiveSet_;
00074 uint iNode_;
00075 uint startDepth_;
00076 uint maxDepth_;
00077 uint minDepth_;
00078 uint initMaxDepth_;
00079 uint initMinDepth_;
00080 };
00081 }
00082 typedef boost::shared_ptr<Tree::Tree> TreeP;
00083
00084 #endif
00085