MultiAgentDecisionProcess
BayesianGameCollaborativeGraphical Class Reference

BayesianGameCollaborativeGraphical represents a collaborative graphical Bayesian game. More...

#include <BayesianGameCollaborativeGraphical.h>

Inheritance diagram for BayesianGameCollaborativeGraphical:
[legend]

Public Member Functions

void AddLRF (const Scope &s)
 Add an LRF with scope s. More...
 
 BayesianGameCollaborativeGraphical ()
 Constructor without arguments. More...
 
 BayesianGameCollaborativeGraphical (size_t nrAgents, const std::vector< size_t > &nrActions, const std::vector< size_t > &nrTypes)
 Constructor - the constructor is called in the same way as a (regular) BayesianGameIdenticalPayoff, with the number of agents and the number of actions, types per agent. More...
 
 BayesianGameCollaborativeGraphical (const BayesianGameCollaborativeGraphical &a)
 Copy constructor. More...
 
virtual double ComputeValueJPol (const JointPolicyDiscretePure &jpolBG) const
 evaluates the value of a joint policy. More...
 
void DistributeProbability (Index jtI, double p)
 Set and distributes probability: More...
 
virtual void ExportAsMAID () const
 
virtual const
BayesianGameIdenticalPayoff
GetBGIPforLRF (Index e) const
 
virtual size_t GetNrJointActionsForLRF (Index e)
 Return the number of joint actions for LRF e. More...
 
virtual size_t GetNrJointTypesForLRF (Index e)
 Return the number of joint types for LRF e. More...
 
virtual size_t GetNrLRFs () const
 Return the number of agents. More...
 
virtual double GetProbability (Index e, const std::vector< Index > &indTypes) const
 
virtual double GetProbability (Index e, Index jtI_e) const
 
double GetProbability (Index jtype) const
 Gets the probability of joint type i. More...
 
std::vector< double > GetRestrictedJointTypeProbabilities (Index jtI) const
 For each LRF e this function returns the probability of the jtI_agSC{e} consistent with jtI. More...
 
virtual Scope GetScope (Index e) const
 Return the scope of LRF e. More...
 
virtual double GetUtility (Index e, Index jtI_e, Index jaI_e) const
 
virtual double GetUtility (Index e, const std::vector< Index > &indTypes_e, const std::vector< Index > &actions_e) const
 
virtual double GetUtility (Index jtype, Index ja) const
 Gets the utility for (for all agents) jtype, ja. More...
 
double GetUtility (const std::vector< Index > &indTypeIndices, const std::vector< Index > &indActionIndices) const
 Gets the utility for (for all agents) joint type corresponding to the individual type indices (indTypeIndices) and joint action corresponding to individual action indices (indActionIndices). More...
 
bool IsFullyConnected () const
 
virtual Index JointToGroupActionIndex (Index e, Index jtI) const
 Returns the group type index jaGI corresponding to joint action index jaI for LRF e. More...
 
virtual Index JointToGroupTypeIndex (Index e, Index jtI) const
 Returns the group type index jtGI corresponding to joint type index jtI for LRF e. More...
 
BayesianGameCollaborativeGraphicaloperator= (const BayesianGameCollaborativeGraphical &o)
 Copy assignment operator. More...
 
template<typename T >
std::vector< T > RestrictIndividualIndicesToScope (const std::vector< T > &indivIndices, Index LRF) const
 Restrict the vector indivIndices to the agents in the scope of LRF e (and returns that result) More...
 
void SanityCheckBGCG () const
 
virtual void SetProbability (Index jtI, double p)
 
virtual void SetProbability (Index e, const std::vector< Index > &indTypes, double p)
 
virtual void SetProbability (Index e, Index jtI_e, double p)
 
void SetProbabilityDistribution (const PDDiscreteInterface *pd)
 
virtual void SetUtility (Index e, Index jtI_e, Index jaI_e, double ut)
 
virtual void SetUtility (Index e, const std::vector< Index > &indTypes_e, const std::vector< Index > &actions_e, double ut)
 
std::string SoftPrint () const
 Prints a description of this entire BayesianGameIdenticalPayoff to a string. More...
 
std::string SoftPrintSummary () const
 
virtual ~BayesianGameCollaborativeGraphical ()
 Destructor. More...
 
- Public Member Functions inherited from BayesianGameIdenticalPayoffInterface
 BayesianGameIdenticalPayoffInterface ()
 (default) Constructor More...
 
 BayesianGameIdenticalPayoffInterface (size_t nrAgents, const std::vector< size_t > &nrActions, const std::vector< size_t > &nrTypes)
 
double ComputeValueJPol (const JointPolicyDiscretePure &jpolBG) const
 
BayesianGameIdenticalPayoffInterfaceoperator= (const BayesianGameIdenticalPayoffInterface &o)
 
virtual void Print () const
 Print this BayesianGameIdenticalPayoff to cout. More...
 
