ECF 1.7
PrimitiveSet.h
1#ifndef PrimitiveSet_h
2#define PrimitiveSet_h
3#include <vector>
4#include "Primitive.h"
5
6
7namespace Tree
8{
9
17class PrimitiveSet
18{
19 friend class Tree;
20public:
21 PrimitiveSet();
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
45 std::vector<PrimitiveP> terminalSet_;
46 std::map <std::string, PrimitiveP> mTerminalSet_;
47 std::vector<PrimitiveP> functionSet_;
48 std::map <std::string, PrimitiveP> mFunctionSet_;
49 std::vector<PrimitiveP> primitives_;
50 std::map <std::string, PrimitiveP> mPrimitiveSet_;
51
52protected:
53 StateP state_;
54};
55typedef std::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
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
PrimitiveP getTerminalByName(std::string name)
Access terminal by name (active terminals only).
std::map< std::string, PrimitiveP > mTerminalSet_
map of active (actual used) terminals
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
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
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
PrimitiveP getFunctionByName(std::string name)
Access function by name (active functions only).
std::vector< PrimitiveP > functionSet_
vector of active (actual used) functions
std::map< std::string, PrimitiveP > mAllPrimitives_
map of all registered primitive functions
PrimitiveP getRandomTerminal()
Get random terminal from the set of active terminals.