40 #define DEBUG_TOIMADPD 0
46 string name,
string descr,
string pf) :
69 throw(
E(
"TransitionObservationIndependentMADPDiscrete: copy ctor not implemented"));
77 vector<MultiAgentDecisionProcessDiscrete*>::iterator it =
79 vector<MultiAgentDecisionProcessDiscrete*>::iterator last =
88 vector<JointActionDiscrete*>::iterator it2 =
90 vector<JointActionDiscrete*>::iterator last2 =
104 vector<MultiAgentDecisionProcessDiscrete*>::iterator it =
106 vector<MultiAgentDecisionProcessDiscrete*>::iterator last =
115 for(
Index i=0; i < n; i++)
117 stringstream name, descr, pf;
118 name <<
"Indiv.MADPDiscr.Agent"<<i;
119 descr <<
"The individual MADPDiscrete used to model the transition \
120 and observation dynamics for agent "<<i;
138 stringstream name, descr, pf;
139 name <<
"Indiv.MADPDiscr.Agent"<<i;
140 descr <<
"The individual MADPDiscrete used to model the transition \
141 and observation dynamics for agent "<<namestring <<
"(agent "<<i<<
")";
156 throw EInvalidIndex(
"TransitionObservationIndependentMADPDiscrete::SetNrStates - agentI out of bounds...");
162 throw EInvalidIndex(
"TransitionObservationIndependentMADPDiscrete::AddState - agentI out of bounds...");
169 throw EInvalidIndex(
"TransitionObservationIndependentMADPDiscrete::SetNrActions - agentI out of bounds...");
176 throw EInvalidIndex(
"TransitionObservationIndependentMADPDiscrete::AddAction - agentI out of bounds...");
183 throw EInvalidIndex(
"TransitionObservationIndependentMADPDiscrete::SetNrObservations - agentI out of bounds...");
190 throw EInvalidIndex(
"TransitionObservationIndependentMADPDiscrete::AddObservation - agentI out of bounds...");
194 #if 0 // will be computed from individual ISDs
195 void TransitionObservationIndependentMADPDiscrete::SetUniformISD()
200 double uprob = 1.0 / nrJS;
214 throw(
E(
"TransitionObservationIndependentMADPDiscrete::CreateISD() joint states should have been created already"));
217 throw E(
"TransitionObservationIndependentMADPDiscrete::SetISD - ERROR: nrStates don't match!");
238 throw(
E(
"TransitionObservationIndependentMADPDiscrete::CreateJointActions() sizes do not match"));
254 if(
DEBUG_CJA) cerr <<
"TransitionObservationIndependentMADPDiscrete::CreateJointActions(Index "<<curAgentI<<
", JointActionDiscrete& ja, Index "<< jaI<<
") called"<<endl;
256 bool lastAgent=
false;
270 for(
Index a=0; a < nrA; a++)
273 GetActionDiscrete(0, a);
278 if(
DEBUG_CJA) cerr <<
"(first action - not making copy)\n";
281 else if ( a == nrA-1 )
284 if(
DEBUG_CJA) cerr <<
"(last action - not making copy)\n";
285 p_ja = p_jaReceivedArgCopy;
289 if(
DEBUG_CJA) cerr <<
"(intermed. action - making copy)\n";
295 if(
DEBUG_CJA)cerr <<
"setting index of this joint action to: "<<
300 cerr <<
"Adding agent's indiv. action to joint action..."<<endl;
304 if(
DEBUG_CJA){cerr <<
"INSERTING the joint action:";
305 p_ja->
Print();cerr<<endl;}
307 if(
DEBUG_CJA){cerr <<
"\nINSERTED the joint action."<<endl;
308 cerr <<
"_m_jointActionVec now containts "<<
317 if(
DEBUG_CJA) cerr <<
">>ProblemDecTiger::CreateJointActionsRecursively(Index "<<curAgentI<<
", JointActionDiscrete& ja, Index "<< jaI<<
") FINISHED"<<endl;
328 for(
Index agI = 0; agI < nrAg; agI++)
336 vector<Index> ind_sI(nrAg, 0);
343 for(
Index agI = 0; agI < nrAg; agI++)
356 throw(
E(
"TransitionObservationIndependentMADPDiscrete::CreateJointStates() sizes do not match"));
370 const std::vector<Index> &sIs)
const
405 vector<Index> ind_sI=
428 vector<Index> ind_sI=
440 const std::vector<Index>&
451 vector<Index> ind_sI=
463 for(
Index agI = 0; agI < nrAg; agI++)
469 for(
Index agI = 0; agI < nrAg; agI++)
471 vector<ObservationDiscrete> indObs;
474 GetObservationDiscrete(0,o));
481 for(
Index agI = 0; agI < nrAg; agI++)
490 throw(
E(
"TransitionObservationIndependentMADPDiscrete::CreateJointObservations() sizes do not match"));
502 bool lastAgent=
false;
510 ss <<
"ConstructJointObservationsRecursively - current Agent index ("<<
511 curAgentI<<
") out of bounds! (_m_indivObs contains "<<
512 "observations for "<<
_m_indivObs.size() <<
" agents...)\n";
513 throw E(ss.str().c_str());
515 ObservationDVec::iterator first =
_m_indivObs[curAgentI].begin();
516 ObservationDVec::iterator it =
_m_indivObs[curAgentI].begin();
517 ObservationDVec::iterator last =
_m_indivObs[curAgentI].end();
518 ObservationDVec::iterator beforelast =
_m_indivObs[curAgentI].end();
524 ss <<
" empty observation set for agent " << curAgentI;
538 else if (it == beforelast)
540 p_jo = p_joReceivedArgCopy;
550 cerr <<
"setting index of this observation to: "<< joI <<endl;
554 cerr <<
"Adding agent's indiv. observation to joint observation..."<<endl;
560 {cerr<<
"INSERTING the joint observation:"; p_jo->
Print();cerr<<endl;}
562 if(
DEBUG_CJO){cerr <<
"\nINSERTED the joint observation"<<endl<<
"_m_jointObservationVec now containts "<<
_m_jointObs.size() <<
" joint actions." << endl;}
569 if(
DEBUG_CJO) cerr <<
">> TransitionObservationIndependentMADPDiscrete::ConstructJointObservationsRecursively(Index "<<curAgentI<<
", JointObservationDiscrete& jo, Index "<< joI<<
") FINISHED"<<endl;
578 throw(
E(
"TransitionObservationIndependentMADPDiscrete::CreateISD() joint states should have been created already"));
582 vector< const StateDistribution* > isdIs;
589 vector<double> ISD(nrJS,1);
590 for(
Index s=0;s!=nrJS;++s)
614 cerr <<
"TransitionObservationIndependentMADPDiscrete::SetInitialized"<<
618 throw E(
"TransitionObservationIndependentMADPDiscrete::SetInitialized(bool b) called, but the number of agents has not been set yet.. (is 0 at the moment...)");
623 vector<MultiAgentDecisionProcessDiscrete*>::iterator it =
625 vector<MultiAgentDecisionProcessDiscrete*>::iterator last =
666 ss <<
"TransitionObservationIndependentMADPDiscrete::"<<
667 "IndividualToJointActionIndices(vector<Index>&)"<<
668 " - Error: not initialized. "<<endl;
684 ss <<
"TransitionObservationIndependentMADPDiscrete::"<<
685 "JointToIndividualActionIndices("<< jaI<<
686 ") - Error: not initialized. "<<endl;
699 cerr <<
"TransitionObservationIndependentMADPDiscrete::"<<
700 "JointToIndividualActionIndices"<<
"(Index "<<jaI<<
")" << endl <<
701 "vai.size() = " <<vai.size() <<
" - elements: "<<endl;
702 vector<Index>::iterator vai_it = vai.begin();
703 vector<Index>::iterator vai_last = vai.end();
704 while(vai_it != vai_last)
706 cerr <<
", " << *vai_it;
716 indivObsIndices)
const
721 ss <<
"TransitionObservationIndependentMADPDiscrete::"<<
722 "IndividualToJointObservationIndices(const vector<Index>)"<<
723 " - Error: not initialized. "<<endl;
743 ss <<
"TransitionObservationIndependentMADPDiscrete::"<<
744 "JointToIndividualObservationIndices("<< joI<<
745 ") - Error: not initialized. "<<endl;
756 cerr <<
"TransitionObservationIndependentMADPDiscrete::"<<
757 "JointToIndividualActionIndices"<<
"(Index "<<joI<<
")" << endl <<
758 "voi.size() = " <<voi.size() <<
" - elements: "<<endl;
759 vector<Index>::iterator voi_it = voi.begin();
760 vector<Index>::iterator voi_last = voi.end();
761 while(voi_it != voi_last)
763 cerr <<
", " << *voi_it;
785 ss <<
"TransitionObservationIndependentMADPDiscrete::Print("<<
786 ") - Error: not initialized. "<<endl;
793 str <<
"Joint Actions:"<<endl;
796 str <<
"Individual MADPs for each agent:"<<endl;
798 str <<
"Agent "<< agI <<
":" <<endl <<
810 ss <<
"TransitionObservationIndependentMADPDiscrete::PrintAction"<<
811 "Sets() - Error: not initialized. "<<endl;
814 str <<
"Actions:"<<endl;
817 str <<
"agentI " << agentIndex <<
" - nrActions " <<
823 GetActionDiscrete(0, actionI);
838 ss <<
"TransitionObservationIndependentMADPDiscrete::PrintJoint"<<
839 "ActionSets() - Error: not initialized. "<<endl;
842 vector<JointActionDiscrete*>::const_iterator ja_it =
844 vector<JointActionDiscrete*>::const_iterator ja_last =
846 while(ja_it != ja_last)
848 str << (*ja_it)->SoftPrint();
860 for(
Index agI = 0; agI < sIs.size(); agI++)
904 const vector<Index> &aIs,
905 const vector<Index> &sucSIs)
const
958 const vector<Index> &sucSIs,
959 const vector<Index> &oIs)
const
984 const vector<Index> &sIs,
985 const vector<Index> &aIs)
const
1007 const vector<Index> &aIs,
1008 const vector<Index> &sucIs)
1042 throw(
E(
"TransitionObservationIndependentMADPDiscrete::GetISD initial state distribution has not been generated as a double vector."));
1052 vector<MultiAgentDecisionProcessDiscrete*>::iterator it =
1054 vector<MultiAgentDecisionProcessDiscrete*>::iterator last =
1058 (*it)->SetSparse(sparse);
1066 throw(
E(
"TransitionObservationIndependentMADPDiscrete::GetNrJointStates() not yet initialized"));
1074 throw(
E(
"TransitionObservationIndependentMADPDiscrete::GetNrJointActions() not yet initialized"));
1082 throw(
E(
"TransitionObservationIndependentMADPDiscrete::GetNrJointObservations() not yet initialized"));
1092 throw(
E(
"TransitionObservationIndependentMADPDiscrete::CreateCentralizedSparseModels not initialized yet"));
1127 throw(
E(
"TransitionObservationIndependentMADPDiscrete::CreateCentralizedFullModels not initialized yet"));