MultiAgentDecisionProcess
Release 0.2.1
|
MADPComponentDiscreteActions contains functionality for discrete action spaces. More...
#include <MADPComponentDiscreteActions.h>
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 Action * | GetAction (Index agentI, Index a) const |
Return a ref to the a-th action of agent agentI. | |
const ActionDiscrete * | GetActionDiscrete (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 JointAction * | GetJointAction (Index i) const |
Return a ref to the i-th joint action. | |
const JointActionDiscrete * | GetJointActionDiscrete (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. | |
![]() | |
virtual MultiAgentDecisionProcessDiscreteInterface * | Clone () const =0 |
Returns a pointer to a copy of this class. | |
virtual double | GetInitialStateProbability (Index sI) const =0 |
virtual const StateDistribution * | GetISD () const =0 |
Returns the complete initial state distribution. | |
virtual const JointObservation * | GetJointObservation (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 Observation * | GetObservation (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 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 | 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! | |
![]() | |
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 |
MADPComponentDiscreteActions contains functionality for discrete action spaces.
It implements a part of the MultiAgentDecisionProcessDiscreteInterface.
Definition at line 54 of file MADPComponentDiscreteActions.h.
MADPComponentDiscreteActions::MADPComponentDiscreteActions | ( | ) |
Default constructor.
Definition at line 44 of file MADPComponentDiscreteActions.cpp.
|
virtual |
Destructor.
Definition at line 54 of file MADPComponentDiscreteActions.cpp.
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().
|
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().
|
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.
|
inline |
Returns the name of a particular action a of agent i.
Definition at line 131 of file MADPComponentDiscreteActions.h.
References _m_actionVecs.
|
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().
|
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().
|
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().
|
virtual |
Return the number of actions of agent agentI.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 310 of file MADPComponentDiscreteActions.cpp.
|
virtual |
Return the number of joiny actions.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 340 of file MADPComponentDiscreteActions.cpp.
Referenced by MultiAgentDecisionProcessDiscrete::CreateNewObservationModel(), DecPOMDPDiscrete::CreateNewRewardModel(), MultiAgentDecisionProcessDiscrete::CreateNewTransitionModel(), ProblemFireFighting::FillObservationModel(), ProblemDecTiger::FillObservationModel(), ProblemFireFighting::FillRewardModel(), ProblemFireFighting::FillTransitionModel(), ProblemDecTiger::FillTransitionModel(), and MultiAgentDecisionProcessDiscrete::SanityCheck().
|
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().
|
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().
|
inlinevirtual |
Returns a vector of indices to indiv.
action indicies corr. to joint action index jaI.
Implements MultiAgentDecisionProcessDiscreteInterface.
Definition at line 163 of file MADPComponentDiscreteActions.h.
References _m_cachedAllJointActions, _m_jointActionIndices, _m_jointIndicesValid, GetJointActionDiscrete(), GetNrActions(), and IndexTools::JointToIndividualIndices().
Referenced by ProblemFireFighting::FillObservationModel(), and ProblemFireFighting::FillTransitionModel().
|
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.
|
virtual |
Prints some information on the MultiAgentDecisionProcessDiscreteInterface.
Implements MultiAgentDecisionProcessDiscreteInterface.
Reimplemented in MultiAgentDecisionProcessDiscrete, DecPOMDPDiscrete, and POSGDiscrete.
Definition at line 482 of file MADPComponentDiscreteActions.cpp.
References DEBUG_MADP_DA.
Referenced by Print().
|
private |
Definition at line 500 of file MADPComponentDiscreteActions.cpp.
|
private |
Definition at line 529 of file MADPComponentDiscreteActions.cpp.
|
private |
The stepsize array - used for indiv->joint index calculation.
Definition at line 69 of file MADPComponentDiscreteActions.h.
Referenced by IndividualToJointActionIndices().
|
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().
|
private |
Definition at line 61 of file MADPComponentDiscreteActions.h.
Referenced by JointToIndividualActionIndices().
|
staticprivate |
Definition at line 60 of file MADPComponentDiscreteActions.h.
|
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().
|
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().
|
private |
Definition at line 62 of file MADPComponentDiscreteActions.h.
Referenced by JointToIndividualActionIndices().
|
private |
Definition at line 66 of file MADPComponentDiscreteActions.h.
Referenced by IndividualToJointActionIndices().
|
protected |
The number of actions for each agent.
Definition at line 89 of file MADPComponentDiscreteActions.h.
Referenced by ProblemFireFighting::ConstructActions(), ProblemDecTiger::ConstructActions(), and GetNrActions().
|
private |
Definition at line 63 of file MADPComponentDiscreteActions.h.