- Public Member Functions inherited from BayesianGameBase
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 (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 Attributes

std::vector< Scope_m_agentScopes
 
PDDiscreteInterface_m_jt_pd
 a pointer to a (discrete) probablity distribution over types. More...
 
std::vector
< BayesianGameIdenticalPayoff * > 
_m_LRFs
 The components or LRFs of the CGBG. More...
 
size_t _m_nrLRFs
 
- Protected Attributes inherited from BayesianGameBase
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 Member Functions

void RecurseOverAgents (Index currentAgent, std::vector< bool > &agentVisited) const
 Private helper function to figure out whether the CGBG is fully connected. More...
 

Additional Inherited Members

- Protected Member Functions inherited from BayesianGameBase
void ChangeNrActions (Index agI, size_t new_nr)
 
void ChangeNrTypes (Index agI, size_t new_nr)
 
void Initialize ()
 

Detailed Description

BayesianGameCollaborativeGraphical represents a collaborative graphical Bayesian game.

Constructor & Destructor Documentation

BayesianGameCollaborativeGraphical::BayesianGameCollaborativeGraphical ( )

Constructor without arguments.

BayesianGameCollaborativeGraphical::BayesianGameCollaborativeGraphical ( size_t  nrAgents,
const std::vector< size_t > &  nrActions,
const std::vector< size_t > &  nrTypes 
)

Constructor - the constructor is called in the same way as a (regular) BayesianGameIdenticalPayoff, with the number of agents and the number of actions, types per agent.

The LRFs (components) of the payoff functions need to be added manually with AddLRF below, and SetUtility(LRF, ...)

BayesianGameCollaborativeGraphical::BayesianGameCollaborativeGraphical ( const BayesianGameCollaborativeGraphical a)

Copy constructor.

References _m_agentScopes, _m_jt_pd, _m_LRFs, _m_nrLRFs, and PDDiscreteInterface::Clone().

BayesianGameCollaborativeGraphical::~BayesianGameCollaborativeGraphical ( )
virtual

Destructor.

References _m_jt_pd, and _m_LRFs.

Member Function Documentation

void BayesianGameCollaborativeGraphical::AddLRF ( const Scope s)
double BayesianGameCollaborativeGraphical::ComputeValueJPol ( const JointPolicyDiscretePure jpolBG) const
virtual
void BayesianGameCollaborativeGraphical::DistributeProbability ( Index  jtI,
double  p 
)

Set and distributes probability:

1) Set the probability of joint type jtI to p. 2) For each LRF e, it adds p to the probability of of the agSC_jtI ( the joint type of the agentScope of e ), that is consistent with jtI.

E.g. assume we call DistributeProbability(<2,4>, .12) if there is 2 LRFs (one with agent scope=<1>, and one with agentscope=<2>), then this adds .12 to P(LRF 1, <2>) and to P(LRF 2, <4>)

References _m_LRFs, _m_nrLRFs, BayesianGameBase::JointToIndividualTypeIndices(), RestrictIndividualIndicesToScope(), and BayesianGameBase::SetProbability().

virtual void BayesianGameCollaborativeGraphical::ExportAsMAID ( ) const
inlinevirtual
virtual const BayesianGameIdenticalPayoff* BayesianGameCollaborativeGraphical::GetBGIPforLRF ( Index  e) const
inlinevirtual
size_t BayesianGameCollaborativeGraphical::GetNrJointActionsForLRF ( Index  e)
virtual

Return the number of joint actions for LRF e.

I.e. the number of joint group actions that are relevent for LRF e. (I.e., the number of joint actions spawned by the agent scope of LRF e);

References _m_LRFs.

size_t BayesianGameCollaborativeGraphical::GetNrJointTypesForLRF ( Index  e)
virtual

Return the number of joint types for LRF e.

References _m_LRFs.

virtual size_t BayesianGameCollaborativeGraphical::GetNrLRFs ( ) const
inlinevirtual

Return the number of agents.

Return the number of agents.

References _m_nrLRFs.

Referenced by ComputeValueJPol(), and RecurseOverAgents().

double BayesianGameCollaborativeGraphical::GetProbability ( Index  e,
const std::vector< Index > &  indTypes 
) const
virtual
double BayesianGameCollaborativeGraphical::GetProbability ( Index  e,
Index  jtI_e 
) const
virtual

References _m_LRFs.

double BayesianGameCollaborativeGraphical::GetProbability ( Index  i) const
virtual

Gets the probability of joint type i.

Reimplemented from BayesianGameBase.

Reimplemented in Problem_CGBG_FF.

References _m_jt_pd, PDDiscreteInterface::Get(), and BayesianGameBase::GetProbability().

vector< double > BayesianGameCollaborativeGraphical::GetRestrictedJointTypeProbabilities ( Index  jtI) const

For each LRF e this function returns the probability of the jtI_agSC{e} consistent with jtI.

References _m_LRFs, _m_nrLRFs, GetProbability(), BayesianGameBase::JointToIndividualTypeIndices(), and RestrictIndividualIndicesToScope().

virtual Scope BayesianGameCollaborativeGraphical::GetScope ( Index  e) const
inlinevirtual

Return the scope of LRF e.

