MultiAgentDecisionProcess  Release 0.2.1
RewardModelTOISparse.cpp
Go to the documentation of this file.
1 
28 #include "RewardModelTOISparse.h"
29 
30 using namespace std;
31 
33  string ja_str)
34 {
35  _m_s_str = s_str;
36  _m_ja_str = ja_str;
37 }
38 
40 {
41 }
42 
43 double RewardModelTOISparse::Get(const std::vector<Index> &sIs,
44  const std::vector<Index> &aIs) const
45 {
46  if(_m_R.find(make_pair(sIs,aIs))!=_m_R.end())
47  return(_m_R.find(make_pair(sIs,aIs))->second);
48  else
49  return(0);
50 }
51 
52 void RewardModelTOISparse::Set(const std::vector<Index> &sIs,
53  const std::vector<Index> &aIs,
54  double reward)
55 {
56  _m_R.insert(make_pair(make_pair(sIs,aIs),reward));
57 }
58 
60 {
61 #if 0
62  stringstream ss;
63  double r;
64  ss << _m_s_str <<"\t"<< _m_ja_str <<"\t"
65  << "R(" << _m_s_str <<","<< _m_ja_str
66  << ") (rewards of 0 are not printed)"<<endl;
67  for(Index s_i = 0; s_i < _m_nrStates; s_i++)
68  for(Index ja_i = 0; ja_i < _m_nrJointActions; ja_i++)
69  {
70  r=Get(s_i, ja_i);
71  if(std::abs(r)>0)
72  ss << s_i << "\t" << ja_i << "\t" << r << endl;
73  }
74  return(ss.str());
75 #else
76 #endif
77  return("RewardModelTOISparse::SoftPrint: not yet implemented");
78 }
79