MultiAgentDecisionProcess  Release 0.2.1
ObservationModelDiscrete.cpp
Go to the documentation of this file.
1 
29 #include <stdlib.h>
30 
31 using namespace std;
32 
33 //Default constructor
35  int nrJA,
36  int nrJO) :
37  _m_nrStates(nrS),
38  _m_nrJointActions(nrJA),
39  _m_nrJointObservations(nrJO)
40 {
41 }
42 
43 //Destructor
45 {
46 }
47 
49 {
50  stringstream ss;
51  double p;
52  ss << "jo\tja\ts'\tP (tuples with P==0 are not printed)"<<endl;
53  for(int jo_i = 0; jo_i < _m_nrJointObservations; jo_i++)
54  for(int ja_i = 0; ja_i < _m_nrJointActions; ja_i++)
55  for(int s_ip = 0; s_ip < _m_nrStates; s_ip++)
56  {
57  p=Get(ja_i, s_ip, jo_i);
58  if(p>0)
59  ss << jo_i << "\t" << ja_i << "\t" << s_ip << "\t" << p
60  << endl;
61  }
62  return(ss.str());
63 }
64 
66 {
67  double randNr=rand() / (RAND_MAX + 1.0);
68 
69  double sum=0;
70  Index jo=0;
71  int i;
72 
73  for(i=0;i<_m_nrJointObservations;i++)
74  {
75  sum+=Get(jaI,sucI,i);
76  if(randNr<=sum)
77  {
78  jo=i;
79  break;
80  }
81  }
82 
83  return(jo);
84 }