MultiAgentDecisionProcess
Release 0.2.1
|
BayesianGameBase is a class that represents a Bayesian game. More...
#include <BayesianGameBase.h>
Public Member Functions | |
void | AddProbability (const Index i, const double p) |
Adds p to the probability of joint type i. | |
void | AddProbability (const std::vector< Index > &indIndices, const double p) |
Adds p to the probability of joint type corresponding to the individual type indices (indIndices). | |
virtual bool | AreCachedJointToIndivIndices (const PolicyGlobals::IndexDomainCategory pdc) const |
Check whether certain index conversions are cached. | |
BayesianGameBase () | |
BayesianGameBase (const size_t nrAgents, const std::vector< size_t > &nrActions, const std::vector< size_t > &nrTypes, int verboseness=0) | |
BayesianGameBase (const BayesianGameBase &a) | |
Copy constructor. | |
bool | CacheJointToIndivAOH_Indices () const |
bool | CacheJointToIndivOH_Indices () const |
bool | CacheJointToIndivType_Indices () const |
virtual PolicyGlobals::IndexDomainCategory | GetDefaultIndexDomCat () const |
Return the default IndexDomainCategory for the problem. | |
size_t | GetNrActions (Index agentI) const |
Get the number of invididual actions of a particular agent. | |
const std::vector< size_t > & | GetNrActions () const |
size_t | GetNrAgents () const |
implement the Interface_ProblemToPolicyDiscrete interface: | |
size_t | GetNrJointActions () const |
Get the number of joint actions. | |
LIndex | GetNrJointPolicies () const |
size_t | GetNrJointTypes () const |
LIndex | GetNrPolicies (Index ag) const |
size_t | GetNrPolicyDomainElements (Index agentI, PolicyGlobals::IndexDomainCategory cat, size_t depth=MAXHORIZON) const |
Get the number of elements in the domain of an agent's policy. | |
const std::vector< size_t > & | GetNrTypes () const |
size_t | GetNrTypes (Index agI) const |
virtual double | GetProbability (const Index i) const |
Gets the probability of joint type i. | |
double | GetProbability (const std::vector< Index > &indIndices) |
Gets the probability of joint type corresponding to the individual type indices (indIndices) | |
Index | IndividualToJointActionIndices (const Index *IndArr) const |
Converts individual action indices to a joint action index. | |
Index | IndividualToJointActionIndices (const std::vector< Index > &indices) const |
Converts individual action indices to a joint action index. | |
Index | IndividualToJointTypeIndices (const std::vector< Index > &indices) const |
std::vector< Index > | JointToIndividualActionIndices (Index jaI) const |
std::vector< Index > | JointToIndividualPolicyDomainIndices (Index jdI, PolicyGlobals::IndexDomainCategory cat) const |
implementation of JointToIndividualPolicyDomainIndices | |
const std::vector< Index > & | JointToIndividualPolicyDomainIndicesRef (Index jdI, PolicyGlobals::IndexDomainCategory cat) const |
implementation of JointToIndividualPolicyDomainIndicesRef | |
const std::vector< Index > & | JointToIndividualTypeIndices (Index jTypeI) const |
void | Print () const |
Print this BayesianGameBase to cout. | |
void | PrintAction (Index agentI, Index actionI) const |
y | |
void | PrintPolicyDomain (Index agentI, Index typeIndex) const |
bool | SanityCheck () const |
virtual void | SanityCheck () |
void | SanityCheckBGBase () |
bool | SetInitialized (bool b) |
Sets the initialized status to b. | |
void | SetProbability (const Index i, const double p) |
Sets the probability of joint type i to p. | |
void | SetProbability (const std::vector< Index > &indIndices, const double p) |
Sets the probability of joint type corresponding to the individual type indices (indIndices) to p. | |
std::string | SoftPrint () const |
Prints a description of this BayesianGameBase to a string. | |
std::string | SoftPrintAction (Index agentI, Index actionI) const |
std::string | SoftPrintPolicyDomainElement (Index agentI, Index typeIndex, PolicyGlobals::IndexDomainCategory cat) const |
~BayesianGameBase () | |
Destructor. | |
![]() | |
LIndex | GetNrJointPolicies (PolicyGlobals::IndexDomainCategory cat, size_t depth=MAXHORIZON) const |
Get the number of joint policies, given the policy's domain. | |
LIndex | GetNrPolicies (Index ag, PolicyGlobals::IndexDomainCategory cat, size_t depth=MAXHORIZON) const |
Get the number of policies for an agent, given the policy's domain. | |
virtual | ~Interface_ProblemToPolicyDiscretePure () |
Destructor. | |
![]() | |
Interface_ProblemToPolicyDiscrete () | |
(default) Constructor | |
virtual | ~Interface_ProblemToPolicyDiscrete () |
Destructor. |
Protected Attributes | |
bool | _m_initialized |
private bool to indicate whether this BG is initialized. | |
std::vector< size_t > | _m_nrActions |
the number of actions for each agent | |
size_t | _m_nrAgents |
the number of players (or agents) | |
size_t | _m_nrJA |
the number of joint types: | |
size_t | _m_nrJTypes |
the number of joint actions: | |
std::vector< size_t > | _m_nrTypes |
the number of types for each agent | |
size_t * | _m_stepSizeActions |
an size_t array that caches the stepsize array for actions: | |
size_t * | _m_stepSizeTypes |
an size_t array that caches the stepsize array for types: | |
int | _m_verboseness |
_m_verboseness >0 verbose, <0 is quiet |
Private Types | |
typedef boost::numeric::ublas::mapped_vector < double > | SparseVector |
Private Attributes | |
std::vector< std::vector < Index > > * | _m_jointToIndTypes |
An joint type -> indiv. type indices cache: | |
std::map< Index, std::vector < Index > > * | _m_jointToIndTypesMap |
An joint type -> indiv. type indices cache: | |
std::vector< double > | _m_jTypeProbs |
the probability distribution over joint types. A mapping from joint indices to probabilities | |
SparseVector | _m_jTypeProbsSparse |
bool | _m_useSparse |
BayesianGameBase is a class that represents a Bayesian game.
This is a self contained class - meaning that it does not depend on any Multi-agent decision problem or Planning unit. This implies that, in order to convert a time-step of a MADP Planning Unit to a Bayesian game, indices of observation(-action) histories have to be converted. This class uses its own indices.
Definition at line 51 of file BayesianGameBase.h.
|
private |
Definition at line 61 of file BayesianGameBase.h.
BayesianGameBase::BayesianGameBase | ( | ) |
Definition at line 34 of file BayesianGameBase.cpp.
References _m_initialized, _m_jointToIndTypes, _m_jTypeProbs, _m_nrActions, _m_nrAgents, _m_nrJA, _m_nrJTypes, _m_nrTypes, _m_stepSizeActions, and _m_stepSizeTypes.
BayesianGameBase::BayesianGameBase | ( | const size_t | nrAgents, |
const std::vector< size_t > & | nrActions, | ||
const std::vector< size_t > & | nrTypes, | ||
int | verboseness = 0 |
||
) |
Definition at line 50 of file BayesianGameBase.cpp.
References _m_initialized, _m_jointToIndTypes, _m_jointToIndTypesMap, _m_jTypeProbs, _m_jTypeProbsSparse, _m_nrActions, _m_nrAgents, _m_nrJA, _m_nrJTypes, _m_nrTypes, _m_stepSizeActions, _m_stepSizeTypes, _m_useSparse, and IndexTools::CalculateStepSize().
BayesianGameBase::BayesianGameBase | ( | const BayesianGameBase & | a | ) |
Copy constructor.
Definition at line 112 of file BayesianGameBase.cpp.
BayesianGameBase::~BayesianGameBase | ( | ) |
Destructor.
Definition at line 118 of file BayesianGameBase.cpp.
References _m_stepSizeActions, and _m_stepSizeTypes.
|
inline |
Adds p to the probability of joint type i.
Definition at line 121 of file BayesianGameBase.h.
References _m_jTypeProbs, _m_jTypeProbsSparse, and _m_useSparse.
|
inline |
Adds p to the probability of joint type corresponding to the individual type indices (indIndices).
Definition at line 126 of file BayesianGameBase.h.
References AddProbability(), and IndividualToJointTypeIndices().
Referenced by AddProbability().
|
virtual |
Check whether certain index conversions are cached.
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 172 of file BayesianGameBase.cpp.
References PolicyGlobals::AOHIST_INDEX, CacheJointToIndivAOH_Indices(), CacheJointToIndivOH_Indices(), CacheJointToIndivType_Indices(), PolicyGlobals::OHIST_INDEX, and PolicyGlobals::TYPE_INDEX.
|
inline |
Definition at line 251 of file BayesianGameBase.h.
Referenced by AreCachedJointToIndivIndices().
|
inline |
Definition at line 250 of file BayesianGameBase.h.
Referenced by AreCachedJointToIndivIndices().
|
inline |
Definition at line 249 of file BayesianGameBase.h.
Referenced by AreCachedJointToIndivIndices().
|
virtual |
Return the default IndexDomainCategory for the problem.
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 192 of file BayesianGameBase.cpp.
References PolicyGlobals::TYPE_INDEX.
|
inlinevirtual |
Get the number of invididual actions of a particular agent.
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 204 of file BayesianGameBase.h.
References _m_nrActions.
Referenced by BGIP_SolverAlternatingMaximization< JP >::ComputeBestResponse().
|
inline |
Definition at line 206 of file BayesianGameBase.h.
References _m_nrActions.
|
inlinevirtual |
implement the Interface_ProblemToPolicyDiscrete interface:
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 202 of file BayesianGameBase.h.
References _m_nrAgents.
Referenced by BayesianGameForDecPOMDPStage::ConstructExtendedPolicy(), BayesianGameForDecPOMDPStage::Fill_FirstOHtsI(), BayesianGameForDecPOMDPStage::Fill_joI_Array(), and BGIP_SolverAlternatingMaximization< JP >::Solve().
|
inline |
Get the number of joint actions.
Reimplemented from Interface_ProblemToPolicyDiscrete.
Definition at line 131 of file BayesianGameBase.h.
References _m_nrJA.
Referenced by BayesianGameForDecPOMDPStage::ComputeAllImmediateRewards(), BayesianGameIdenticalPayoff::GenerateRandomBG(), and BayesianGameForDecPOMDPStage::Initialize().
|
inline |
Definition at line 215 of file BayesianGameBase.h.
References Interface_ProblemToPolicyDiscretePure::GetNrJointPolicies(), and PolicyGlobals::TYPE_INDEX.
Referenced by AlphaVectorBG::BeliefBackupExhaustiveStoreAll(), GMAA_MAAstar::ConstructAndValuateNextPolicies(), and BGIP_SolverBruteForceSearch< JP >::Solve().
|
inline |
Definition at line 132 of file BayesianGameBase.h.
References _m_nrJTypes.
Referenced by BayesianGameForDecPOMDPStage::ComputeAllImmediateRewards(), BGIP_SolverAlternatingMaximization< JP >::ComputeBestResponse(), BayesianGameForDecPOMDPStage::ComputeDiscountedImmediateRewardForJPol(), GMAA_MAAstar::ConstructAndValuateNextPolicies(), BayesianGameIdenticalPayoffSolver< JointPolicyPureVector >::Evaluate(), BayesianGameIdenticalPayoff::GenerateRandomBG(), BGIP_SolverRandom::Solve(), and BGIP_SolverBruteForceSearch< JP >::Solve().
|
inline |
Definition at line 212 of file BayesianGameBase.h.
References Interface_ProblemToPolicyDiscretePure::GetNrPolicies(), and PolicyGlobals::TYPE_INDEX.
|
virtual |
Get the number of elements in the domain of an agent's policy.
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 198 of file BayesianGameBase.cpp.
References _m_nrTypes, and Globals::MAXHORIZON.
|
inline |
Definition at line 133 of file BayesianGameBase.h.
References _m_nrTypes.
Referenced by BGIP_SolverAlternatingMaximization< JP >::ComputeBestResponse(), GMAA_MAAstar::ConstructAndValuateNextPolicies(), and GMAA_kGMAA::ConstructAndValuateNextPolicies().
|
inline |
Definition at line 134 of file BayesianGameBase.h.
References _m_nrTypes.
|
inlinevirtual |
Gets the probability of joint type i.
Definition at line 137 of file BayesianGameBase.h.
References _m_jTypeProbs, _m_jTypeProbsSparse, and _m_useSparse.
Referenced by BGIP_SolverAlternatingMaximization< JP >::ComputeBestResponse(), BayesianGameForDecPOMDPStage::ComputeDiscountedImmediateRewardForJPol(), GMAA_MAAstar::ConstructAndValuateNextPolicies(), BayesianGameIdenticalPayoffSolver< JointPolicyPureVector >::Evaluate(), SanityCheck(), SanityCheckBGBase(), BayesianGameIdenticalPayoff::SoftPrintUtilForJointType(), BGIP_SolverRandom::Solve(), and BGIP_SolverBruteForceSearch< JP >::Solve().
|
inline |
Gets the probability of joint type corresponding to the individual type indices (indIndices)
Definition at line 142 of file BayesianGameBase.h.
References GetProbability(), and IndividualToJointTypeIndices().
Referenced by GetProbability().
|
inlinevirtual |
Converts individual action indices to a joint action index.
indivIndices is an array of size GetNrAgents()
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 150 of file BayesianGameBase.h.
References _m_nrAgents, _m_stepSizeActions, and IndexTools::IndividualToJointIndicesArrayStepSize().
Referenced by BGIP_SolverAlternatingMaximization< JP >::ComputeBestResponse(), BayesianGameIdenticalPayoff::GetUtility(), and BayesianGameIdenticalPayoff::SetUtility().
|
inlinevirtual |
Converts individual action indices to a joint action index.
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 153 of file BayesianGameBase.h.
References _m_stepSizeActions, and IndexTools::IndividualToJointIndicesStepSize().
|
inline |
Definition at line 158 of file BayesianGameBase.h.
References _m_stepSizeTypes, and IndexTools::IndividualToJointIndicesStepSize().
Referenced by AddProbability(), GetProbability(), BayesianGameIdenticalPayoff::GetUtility(), SetProbability(), and BayesianGameIdenticalPayoff::SetUtility().
|
inline |
Definition at line 161 of file BayesianGameBase.h.
References _m_nrAgents, _m_stepSizeActions, and IndexTools::JointToIndividualIndicesStepSize().
Referenced by BGIP_SolverAlternatingMaximization< JP >::ComputeBestResponse().
|
inlinevirtual |
implementation of JointToIndividualPolicyDomainIndices
(specified in the Interface_ProblemToPolicyDiscrete )
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 226 of file BayesianGameBase.h.
References JointToIndividualTypeIndices(), and PolicyGlobals::TYPE_INDEX.
|
inlinevirtual |
implementation of JointToIndividualPolicyDomainIndicesRef
(specified in the Interface_ProblemToPolicyDiscrete )
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 237 of file BayesianGameBase.h.
References JointToIndividualTypeIndices(), and PolicyGlobals::TYPE_INDEX.
|
inline |
Definition at line 168 of file BayesianGameBase.h.
References _m_jointToIndTypes, _m_jointToIndTypesMap, _m_nrTypes, _m_useSparse, and IndexTools::JointToIndividualIndices().
Referenced by BGIP_SolverAlternatingMaximization< JP >::ComputeBestResponse(), BayesianGameForDecPOMDPStage::Initialize(), JointToIndividualPolicyDomainIndices(), and JointToIndividualPolicyDomainIndicesRef().
|
inline |
Print this BayesianGameBase to cout.
Reimplemented in BayesianGameForDecPOMDPStage, BayesianGameIdenticalPayoff, BayesianGame, and BayesianGameIdenticalPayoffInterface.
Definition at line 195 of file BayesianGameBase.h.
References SoftPrint().
void BayesianGameBase::PrintAction | ( | Index | agentI, |
Index | actionI | ||
) | const |
y
Definition at line 167 of file BayesianGameBase.cpp.
void BayesianGameBase::PrintPolicyDomain | ( | Index | agentI, |
Index | typeIndex | ||
) | const |
Definition at line 163 of file BayesianGameBase.cpp.
bool BayesianGameBase::SanityCheck | ( | void | ) | const |
Definition at line 211 of file BayesianGameBase.cpp.
References _m_nrJTypes, Globals::EqualProbability(), and GetProbability().
|
inlinevirtual |
Definition at line 279 of file BayesianGameBase.h.
References SanityCheckBGBase().
void BayesianGameBase::SanityCheckBGBase | ( | ) |
Definition at line 226 of file BayesianGameBase.cpp.
References _m_jTypeProbs, Globals::EqualProbability(), and GetProbability().
Referenced by SanityCheck().
bool BayesianGameBase::SetInitialized | ( | bool | b | ) |
Sets the initialized status to b.
When setting to true - checks are performed to see if this is a consistent Bayesian Game.
Reimplemented in BayesianGameIdenticalPayoff, and BayesianGame.
Definition at line 124 of file BayesianGameBase.cpp.
References _m_initialized.
|
inline |
Sets the probability of joint type i to p.
Definition at line 113 of file BayesianGameBase.h.
References _m_jTypeProbs, _m_jTypeProbsSparse, and _m_useSparse.
Referenced by AlphaVectorBG::BeliefBackupBGIP_Solver(), QPOMDP::ComputeRecursively(), QBG::ComputeRecursively(), QBG::ComputeRecursivelyNoCache(), BayesianGameIdenticalPayoff::GenerateRandomBG(), and BayesianGameForDecPOMDPStage::Initialize().
|
inline |
Sets the probability of joint type corresponding to the individual type indices (indIndices) to p.
Definition at line 118 of file BayesianGameBase.h.
References IndividualToJointTypeIndices(), and SetProbability().
Referenced by SetProbability().
string BayesianGameBase::SoftPrint | ( | void | ) | const |
Prints a description of this BayesianGameBase to a string.
Reimplemented in BayesianGameForDecPOMDPStage, BayesianGameIdenticalPayoff, and BayesianGameIdenticalPayoffInterface.
Definition at line 131 of file BayesianGameBase.cpp.
References _m_jTypeProbs, _m_nrActions, _m_nrAgents, _m_nrJA, _m_nrJTypes, _m_nrTypes, and PrintTools::SoftPrintVector().
Referenced by Print().
|
virtual |
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 157 of file BayesianGameBase.cpp.
|
virtual |
Implements Interface_ProblemToPolicyDiscrete.
Definition at line 147 of file BayesianGameBase.cpp.
References PolicyGlobals::TYPE_INDEX.
|
protected |
private bool to indicate whether this BG is initialized.
Definition at line 71 of file BayesianGameBase.h.
Referenced by BayesianGameBase(), and SetInitialized().
|
private |
An joint type -> indiv. type indices cache:
Definition at line 65 of file BayesianGameBase.h.
Referenced by BayesianGameBase(), and JointToIndividualTypeIndices().
|
private |
An joint type -> indiv. type indices cache:
Definition at line 67 of file BayesianGameBase.h.
Referenced by BayesianGameBase(), and JointToIndividualTypeIndices().
|
private |
the probability distribution over joint types. A mapping from joint indices to probabilities
Definition at line 60 of file BayesianGameBase.h.
Referenced by AddProbability(), BayesianGameBase(), GetProbability(), SanityCheckBGBase(), SetProbability(), and SoftPrint().
|
private |
Definition at line 62 of file BayesianGameBase.h.
Referenced by AddProbability(), BayesianGameBase(), GetProbability(), and SetProbability().
|
protected |
the number of actions for each agent
Definition at line 79 of file BayesianGameBase.h.
Referenced by BayesianGameBase(), GetNrActions(), and SoftPrint().
|
protected |
the number of players (or agents)
Definition at line 77 of file BayesianGameBase.h.
Referenced by BayesianGame::BayesianGame(), BayesianGameBase(), GetNrAgents(), IndividualToJointActionIndices(), JointToIndividualActionIndices(), BayesianGame::Print(), and SoftPrint().
|
protected |
the number of joint types:
Definition at line 85 of file BayesianGameBase.h.
Referenced by BayesianGame::BayesianGame(), BayesianGameBase(), GetNrJointActions(), BayesianGameIdenticalPayoff::SoftPrint(), SoftPrint(), and BayesianGameIdenticalPayoff::SoftPrintUtilForJointType().
|
protected |
the number of joint actions:
Definition at line 83 of file BayesianGameBase.h.
Referenced by BayesianGame::BayesianGame(), BayesianGameBase(), GetNrJointTypes(), SanityCheck(), BayesianGameIdenticalPayoff::SoftPrint(), and SoftPrint().
|
protected |
the number of types for each agent
Definition at line 81 of file BayesianGameBase.h.
Referenced by BayesianGameBase(), GetNrPolicyDomainElements(), GetNrTypes(), JointToIndividualTypeIndices(), and SoftPrint().
|
protected |
an size_t array that caches the stepsize array for actions:
Definition at line 88 of file BayesianGameBase.h.
Referenced by BayesianGameBase(), IndividualToJointActionIndices(), JointToIndividualActionIndices(), and ~BayesianGameBase().
|
protected |
an size_t array that caches the stepsize array for types:
Definition at line 90 of file BayesianGameBase.h.
Referenced by BayesianGameBase(), IndividualToJointTypeIndices(), and ~BayesianGameBase().
|
private |
Definition at line 57 of file BayesianGameBase.h.
Referenced by AddProbability(), BayesianGameBase(), GetProbability(), JointToIndividualTypeIndices(), and SetProbability().
|
protected |
_m_verboseness >0 verbose, <0 is quiet
Definition at line 74 of file BayesianGameBase.h.