MultiAgentDecisionProcess
BayesianGameBase Class Reference

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

#include <BayesianGameBase.h>

Inheritance diagram for BayesianGameBase:
[legend]

Public Member Functions

void AddProbability (Index i, double p)
 Adds p to the probability of joint type i. More...
 
void AddProbability (const std::vector< Index > &indIndices, double p)
 Adds p to the probability of joint type corresponding to the individual type indices (indIndices). More...
 
virtual bool AreCachedJointToIndivIndices (const PolicyGlobals::PolicyDomainCategory pdc) const
 Check whether certain index conversions are cached. More...
 
 BayesianGameBase ()
 
 BayesianGameBase (size_t nrAgents, const std::vector< size_t > &nrActions, const std::vector< size_t > &nrTypes, int verboseness=0)
 
 BayesianGameBase (const BayesianGameBase &a)
 Copy constructor. More...
 
bool CacheJointToIndivAOH_Indices () const
 
bool CacheJointToIndivOH_Indices () const
 
bool CacheJointToIndivType_Indices () const
 
virtual
PolicyGlobals::PolicyDomainCategory 
GetDefaultIndexDomCat () const
 Return the default PolicyDomainCategory for the problem. More...
 
size_t GetNrActions (Index agentI) const
 Get the number of invididual actions of a particular agent. More...
 
const std::vector< size_t > & GetNrActions () const
 
size_t GetNrAgents () const
 implement the Interface_ProblemToPolicyDiscrete interface: More...
 
size_t GetNrJointActions () const
 
LIndex GetNrJointPolicies () const
 
size_t GetNrJointTypes () const
 
LIndex GetNrPolicies (Index ag) const
 
size_t GetNrPolicyDomainElements (Index agentI, PolicyGlobals::PolicyDomainCategory cat, size_t depth=MAXHORIZON) const
 Get the number of elements in the domain of an agent's policy. More...
 
const std::vector< size_t > & GetNrTypes () const
 
size_t GetNrTypes (Index agI) const
 
virtual double GetProbability (Index i) const
 Gets the probability of joint type i. More...
 
virtual double GetProbability (const std::vector< Index > &indIndices) const
 Gets the probability of joint type corresponding to the individual type indices (indIndices) More...
 
Index IndividualToJointActionIndices (const Index *IndArr) const
 Converts individual action indices to a joint action index. More...
 
Index IndividualToJointActionIndices (const std::vector< Index > &indices) const
 Converts individual action indices to a joint action index. More...
 
Index IndividualToJointTypeIndices (const std::vector< Index > &indices) const
 
std::vector< IndexJointToIndividualActionIndices (Index jaI) const
 
std::vector< IndexJointToIndividualPolicyDomainIndices (Index jdI, PolicyGlobals::PolicyDomainCategory cat) const
 implementation of JointToIndividualPolicyDomainIndices More...
 
const std::vector< Index > & JointToIndividualPolicyDomainIndicesRef (Index jdI, PolicyGlobals::PolicyDomainCategory cat) const
 implementation of JointToIndividualPolicyDomainIndicesRef More...
 
const std::vector< Index > & JointToIndividualTypeIndices (Index jTypeI) const
 
BayesianGameBaseoperator= (const BayesianGameBase &o)
 
void Print () const
 Print this BayesianGameBase to cout. More...
 
