MultiAgentDecisionProcess  Release 0.2.1
MADPComponentDiscreteObservations Class Reference

MADPComponentDiscreteObservations contains functionality for discrete observation spaces. More...

#include <MADPComponentDiscreteObservations.h>

+ Inheritance diagram for MADPComponentDiscreteObservations:
+ Collaboration diagram for MADPComponentDiscreteObservations:

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 JointObservationGetJointObservation (Index i) const
 Return a ref to the i-th joint observation.
const JointObservationDiscreteGetJointObservationDiscrete (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 ObservationGetObservation (Index agentI, Index a) const
 Return a ref to the a-th observation of agent agentI.
const ObservationDiscreteGetObservationDiscrete (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.
- Public Member Functions inherited from MultiAgentDecisionProcessDiscreteInterface
virtual
MultiAgentDecisionProcessDiscreteInterface
Clone () const =0
 Returns a pointer to a copy of this class.
virtual const ActionGetAction (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 StateDistributionGetISD () const =0
 Returns the complete initial state distribution.
virtual const JointActionGetJointAction (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 OGetGetOGet () const =0
virtual const StateGetState (Index i) const =0
 Returns a pointer to state i.
virtual TGetGetTGet () 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!
- Public Member Functions inherited from MultiAgentDecisionProcessInterface
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

Detailed Description

MADPComponentDiscreteObservations contains functionality for discrete observation spaces.

It implements a part of the MultiAgentDecisionProcessDiscreteInterface.

Definition at line 52 of file MADPComponentDiscreteObservations.h.

Constructor & Destructor Documentation

MADPComponentDiscreteObservations::MADPComponentDiscreteObservations ( )

(default) Constructor

Definition at line 38 of file MADPComponentDiscreteObservations.cpp.

MADPComponentDiscreteObservations::~MADPComponentDiscreteObservations ( )
virtual

Destructor.

Definition at line 48 of file MADPComponentDiscreteObservations.cpp.

Member Function Documentation

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().

size_t MADPComponentDiscreteObservations::ConstructJointObservationsRecursively ( Index  curAgentI,
JointObservationDiscrete jo,
Index  joI 
)
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().

const JointObservation * MADPComponentDiscreteObservations::GetJointObservation ( Index  i) const
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().

std::string MADPComponentDiscreteObservations::GetJointObservationName ( Index  o) const
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().

size_t MADPComponentDiscreteObservations::GetNrJointObservations ( ) const
virtual
const std::vector<size_t>& MADPComponentDiscreteObservations::GetNrObservations ( ) const
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().

size_t MADPComponentDiscreteObservations::GetNrObservations ( Index  AgentI) const
virtual

Return the number of observations of agent agentI.

Implements MultiAgentDecisionProcessDiscreteInterface.

Definition at line 313 of file MADPComponentDiscreteObservations.cpp.

const Observation* MADPComponentDiscreteObservations::GetObservation ( Index  agentI,
Index  a 
) const
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.

std::string MADPComponentDiscreteObservations::GetObservationName ( Index  o,
Index  i 
) const
inline

Returns the name of a particular observation o of agent i.

Definition at line 126 of file MADPComponentDiscreteObservations.h.

References _m_observationVecs.

Index MADPComponentDiscreteObservations::IndividualToJointObservationIndices ( const std::vector< Index > &  indivObservationIndices) const
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().

const std::vector<Index>& MADPComponentDiscreteObservations::JointToIndividualObservationIndices ( Index  joI) const
inlinevirtual
void MADPComponentDiscreteObservations::Print ( ) const
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.

string MADPComponentDiscreteObservations::SoftPrint ( ) const
virtual
string MADPComponentDiscreteObservations::SoftPrintJointObservationSet ( ) const
private

Definition at line 512 of file MADPComponentDiscreteObservations.cpp.

string MADPComponentDiscreteObservations::SoftPrintObservationSets ( ) const
private

Definition at line 483 of file MADPComponentDiscreteObservations.cpp.

Member Data Documentation

bool MADPComponentDiscreteObservations::_m_cachedAllJointObservations
private
bool MADPComponentDiscreteObservations::_m_initialized
staticprivate

Definition at line 57 of file MADPComponentDiscreteObservations.h.

bool MADPComponentDiscreteObservations::_m_jointIndicesValid
private
std::map<Index, std::vector<Index> *>* MADPComponentDiscreteObservations::_m_jointObservationIndices
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().

std::vector<JointObservationDiscrete*> MADPComponentDiscreteObservations::_m_jointObservationVec
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().

size_t MADPComponentDiscreteObservations::_m_nrJointObservations
private

Definition at line 60 of file MADPComponentDiscreteObservations.h.

std::vector<size_t> MADPComponentDiscreteObservations::_m_nrObservations
protected

The number of observations for each agent.

Definition at line 83 of file MADPComponentDiscreteObservations.h.

Referenced by ProblemFireFighting::ConstructObservations(), ProblemDecTiger::ConstructObservations(), and GetNrObservations().

size_t* MADPComponentDiscreteObservations::_m_observationStepSize
private

The stepsize array - used for indiv->joint index calculation.

Definition at line 63 of file MADPComponentDiscreteObservations.h.

std::vector<std::vector<ObservationDiscrete> > MADPComponentDiscreteObservations::_m_observationVecs
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().


The documentation for this class was generated from the following files: