MultiAgentDecisionProcess  Release 0.2.1
AgentPOMDP.cpp
Go to the documentation of this file.
1 
28 #include "AgentPOMDP.h"
29 #include <float.h>
31 #include "JointBeliefInterface.h"
32 
33 using namespace std;
34 
35 #define DEBUG_AgentPOMDP 0
36 
40  _m_QPOMDP(QPOMDP),
41  _m_t(0)
42 {
44 }
45 
48  _m_QPOMDP(a._m_QPOMDP),
49  _m_t(a._m_t),
50  _m_prevJaI(a._m_prevJaI)
51 {
53  *_m_jb=*a._m_jb;
54 }
55 
56 //Destructor
58 {
59  delete _m_jb;
60 }
61 
63 {
64  if(_m_t>0)
65  _m_jb->Update(*GetPU()->GetReferred(),_m_prevJaI,joI);
66 
67  Index jaInew=INT_MAX;
68  double q,v=-DBL_MAX;
69  for(size_t a=0;a!=GetPU()->GetNrJointActions();++a)
70  {
71  q=_m_QPOMDP->GetQ(*_m_jb,a);
72  if(q>v)
73  {
74  v=q;
75  jaInew=a;
76  }
77  }
78 
79 #if DEBUG_AgentPOMDP
80  cout << GetIndex() << ": ";
81  _m_jb.Print();
82  cout << " v " << v << endl;
83 #endif
84 
85  vector<Index> aIs=GetPU()->JointToIndividualActionIndices(jaInew);
86 
87  _m_prevJaI=jaInew;
88  _m_t++;
89 
90  return(aIs[GetIndex()]);
91 }
92 
94 {
95  _m_t=0;
96  *_m_jb=*GetPU()->GetNewJointBeliefFromISD(); // isa JointBeliefInterface*
97  _m_prevJaI=INT_MAX;
98 }