MultiAgentDecisionProcess  Release 0.2.1
BayesianGameBase Class Reference

BayesianGameBase is a class that represents a Bayesian game. More...

#include <BayesianGameBase.h>

+ Inheritance diagram for BayesianGameBase:
+ Collaboration diagram for BayesianGameBase:

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.
- Public Member Functions inherited from Interface_ProblemToPolicyDiscretePure
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.
- Public Member Functions inherited from Interface_ProblemToPolicyDiscrete
 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

Detailed Description

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.

Member Typedef Documentation

typedef boost::numeric::ublas::mapped_vector<double> BayesianGameBase::SparseVector
private

Definition at line 61 of file BayesianGameBase.h.

Constructor & Destructor Documentation

BayesianGameBase::BayesianGameBase ( )
BayesianGameBase::BayesianGameBase ( const size_t  nrAgents,
const std::vector< size_t > &  nrActions,
const std::vector< size_t > &  nrTypes,
int  verboseness = 0 
)
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.

Member Function Documentation

void BayesianGameBase::AddProbability ( const Index  i,
const double  p 
)
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.

void BayesianGameBase::AddProbability ( const std::vector< Index > &  indIndices,
const double  p 
)
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().

bool BayesianGameBase::AreCachedJointToIndivIndices ( const PolicyGlobals::IndexDomainCategory  pdc) const
virtual
bool BayesianGameBase::CacheJointToIndivAOH_Indices ( ) const
inline

Definition at line 251 of file BayesianGameBase.h.

Referenced by AreCachedJointToIndivIndices().

bool BayesianGameBase::CacheJointToIndivOH_Indices ( ) const
inline

Definition at line 250 of file BayesianGameBase.h.

Referenced by AreCachedJointToIndivIndices().

bool BayesianGameBase::CacheJointToIndivType_Indices ( ) const
inline

Definition at line 249 of file BayesianGameBase.h.

Referenced by AreCachedJointToIndivIndices().

PolicyGlobals::IndexDomainCategory BayesianGameBase::GetDefaultIndexDomCat ( ) const
virtual

Return the default IndexDomainCategory for the problem.

Implements Interface_ProblemToPolicyDiscrete.

Definition at line 192 of file BayesianGameBase.cpp.

References PolicyGlobals::TYPE_INDEX.

size_t BayesianGameBase::GetNrActions ( Index  agentI) const
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().

const std::vector<size_t>& BayesianGameBase::GetNrActions ( ) const
inline

Definition at line 206 of file BayesianGameBase.h.

References _m_nrActions.

size_t BayesianGameBase::GetNrJointActions ( ) const
inline
LIndex BayesianGameBase::GetNrPolicies ( Index  ag) const
inline
size_t BayesianGameBase::GetNrPolicyDomainElements ( Index  agentI,
PolicyGlobals::IndexDomainCategory  cat,
size_t  depth = MAXHORIZON 
) const
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.

const std::vector<size_t>& BayesianGameBase::GetNrTypes ( ) const
inline
size_t BayesianGameBase::GetNrTypes ( Index  agI) const
inline

Definition at line 134 of file BayesianGameBase.h.

References _m_nrTypes.

double BayesianGameBase::GetProbability ( const std::vector< Index > &  indIndices)
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().

Index BayesianGameBase::IndividualToJointActionIndices ( const Index *  indivIndices) const
inlinevirtual
Index BayesianGameBase::IndividualToJointActionIndices ( const std::vector< Index > &  indivIndices) const
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().

Index BayesianGameBase::IndividualToJointTypeIndices ( const std::vector< Index > &  indices) const
inline
std::vector<Index> BayesianGameBase::JointToIndividualActionIndices ( Index  jaI) const
inline
std::vector<Index> BayesianGameBase::JointToIndividualPolicyDomainIndices ( Index  jdI,
PolicyGlobals::IndexDomainCategory  cat 
) const
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.

const std::vector<Index>& BayesianGameBase::JointToIndividualPolicyDomainIndicesRef ( Index  jdI,
PolicyGlobals::IndexDomainCategory  cat 
) const
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.

void BayesianGameBase::Print ( ) const
inline
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().

virtual void BayesianGameBase::SanityCheck ( void  )
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.

void BayesianGameBase::SetProbability ( const Index  i,
const double  p 
)
inline
void BayesianGameBase::SetProbability ( const std::vector< Index > &  indIndices,
const double  p 
)
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
string BayesianGameBase::SoftPrintAction ( Index  agentI,
Index  actionI 
) const
virtual

Implements Interface_ProblemToPolicyDiscrete.

Definition at line 157 of file BayesianGameBase.cpp.

string BayesianGameBase::SoftPrintPolicyDomainElement ( Index  agentI,
Index  typeIndex,
PolicyGlobals::IndexDomainCategory  cat 
) const
virtual

Implements Interface_ProblemToPolicyDiscrete.

Definition at line 147 of file BayesianGameBase.cpp.

References PolicyGlobals::TYPE_INDEX.

Member Data Documentation

bool BayesianGameBase::_m_initialized
protected

private bool to indicate whether this BG is initialized.

Definition at line 71 of file BayesianGameBase.h.

Referenced by BayesianGameBase(), and SetInitialized().

std::vector< std::vector<Index> >* BayesianGameBase::_m_jointToIndTypes
private

An joint type -> indiv. type indices cache:

Definition at line 65 of file BayesianGameBase.h.

Referenced by BayesianGameBase(), and JointToIndividualTypeIndices().

std::map<Index, std::vector<Index> >* BayesianGameBase::_m_jointToIndTypesMap
private

An joint type -> indiv. type indices cache:

Definition at line 67 of file BayesianGameBase.h.

Referenced by BayesianGameBase(), and JointToIndividualTypeIndices().

std::vector<double> BayesianGameBase::_m_jTypeProbs
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().

SparseVector BayesianGameBase::_m_jTypeProbsSparse
private
std::vector<size_t> BayesianGameBase::_m_nrActions
protected

the number of actions for each agent

Definition at line 79 of file BayesianGameBase.h.

Referenced by BayesianGameBase(), GetNrActions(), and SoftPrint().

size_t BayesianGameBase::_m_nrAgents
protected
size_t BayesianGameBase::_m_nrJA
protected
size_t BayesianGameBase::_m_nrJTypes
protected
std::vector<size_t> BayesianGameBase::_m_nrTypes
protected

the number of types for each agent

Definition at line 81 of file BayesianGameBase.h.

Referenced by BayesianGameBase(), GetNrPolicyDomainElements(), GetNrTypes(), JointToIndividualTypeIndices(), and SoftPrint().

size_t* BayesianGameBase::_m_stepSizeActions
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().

size_t* BayesianGameBase::_m_stepSizeTypes
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().

bool BayesianGameBase::_m_useSparse
private
int BayesianGameBase::_m_verboseness
protected

_m_verboseness >0 verbose, <0 is quiet

Definition at line 74 of file BayesianGameBase.h.


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