MultiAgentDecisionProcess
Problem_CGBG_FF Class Reference

Problem_CGBG_FF reprents a generalized single-shot fire fighting problem. More...

#include <Problem_CGBG_FF.h>

Inheritance diagram for Problem_CGBG_FF:
[legend]

Classes

struct  diPairComp
 

Public Types

typedef Index observation_t
 

Public Member Functions

virtual void ExportAsMAID (const std::string &suffix="", const std::string &prefix="/tmp/") const
 
void ExportToTextFiles (const std::string &suffix="", const std::string &prefix="/tmp/") const
 
double GetProbability (Index jtype) const
 Gets the probability of joint type i. More...
 
std::string GetUnixName () const
 
 Problem_CGBG_FF (size_t nrHouses, size_t nrFLs, size_t nrAgents, size_t nrActionsPerAgent, size_t nrObservedHousesPerAgent, size_t k)
 (default) Constructor More...
 
std::string SoftPrintReadableType (Index agI, Index typeI) const
 Copy assignment operator. More...
 
 ~Problem_CGBG_FF ()
 Copy constructor. More...
 
- Public Member Functions inherited from BayesianGameCollaborativeGraphical
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
 
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 Types

typedef std::pair< double, IndexdiPair
 

Private Types

typedef std::map< std::vector
< observation_t >, double > 
VecDMap
 
typedef std::pair< std::vector
< observation_t >, double > 
VecDPair
 

Private Member Functions

void AddEdge (Index hI)
 
void AssignAgentActionsToHouses ()
 
void AssignAgentTypesToHouses ()
 
double ComputeDistanceAgentToHouse (Index agI, Index hI)
 
double ComputeHouseProbability (Index hI, const Scope &tupleOfAgents, const std::vector< Index > &types) const
 
double ComputeIndividualTypeProb (Index agI, Index typeI, std::vector< Index > &FL_vec) const
 Compute the probability of an individual type given the vector of fire levels (used in MAID export) More...
 
double ComputeLocalProbability (const Scope &tupleOfAgents, const std::vector< Index > &types) const
 
double ComputeLocalUtility (Index hI, const Scope &tupleOfAgents, const std::vector< Index > &actions, const std::vector< Index > &types)
 
size_t ComputeNumberOfAgentsPresentAtHouse (Index houseI, const std::vector< Index > &a_vec) const
 
std::vector< observation_tFilterObservationsForHouse (Index hI, const Scope &tupleOfAgents, const std::vector< Index > &types) const
 Extracts all the observations that concern house hI from the types of tupleOfAgents. More...
 
double FLObservationProb (Index fireLevel, Problem_CGBG_FF::observation_t obs) const
 
const ScopeGetAgentsForHouse (Index houseI)
 
double GetHouseReward (Index fl, size_t nrAgentsPresent) const
 
double Likelihood (Index houseI, const std::vector< observation_t > &oVec_hI, Index fireLevel) const
 
double Prior (Index houseI, Index fireLevel) const
 
void ScatterAgents ()
 
void ScatterHouses ()
 
std::vector< IndexTypeIndexToObservationIndices (Index agI, Index typeI) const
 
void TypeIndexToObservationIndices (Index typeI, std::vector< Index > &obsIndices) const
 

Private Attributes

std::vector< double > _m_agentPositionX
 
std::vector< double > _m_agentPositionY
 
std::vector< Scope_m_agentsForHouse_action
 
std::vector< Scope_m_agentsForHouse_obs
 
Scope _m_allAgents
 
std::vector< std::vector< Index > > _m_houseIndices_action
 similarly, the houses that the agent has as its actions (can go to): More...
 
std::vector< std::vector< Index > > _m_houseIndices_obs
 _m_houseIndices_obs[agI] contains a vector of house indices, indicating the houses that agent agI can observe. More...
 
std::vector< double > _m_housePositionX
 
std::vector< double > _m_housePositionY
 
size_t _m_k
 
size_t _m_maxNrAgentsObservingAHouse
 
VecDMap _m_Norm_cache
 
size_t _m_nrActionsPerAgent
 
size_t _m_nrFireLevels
 
size_t _m_nrHouses
 
size_t _m_nrObservedHousesPerAgents
 
size_t _m_nrObsPerHouse
 

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 ()
 
- Protected Attributes inherited from BayesianGameCollaborativeGraphical
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...
 

Detailed Description

Problem_CGBG_FF reprents a generalized single-shot fire fighting problem.

-there are x houses scattered uniformly in the 2D plane (in the box bounded by [0,0], [1,1]) -the fire level of each house is uniformly drawn from {0, ..., nrFireLevels-1} -each agent is assigned a random position in the same box (also uniform). -each agent can fight fire at the z nearest houses. -each agent gets an observation of the y nearest houses. -each house induces a cost, -more agents at a house means a lower cost, however, the effect of adding agents is sub-additive. -a higher fire-level means a higher penalty formula ?

-In order to prevent an arbitrary number of agents from participating in a single house, we remove house from being selected when #agents that participate in it reaches a threshold k. "this will in general not lead to an optimal assignment, other assignments methods may be used in the construction of the CGBG"

Note, that this implementation only supports y<z. I.e., it will not correctly deal with the case where the agents can observe houses where they do not fight fire at. The problem is that in that case, even though an agent cannot influence such a house via its action, it does influence the local utility u(jt,ja) via its type. (However, I guess that that will not influence the optimal joint policy?)

Member Typedef Documentation

typedef std::pair<double, Index > Problem_CGBG_FF::diPair
protected
typedef std::map< std::vector<observation_t>, double > Problem_CGBG_FF::VecDMap
private
typedef std::pair< std::vector<observation_t>, double > Problem_CGBG_FF::VecDPair
private

