MultiAgentDecisionProcess  Release 0.2.1
POSGDiscrete.cpp
Go to the documentation of this file.
1 
28 #include "POSGDiscrete.h"
29 
30 using namespace std;
31 
32 POSGDiscrete::POSGDiscrete(string name, string descr, string pf) :
33  MultiAgentDecisionProcessDiscrete(name, descr, pf)
34 {
35  _m_initialized = false;
36  size_t nrAgents = GetNrAgents();
37  POSG::SetNrAgents(nrAgents);
39  _m_p_rModel = vector<RewardModelMapping*>(nrAgents, 0);
40 
41 }
42 
44 {
45  for(vector<RewardModelMapping*>::iterator it = _m_p_rModel.begin();
46  it != _m_p_rModel.end(); it++)
47  delete *it;
48 }
49 
51 {
53  {
54  _m_initialized = b;
55  return(true);
56  }
57  else
58  return(false);
59 }
60 
62  (Index agentI, size_t nrS, size_t nrJA)
63 {
64  if(_m_initialized)
65  delete(_m_p_rModel.at(agentI));
66 
67  _m_p_rModel.at(agentI) = new RewardModelMapping( nrS, nrJA);
68 }
69 
71 {
72  stringstream ss;
74  ss << POSG::SoftPrint();
75 
76  if(_m_initialized)
77  {
78  for(Index agentI = 0; agentI < GetNrAgents(); agentI++)
79  {
80  ss << "Reward model for agent "<<agentI<<": " << endl;
81  ss << _m_p_rModel.at(agentI)->SoftPrint() << endl;
82  }
83  }
84  else
85  throw E("POSGDiscrete components (reward model) not initialized");
86 
87  return(ss.str());
88 }
89 
91  const
92 {
93  return GetReward(agentI,
94  ((StateDiscrete*)s)->GetIndex(),
95  ((JointActionDiscrete*)ja)->GetIndex());
96 }
97 
99  Index sucSI, double r)
100 {
101  double rOld=GetReward(agentI, sI,jaI),
102  rExp=GetTransitionProbability(sI,jaI,sucSI)*r;
103  SetReward(agentI, sI,jaI,rOld+rExp);
104 }
105 
106 void POSGDiscrete::SetReward(Index agentI, Index sI, Index jaI, Index sucSI,
107  Index joI, double r)
108 {
109  throw(E("POSGDiscrete::SetReward(agentI, sI,jaI,sucSI,joI,r) not implemented"));
110 }
111