virtual void SanityCheck ()
 Sanity check should be overriden by classes that do not use the implementation provided by this class (e.g. More...
 
void SanityCheckBGBase ()
 
bool SetInitialized (bool b)
 Sets the initialized status to b. More...
 
void SetProbability (Index i, double p)
 Sets the probability of joint type i to p. More...
 
void SetProbability (const std::vector< Index > &indIndices, double p)
 Sets the probability of joint type corresponding to the individual type indices (indIndices) to p. More...
 
std::string SoftPrint () const
 Prints a description of this BayesianGameBase to a string. More...
 
std::string SoftPrintAction (Index agentI, Index actionI) const
 Virtual function that has to be implemented by derived class. More...
 
std::string SoftPrintPolicyDomainElement (Index agentI, Index typeIndex, PolicyGlobals::PolicyDomainCategory cat) const
 Virtual function that has to be implemented by derived class. More...
 
std::string SoftPrintSummary () const
 
std::string SoftPrintType (Index agentI, Index typeIndex) const
 
 ~BayesianGameBase ()
 Destructor. More...
 
- Public Member Functions inherited from Interface_ProblemToPolicyDiscretePure
LIndex GetNrJointPolicies (PolicyGlobals::PolicyDomainCategory cat, size_t depth=MAXHORIZON) const
 Get the number of joint policies, given the policy's domain. More...
 
LIndex GetNrPolicies (Index ag, PolicyGlobals::PolicyDomainCategory cat, size_t depth=MAXHORIZON) const
 Get the number of policies for an agent, given the policy's domain. More...
 
virtual ~Interface_ProblemToPolicyDiscretePure ()
 Destructor. More...
 
- Public Member Functions inherited from Interface_ProblemToPolicyDiscrete
size_t GetNrJointActions () const
 Get the number of joint actions. More...
 
 Interface_ProblemToPolicyDiscrete ()
 (default) Constructor More...
 
virtual ~Interface_ProblemToPolicyDiscrete ()
 Destructor. More...
 

Protected Member Functions

void ChangeNrActions (Index agI, size_t new_nr)
 
void ChangeNrTypes (Index agI, size_t new_nr)
 
void Initialize ()
 

Protected Attributes

bool _m_initialized
 private bool to indicate whether this BG is initialized. More...
 
bool _m_JAoverflow
 Boolean that indicates whether the number of joint actions can be represented by size_t (or that overflowing occurs) More...
 
bool _m_JToverflow
 Boolean that indicates whether the number of joint types can be represented by size_t (or that overflowing occurs) More...
 
std::vector< size_t > _m_nrActions
 the number of actions for each agent More...
 
size_t _m_nrAgents
 the number of players (or agents) More...
 
size_t _m_nrJA
 the number of joint types: More...
 
size_t _m_nrJTypes
 the number of joint actions: More...
 
std::vector< size_t > _m_nrTypes
 the number of types for each agent More...
 
size_t * _m_stepSizeActions
 an size_t array that caches the stepsize array for actions: More...
 
size_t * _m_stepSizeTypes
 an size_t array that caches the stepsize array for types: More...
 
int _m_verboseness
 _m_verboseness >0 verbose, <0 is quiet More...
 

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: More...
 
std::map< Index, std::vector
< Index > > * 
_m_jointToIndTypesMap
 An joint type -> indiv. type indices cache: More...
 
std::vector< double > _m_jTypeProbs
 the probability distribution over joint types. A mapping from joint indices to probabilities More...
 
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.

Member Typedef Documentation

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

Constructor & Destructor Documentation

BayesianGameBase::BayesianGameBase ( size_t  nrAgents,
const std::vector< size_t > &  nrActions,
const std::vector< size_t > &  nrTypes,
int  verboseness = 0 
)
BayesianGameBase::BayesianGameBase ( const BayesianGameBase a)
BayesianGameBase::~BayesianGameBase ( )

Member Function Documentation

void BayesianGameBase::AddProbability ( Index  i,
double  p 
)
inline

Adds p to the probability of joint type i.

Referenced by AddProbability().

void BayesianGameBase::AddProbability ( const std::vector< Index > &  indIndices,
double  p 
)
inline

Adds p to the probability of joint type corresponding to the individual type indices (indIndices).

References AddProbability(), and IndividualToJointTypeIndices().

bool BayesianGameBase::AreCachedJointToIndivIndices ( const PolicyGlobals::PolicyDomainCategory  pdc) const
virtual
bool BayesianGameBase::CacheJointToIndivAOH_Indices ( ) const
inline
bool BayesianGameBase::CacheJointToIndivOH_Indices ( ) const
inline
bool BayesianGameBase::CacheJointToIndivType_Indices ( ) const
inline
void BayesianGameBase::ChangeNrActions ( Index  agI,
size_t  new_nr 
)
protected
void BayesianGameBase::ChangeNrTypes ( Index  agI,
size_t  new_nr 
)
protected
PolicyGlobals::PolicyDomainCategory BayesianGameBase::GetDefaultIndexDomCat ( ) const
virtual

Return the default PolicyDomainCategory for the problem.

Implements Interface_ProblemToPolicyDiscrete.

References PolicyGlobals::TYPE_INDEX.

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

References _m_nrActions.

Referenced by Problem_CGBG_FF::ExportAsMAID().

LIndex BayesianGameBase::GetNrPolicies ( Index  ag) const
inline
size_t BayesianGameBase::GetNrPolicyDomainElements ( Index  agentI,
PolicyGlobals::PolicyDomainCategory  cat,
size_t  depth = MAXHORIZON 
) const
virtual

Get the number of elements in the domain of an agent's policy.

Implements Interface_ProblemToPolicyDiscrete.

References _m_nrTypes, and Globals::MAXHORIZON.

size_t BayesianGameBase::GetNrTypes ( Index  agI) const
inline
virtual double BayesianGameBase::GetProbability ( const std::vector< Index > &  indIndices) const
inlinevirtual

Gets the probability of joint type corresponding to the individual type indices (indIndices)

References GetProbability(), and IndividualToJointTypeIndices().

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.

References IndexTools::IndividualToJointIndicesStepSize().

std::vector<Index> BayesianGameBase::JointToIndividualPolicyDomainIndices ( Index  jdI,
PolicyGlobals::PolicyDomainCategory  cat 
) const
inlinevirtual

implementation of JointToIndividualPolicyDomainIndices

(specified in the Interface_ProblemToPolicyDiscrete )

Implements Interface_ProblemToPolicyDiscrete.

References JointToIndividualTypeIndices(), and PolicyGlobals::TYPE_INDEX.

const std::vector<Index>& BayesianGameBase::JointToIndividualPolicyDomainIndicesRef ( Index  jdI,
PolicyGlobals::PolicyDomainCategory  cat 
) const
inlinevirtual

implementation of JointToIndividualPolicyDomainIndicesRef

(specified in the Interface_ProblemToPolicyDiscrete )

Implements Interface_ProblemToPolicyDiscrete.

References JointToIndividualTypeIndices(), and PolicyGlobals::TYPE_INDEX.

void BayesianGameBase::Print ( ) const
inline

Print this BayesianGameBase to cout.

References SoftPrint().

Referenced by BayesianGame::Print().

virtual void BayesianGameBase::SanityCheck ( void  )
inlinevirtual

Sanity check should be overriden by classes that do not use the implementation provided by this class (e.g.

CGBGs)

References SanityCheckBGBase().

Referenced by BayesianGameCollaborativeGraphical::SetProbabilityDistribution().

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

References _m_initialized.

void BayesianGameBase::SetProbability ( const std::vector< Index > &  indIndices,
double  p 
)
inline

Sets the probability of joint type corresponding to the individual type indices (indIndices) to p.

References IndividualToJointTypeIndices(), and SetProbability().

string BayesianGameBase::SoftPrint ( void  ) const
string BayesianGameBase::SoftPrintAction ( Index  agentI,
Index  actionI 
) const
virtual

Virtual function that has to be implemented by derived class.

This should return a string describing action actionI of agent agentI.

Implements Interface_ProblemToPolicyDiscrete.

string BayesianGameBase::SoftPrintPolicyDomainElement ( Index  agentI,
Index  dIndex,
PolicyGlobals::PolicyDomainCategory  cat 
) const
virtual

Virtual function that has to be implemented by derived class.

This should return a string describing element dIndex of the domain (e.g. an observation history) of agent agentI.

Implements Interface_ProblemToPolicyDiscrete.

References SoftPrintType(), and PolicyGlobals::TYPE_INDEX.

string BayesianGameBase::SoftPrintSummary ( ) const
string BayesianGameBase::SoftPrintType ( Index  agentI,
Index  typeIndex 
) const

Member Data Documentation

bool BayesianGameBase::_m_initialized
protected

private bool to indicate whether this BG is initialized.

Referenced by BayesianGameBase(), Initialize(), operator=(), and SetInitialized().

bool BayesianGameBase::_m_JAoverflow
protected

Boolean that indicates whether the number of joint actions can be represented by size_t (or that overflowing occurs)

Referenced by BayesianGameBase(), GetNrJointActions(), and Initialize().

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

An joint type -> indiv. type indices cache:

Referenced by BayesianGameBase(), Initialize(), operator=(), and ~BayesianGameBase().

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

An joint type -> indiv. type indices cache:

Referenced by BayesianGameBase(), Initialize(), operator=(), and ~BayesianGameBase().

bool BayesianGameBase::_m_JToverflow
protected

Boolean that indicates whether the number of joint types can be represented by size_t (or that overflowing occurs)

Referenced by BayesianGameBase(), GetNrJointTypes(), Initialize(), and SanityCheckBGBase().

std::vector<double> BayesianGameBase::_m_jTypeProbs
private

the probability distribution over joint types. A mapping from joint indices to probabilities

Referenced by GetProbability(), Initialize(), operator=(), SanityCheckBGBase(), and SoftPrint().

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

an size_t array that caches the stepsize array for actions:

Referenced by BayesianGameBase(), Initialize(), operator=(), and ~BayesianGameBase().

size_t* BayesianGameBase::_m_stepSizeTypes
protected

an size_t array that caches the stepsize array for types:

Referenced by BayesianGameBase(), Initialize(), operator=(), and ~BayesianGameBase().

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

_m_verboseness >0 verbose, <0 is quiet

Referenced by operator=().