MultiAgentDecisionProcess
MADPComponentDiscreteObservations Class Reference

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

#include <MADPComponentDiscreteObservations.h>

Public Member Functions

void AddObservation (Index AI, const std::string &name, const std::string &description="")
 Add a new observation with name "name" to the observ. of agent AI. More...
 
size_t ConstructJointObservations ()
 Recursively constructs all the joint observations. More...
 
const JointObservationGetJointObservation (Index i) const
 Return a ref to the i-th joint observation. More...
 
const JointObservationDiscreteGetJointObservationDiscrete (Index i) const
 Return a ref to the i-th joint observation integer. More...
 
std::string GetJointObservationName (Index o) const
 Returns the name of a particular joint observation o. More...
 
size_t GetNrJointObservations () const
 Return the number of joint observations. More...
 
const std::vector< size_t > & GetNrObservations () const
 Return the number of observations vector. More...
 
size_t GetNrObservations (Index AgentI) const
 Return the number of observations of agent agentI. More...
 
const ObservationGetObservation (Index agentI, Index a) const
 Return a ref to the a-th observation of agent agentI. More...
 
const ObservationDiscreteGetObservationDiscrete (Index agentI, Index a) const
 Return a ref to the a-th observation of agent agentI. More...
 
Index GetObservationIndexByName (const std::string &s, Index agentI) const
 Returns the observation index of the agent I's observation s. More...
 
std::string GetObservationName (Index o, Index i) const
 Returns the name of a particular observation o of agent i. More...
 
Index IndividualToJointObservationIndices (const std::vector< Index > &indivObservationIndices) const
 Returns the joint observation index that corresponds to the vector of specified individual observation indices. More...
 
Index IndividualToJointObservationIndices (const std::vector< Index > &jo_e, const Scope &agSC) const
 
bool JointIndicesValid () const
 Find out if there is an overflow in the joint indices variable. More...
 
const std::vector< Index > & JointToIndividualObservationIndices (Index joI) const
 Returns a vector of indices to indiv. More...
 
std::vector< IndexJointToIndividualObservationIndices (Index jo_e, const Scope &agSC) const
 
Index JointToRestrictedJointObservationIndex (Index joI, const Scope &agSc_e) const
 
 MADPComponentDiscreteObservations ()
 (default) Constructor More...
 
 MADPComponentDiscreteObservations (const MADPComponentDiscreteObservations &a)
 Copy constructor. More...
 
void Print () const
 
bool SetInitialized (bool b)
 Sets _m_initialized to b. More...
 
void SetNrObservations (Index AI, size_t nrO)
 Sets the number of observations for agent AI. More...
 
std::string SoftPrint () const
 
virtual ~MADPComponentDiscreteObservations ()
 Destructor. More...
 

Private Member Functions

size_t ConstructJointObservationsRecursively (Index curAgentI, JointObservationDiscrete &jo, Index joI)
 Recursively creates the joint observations. More...
 
std::string SoftPrintJointObservationSet () const
 
std::string SoftPrintObservationSets () const
 

Private Attributes

bool _m_cachedAllJointObservations
 
bool _m_initialized
 
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() More...
 
std::vector
< JointObservationDiscrete * > 
_m_jointObservationVec
 The vector storing the joint observations. More...
 
size_t _m_nrJointObservations
 
std::vector< size_t > _m_nrObservations
 The number of observations for each agent. More...
 
size_t * _m_observationStepSize
 The stepsize array - used for indiv->joint index calculation. More...
 
std::vector< std::vector
< ObservationDiscrete > > 
_m_observationVecs
 The vectors of observations (vectors of ObservationDiscrete) for each agent. More...
 

Detailed Description

MADPComponentDiscreteObservations contains functionality for discrete observation spaces.

It implements a part of the MultiAgentDecisionProcessDiscreteInterface.

Constructor & Destructor Documentation

MADPComponentDiscreteObservations::MADPComponentDiscreteObservations ( )

(default) Constructor

MADPComponentDiscreteObservations::~MADPComponentDiscreteObservations ( )
virtual

Destructor.

Member Function Documentation

void MADPComponentDiscreteObservations::AddObservation ( Index  AI,
const std::string &  name,
const std::string &  description = "" 
)

Add a new observation with name "name" to the observ. of agent AI.

References DEBUG_ADD_DO.

Referenced by MultiAgentDecisionProcessDiscrete::AddObservation(), and MultiAgentDecisionProcessDiscreteFactoredStates::AddObservation().

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)

References DEBUG_CJO.

Referenced by MultiAgentDecisionProcessDiscrete::ConstructJointObservations(), and MultiAgentDecisionProcessDiscreteFactoredStates::ConstructJointObservations().

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

