49 #if USE_BeliefIteratorGeneric
55 Q += jb.
Get(sI) * GetQ(time_step,sI,jaI);
64 #if USE_BeliefIteratorGeneric
70 Q += jb.
Get(sI) * GetQ(sI,jaI);
78 size_t horizon = GetPU()->GetHorizon();
79 size_t nrS = GetPU()->GetNrStates();
80 size_t nrJA = GetPU()->GetNrJointActions();
83 for(
Index sI = 0; sI < nrS; sI++)
84 cout << _m_pu->GetState(sI)->SoftPrintBrief() <<
" ";
89 for(
size_t t = 0; t!=horizon; t++)
90 for(
Index jaI = 0; jaI < nrJA; jaI++)
92 cout <<
"Q(t=" << t <<
",:," << jaI <<
") =\t";
93 for(
Index sI = 0; sI < nrS; sI++)
94 cout <<
" " << GetQ(t,sI,jaI);
95 cout <<
" " << _m_pu->GetJointAction(jaI)->SoftPrintBrief();
101 for(
Index jaI = 0; jaI < nrJA; jaI++)
103 cout <<
"Q(:," << jaI <<
") =\t";
104 for(
Index sI = 0; sI < nrS; sI++)
105 cout <<
" " << GetQ(sI,jaI);
106 cout <<
" " << _m_pu->GetJointAction(jaI)->SoftPrintBrief();
111 for(
Index sI = 0; sI < nrS; sI++)
113 cout << _m_pu->GetState(sI)->SoftPrintBrief() <<
"->";
117 for(
Index jaI = 0; jaI < nrJA; jaI++)
126 cout << _m_pu->GetJointAction(aMax)->SoftPrintBrief() <<
" ";
137 for(
size_t a=0;a!=GetPU()->GetNrJointActions();++a)
139 q=GetQ(time_step,sI,a);
152 return(LoadQTable(filename,
153 GetPU()->GetNrStates(),
154 GetPU()->GetNrJointActions()));
161 const int bufsize=65536;
162 char buffer[bufsize];
164 ifstream fp(filename.c_str());
167 cerr <<
"MDPSolver::LoadQTable: failed to "
168 <<
"open file " << filename << endl;
177 while(!fp.getline(buffer,bufsize).eof())
179 istringstream is(buffer);
185 throw(
E(
"MDPSolver::LoadQTable wrong number of actions"));
191 throw(
E(
"MDPSolver::LoadQTable wrong number of states"));
198 return(LoadQTables(filename,
199 GetPU()->GetNrStates(),
200 GetPU()->GetNrJointActions(),
207 unsigned int nrTables)
209 const int bufsize=65536;
210 char buffer[bufsize];
212 ifstream fp(filename.c_str());
215 cerr <<
"MDPSolver::LoadQTables: failed to "
216 <<
"open file " << filename << endl;
224 for(i=0;i!=nrTables;i++)
229 while(!fp.getline(buffer,bufsize).eof())
231 istringstream is(buffer);
237 throw(
E(
"MDPSolver::LoadQTables wrong number of actions"));
248 throw(
E(
"MDPSolver::LoadQTables wrong number of tables"));
255 ofstream fp(filename.c_str());
259 ss <<
"MDPSolver::SaveQTable: failed to open file " << filename << endl;
265 unsigned int nrS=Q.size1(),
268 for(
unsigned int s=0;s!=nrS;++s)
270 for(
unsigned int a=0;a!=nrA;++a)
282 ofstream fp(filename.c_str());
286 ss <<
"MDPSolver::SaveQTables: failed to open file " << filename << endl;
292 unsigned int nrS=Qs[0].size1(),
296 for(
unsigned int k=0;k!=h;++k)
297 for(
unsigned int s=0;s!=nrS;++s)
299 for(
unsigned int a=0;a!=nrA;++a)