MultiAgentDecisionProcess  Release 0.2.1
MADPComponentDiscreteActions Class Reference

MADPComponentDiscreteActions contains functionality for discrete action spaces. More...

#include <MADPComponentDiscreteActions.h>

+ Inheritance diagram for MADPComponentDiscreteActions:
+ Collaboration diagram for MADPComponentDiscreteActions:

Public Member Functions

void AddAction (Index AI, std::string name)
 Add a new action with name "name" to the actions of agent AI.
size_t ConstructJointActions ()
 Recursively constructs all the joint actions.
const ActionGetAction (Index agentI, Index a) const
 Return a ref to the a-th action of agent agentI.
const ActionDiscreteGetActionDiscrete (Index agentI, Index a) const
 Return a ref to the a-th action of agent agentI.
Index GetActionIndexByName (std::string s, Index agentI) const
 Returns the action index of the agent I's action s.
std::string GetActionName (Index a, Index i) const
 Returns the name of a particular action a of agent i.
const JointActionGetJointAction (Index i) const
 Return a ref to the i-th joint action.
const JointActionDiscreteGetJointActionDiscrete (Index i) const
 Return a ref to the i-th joint action (a JointActionDiscrete).
std::string GetJointActionName (Index a) const
 Returns the name of a particular joint action a.
const std::vector< size_t > & GetNrActions () const
 Return the number of actions vector.
size_t GetNrActions (Index AgentI) const
 Return the number of actions of agent agentI.
size_t GetNrJointActions () const
 Return the number of joiny actions.
Index IndividualToJointActionIndices (const std::vector< Index > &indivActionIndices) const
 Returns the joint action index that corresponds to the vector of specified individual action indices.
Index IndividualToJointActionIndices (const Index *IndexArray) const
 Returns the joint action index that corresponds to the array of specified individual action indices.
const std::vector< Index > & JointToIndividualActionIndices (Index jaI) const
 Returns a vector of indices to indiv.
 MADPComponentDiscreteActions ()
 Default constructor.
void Print () const
bool SetInitialized (bool b)
 Sets _m_initialized to b.
void SetNrActions (Index AI, size_t nrA)
 Sets the number of actions for agent AI.
std::string SoftPrint () const
 Prints some information on the MultiAgentDecisionProcessDiscreteInterface.
virtual ~MADPComponentDiscreteActions ()
 Destructor.
- Public Member Functions inherited from MultiAgentDecisionProcessDiscreteInterface
virtual
MultiAgentDecisionProcessDiscreteInterface
Clone () const =0
 Returns a pointer to a copy of this class.
virtual double GetInitialStateProbability (Index sI) const =0
virtual const StateDistributionGetISD () const =0
 Returns the complete initial state distribution.
virtual const JointObservationGetJointObservation (Index i) const =0
 Return a ref to the i-th joint observation.
virtual size_t GetNrJointObservations () const =0
 Return the number of joiny observations.
virtual const std::vector
< size_t > & 
GetNrObservations () const =0
 Return the number of observations vector.
virtual size_t GetNrObservations (Index AgentI) const =0
 Return the number of observations of agent agentI.
virtual size_t GetNrStates () const =0
 Return the number of states.
virtual const ObservationGetObservation (Index agentI, Index a) const =0
 Return a ref to the a-th observation of agent agentI.
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 IndividualToJointObservationIndices (const std::vector< Index > &indivObservationIndices) const =0
 Returns the joint observation index that corresponds to the vector of specified individual observation indices.
virtual const std::vector
< Index > & 
JointToIndividualObservationIndices (Index joI) 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< std::vector
< ActionDiscrete > > 
_m_actionVecs
 The vectors of actions (vectors of ActionDiscrete) for each agent.
std::vector< size_t > _m_nrActions
 The number of actions for each agent.

Private Member Functions

size_t ConstructJointActionsRecursively (Index curAgentI, JointActionDiscrete &ja, Index jaI)
 Recursively creates the joint actions.
std::string SoftPrintActionSets () const
std::string SoftPrintJointActionSet () const

Private Attributes

size_t * _m_actionStepSize
 The stepsize array - used for indiv->joint index calculation.
bool _m_cachedAllJointActions
std::map< Index, std::vector
< Index > * > * 
_m_jointActionIndices
 When not all joint actions have been created, here we cache the individual indices created by JointToIndividualActionIndices()
std::vector
< JointActionDiscrete * > 
_m_jointActionVec
 The vector storing pointers to joint actions.