Constructor & Destructor Documentation

Problem_CGBG_FF::Problem_CGBG_FF ( size_t  nrHouses,
size_t  nrFLs,
size_t  nrAgents,
size_t  nrActionsPerAgent,
size_t  nrObservedHousesPerAgent,
size_t  k 
)
Problem_CGBG_FF::~Problem_CGBG_FF ( )

Copy constructor.

Destructor.

Member Function Documentation

double Problem_CGBG_FF::ComputeDistanceAgentToHouse ( Index  agI,
Index  hI 
)
private
double Problem_CGBG_FF::ComputeHouseProbability ( Index  hI,
const Scope tupleOfAgents,
const std::vector< Index > &  types 
) const
private
double Problem_CGBG_FF::ComputeIndividualTypeProb ( Index  agI,
Index  typeI,
std::vector< Index > &  FL_vec 
) const
private

Compute the probability of an individual type given the vector of fire levels (used in MAID export)

References FLObservationProb(), and TypeIndexToObservationIndices().

Referenced by ExportAsMAID().

double Problem_CGBG_FF::ComputeLocalProbability ( const Scope tupleOfAgents,
const std::vector< Index > &  types 
) const
private
double Problem_CGBG_FF::ComputeLocalUtility ( Index  hI,
const Scope tupleOfAgents,
const std::vector< Index > &  actions,
const std::vector< Index > &  types 
)
private
size_t Problem_CGBG_FF::ComputeNumberOfAgentsPresentAtHouse ( Index  houseI,
const std::vector< Index > &  a_vec 
) const
private
void Problem_CGBG_FF::ExportToTextFiles ( const std::string &  suffix = "",
const std::string &  prefix = "/tmp/" 
) const
vector< Problem_CGBG_FF::observation_t > Problem_CGBG_FF::FilterObservationsForHouse ( Index  hI,
const Scope tupleOfAgents,
const std::vector< Index > &  types 
) const
private

Extracts all the observations that concern house hI from the types of tupleOfAgents.

References _m_houseIndices_obs, PrintTools::SoftPrintVector(), and TypeIndexToObservationIndices().

Referenced by ComputeHouseProbability(), and ComputeLocalUtility().

double Problem_CGBG_FF::FLObservationProb ( Index  fireLevel,
Problem_CGBG_FF::observation_t  obs 
) const
private
const Scope& Problem_CGBG_FF::GetAgentsForHouse ( Index  houseI)
private
double Problem_CGBG_FF::GetHouseReward ( Index  fl,
size_t  nrAgentsPresent 
) const
private
double Problem_CGBG_FF::GetProbability ( Index  i) const
virtual

Gets the probability of joint type i.

Reimplemented from BayesianGameCollaborativeGraphical.

References _m_allAgents, ComputeLocalProbability(), and BayesianGameBase::JointToIndividualTypeIndices().

string Problem_CGBG_FF::GetUnixName ( ) const
double Problem_CGBG_FF::Likelihood ( Index  houseI,
const std::vector< observation_t > &  oVec_hI,
Index  fireLevel 
) const
private
double Problem_CGBG_FF::Prior ( Index  houseI,
Index  fireLevel 
) const
private
void Problem_CGBG_FF::ScatterAgents ( )
private
void Problem_CGBG_FF::ScatterHouses ( )
private
std::string Problem_CGBG_FF::SoftPrintReadableType ( Index  agI,
Index  typeI 
) const

Copy assignment operator.

References _m_houseIndices_obs, and TypeIndexToObservationIndices().

Referenced by ExportAsMAID().

vector< Index > Problem_CGBG_FF::TypeIndexToObservationIndices ( Index  agI,
Index  typeI 
) const
private
void Problem_CGBG_FF::TypeIndexToObservationIndices ( Index  typeI,
std::vector< Index > &  obsIndices 
) const
private

Member Data Documentation

std::vector< double > Problem_CGBG_FF::_m_agentPositionX
private
std::vector< double > Problem_CGBG_FF::_m_agentPositionY
private
std::vector<Scope> Problem_CGBG_FF::_m_agentsForHouse_action
private
std::vector<Scope> Problem_CGBG_FF::_m_agentsForHouse_obs
private
Scope Problem_CGBG_FF::_m_allAgents
private

Referenced by GetProbability(), and Problem_CGBG_FF().

std::vector< std::vector<Index> > Problem_CGBG_FF::_m_houseIndices_action
private

similarly, the houses that the agent has as its actions (can go to):

Referenced by AssignAgentActionsToHouses(), AssignAgentTypesToHouses(), ComputeNumberOfAgentsPresentAtHouse(), and Problem_CGBG_FF().

std::vector< std::vector<Index> > Problem_CGBG_FF::_m_houseIndices_obs
private

_m_houseIndices_obs[agI] contains a vector of house indices, indicating the houses that agent agI can observe.

Referenced by AssignAgentTypesToHouses(), ComputeLocalProbability(), ExportAsMAID(), FilterObservationsForHouse(), Problem_CGBG_FF(), SoftPrintReadableType(), and TypeIndexToObservationIndices().

std::vector< double > Problem_CGBG_FF::_m_housePositionX
private
std::vector< double > Problem_CGBG_FF::_m_housePositionY
private
size_t Problem_CGBG_FF::_m_k
private
size_t Problem_CGBG_FF::_m_maxNrAgentsObservingAHouse
private
VecDMap Problem_CGBG_FF::_m_Norm_cache
private
size_t Problem_CGBG_FF::_m_nrActionsPerAgent
private
size_t Problem_CGBG_FF::_m_nrFireLevels
private
size_t Problem_CGBG_FF::_m_nrObservedHousesPerAgents
private
size_t Problem_CGBG_FF::_m_nrObsPerHouse
private