4#include "../Genotype.h"
18typedef std::shared_ptr<PrimitiveSet> PrimitiveSetP;
28class Tree :
public std::vector<NodeP>,
public Genotype
31 uint
growBuild(PrimitiveSetP primitiveSet, uint myDepth);
32 uint
fullBuild(PrimitiveSetP primitiveSet, uint myDepth);
37 std::vector<PrimitiveP> userFunctions_;
38 std::vector<PrimitiveP> userTerminals_;
46 void growBuild(PrimitiveSetP primitiveSet);
47 void fullBuild(PrimitiveSetP primitiveSet);
50 void addNode(
Node* node);
51 void addNode(NodeP node);
74 PrimitiveSetP primitiveSet_;
83typedef std::shared_ptr<Tree::Tree> TreeP;
Node base class (Tree genotype).
Primitive set class: collects all Tree Primitives.
bool addFunction(PrimitiveP)
Add user defined function primitive. Must be called prior to initialization (no impact otherwise).
uint startDepth_
start depth of the first node (0 by default)
uint fullBuild(PrimitiveSetP primitiveSet, uint myDepth)
Build Tree using 'full' method.
uint minDepth_
min allowed Tree depth
void getTerminalValue(std::string, void *)
Retrieve a terminal's value.
void setTerminalValue(std::string, void *)
Set a terminal's value.
Tree * copy()
Create an identical copy of the genotype object.
uint initMinDepth_
min allowed Tree depth at initialization (minDepth_ used if not defined)
uint growBuild(PrimitiveSetP primitiveSet, uint myDepth)
Build Tree using 'grow' method.
uint iNode_
current node index (when parsing the tree)
bool addTerminal(PrimitiveP)
Add user defined terminal primitive. Must be called prior to initialization (no impact otherwise).
std::vector< CrossoverOpP > getCrossoverOp()
Create and return a vector of crossover operators.
void setDepth(uint myDepth)
Calculate depth of each node in the tree.
std::vector< MutationOpP > getMutationOp()
Create and return a vector of mutation operators.
void write(XMLNode &)
Write genotype data to XMLNode.
uint initMaxDepth_
max allowed Tree depth at initialization (maxDepth_ used if not defined)
void update()
Calculate depth and subtree sizes of each node in the tree.
void registerParameters(StateP)
Register genotype's parameters (called before Genotype::initialize).
uint setSize(uint)
Calculate subtree sizes of each node in the tree.
void execute(void *)
Execute current tree.
void read(XMLNode &)
Read genotype data from XMLNode.
uint maxDepth_
max allowed Tree depth
virtual void initializeFirst(Tree *hometree)
Performs the first Tree initialization (performed only once for each active Tree Genotype)....
bool initialize(StateP state)
Initialize a genotype object (read parameters, perform sanity check, build data).