Referenced by ComputeValueJPol(), RecurseOverAgents(), and SetProbabilityDistribution().

double BayesianGameCollaborativeGraphical::GetUtility ( Index  e,
Index  jtI_e,
Index  jaI_e 
) const
virtual

References _m_LRFs.

Referenced by ComputeValueJPol(), and GetUtility().

double BayesianGameCollaborativeGraphical::GetUtility ( Index  e,
const std::vector< Index > &  indTypes_e,
const std::vector< Index > &  actions_e 
) const
virtual

References _m_LRFs.

double BayesianGameCollaborativeGraphical::GetUtility ( Index  jtype,
Index  ja 
) const
virtual

Gets the utility for (for all agents) jtype, ja.

Implements BayesianGameIdenticalPayoffInterface.

References _m_nrLRFs, GetUtility(), JointToGroupActionIndex(), and JointToGroupTypeIndex().

double BayesianGameCollaborativeGraphical::GetUtility ( const std::vector< Index > &  indTypeIndices,
const std::vector< Index > &  indActionIndices 
) const
virtual

Gets the utility for (for all agents) joint type corresponding to the individual type indices (indTypeIndices) and joint action corresponding to individual action indices (indActionIndices).

Implements BayesianGameIdenticalPayoffInterface.

bool BayesianGameCollaborativeGraphical::IsFullyConnected ( ) const
Index BayesianGameCollaborativeGraphical::JointToGroupActionIndex ( Index  e,
Index  jtI 
) const
virtual

Returns the group type index jaGI corresponding to joint action index jaI for LRF e.

References _m_LRFs, BayesianGameBase::IndividualToJointActionIndices(), BayesianGameBase::JointToIndividualActionIndices(), and RestrictIndividualIndicesToScope().

Referenced by GetUtility().

Index BayesianGameCollaborativeGraphical::JointToGroupTypeIndex ( Index  e,
Index  jtI 
) const
virtual

Returns the group type index jtGI corresponding to joint type index jtI for LRF e.

References _m_LRFs, BayesianGameBase::IndividualToJointTypeIndices(), BayesianGameBase::JointToIndividualTypeIndices(), and RestrictIndividualIndicesToScope().

Referenced by GetUtility().

BayesianGameCollaborativeGraphical & BayesianGameCollaborativeGraphical::operator= ( const BayesianGameCollaborativeGraphical o)

Copy assignment operator.

void BayesianGameCollaborativeGraphical::RecurseOverAgents ( Index  currentAgent,
std::vector< bool > &  agentVisited 
) const
private

Private helper function to figure out whether the CGBG is fully connected.

References Scope::Contains(), GetNrLRFs(), GetScope(), and Scope::Insert().

Referenced by IsFullyConnected().

template<typename T >
std::vector< T > BayesianGameCollaborativeGraphical::RestrictIndividualIndicesToScope ( const std::vector< T > &  indivIndices,
Index  LRF 
) const

Restrict the vector indivIndices to the agents in the scope of LRF e (and returns that result)

References _m_agentScopes, and IndexTools::RestrictIndividualIndicesToScope().

Referenced by DistributeProbability(), GetRestrictedJointTypeProbabilities(), JointToGroupActionIndex(), and JointToGroupTypeIndex().

void BayesianGameCollaborativeGraphical::SanityCheckBGCG ( ) const
virtual void BayesianGameCollaborativeGraphical::SetProbability ( Index  jtI,
double  p 
)
inlinevirtual
void BayesianGameCollaborativeGraphical::SetProbability ( Index  e,
const std::vector< Index > &  indTypes,
double  p 
)
virtual

References _m_LRFs.

void BayesianGameCollaborativeGraphical::SetProbability ( Index  e,
Index  jtI_e,
double  p 
)
virtual

References _m_LRFs.

void BayesianGameCollaborativeGraphical::SetUtility ( Index  e,
Index  jtI_e,
Index  jaI_e,
double  ut 
)
virtual

References _m_LRFs.

Referenced by Problem_CGBG_FF::AddEdge().

void BayesianGameCollaborativeGraphical::SetUtility ( Index  e,
const std::vector< Index > &  indTypes_e,
const std::vector< Index > &  actions_e,
double  ut 
)
virtual

References _m_LRFs.

string BayesianGameCollaborativeGraphical::SoftPrint ( void  ) const
virtual

Prints a description of this entire BayesianGameIdenticalPayoff to a string.

Implements BayesianGameIdenticalPayoffInterface.

References _m_agentScopes, _m_LRFs, _m_nrLRFs, and PrintTools::SoftPrintVector().

string BayesianGameCollaborativeGraphical::SoftPrintSummary ( ) const

Member Data Documentation

std::vector<Scope> BayesianGameCollaborativeGraphical::_m_agentScopes
protected
PDDiscreteInterface* BayesianGameCollaborativeGraphical::_m_jt_pd
protected

a pointer to a (discrete) probablity distribution over types.

It should typically be compact!

Referenced by BayesianGameCollaborativeGraphical(), GetProbability(), SetProbabilityDistribution(), and ~BayesianGameCollaborativeGraphical().