PCB Environment: /home/chr/devel/PhD/Environment/pub/PCBEnv/pcbenv/cxx/RL/ActionSpace.hpp Source File

PCB Environment 2

Loading...
Searching...
No Matches
ActionSpace.hpp
1
2#ifndef GYM_PCB_RL_ACTIONSPACE_H
3#define GYM_PCB_RL_ACTIONSPACE_H
4
5#include "Py.hpp"
6#include "Action.hpp"
7#include <map>
8#include <set>
9#include <string>
10#include <vector>
11
12 class ActionSpace
13{
14public:
15 virtual ~ActionSpace() { clear(mOwnsActions); }
16 virtual void clear(bool deleteActions);
17 uint size() const { return mActions.size(); }
18 const std::vector<Action *>& actions() const { return mActions; }
19 Action *getAction(Action::Index a) const { return mActions.at(a); }
20 Action *getAction(const std::string &name) const;
21 Action *getAction(PyObject *) const;
22 void addAction(Action *);
23 void setOwnsActions(bool own) { mOwnsActions = own; }
24 bool ownsActions() const { return mOwnsActions; }
25 const std::set<Action::Index>& getIllegal() const { return mIllegal; }
26 void setLegal(Action *, bool);
27 PyObject *getPy() const;
28protected:
29 std::vector<Action *> mActions;
30private:
31 std::set<Action::Index> mIllegal;
32 std::map<std::string, Action *> mActionMap;
33 bool mOwnsActions{false};
34};
35inline Action *ActionSpace::getAction(const std::string &name) const
36{
37 auto I = mActionMap.find(name);
38 if (I != mActionMap.end())
39 return I->second;
40 return 0;
41}
42
43 class ActionSet
44{
45public:
46 void init(ActionSpace&, Action::Index first, Action::Index last);
47 void init(ActionSpace&, const std::set<Action::Index> * = 0);
48 const std::vector<Action::Index> actions() const { return mActions; }
49 uint size() const { return mActions.size(); }
50 void clear() { mActions.clear(); }
51 void insert(Action::Index);
52 void remove(Action::Index);
53 ActionSpace *space() const { return mAS; }
54private:
55 ActionSpace *mAS{0};
56 std::vector<Action::Index> mActions;
57};
58
59#endif // GYM_PCB_RL_ACTIONSPACE_H
ActionSet
Definition ActionSpace.hpp:44
ActionSpace
Definition ActionSpace.hpp:13
Action
NOTE: Actions always set the Agent's least recently used connction (getConnectionLRU()) which is some...
Definition Action.hpp:14