MultiAgentDecisionProcess  Release 0.2.1
POSG.cpp
Go to the documentation of this file.
1 
28 #include "POSG.h"
29 
30 using namespace std;
31 
33 {
34  _m_initialized = false;
35  _m_nrAgents = 0;
36  //we can not call GetNrAgents from here...
37  //instead this object will have to have the number of agents set and be
38  //initialized.
39  //_m_rewardType = vector<double>(GetNrAgents(), REWARD);
40  //_m_discount = vector<double>(GetNrAgents(), 1.0);
41 }
42 
43 void POSG::SetDiscount(Index agentI, double d)
44 {
45  if(d>=0 && d<=1)
46  _m_discount.at(agentI)=d;
47  else
48  throw(E("POSG::SetDiscount() discount not valid, should be >=0 and <=1"));
49 }
50 
51 string POSG::SoftPrint() const
52 {
53  stringstream ss;
54  ss << "Discount factors: " <<
55  PrintTools::SoftPrintVector(_m_discount) << endl;
56  ss << "Reward type: " <<
57  PrintTools::SoftPrintVector(_m_rewardType) << endl;
58  return ss.str();
59 }
60 
62 {
63  if(r!=REWARD)
64  throw(E("POSG::SetRewardType only reward type REWARD is supported"));
65  _m_rewardType.at(agentI) = r;
66 }
67 
70 {
71  if(_m_nrAgents == 0)
72  {
73  throw E("POSG::SetInitialized failed because POSG doesn't know the \
74 number of agents yet. (use SetNrAgents first!)");
75  }
76 
77  //do some checks?
78  _m_initialized = true;
79  return(true);
80 }
81 
83 void POSG::SetNrAgents (size_t nrAgents)
84 {
85  if(_m_initialized)
86  {
87  //do some de-initialization things ?
88  _m_initialized = false;
89  _m_nrAgents = nrAgents;
90  }
91 
92  _m_discount = vector<double>(_m_nrAgents, 1.0);
93  _m_rewardType = vector<reward_t>(_m_nrAgents, REWARD);
94 
95 }
96