AIToolbox
A library that offers tools for AI problem solving.
CooperativeExperience.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_FACTORED_MDP_COOPERATIVE_EXPERIENCE_HEADER_FILE
2 #define AI_TOOLBOX_FACTORED_MDP_COOPERATIVE_EXPERIENCE_HEADER_FILE
3 
6 
7 namespace AIToolbox::Factored::MDP {
29  public:
30  using RewardMatrix = std::vector<Vector>;
31  using VisitsTable = std::vector<Table2D>;
32 
33  // Used to avoid recomputation when doing sync in RL.
34  using Indeces = std::vector<size_t>;
35 
45  CooperativeExperience(const DDNGraph & graph);
46 
65  const Indeces & record(const State & s, const Action & a, const State & s1, const Rewards & rew);
66 
70  void reset();
71 
77  unsigned long getTimesteps() const;
78 
84  const VisitsTable & getVisitsTable() const;
85 
91  const RewardMatrix & getRewardMatrix() const;
92 
98  const RewardMatrix & getM2Matrix() const;
99 
105  const State & getS() const;
106 
112  const Action & getA() const;
113 
119  const DDNGraph & getGraph() const;
120 
121  private:
122  const DDNGraph & graph_;
123 
124  VisitsTable visits_;
125  RewardMatrix rewards_;
126  RewardMatrix M2s_;
127  Indeces indeces_;
128 
129  unsigned long timesteps_;
130  };
131 }
132 
133 #endif
134 
AIToolbox::Factored::MDP::CooperativeExperience::VisitsTable
std::vector< Table2D > VisitsTable
Definition: CooperativeExperience.hpp:31
AIToolbox::Factored::MDP::CooperativeExperience::Indeces
std::vector< size_t > Indeces
Definition: CooperativeExperience.hpp:34
AIToolbox::Factored::MDP::CooperativeExperience::getA
const Action & getA() const
This function returns the number of available actions to the agent.
AIToolbox::Factored::MDP::CooperativeExperience::record
const Indeces & record(const State &s, const Action &a, const State &s1, const Rewards &rew)
This function adds a new event to the recordings.
AIToolbox::Factored::MDP::CooperativeExperience::RewardMatrix
std::vector< Vector > RewardMatrix
Definition: CooperativeExperience.hpp:30
AIToolbox::Factored::MDP::CooperativeExperience::getGraph
const DDNGraph & getGraph() const
This function returns the underlying DDNGraph of the CooperativeExperience.
AIToolbox::Factored::Rewards
Vector Rewards
Definition: Types.hpp:71
AIToolbox::Factored::MDP
Definition: CooperativePrioritizedSweeping.hpp:13
AIToolbox::Factored::State
Factors State
Definition: Types.hpp:67
BayesianNetwork.hpp
AIToolbox::Factored::MDP::CooperativeExperience::getRewardMatrix
const RewardMatrix & getRewardMatrix() const
This function returns the rewards matrix for inspection.
AIToolbox::Factored::DynamicDecisionNetworkGraph
This class represents the structure of a dynamic decision network.
Definition: BayesianNetwork.hpp:52
AIToolbox::Factored::MDP::CooperativeExperience
This class keeps track of registered events and rewards.
Definition: CooperativeExperience.hpp:28
AIToolbox::Factored::Action
Factors Action
Definition: Types.hpp:69
AIToolbox::Factored::MDP::CooperativeExperience::getTimesteps
unsigned long getTimesteps() const
This function returns the number of times the record function has been called.
AIToolbox::Factored::MDP::CooperativeExperience::CooperativeExperience
CooperativeExperience(const DDNGraph &graph)
Basic constructor.
AIToolbox::Factored::MDP::CooperativeExperience::reset
void reset()
This function resets all experienced rewards and transitions.
AIToolbox::Factored::MDP::CooperativeExperience::getM2Matrix
const RewardMatrix & getM2Matrix() const
This function returns the rewards squared matrix for inspection.
Types.hpp
AIToolbox::Factored::MDP::CooperativeExperience::getVisitsTable
const VisitsTable & getVisitsTable() const
This function returns the visits table for inspection.
AIToolbox::Factored::MDP::CooperativeExperience::getS
const State & getS() const
This function returns the number of states of the world.