MultiAgentDecisionProcess
|
MADPComponentDiscreteActions contains functionality for discrete action spaces. More...
#include <MADPComponentDiscreteActions.h>
Public Member Functions | |
void | AddAction (Index AI, const std::string &name, const std::string &description="") |
Add a new action with name "name" to the actions of agent AI. More... | |
size_t | ConstructJointActions () |
Recursively constructs all the joint actions. More... | |
const Action * | GetAction (Index agentI, Index a) const |
Return a ref to the a-th action of agent agentI. More... | |
const ActionDiscrete * | GetActionDiscrete (Index agentI, Index a) const |
Return a ref to the a-th action of agent agentI. More... | |
Index | GetActionIndexByName (const std::string &s, Index agentI) const |
Returns the action index of the agent I's action s. More... | |
std::string | GetActionName (Index a, Index i) const |
Returns the name of a particular action a of agent i. More... | |
const JointAction * | GetJointAction (Index i) const |
Return a ref to the i-th joint action. More... | |
const JointActionDiscrete * | GetJointActionDiscrete (Index i) const |
Return a ref to the i-th joint action (a JointActionDiscrete). More... | |
std::string | GetJointActionName (Index a) const |
Returns the name of a particular joint action a. More... | |
const std::vector< size_t > & | GetNrActions () const |
Return the number of actions vector. More... | |
size_t | GetNrActions (Index AgentI) const |
Return the number of actions of agent agentI. More... | |
size_t | GetNrJointActions () const |
Return the number of joiny actions. More... | |
size_t | GetNrJointActions (const Scope &agScope) const |
Get the number of joint actions the agents in agScope can form. More... | |
Index | IndividualToJointActionIndices (const std::vector< Index > &indivActionIndices) const |
Returns the joint action index that corresponds to the vector of specified individual action indices. More... | |
Index | IndividualToJointActionIndices (const Index *IndexArray) const |
Returns the joint action index that corresponds to the array of specified individual action indices. More... | |
Index | IndividualToJointActionIndices (const std::vector< Index > &ja_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 > & | JointToIndividualActionIndices (Index jaI) const |
Returns a vector of indices to indiv. More... | |
std::vector< Index > | JointToIndividualActionIndices (Index ja_e, const Scope &agSC) const |
Index | JointToRestrictedJointActionIndex (Index jaI, const Scope &agSc_e) const |
MADPComponentDiscreteActions () | |
Default constructor. More... | |
MADPComponentDiscreteActions (const MADPComponentDiscreteActions &a) | |
Copy constructor. More... | |
void | Print () const |
bool | SetInitialized (bool b) |
Sets _m_initialized to b. More... | |
void | SetNrActions (Index AI, size_t nrA) |
Sets the number of actions for agent AI. More... | |
std::string | SoftPrint () const |
virtual | ~MADPComponentDiscreteActions () |
Destructor. More... | |
Private Member Functions | |
size_t | ConstructJointActionsRecursively (Index curAgentI, JointActionDiscrete &ja, Index jaI) |
Recursively creates the joint actions. More... | |
std::string | SoftPrintActionSets () const |
std::string | SoftPrintJointActionSet () const |
Private Attributes | |
size_t * | _m_actionStepSize |
The stepsize array - used for indiv->joint index calculation. More... | |
std::vector< std::vector < ActionDiscrete > > | _m_actionVecs |
The vectors of actions (vectors of ActionDiscrete) for each agent. More... | |
bool | _m_cachedAllJointActions |
bool | _m_initialized |
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() More... | |
std::vector < JointActionDiscrete * > | _m_jointActionVec |
The vector storing pointers to joint actions. More... | |
bool | _m_jointIndicesValid |
std::vector< size_t > | _m_nrActions |
The number of actions for each agent. More... | |
size_t | _m_nrJointActions |
MADPComponentDiscreteActions contains functionality for discrete action spaces.
It implements a part of the MultiAgentDecisionProcessDiscreteInterface.
MADPComponentDiscreteActions::MADPComponentDiscreteActions | ( | ) |
Default constructor.
MADPComponentDiscreteActions::MADPComponentDiscreteActions | ( | const MADPComponentDiscreteActions & | a | ) |
Copy constructor.
References _m_actionVecs, _m_cachedAllJointActions, _m_initialized, _m_jointActionIndices, _m_jointActionVec, _m_jointIndicesValid, _m_nrActions, _m_nrJointActions, and IndexTools::CalculateStepSize().
|
virtual |
Destructor.
void MADPComponentDiscreteActions::AddAction | ( | Index | AI, |
const std::string & | name, | ||
const std::string & | description = "" |
||
) |
Add a new action with name "name" to the actions of agent AI.
References DEBUG_ADD_DA.
Referenced by MultiAgentDecisionProcessDiscrete::AddAction(), and MultiAgentDecisionProcessDiscreteFactoredStates::AddAction().
size_t MADPComponentDiscreteActions::ConstructJointActions | ( | ) |
Recursively constructs all the joint actions.
Calls ConstructJointActionsRecursively() on a new (empty) joint action.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::ConstructJointActions(), and MultiAgentDecisionProcessDiscrete::ConstructJointActions().
|
private |
Recursively creates the joint actions.
Creates (_m_jointActionVec) using _m_actionVecs (which need to be initialized before calling this function...)
References JointActionDiscrete::AddIndividualAction(), DEBUG_CJA, JointAction::Print(), and DiscreteEntity::SetIndex().
Return a ref to the a-th action of agent agentI.
Referenced by MultiAgentDecisionProcessDiscrete::GetAction(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetAction().
const ActionDiscrete * MADPComponentDiscreteActions::GetActionDiscrete | ( | Index | agentI, |
Index | a | ||
) | const |
Return a ref to the a-th action of agent agentI.
Referenced by MultiAgentDecisionProcessDiscrete::GetActionDiscrete().
Index MADPComponentDiscreteActions::GetActionIndexByName | ( | const 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.
Referenced by MultiAgentDecisionProcessDiscrete::GetActionIndexByName().
Returns the name of a particular action a of agent i.
const JointAction * MADPComponentDiscreteActions::GetJointAction | ( | Index | i | ) | const |
Return a ref to the i-th joint action.
Referenced by MultiAgentDecisionProcessDiscrete::GetJointAction(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetJointAction().
const JointActionDiscrete * MADPComponentDiscreteActions::GetJointActionDiscrete | ( | Index | i | ) | const |
Return a ref to the i-th joint action (a JointActionDiscrete).
Referenced by JointToIndividualActionIndices().
|
inline |
Returns the name of a particular joint action a.
Referenced by MultiAgentDecisionProcessDiscrete::SanityCheck().
|
inline |
Return the number of actions vector.
References _m_nrActions.
Referenced by MultiAgentDecisionProcessDiscrete::GetNrActions(), MultiAgentDecisionProcessDiscreteFactoredStates::GetNrActions(), and JointToIndividualActionIndices().
size_t MADPComponentDiscreteActions::GetNrActions | ( | Index | AgentI | ) | const |
Return the number of actions of agent agentI.
size_t MADPComponentDiscreteActions::GetNrJointActions | ( | ) | const |
Return the number of joiny actions.
Referenced by MultiAgentDecisionProcessDiscrete::GetNrJointActions(), and MultiAgentDecisionProcessDiscreteFactoredStates::GetNrJointActions().
size_t MADPComponentDiscreteActions::GetNrJointActions | ( | const Scope & | agScope | ) | const |
Get the number of joint actions the agents in agScope can form.
References IndexTools::RestrictIndividualIndicesToScope(), and VectorTools::VectorProduct().
Index MADPComponentDiscreteActions::IndividualToJointActionIndices | ( | const std::vector< Index > & | indivActionIndices | ) | const |
Returns the joint action index that corresponds to the vector of specified individual action indices.
References IndexTools::IndividualToJointIndicesStepSize().
Referenced by MultiAgentDecisionProcessDiscrete::IndividualToJointActionIndices(), and MultiAgentDecisionProcessDiscreteFactoredStates::IndividualToJointActionIndices().
|
inline |
Returns the joint action index that corresponds to the array of specified individual action indices.
References IndexTools::IndividualToJointIndicesArrayStepSize().
|
inline |
Find out if there is an overflow in the joint indices variable.
References _m_jointIndicesValid.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::JointAIndicesValid().
|
inline |
Returns a vector of indices to indiv.
action indicies corr. to joint action index jaI.
References GetJointActionDiscrete(), GetNrActions(), and IndexTools::JointToIndividualIndices().
Referenced by MultiAgentDecisionProcessDiscrete::JointToIndividualActionIndices(), and MultiAgentDecisionProcessDiscreteFactoredStates::JointToIndividualActionIndices().
|
inline |
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)
References IndexTools::CalculateStepSize().
Referenced by MultiAgentDecisionProcessDiscrete::SetActionsInitialized(), MultiAgentDecisionProcessDiscreteFactoredStates::SetActionsInitialized(), MultiAgentDecisionProcessDiscrete::SetInitialized(), and MultiAgentDecisionProcessDiscreteFactoredStates::SetInitialized().
void MADPComponentDiscreteActions::SetNrActions | ( | Index | AI, |
size_t | nrA | ||
) |
Sets the number of actions for agent AI.
This creates nrA unnamed actions.
Referenced by MultiAgentDecisionProcessDiscrete::SetNrActions(), and MultiAgentDecisionProcessDiscreteFactoredStates::SetNrActions().
string MADPComponentDiscreteActions::SoftPrint | ( | ) | const |
References DEBUG_MADP_DA.
Referenced by Print(), MultiAgentDecisionProcessDiscrete::SoftPrint(), and MultiAgentDecisionProcessDiscreteFactoredStates::SoftPrint().
|
private |
|
private |
|
private |
The stepsize array - used for indiv->joint index calculation.
|
private |
The vectors of actions (vectors of ActionDiscrete) for each agent.
Referenced by MADPComponentDiscreteActions().
|
private |
Referenced by MADPComponentDiscreteActions().
|
private |
Referenced by MADPComponentDiscreteActions().
When not all joint actions have been created, here we cache the individual indices created by JointToIndividualActionIndices()
Referenced by MADPComponentDiscreteActions().
|
private |
The vector storing pointers to joint actions.
To use this, ConstructJointActions() should be called
Referenced by MADPComponentDiscreteActions().
|
private |
Referenced by JointIndicesValid(), and MADPComponentDiscreteActions().
|
private |
The number of actions for each agent.
Referenced by GetNrActions(), and MADPComponentDiscreteActions().
|
private |
Referenced by MADPComponentDiscreteActions().