MultiAgentDecisionProcess
Release 0.2.1
|
MADPComponentDiscreteObservations contains functionality for discrete observation spaces. More...
#include <MADPComponentDiscreteObservations.h>
Public Member Functions | |
void | AddObservation (Index AI, std::string name) |
Add a new observation with name "name" to the observ. of agent AI. | |
size_t | ConstructJointObservations () |
Recursively constructs all the joint observations. | |
const JointObservation * | GetJointObservation (Index i) const |
Return a ref to the i-th joint observation. | |
const JointObservationDiscrete * | GetJointObservationDiscrete (Index i) const |
Return a ref to the i-th joint observation integer. | |
std::string | GetJointObservationName (Index o) const |
Returns the name of a particular joint observation o. | |
size_t | GetNrJointObservations () const |
Return the number of joiny observations. | |
const std::vector< size_t > & | GetNrObservations () const |
Return the number of observations vector. | |
size_t | GetNrObservations (Index AgentI) const |
Return the number of observations of agent agentI. | |
const Observation * | GetObservation (Index agentI, Index a) const |
Return a ref to the a-th observation of agent agentI. | |
const ObservationDiscrete * | GetObservationDiscrete (Index agentI, Index a) const |
Return a ref to the a-th observation of agent agentI. | |
Index | GetObservationIndexByName (std::string s, Index agentI) const |
Returns the observation index of the agent I's observation s. | |
std::string | GetObservationName (Index o, Index i) const |
Returns the name of a particular observation o of agent i. | |
Index | IndividualToJointObservationIndices (const std::vector< Index > &indivObservationIndices) const |
Returns the joint observation index that corresponds to the vector of specified individual observation indices. | |
const std::vector< Index > & | JointToIndividualObservationIndices (Index joI) const |
Returns a vector of indices to indiv. | |
MADPComponentDiscreteObservations () | |
(default) Constructor | |
void | Print () const |
bool | SetInitialized (bool b) |
Sets _m_initialized to b. | |
void | SetNrObservations (Index AI, size_t nrO) |
Sets the number of observations for agent AI. | |
std::string | SoftPrint () const |
Prints some information on the MultiAgentDecisionProcessDiscreteInterface. | |
virtual | ~MADPComponentDiscreteObservations () |
Destructor. | |
![]() | |
virtual MultiAgentDecisionProcessDiscreteInterface * | Clone () const =0 |
Returns a pointer to a copy of this class. | |
virtual const Action * | GetAction (Index agentI, Index a) const =0 |
Return a ref to the a-th action of agent agentI. | |
virtual double | GetInitialStateProbability (Index sI) const =0 |
virtual const StateDistribution * | GetISD () const =0 |
Returns the complete initial state distribution. | |
virtual const JointAction * | GetJointAction (Index i) const =0 |
Return a ref to the i-th joint action. | |
virtual const std::vector < size_t > & | GetNrActions () const =0 |
Return the number of actions vector. | |
virtual size_t | GetNrActions (Index AgentI) const =0 |
Return the number of actions of agent agentI. | |
virtual size_t | GetNrJointActions () const =0 |
Return the number of joiny actions. | |
virtual size_t | GetNrStates () const =0 |
Return the number of states. | |
virtual const ObservationModelDiscrete * | GetObservationModelDiscretePtr () const =0 |
Returns a pointer to the underlying observation model. | |
virtual double | GetObservationProbability (Index jaI, Index sucSI, Index joI) const =0 |
Return the probability of joint observation joI: P(joI|jaI,sucSI). | |
virtual OGet * | GetOGet () const =0 |
virtual const State * | GetState (Index i) const =0 |
Returns a pointer to state i. | |
virtual TGet * | GetTGet () const =0 |
virtual const TransitionModelDiscrete * | GetTransitionModelDiscretePtr () const =0 |
Returns a pointer to the underlying transition model. | |
virtual double | GetTransitionProbability (Index sI, Index jaI, Index sucSI) const =0 |
Return the probability of successor state sucSI: P(sucSI|sI,jaI). | |
virtual Index | IndividualToJointActionIndices (const Index *AI_ar) const =0 |
Returns the joint action index that corresponds to the array of specified individual action indices. | |
virtual Index | IndividualToJointActionIndices (const std::vector< Index > &indivActionIndices) const =0 |
Returns the joint action index that corresponds to the vector of specified individual action indices. | |
virtual const std::vector < Index > & | JointToIndividualActionIndices (Index jaI) const =0 |
Returns a vector of indices to indiv. | |
virtual Index | SampleInitialState (void) const =0 |
Sample a state according to the initial state PDF. | |
virtual Index | SampleJointObservation (Index jaI, Index sucI) const =0 |
Sample an observation - needed for simulations. | |
virtual Index | SampleSuccessorState (Index sI, Index jaI) const =0 |
Sample a successor state - needed by simulations. | |
virtual std::string | SoftPrintState (Index sI) const =0 |
virtual | ~MultiAgentDecisionProcessDiscreteInterface () |
Destructor. Can't make a virt.destr. pure abstract! | |
![]() | |
virtual size_t | GetNrAgents () const =0 |
Return the number of agents. | |
virtual std::string | GetUnixName () const =0 |
Returns the base part of the problem filename. | |
virtual | ~MultiAgentDecisionProcessInterface () |
Destructor. |
Protected Attributes | |
std::vector< size_t > | _m_nrObservations |
The number of observations for each agent. | |
std::vector< std::vector < ObservationDiscrete > > | _m_observationVecs |
The vectors of observations (vectors of ObservationDiscrete) for each agent. |
Private Member Functions | |
size_t | ConstructJointObservationsRecursively (Index curAgentI, JointObservationDiscrete &jo, Index joI) |
Recursively creates the joint observations. | |
std::string | SoftPrintJointObservationSet () const |
std::string | SoftPrintObservationSets () const |
Private Attributes | |
bool | _m_cachedAllJointObservations |
bool | _m_jointIndicesValid |
std::map< Index, std::vector < Index > * > * | _m_jointObservationIndices |
When not all joint observations have been created, here we cache the individual indices created by JointToIndividualObservationIndices() | |
std::vector < JointObservationDiscrete * > | _m_jointObservationVec |
The vector storing the joint observations. | |
size_t | _m_nrJointObservations |
size_t * | _m_observationStepSize |
The stepsize array - used for indiv->joint index calculation. |
Static Private Attributes | |
bool | _m_initialized |
MADPComponentDiscreteObservations contains functionality for discrete observation spaces.
It implements a part of the MultiAgentDecisionProcessDiscreteInterface.
Definition at line 52 of file MADPComponentDiscreteObservations.h.
MADPComponentDiscreteObservations::MADPComponentDiscreteObservations | ( | ) |
(default) Constructor
Definition at line 38 of file MADPComponentDiscreteObservations.cpp.
|
virtual |
Destructor.
Definition at line 48 of file MADPComponentDiscreteObservations.cpp.
void MADPComponentDiscreteObservations::AddObservation | ( | Index | AI, |
std::string | name | ||
) |
Add a new observation with name "name" to the observ. of agent AI.
Definition at line 228 of file MADPComponentDiscreteObservations.cpp.
References DEBUG_ADD_DO.
Referenced by DecPOMDPDiscrete::ExtractMADPDiscrete().
size_t MADPComponentDiscreteObservations::ConstructJointObservations | ( | ) |
Recursively constructs all the joint observations.
Calls ConstructJointObservationsRecursively on a new (empty) joint observation.
this function is typically called from the parser (parser/ParserDecPOMDPDiscrete.h)
Definition at line 103 of file MADPComponentDiscreteObservations.cpp.
References DEBUG_CJO.
Referenced by DecPOMDPDiscrete::ExtractMADPDiscrete(), ProblemDecTiger::ProblemDecTiger(), and ProblemFireFighting::ProblemFireFighting().
|
private |
Recursively creates the joint observations.
Creates (_m_jointObservationVec) using _m_observationVecs (which need to be initialized before calling this function...)
Definition at line 114 of file MADPComponentDiscreteObservations.cpp.
References JointObservationDiscrete::AddIndividualObservation(), DEBUG_CJO, JointObservation::Print(), and DiscreteEntity::SetIndex().
|
virtual |
Return a ref to the i-th joint observation.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 435 of file MADPComponentDiscreteObservations.cpp.
const JointObservationDiscrete * MADPComponentDiscreteObservations::GetJointObservationDiscrete | ( | Index | i | ) | const |
Return a ref to the i-th joint observation integer.
Definition at line 411 of file MADPComponentDiscreteObservations.cpp.
Referenced by JointToIndividualObservationIndices().
|
inline |
Returns the name of a particular joint observation o.
Definition at line 130 of file MADPComponentDiscreteObservations.h.
References _m_jointObservationVec.
Referenced by MultiAgentDecisionProcessDiscrete::SanityCheck().
|
virtual |
Return the number of joiny observations.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 340 of file MADPComponentDiscreteObservations.cpp.
Referenced by MultiAgentDecisionProcessDiscrete::CreateNewObservationModel(), ProblemFireFighting::FillObservationModel(), ProblemDecTiger::FillObservationModel(), and MultiAgentDecisionProcessDiscrete::SanityCheck().
|
inlinevirtual |
Return the number of observations vector.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 113 of file MADPComponentDiscreteObservations.h.
References _m_nrObservations.
Referenced by DecPOMDPDiscrete::ExtractMADPDiscrete(), and JointToIndividualObservationIndices().
|
virtual |
Return the number of observations of agent agentI.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 313 of file MADPComponentDiscreteObservations.cpp.
|
inlinevirtual |
Return a ref to the a-th observation of agent agentI.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 138 of file MADPComponentDiscreteObservations.h.
References GetObservationDiscrete().
Referenced by DecPOMDPDiscrete::ExtractMADPDiscrete().
const ObservationDiscrete * MADPComponentDiscreteObservations::GetObservationDiscrete | ( | Index | agentI, |
Index | a | ||
) | const |
Return a ref to the a-th observation of agent agentI.
Definition at line 385 of file MADPComponentDiscreteObservations.cpp.
Referenced by GetObservation().
Index MADPComponentDiscreteObservations::GetObservationIndexByName | ( | std::string | s, |
Index | agentI | ||
) | const |
Returns the observation index of the agent I's observation s.
Throws an exception if there is no Observation with name s.
Definition at line 353 of file MADPComponentDiscreteObservations.cpp.
|
inline |
Returns the name of a particular observation o of agent i.
Definition at line 126 of file MADPComponentDiscreteObservations.h.
References _m_observationVecs.
|
virtual |
Returns the joint observation index that corresponds to the vector of specified individual observation indices.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 455 of file MADPComponentDiscreteObservations.cpp.
References IndexTools::IndividualToJointIndicesStepSize().
|
inlinevirtual |
Returns a vector of indices to indiv.
observation indicies corr. to joint observation index joI.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 157 of file MADPComponentDiscreteObservations.h.
References _m_cachedAllJointObservations, _m_jointIndicesValid, _m_jointObservationIndices, GetJointObservationDiscrete(), GetNrObservations(), and IndexTools::JointToIndividualIndices().
Referenced by ProblemFireFighting::FillObservationModel().
|
inline |
Reimplemented in MultiAgentDecisionProcessDiscrete.
Definition at line 180 of file MADPComponentDiscreteObservations.h.
References SoftPrint().
bool MADPComponentDiscreteObservations::SetInitialized | ( | bool | b | ) |
Sets _m_initialized to b.
When setting to true, a verification of member elements is performed.
(i.e. a check whether all vectors have the correct size and non-zero entries)
Reimplemented in MultiAgentDecisionProcessDiscrete, DecPOMDPDiscrete, and POSGDiscrete.
Definition at line 267 of file MADPComponentDiscreteObservations.cpp.
References IndexTools::CalculateStepSize().
Referenced by MultiAgentDecisionProcessDiscrete::SetInitialized().
void MADPComponentDiscreteObservations::SetNrObservations | ( | Index | AI, |
size_t | nrO | ||
) |
Sets the number of observations for agent AI.
Creates nrA unnamed observations.
Definition at line 199 of file MADPComponentDiscreteObservations.cpp.
|
virtual |
Prints some information on the MultiAgentDecisionProcessDiscreteInterface.
Implements MultiAgentDecisionProcessDiscreteInterface.
Reimplemented in MultiAgentDecisionProcessDiscrete, DecPOMDPDiscrete, and POSGDiscrete.
Definition at line 472 of file MADPComponentDiscreteObservations.cpp.
Referenced by Print().
|
private |
Definition at line 512 of file MADPComponentDiscreteObservations.cpp.
|
private |
Definition at line 483 of file MADPComponentDiscreteObservations.cpp.
|
private |
Definition at line 58 of file MADPComponentDiscreteObservations.h.
Referenced by JointToIndividualObservationIndices().
|
staticprivate |
Definition at line 57 of file MADPComponentDiscreteObservations.h.
|
private |
Definition at line 59 of file MADPComponentDiscreteObservations.h.
Referenced by JointToIndividualObservationIndices().
|
private |
When not all joint observations have been created, here we cache the individual indices created by JointToIndividualObservationIndices()
Definition at line 72 of file MADPComponentDiscreteObservations.h.
Referenced by JointToIndividualObservationIndices().
|
private |
The vector storing the joint observations.
To use this, ConstructJointObservations() should be called
Definition at line 67 of file MADPComponentDiscreteObservations.h.
Referenced by GetJointObservationName().
|
private |
Definition at line 60 of file MADPComponentDiscreteObservations.h.
|
protected |
The number of observations for each agent.
Definition at line 83 of file MADPComponentDiscreteObservations.h.
Referenced by ProblemFireFighting::ConstructObservations(), ProblemDecTiger::ConstructObservations(), and GetNrObservations().
|
private |
The stepsize array - used for indiv->joint index calculation.
Definition at line 63 of file MADPComponentDiscreteObservations.h.
|
protected |
The vectors of observations (vectors of ObservationDiscrete) for each agent.
Definition at line 86 of file MADPComponentDiscreteObservations.h.
Referenced by ProblemFireFighting::ConstructObservations(), ProblemDecTiger::ConstructObservations(), and GetObservationName().