bool _m_jointIndicesValid
size_t _m_nr_agents
size_t _m_nrJointActions

Static Private Attributes

bool _m_initialized

Detailed Description

MADPComponentDiscreteActions contains functionality for discrete action spaces.

It implements a part of the MultiAgentDecisionProcessDiscreteInterface.

Definition at line 54 of file MADPComponentDiscreteActions.h.

Constructor & Destructor Documentation

MADPComponentDiscreteActions::MADPComponentDiscreteActions ( )

Default constructor.

Definition at line 44 of file MADPComponentDiscreteActions.cpp.

MADPComponentDiscreteActions::~MADPComponentDiscreteActions ( )
virtual

Destructor.

Definition at line 54 of file MADPComponentDiscreteActions.cpp.

Member Function Documentation

void MADPComponentDiscreteActions::AddAction ( Index  AI,
std::string  name 
)

Add a new action with name "name" to the actions of agent AI.

Definition at line 128 of file MADPComponentDiscreteActions.cpp.

References DEBUG_ADD_DA.

Referenced by DecPOMDPDiscrete::ExtractMADPDiscrete().

size_t MADPComponentDiscreteActions::ConstructJointActions ( )

Recursively constructs all the joint actions.

Calls ConstructJointActionsRecursively() on a new (empty) joint action.

Definition at line 165 of file MADPComponentDiscreteActions.cpp.

Referenced by DecPOMDPDiscrete::ExtractMADPDiscrete(), ProblemDecTiger::ProblemDecTiger(), and ProblemFireFighting::ProblemFireFighting().

size_t MADPComponentDiscreteActions::ConstructJointActionsRecursively ( Index  curAgentI,
JointActionDiscrete ja,
Index  jaI 
)
private

Recursively creates the joint actions.

Creates (_m_jointActionVec) using _m_actionVecs (which need to be initialized before calling this function...)

Definition at line 175 of file MADPComponentDiscreteActions.cpp.

References JointActionDiscrete::AddIndividualAction(), DEBUG_CJA, JointAction::Print(), and DiscreteEntity::SetIndex().

const Action * MADPComponentDiscreteActions::GetAction ( Index  agentI,
Index  a 
) const
virtual

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

Implements MultiAgentDecisionProcessDiscreteInterface.

Definition at line 389 of file MADPComponentDiscreteActions.cpp.

Referenced by DecPOMDPDiscrete::ExtractMADPDiscrete().

const ActionDiscrete * MADPComponentDiscreteActions::GetActionDiscrete ( Index  agentI,
Index  a 
) const

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

Definition at line 393 of file MADPComponentDiscreteActions.cpp.

Index MADPComponentDiscreteActions::GetActionIndexByName ( std::string  s,
Index  agentI 
) const

Returns the action index of the agent I's action s.

Throws an exception if there is no action with name s.

Definition at line 357 of file MADPComponentDiscreteActions.cpp.

std::string MADPComponentDiscreteActions::GetActionName ( Index  a,
Index  i 
) const
inline

Returns the name of a particular action a of agent i.

Definition at line 131 of file MADPComponentDiscreteActions.h.

References _m_actionVecs.

const JointAction * MADPComponentDiscreteActions::GetJointAction ( Index  i) const
virtual

Return a ref to the i-th joint action.

Implements MultiAgentDecisionProcessDiscreteInterface.

Definition at line 443 of file MADPComponentDiscreteActions.cpp.

const JointActionDiscrete * MADPComponentDiscreteActions::GetJointActionDiscrete ( Index  i) const

Return a ref to the i-th joint action (a JointActionDiscrete).

Definition at line 419 of file MADPComponentDiscreteActions.cpp.

Referenced by JointToIndividualActionIndices().

std::string MADPComponentDiscreteActions::GetJointActionName ( Index  a) const
inline

Returns the name of a particular joint action a.

Definition at line 135 of file MADPComponentDiscreteActions.h.

References _m_jointActionVec.

Referenced by MultiAgentDecisionProcessDiscrete::SanityCheck().

const std::vector<size_t>& MADPComponentDiscreteActions::GetNrActions ( ) const
inlinevirtual

Return the number of actions vector.

Implements MultiAgentDecisionProcessDiscreteInterface.

Definition at line 118 of file MADPComponentDiscreteActions.h.

References _m_nrActions.

Referenced by DecPOMDPDiscrete::ExtractMADPDiscrete(), and JointToIndividualActionIndices().

size_t MADPComponentDiscreteActions::GetNrActions ( Index  AgentI) const
virtual

Return the number of actions of agent agentI.

