AIToolbox
A library that offers tools for AI problem solving.
CooperativeMaximumLikelihoodModel.hpp
Go to the documentation of this file.
1 #ifndef AI_TOOLBOX_FACTORED_MDP_COOPERATIVE_MAXIMUM_LIKELIHOOD_MODEL_HEADER_FILE
2 #define AI_TOOLBOX_FACTORED_MDP_COOPERATIVE_MAXIMUM_LIKELIHOOD_MODEL_HEADER_FILE
3 
6 
7 namespace AIToolbox::Factored::MDP {
52  public:
54  using RewardMatrix = std::vector<Vector>;
55 
84  CooperativeMaximumLikelihoodModel(const CooperativeExperience & exp, double discount = 1.0, bool sync = false);
85 
99  void sync();
100 
107  void sync(const State & s, const Action & a);
108 
124  void sync(const CooperativeExperience::Indeces & indeces);
125 
142  std::tuple<State, double> sampleSR(const State & s, const Action & a) const;
143 
160  std::tuple<State, Rewards> sampleSRs(const State & s, const Action & a) const;
161 
179  double sampleSR(const State & s, const Action & a, State * s1) const;
180 
197  void sampleSRs(const State & s, const Action & a, State * s1, Rewards * rews) const;
198 
208  double getTransitionProbability(const State & s, const Action & a, const State & s1) const;
209 
219  double getExpectedReward(const State & s, const Action & a, const State & s1) const;
220 
235  Rewards getExpectedRewards(const State & s, const Action & a, const State & s1) const;
236 
256  void getExpectedRewards(const State & s, const Action & a, const State & s1, Rewards * rews) const;
257 
263  const State & getS() const;
264 
270  const Action & getA() const;
271 
277  void setDiscount(double d);
278 
284  double getDiscount() const;
285 
291  const CooperativeExperience & getExperience() const;
292 
298  const TransitionMatrix & getTransitionFunction() const;
299 
305  const RewardMatrix & getRewardFunction() const;
306 
312  const DDNGraph & getGraph() const;
313 
314  private:
323  void syncRow(size_t i, size_t j);
324 
325  const CooperativeExperience & experience_;
326  double discount_;
327 
328  TransitionMatrix transitions_;
329  RewardMatrix rewards_;
330 
331  mutable RandomEngine rand_;
332  };
333 }
334 
335 #endif
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::CooperativeMaximumLikelihoodModel
CooperativeMaximumLikelihoodModel(const CooperativeExperience &exp, double discount=1.0, bool sync=false)
Constructor using previous Experience.
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::sync
void sync()
This function syncs the whole CooperativeMaximumLikelihoodModel to the underlying CooperativeExperien...
AIToolbox::Factored::MDP::CooperativeExperience::Indeces
std::vector< size_t > Indeces
Definition: CooperativeExperience.hpp:34
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getTransitionProbability
double getTransitionProbability(const State &s, const Action &a, const State &s1) const
This function returns the stored transition probability for the specified transition.
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getExpectedRewards
Rewards getExpectedRewards(const State &s, const Action &a, const State &s1) const
This function returns the stored expected rewards for the specified transition.
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getExpectedReward
double getExpectedReward(const State &s, const Action &a, const State &s1) const
This function returns the stored expected reward for the specified transition.
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::sampleSRs
std::tuple< State, Rewards > sampleSRs(const State &s, const Action &a) const
This function samples the MDP with the specified state action pair.
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getA
const Action & getA() const
This function returns the number of available actions to the agent.
AIToolbox::Factored::Rewards
Vector Rewards
Definition: Types.hpp:71
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getS
const State & getS() const
This function returns the number of states of the world.
AIToolbox::Factored::MDP
Definition: CooperativePrioritizedSweeping.hpp:13
AIToolbox::Factored::State
Factors State
Definition: Types.hpp:67
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::sampleSR
std::tuple< State, double > sampleSR(const State &s, const Action &a) const
This function samples the MDP with the specified state action pair.
BayesianNetwork.hpp
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::setDiscount
void setDiscount(double d)
This function sets a new discount factor for the Model.
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getTransitionFunction
const TransitionMatrix & getTransitionFunction() const
This function returns the transition matrix for inspection.
CooperativeExperience.hpp
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getDiscount
double getDiscount() const
This function returns the currently set discount factor.
AIToolbox::Factored::DynamicDecisionNetworkGraph
This class represents the structure of a dynamic decision network.
Definition: BayesianNetwork.hpp:52
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel
This class models CooperativeExperience as a CooperativeModel using Maximum Likelihood.
Definition: CooperativeMaximumLikelihoodModel.hpp:51
AIToolbox::RandomEngine
std::mt19937 RandomEngine
Definition: Types.hpp:14
AIToolbox::Factored::DynamicDecisionNetwork
This class represents a Dynamic Decision Network with factored actions.
Definition: BayesianNetwork.hpp:275
AIToolbox::Factored::MDP::CooperativeExperience
This class keeps track of registered events and rewards.
Definition: CooperativeExperience.hpp:28
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getGraph
const DDNGraph & getGraph() const
This function returns the underlying DDNGraph of the CooperativeExperience.
AIToolbox::Factored::Action
Factors Action
Definition: Types.hpp:69
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::RewardMatrix
std::vector< Vector > RewardMatrix
Definition: CooperativeMaximumLikelihoodModel.hpp:54
AIToolbox::Factored::DDN
DynamicDecisionNetwork DDN
Definition: BayesianNetwork.hpp:308
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getRewardFunction
const RewardMatrix & getRewardFunction() const
This function returns the rewards matrix for inspection.
AIToolbox::Factored::MDP::CooperativeMaximumLikelihoodModel::getExperience
const CooperativeExperience & getExperience() const
This function enables inspection of the underlying Experience of the RLModel.