ECF 1.5
PrimitiveSet.h
1#ifndef PrimitiveSet_h
2#define PrimitiveSet_h
3#include <vector>
4#include "Primitive.h"
5
6
7namespace Tree
8{
9
18{
19 friend class Tree;
20public:
22 virtual ~PrimitiveSet();
23
24 bool initialize(StateP state);
25
26 //void addFunction(PrimitiveP functionPrimitive);
27 bool addFunction(std::string name);
28 void addTerminal(PrimitiveP terminalPrimitive);
29
30 PrimitiveP getRandomTerminal();
31 PrimitiveP getRandomFunction();
32 PrimitiveP getRandomPrimitive();
33
34 PrimitiveP getTerminalByName(std::string name);
35 PrimitiveP getFunctionByName(std::string name);
36 PrimitiveP getPrimitiveByName(std::string name);
37
38 uint getFunctionSetSize();
39 uint getTerminalSetSize();
40 uint getPrimitivesSize();
41
42 std::map <std::string, PrimitiveP> mAllPrimitives_;
43 std::map <std::string, Primitives::terminal_type> mTypeNames_;
44
45protected:
46 StateP state_;
47
48 std::vector<PrimitiveP> terminalSet_;
49 std::map <std::string, PrimitiveP> mTerminalSet_;
50 std::vector<PrimitiveP> functionSet_;
51 std::map <std::string, PrimitiveP> mFunctionSet_;
52 std::vector<PrimitiveP> primitives_;
53 std::map <std::string, PrimitiveP> mPrimitiveSet_;
54};
55typedef boost::shared_ptr<PrimitiveSet> PrimitiveSetP;
56
57typedef std::map <std::string, PrimitiveP>::iterator prim_iter;
58typedef std::map <std::string, Primitives::terminal_type>::iterator type_iter;
59
60}
61#endif
Primitive set class: collects all Tree Primitives.
Definition: PrimitiveSet.h:18
PrimitiveP getRandomFunction()
Get random function from the set of active functions.
uint getPrimitivesSize()
Get the number of active primitives (functions and terminals).
std::vector< PrimitiveP > primitives_
vector of active (actual used) primitives
Definition: PrimitiveSet.h:52
PrimitiveP getTerminalByName(std::string name)
Access terminal by name (active terminals only).
std::map< std::string, PrimitiveP > mTerminalSet_
map of active (actual used) terminals
Definition: PrimitiveSet.h:49
void addTerminal(PrimitiveP terminalPrimitive)
Add a terminal primitive to the set of active primitives.
PrimitiveP getRandomPrimitive()
Get random primitive (function or terminal) from the set of active primitives.
std::map< std::string, PrimitiveP > mPrimitiveSet_
map of active (actual used) primitives
Definition: PrimitiveSet.h:53
uint getTerminalSetSize()
Get the number of active terminals.
uint getFunctionSetSize()
Get the number of active functions.
std::map< std::string, PrimitiveP > mFunctionSet_
map of active (actual used) functions
Definition: PrimitiveSet.h:51
bool addFunction(std::string name)
Add a function primitive to the set of active primitives - if found by name in collection of all prim...
PrimitiveP getPrimitiveByName(std::string name)
Access primitive by name (active functions or terminals only).
std::vector< PrimitiveP > terminalSet_
vector of active (actual used) terminals
Definition: PrimitiveSet.h:48
PrimitiveP getFunctionByName(std::string name)
Access function by name (active functions only).
std::vector< PrimitiveP > functionSet_
vector of active (actual used) functions
Definition: PrimitiveSet.h:50
std::map< std::string, PrimitiveP > mAllPrimitives_
map of all registered primitive functions
Definition: PrimitiveSet.h:42
PrimitiveP getRandomTerminal()
Get random terminal from the set of active terminals.
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29
bool initialize(StateP state)
Initialize a genotype object (read parameters, perform sanity check, build data)
Definition: Tree.cpp:115