Implements MultiAgentDecisionProcessDiscreteInterface.

Definition at line 310 of file MADPComponentDiscreteActions.cpp.

Index MADPComponentDiscreteActions::IndividualToJointActionIndices ( const std::vector< Index > &  indivActionIndices) const
virtual

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

Implements MultiAgentDecisionProcessDiscreteInterface.

Definition at line 464 of file MADPComponentDiscreteActions.cpp.

References IndexTools::IndividualToJointIndicesStepSize().

Index MADPComponentDiscreteActions::IndividualToJointActionIndices ( const Index *  IndexArray) const
inlinevirtual

Returns the joint action index that corresponds to the array of specified individual action indices.

Implements MultiAgentDecisionProcessDiscreteInterface.

Definition at line 157 of file MADPComponentDiscreteActions.h.

References _m_actionStepSize, _m_nr_agents, and IndexTools::IndividualToJointIndicesArrayStepSize().

const std::vector<Index>& MADPComponentDiscreteActions::JointToIndividualActionIndices ( Index  jaI) const
inlinevirtual
void MADPComponentDiscreteActions::Print ( ) const
inline

Reimplemented in MultiAgentDecisionProcessDiscrete.

Definition at line 186 of file MADPComponentDiscreteActions.h.

References SoftPrint().

bool MADPComponentDiscreteActions::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 264 of file MADPComponentDiscreteActions.cpp.

References IndexTools::CalculateStepSize().

Referenced by MultiAgentDecisionProcessDiscrete::SetInitialized().

void MADPComponentDiscreteActions::SetNrActions ( Index  AI,
size_t  nrA 
)

Sets the number of actions for agent AI.

This creates nrA unnamed actions.

Definition at line 100 of file MADPComponentDiscreteActions.cpp.

string MADPComponentDiscreteActions::SoftPrint ( ) const
virtual
string MADPComponentDiscreteActions::SoftPrintActionSets ( ) const
private

Definition at line 500 of file MADPComponentDiscreteActions.cpp.

string MADPComponentDiscreteActions::SoftPrintJointActionSet ( ) const
private

Definition at line 529 of file MADPComponentDiscreteActions.cpp.

Member Data Documentation

size_t* MADPComponentDiscreteActions::_m_actionStepSize
private

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

Definition at line 69 of file MADPComponentDiscreteActions.h.

Referenced by IndividualToJointActionIndices().

std::vector<std::vector<ActionDiscrete> > MADPComponentDiscreteActions::_m_actionVecs
protected

The vectors of actions (vectors of ActionDiscrete) for each agent.

Definition at line 91 of file MADPComponentDiscreteActions.h.

Referenced by ProblemFireFighting::ConstructActions(), ProblemDecTiger::ConstructActions(), and GetActionName().

bool MADPComponentDiscreteActions::_m_cachedAllJointActions
private

Definition at line 61 of file MADPComponentDiscreteActions.h.

Referenced by JointToIndividualActionIndices().

bool MADPComponentDiscreteActions::_m_initialized
staticprivate

Definition at line 60 of file MADPComponentDiscreteActions.h.

std::map<Index, std::vector<Index> *>* MADPComponentDiscreteActions::_m_jointActionIndices
private

When not all joint actions have been created, here we cache the individual indices created by JointToIndividualActionIndices()

Definition at line 78 of file MADPComponentDiscreteActions.h.

Referenced by JointToIndividualActionIndices().

std::vector<JointActionDiscrete*> MADPComponentDiscreteActions::_m_jointActionVec
private

The vector storing pointers to joint actions.

To use this, ConstructJointActions() should be called

Definition at line 73 of file MADPComponentDiscreteActions.h.

Referenced by GetJointActionName().

bool MADPComponentDiscreteActions::_m_jointIndicesValid
private

Definition at line 62 of file MADPComponentDiscreteActions.h.

Referenced by JointToIndividualActionIndices().

size_t MADPComponentDiscreteActions::_m_nr_agents
private

Definition at line 66 of file MADPComponentDiscreteActions.h.

Referenced by IndividualToJointActionIndices().

std::vector<size_t> MADPComponentDiscreteActions::_m_nrActions
protected

The number of actions for each agent.

Definition at line 89 of file MADPComponentDiscreteActions.h.

Referenced by ProblemFireFighting::ConstructActions(), ProblemDecTiger::ConstructActions(), and GetNrActions().

size_t MADPComponentDiscreteActions::_m_nrJointActions
private

Definition at line 63 of file MADPComponentDiscreteActions.h.


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