MultiAgentDecisionProcess
|
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 JointObservation * | GetJointObservation (Index i) const |
Return a ref to the i-th joint observation. More... | |
const JointObservationDiscrete * | GetJointObservationDiscrete (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 Observation * | GetObservation (Index agentI, Index a) const |
Return a ref to the a-th observation of agent agentI. More... | |
const ObservationDiscrete * | GetObservationDiscrete (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< Index > | JointToIndividualObservationIndices (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... | |
MADPComponentDiscreteObservations contains functionality for discrete observation spaces.
It implements a part of the MultiAgentDecisionProcessDiscreteInterface.
MADPComponentDiscreteObservations::MADPComponentDiscreteObservations | ( | ) |
(default) Constructor
MADPComponentDiscreteObservations::MADPComponentDiscreteObservations | ( | const MADPComponentDiscreteObservations & | a | ) |
Copy constructor.
References _m_cachedAllJointObservations, _m_initialized, _m_jointIndicesValid, _m_jointObservationIndices, _m_jointObservationVec, _m_nrJointObservations, _m_nrObservations, _m_observationVecs, and IndexTools::CalculateStepSize().
|
virtual |
Destructor.
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().
|
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 |
Return a ref to the i-th joint observation.
Referenced by MultiAgentDecisionProcessDiscrete::GetJointObservation(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetJointObservation().
const JointObservationDiscrete * MADPComponentDiscreteObservations::GetJointObservationDiscrete | ( | Index | i | ) | const |
Return a ref to the i-th joint observation integer.
Referenced by JointToIndividualObservationIndices().
|
inline |
Returns the name of a particular joint observation o.
Referenced by MultiAgentDecisionProcessDiscrete::SanityCheck().
size_t MADPComponentDiscreteObservations::GetNrJointObservations | ( | ) | const |
Return the number of joint observations.
Referenced by MultiAgentDecisionProcessDiscrete::GetNrJointObservations(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetNrJointObservations().
|
inline |
Return the number of observations vector.
References _m_nrObservations.
Referenced by MultiAgentDecisionProcessDiscrete::GetNrObservations(), MultiAgentDecisionProcessDiscreteFactoredStates::GetNrObservations(), and JointToIndividualObservationIndices().
size_t MADPComponentDiscreteObservations::GetNrObservations | ( | Index | AgentI | ) | const |
Return the number of observations of agent agentI.
|
inline |
Return a ref to the a-th observation of agent agentI.
References GetObservationDiscrete().
Referenced by MultiAgentDecisionProcessDiscrete::GetObservation(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetObservation().
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().
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().
|
inline |
Find out if there is an overflow in the joint indices variable.
References _m_jointIndicesValid.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::JointOIndicesValid().
|
inline |
Returns a vector of indices to indiv.
observation indicies corr. to joint observation index joI.
References GetJointObservationDiscrete(), GetNrObservations(), and IndexTools::JointToIndividualIndices().
Referenced by MultiAgentDecisionProcessDiscrete::JointToIndividualObservationIndices(), and MultiAgentDecisionProcessDiscreteFactoredStates::JointToIndividualObservationIndices().
|
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 |
|
private |
|
private |
|
private |
Referenced by MADPComponentDiscreteObservations().
|
private |
Referenced by MADPComponentDiscreteObservations().
|
private |
Referenced by JointIndicesValid(), and MADPComponentDiscreteObservations().
|
private |
When not all joint observations have been created, here we cache the individual indices created by JointToIndividualObservationIndices()
Referenced by MADPComponentDiscreteObservations().
|
private |
The vector storing the joint observations.
To use this, ConstructJointObservations() should be called
Referenced by MADPComponentDiscreteObservations().
|
private |
Referenced by MADPComponentDiscreteObservations().
|
private |
The number of observations for each agent.
Referenced by GetNrObservations(), and MADPComponentDiscreteObservations().
|
private |
The stepsize array - used for indiv->joint index calculation.
|
private |
The vectors of observations (vectors of ObservationDiscrete) for each agent.
Referenced by MADPComponentDiscreteObservations().