References JointObservationDiscrete::AddIndividualObservation(), DEBUG_CJO, JointObservation::Print(), and DiscreteEntity::SetIndex().

const JointObservation * MADPComponentDiscreteObservations::GetJointObservation ( Index  i) const
const JointObservationDiscrete * MADPComponentDiscreteObservations::GetJointObservationDiscrete ( Index  i) const

Return a ref to the i-th joint observation integer.

Referenced by JointToIndividualObservationIndices().

std::string MADPComponentDiscreteObservations::GetJointObservationName ( Index  o) const
inline

Returns the name of a particular joint observation o.

Referenced by MultiAgentDecisionProcessDiscrete::SanityCheck().

size_t MADPComponentDiscreteObservations::GetNrJointObservations ( ) const
const std::vector<size_t>& MADPComponentDiscreteObservations::GetNrObservations ( ) const
inline
size_t MADPComponentDiscreteObservations::GetNrObservations ( Index  AgentI) const

Return the number of observations of agent agentI.

const Observation* MADPComponentDiscreteObservations::GetObservation ( Index  agentI,
Index  a 
) const
inline
const ObservationDiscrete * MADPComponentDiscreteObservations::GetObservationDiscrete ( Index  agentI,
Index  a 
) const

Return a ref to the a-th observation of agent agentI.

Referenced by GetObservation(), and MultiAgentDecisionProcessDiscrete::GetObservationDiscrete().

Index MADPComponentDiscreteObservations::GetObservationIndexByName ( const 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.

Referenced by MultiAgentDecisionProcessDiscrete::GetObservationIndexByName().

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

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

Index MADPComponentDiscreteObservations::IndividualToJointObservationIndices ( const std::vector< Index > &  indivObservationIndices) const

Returns the joint observation index that corresponds to the vector of specified individual observation indices.

References IndexTools::IndividualToJointIndicesStepSize().

Referenced by MultiAgentDecisionProcessDiscrete::IndividualToJointObservationIndices(), and MultiAgentDecisionProcessDiscreteFactoredStates::IndividualToJointObservationIndices().

Index MADPComponentDiscreteObservations::IndividualToJointObservationIndices ( const std::vector< Index > &  jo_e,
const Scope agSC 
) const
bool MADPComponentDiscreteObservations::JointIndicesValid ( ) const
inline

Find out if there is an overflow in the joint indices variable.

References _m_jointIndicesValid.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::JointOIndicesValid().

const std::vector<Index>& MADPComponentDiscreteObservations::JointToIndividualObservationIndices ( Index  joI) const
inline
std::vector< Index > MADPComponentDiscreteObservations::JointToIndividualObservationIndices ( Index  jo_e,
const Scope agSC 
) const
void MADPComponentDiscreteObservations::Print ( ) const
inline

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)

References IndexTools::CalculateStepSize().

Referenced by MultiAgentDecisionProcessDiscrete::SetInitialized(), MultiAgentDecisionProcessDiscreteFactoredStates::SetInitialized(), MultiAgentDecisionProcessDiscrete::SetObservationsInitialized(), and MultiAgentDecisionProcessDiscreteFactoredStates::SetObservationsInitialized().

void MADPComponentDiscreteObservations::SetNrObservations ( Index  AI,
size_t  nrO 
)

Sets the number of observations for agent AI.

Creates nrO unnamed observations.

Referenced by MultiAgentDecisionProcessDiscrete::SetNrObservations(), and MultiAgentDecisionProcessDiscreteFactoredStates::SetNrObservations().

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

Member Data Documentation

bool MADPComponentDiscreteObservations::_m_cachedAllJointObservations
private
bool MADPComponentDiscreteObservations::_m_initialized
private
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()

Referenced by MADPComponentDiscreteObservations().

std::vector<JointObservationDiscrete*> MADPComponentDiscreteObservations::_m_jointObservationVec
private

The vector storing the joint observations.

To use this, ConstructJointObservations() should be called

Referenced by MADPComponentDiscreteObservations().

size_t MADPComponentDiscreteObservations::_m_nrJointObservations
private
std::vector<size_t> MADPComponentDiscreteObservations::_m_nrObservations
private

The number of observations for each agent.

Referenced by GetNrObservations(), and MADPComponentDiscreteObservations().

size_t* MADPComponentDiscreteObservations::_m_observationStepSize
private

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

std::vector<std::vector<ObservationDiscrete> > MADPComponentDiscreteObservations::_m_observationVecs
private

The vectors of observations (vectors of ObservationDiscrete) for each agent.

Referenced by MADPComponentDiscreteObservations().