MultiAgentDecisionProcess
TwoStageDynamicBayesianNetwork Class Reference

TwoStageDynamicBayesianNetwork (2DBN) is a class that represents the transition and observation model for a factored MADP. More...

#include <TwoStageDynamicBayesianNetwork.h>

Public Member Functions

void AddCPDForO (Index o)
 Add a CPD for an observation o. More...
 
void AddCPDForY (Index y)
 Add a CPD for a NS SF y. More...
 
Scope AgentScopeBackup (const Scope &stateScope, const Scope &agentScope) const
 Get the agent actions that are a ancestor of the arguments. More...
 
size_t GetAiiSize_O (Index oI) const
 returns the nr instantiations of ASoI(o) More...
 
size_t GetAiiSize_Y (Index yI) const
 returns the nr instantiations of ASoI(y) More...
 
const ScopeGetASoI_O (Index o) const
 
const ScopeGetASoI_Y (Index y) const
 
CPDDiscreteInterfaceGetCPD_O (Index oI)
 Set the CPDDiscreteInterface for O. More...
 
CPDDiscreteInterfaceGetCPD_Y (Index yI)
 
size_t GetiiSize_O (Index oI) const
 returns the total number of IIs More...
 
size_t GetiiSize_Y (Index yI) const
 returns the total number of IIs More...
 
const std::vector< size_t > & GetNrVals_ASoI_O (Index oI) const
 returns the number of values for all actions in ASoI(o) More...
 
const std::vector< size_t > & GetNrVals_ASoI_Y (Index yI) const
 returns the number of values for all actions in XSoI(y) More...
 
const std::vector< size_t > & GetNrVals_OSoI_O (Index oI) const
 returns the number of values for all state factors in OSoI(o) More...
 
const std::vector< size_t > & GetNrVals_XSoI_O (Index oI) const
 returns the number of values for all state factors in XSoI(o) More...
 
const std::vector< size_t > & GetNrVals_XSoI_Y (Index yI) const
 returns the number of values for all state factors in XSoI(y) More...
 
const std::vector< size_t > & GetNrVals_YSoI_O (Index oI) const
 returns the number of values for all state factors in YSoI(o) More...
 
const std::vector< size_t > & GetNrVals_YSoI_Y (Index yI) const
 returns the number of values for all state factors in YSoI(y) More...
 
size_t GetOiiSize_O (Index oI) const
 returns the nr instantiations of OSoI(o) More...
 
std::vector< double > GetOProbabilitiesExactScopes (const std::vector< Index > &Aii, const std::vector< Index > &Yii, const std::vector< Index > &Oii, const Index &oIndex) const
 Get the probability of all possible values of oIndex given II. More...
 
std::vector< double > GetOProbabilitiesExactScopes (const std::vector< Index > &Xii, const std::vector< Index > &Aii, const std::vector< Index > &Yii, const std::vector< Index > &Oii, const Index &oIndex) const
 
double GetOProbability (const std::vector< Index > &A, const std::vector< Index > &Y, const std::vector< Index > &O) const
 Get the probability of O given A,Y. All std::vectors are full length. More...
 
double GetOProbability (const std::vector< Index > &X, const std::vector< Index > &A, const std::vector< Index > &Y, const std::vector< Index > &O) const
 
const ScopeGetOSoI_O (Index o) const
 
size_t GetXiiSize_O (Index oI) const
 returns the nr instantiations of XSoI(o) More...
 
size_t GetXiiSize_Y (Index yI) const
 returns the nr. instantiations of XSoI(y) More...
 
const ScopeGetXSoI_O (Index o) const
 
const ScopeGetXSoI_Y (Index y) const
 
size_t GetYiiSize_O (Index oI) const
 returns the nr instantiations of YSoI(o) More...
 
size_t GetYiiSize_Y (Index yI) const
 returns the nr instantiations of YSoI(y) More...
 
double GetYOProbability (const Scope &X, const std::vector< Index > &Xs, const Scope &A, const std::vector< Index > &As, const Scope &Y, const std::vector< Index > &Ys, const Scope &O, const std::vector< Index > &Os) const
 Compute the probability P(Ys,Os|Xs,As) More...
 
std::vector< double > GetYProbabilitiesExactScopes (const std::vector< Index > &Xii, const std::vector< Index > &Aii, const std::vector< Index > &Yii, const Index &yIndex) const
 Get the probability of all possible values of yIndex given II. More...
 
double GetYProbability (const std::vector< Index > &X, const std::vector< Index > &A, const std::vector< Index > &Y) const
 Get the probability of Y given X,A. All are full-length. More...
 
double GetYProbabilityGeneral (const Scope &Xscope, const std::vector< Index > &X, const Scope &Ascope, const std::vector< Index > &A, const Scope &YIIscope, const std::vector< Index > &YII, const Scope &Yscope, const std::vector< Index > &Y) const
 Get the probability of Y given X,A. general version. More...
 
const ScopeGetYSoI_O (Index o) const
 
const ScopeGetYSoI_Y (Index y) const
 
Index IndividualToJointOiiIndices (Index o, const std::vector< Index > &A_rest, const std::vector< Index > &Y_rest, const std::vector< Index > &O_rest) const
 Computes the joint II index for restricted std::vectors As,Ys,Os. More...
 
Index IndividualToJointOiiIndices (Index o, const std::vector< Index > &X_rest, const std::vector< Index > &A_rest, const std::vector< Index > &Y_rest, const std::vector< Index > &O_rest) const
 
Index IndividualToJointYiiIndices (Index y, const std::vector< Index > &X_rest, const std::vector< Index > &A_rest, const std::vector< Index > &Y_rest) const
 Computes the joint II index for restricted std::vectors Xs,As,Ys. More...
 
void InitializeIIs ()
 Computes some administrative things necessary for II functions. More...
 
void InitializeStorage ()
 Copy assignment operator. More...
 
void JointToIndividualOiiIndices (Index o, Index iiI, std::vector< Index > &A_rest, std::vector< Index > &Y_rest, std::vector< Index > &O_rest) const
 Computes Xs, As, Ys from the joint iiI denoting a II of SoI(o). More...
 
void JointToIndividualOiiIndices (Index o, Index iiI, std::vector< Index > &X_rest, std::vector< Index > &A_rest, std::vector< Index > &Y_rest, std::vector< Index > &O_rest) const
 
void JointToIndividualYiiIndices (Index y, Index iiI, std::vector< Index > &X_rest, std::vector< Index > &A_rest, std::vector< Index > &Y_rest) const
 Computes Xs, As, Ys from the joint iiI denoting a II of SoI(y). More...
 
std::vector< IndexSampleO (const std::vector< Index > &A, const std::vector< Index > &Y) const
 Sample an observation. More...
 
std::vector< IndexSampleO (const std::vector< Index > &X, const std::vector< Index > &A, const std::vector< Index > &Y) const
 Sample an observation. More...
 
std::vector< IndexSampleY (const std::vector< Index > &X, const std::vector< Index > &A) const
 Sample a NS state. More...
 
void ScopeBackup (const Scope &Y, const Scope &X, Scope &Xout, Scope &Aout) const
 Perfom the Stat and Agent Scope backup. More...
 
void SetCPD_O (Index oI, CPDDiscreteInterface *cpt)
 Set the CPDDiscreteInterface for O. More...
 
void SetCPD_Y (Index yI, CPDDiscreteInterface *cpt)
 Set the CPDDiscreteInterface for Y. More...
 
void SetSoI_O (Index o, const Scope &ASoI, const Scope &YSoI, const Scope &OSoI)
 Sets the SoI of an observation o. More...
 
void SetSoI_O (Index o, const Scope &XSoI, const Scope &ASoI, const Scope &YSoI, const Scope &OSoI)
 Sets the SoI of an observation o. More...
 
void SetSoI_Y (Index y, const Scope &XSoI, const Scope &ASoI, const Scope &YSoI)
 Sets the SoI of a NS SF y. More...
 
std::string SoftPrint () const
 
std::string SoftPrintSoI_O (Index agI) const
 
std::string SoftPrintSoI_Y (Index y) const
 
Scope StateScopeBackup (const Scope &stateScope, const Scope &agentScope) const
 Get the state factors that are a ancestor of the arguments. More...
 
 TwoStageDynamicBayesianNetwork (MultiAgentDecisionProcessDiscreteFactoredStatesInterface &madp)
 (default) Constructor More...
 
 ~TwoStageDynamicBayesianNetwork ()
 Copy constructor. More...
 

Private Member Functions

void ComputeWithinNextStageClosure (Scope &Y, Scope &O) const
 Computes the 'closure' of NS variables Y and O. More...
 

Private Attributes

std::vector< std::vector
< Index > * > 
_m_A_restr_perO
 
std::vector< std::vector
< Index > * > 
_m_A_restr_perY
 
std::vector< size_t > _m_Aii_size_O
 For each O we maintain the number of instantiations of ASoI(O) More...
 
std::vector< size_t > _m_Aii_size_Y
 For each Y we maintain the number of instantiations of ASoI(Y) More...
 
std::vector< Scope_m_ASoI_O
 For each O we maintain the actions, A, in its SoI. More...
 
std::vector< Scope_m_ASoI_Y
 For each NS SF we maintain the actions, A, in its SoI. More...
 
bool _m_ii_initialized
 Boolean that is set when all ii info is initialized. More...
 
std::vector< size_t > _m_ii_size_O
 For each y we maintain the number of II's. More...
 
std::vector< size_t > _m_ii_size_Y
 For each y we maintain the number of II's. More...
 
std::vector< Index > * _m_IndividualToJointOiiIndices_catVector
 Temporary storage used in IndividualToJointOiiIndices. More...
 
std::vector< Index > * _m_IndividualToJointYiiIndices_catVector
 Temporary storage used in IndividualToJointYiiIndices. More...
 
MultiAgentDecisionProcessDiscreteFactoredStatesInterface_m_madp
 pointer to a MultiAgentDecisionProcessFactoredStatesInterface More...
 
size_t _m_nrO
 the number of observation factors (i.e., the number of agents) More...
 
std::vector< std::vector
< size_t > > 
_m_nrVals_ASoI_O
 For each O we maintain the number of actions in ASoI(O) More...
 
std::vector< std::vector
< size_t > > 
_m_nrVals_ASoI_Y
 For each NS SF Y we maintain the number of actions in ASoI(Y) More...
 
std::vector< std::vector
< size_t > > 
_m_nrVals_OSoI_O
 For each O we maintain the number of observations in OSoI(O) More...
 
std::vector< std::vector
< size_t > > 
_m_nrVals_SoI_O
 For each NS SF O we maintain the number of SF values in SoI(O) More...
 
std::vector< size_t * > _m_nrVals_SoI_O_stepsize
 Cache the step size for speed. More...
 
std::vector< std::vector
< size_t > > 
_m_nrVals_SoI_Y
 For each NS SF Y we maintain the number of SF values in SoI(Y) More...
 
std::vector< size_t * > _m_nrVals_SoI_Y_stepsize
 Cache the step size for speed. More...
 
std::vector< std::vector
< size_t > > 
_m_nrVals_XSoI_O
 For each O we maintain the number of SF values in XSoI(O) More...
 
std::vector< std::vector
< size_t > > 
_m_nrVals_XSoI_Y
 For each NS SF Y we maintain the number of SF values in XSoI(Y) More...
 
std::vector< std::vector
< size_t > > 
_m_nrVals_YSoI_O
 For each O we maintain the number of SF values in YSoI(O) More...
 
std::vector< std::vector
< size_t > > 
_m_nrVals_YSoI_Y
 For each NS SF Y we maintain the number of SF values in YSoI(Y) More...
 
size_t _m_nrY
 the number of state factors More...
 
std::vector
< CPDDiscreteInterface * > 
_m_O_CPDs
 For each observation we maintain a CPD. More...
 
std::vector< std::vector
< Index > * > 
_m_O_restr_perO
 
std::vector< size_t > _m_Oii_size_O
 For each O we maintain the number of instantiations of OSoI(O) More...
 
std::vector< Scope_m_OSoI_O
 For each O we maintain the observations, O, in its SoI. More...
 
std::vector< size_t > * _m_SampleNrO
 Temporary storage used in SampleO. More...
 
std::vector< Index > * _m_SampleO
 Temporary storage used in SampleO. More...
 
std::vector< Index > * _m_SampleY
 Temporary storage used in SampleY. More...
 
bool _m_SoIStorageInitialized
 
std::vector< std::vector
< Index > * > 
_m_X_restr_perO
 
std::vector< std::vector
< Index > * > 
_m_X_restr_perY
 
std::vector< size_t > _m_Xii_size_O
 For each O we maintain the number of instantiations of XSoI(O) More...
 
std::vector< size_t > _m_Xii_size_Y
 For each Y we maintain the number of instantiations of XSoI(Y) More...
 
std::vector< Scope_m_XSoI_O
 For each O we maintain the PS SFs, X, in its SoI. More...
 
std::vector< Scope_m_XSoI_Y
 For each NS SF we maintain the PS SFs, X, in its SoI. More...
 
std::vector
< CPDDiscreteInterface * > 
_m_Y_CPDs
 For each next-stage state variable y we maintain a CPD. More...
 
std::vector< std::vector
< Index > * > 
_m_Y_restr_perO
 
std::vector< std::vector
< Index > * > 
_m_Y_restr_perY
 
std::vector< size_t > _m_Yii_size_O
 For each O we maintain the number of instantiations of YSoI(O) More...
 
std::vector< size_t > _m_Yii_size_Y
 For each Y we maintain the number of instantiations of YSoI(Y) More...
 
std::vector< Scope_m_YSoI_O
 For each O we maintain the NS SFs, Y, in its SoI. More...
 
std::vector< Scope_m_YSoI_Y
 For each NS SF we maintain the NS SFs, Y, in its SoI. More...
 

Detailed Description

TwoStageDynamicBayesianNetwork (2DBN) is a class that represents the transition and observation model for a factored MADP.

(i.e., for something that implements the MultiAgentDecisionProcessDiscreteFactoredStatesInterface. E.g., a MultiAgentDecisionProcessDiscreteFactoredStates)

Components

A TwoStageDynamicBayesianNetwork is composed of the

  • previous-stage (PS) state factors (SF) - x
  • next-stage (NS) state factors - y
  • actions variables - a
  • observation variables - o

Connections

There are causal connections of the following forms

  • x -> y influence of a PS SF on a NS SF
  • a -> y influence of an action on a NS SF
  • a -> o influence of an action on an observation
  • y -> y influence of a NS SF (with a lower index) on a NS SF (with a higher index)
  • y -> o influence of a NS SF on an observation
  • o -> o influence of a observation ((of an agent) with a lower index) on an observation ((of an agent) with a higher index).

Scopes of influence
----------------—
As such each y has a Scope of influence (SoI): SoI(y) = subset{x,a,y} And similar for each o: SoI(o) = subset{a,y,o}

Influence Instantiations (II)
--------------------------—
We refer to 1 instantiation of all variables in SoI(y) as an 'influence instantiation' (II). This class provides some convenience functions for converting a joint II index (denoted iiI), from vectors describing an instantiation, and vice versa.

We discriminate Yii's and Oii's for resp. NS SFs and Observations.

CPFs
-—
For each y and o, the 2DBN maintains a conditional probability distr. (CPD). These functions maintain the actual probabilities

  • CPD(y) = Pr(y | SoI(y) )
  • CPD(o) = Pr(o | SoI(o) )

Computing joint probabilities
--------------------------—
Joint probabilities can now be computed as illustrated here:

  • Pr( y1, y2 | SoI(y1), SoI(y2) ) = CPD(y1,y2) = CPD(y1) * CPD(y2) = Pr(y1 | SoI(y1)) * Pr(y2 | SoI(y2))
  • similar for observations and combinations of o and y.

In the future we may want to use compact CPDs such as decision trees, ADDs or rules based descriptions. Then we can also consider concretizing the product CPD(y1,y2) = CPD(y1) * CPD(y2) (e.g., overloading the operator* for CPDs etc...)

Constructor & Destructor Documentation

Member Function Documentation

void TwoStageDynamicBayesianNetwork::AddCPDForO ( Index  o)
void TwoStageDynamicBayesianNetwork::AddCPDForY ( Index  y)
Scope TwoStageDynamicBayesianNetwork::AgentScopeBackup ( const Scope stateScope,
const Scope agentScope 
) const

Get the agent actions that are a ancestor of the arguments.

References ScopeBackup().

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::AgentScopeBackup().

void TwoStageDynamicBayesianNetwork::ComputeWithinNextStageClosure ( Scope Y,
Scope O 
) const
private

Computes the 'closure' of NS variables Y and O.

References _m_OSoI_O, _m_YSoI_O, _m_YSoI_Y, Scope::Contains(), and Scope::Insert().

Referenced by ScopeBackup().

size_t TwoStageDynamicBayesianNetwork::GetAiiSize_O ( Index  oI) const

returns the nr instantiations of ASoI(o)

References _m_Aii_size_O, and _m_ii_initialized.

size_t TwoStageDynamicBayesianNetwork::GetAiiSize_Y ( Index  yI) const

returns the nr instantiations of ASoI(y)

References _m_Aii_size_Y, and _m_ii_initialized.

CPDDiscreteInterface* TwoStageDynamicBayesianNetwork::GetCPD_O ( Index  oI)
inline
CPDDiscreteInterface* TwoStageDynamicBayesianNetwork::GetCPD_Y ( Index  yI)
inline
size_t TwoStageDynamicBayesianNetwork::GetiiSize_O ( Index  oI) const

returns the total number of IIs

References _m_ii_initialized, and _m_ii_size_O.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN().

size_t TwoStageDynamicBayesianNetwork::GetiiSize_Y ( Index  yI) const
const vector< size_t > & TwoStageDynamicBayesianNetwork::GetNrVals_ASoI_O ( Index  oI) const

returns the number of values for all actions in ASoI(o)

References _m_ii_initialized, and _m_nrVals_ASoI_O.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN().

const vector< size_t > & TwoStageDynamicBayesianNetwork::GetNrVals_ASoI_Y ( Index  yI) const

returns the number of values for all actions in XSoI(y)

References _m_ii_initialized, and _m_nrVals_ASoI_Y.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN().

const vector< size_t > & TwoStageDynamicBayesianNetwork::GetNrVals_OSoI_O ( Index  oI) const

returns the number of values for all state factors in OSoI(o)

References _m_ii_initialized, and _m_nrVals_OSoI_O.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN().

const vector< size_t > & TwoStageDynamicBayesianNetwork::GetNrVals_XSoI_O ( Index  oI) const

returns the number of values for all state factors in XSoI(o)

References _m_ii_initialized, and _m_nrVals_XSoI_O.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN().

const vector< size_t > & TwoStageDynamicBayesianNetwork::GetNrVals_XSoI_Y ( Index  yI) const

returns the number of values for all state factors in XSoI(y)

References _m_ii_initialized, and _m_nrVals_XSoI_Y.

Referenced by FactoredDecPOMDPDiscrete::ExportSpuddFile(), and MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN().

const vector< size_t > & TwoStageDynamicBayesianNetwork::GetNrVals_YSoI_O ( Index  oI) const

returns the number of values for all state factors in YSoI(o)

References _m_ii_initialized, and _m_nrVals_YSoI_O.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN().

const vector< size_t > & TwoStageDynamicBayesianNetwork::GetNrVals_YSoI_Y ( Index  yI) const

returns the number of values for all state factors in YSoI(y)

References _m_ii_initialized, and _m_nrVals_YSoI_Y.

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN().

size_t TwoStageDynamicBayesianNetwork::GetOiiSize_O ( Index  oI) const

returns the nr instantiations of OSoI(o)

References _m_ii_initialized, and _m_Oii_size_O.

vector< double > TwoStageDynamicBayesianNetwork::GetOProbabilitiesExactScopes ( const std::vector< Index > &  Aii,
const std::vector< Index > &  Yii,
const std::vector< Index > &  Oii,
const Index oIndex 
) const

Get the probability of all possible values of oIndex given II.

  • oIndex the index of the observation factor (i.e., of the agent) for which we request the probability of all its possible values.
  • Aii,Yii, Oii are the vectors of influence instantiations of exact scopes. (I.e., Aii, Yii and Oii are of scope as specified by GetASoI_O(), GetYSoI_O(), GetOSoI_O(). )

References _m_madp, _m_O_CPDs, MultiAgentDecisionProcessDiscreteInterface::GetNrObservations(), GetXSoI_O(), IndividualToJointOiiIndices(), and ArgumentHandlers::size().

Referenced by FSAOHDist_NECOF::Update().

vector< double > TwoStageDynamicBayesianNetwork::GetOProbabilitiesExactScopes ( const std::vector< Index > &  Xii,
const std::vector< Index > &  Aii,
const std::vector< Index > &  Yii,
const std::vector< Index > &  Oii,
const Index oIndex 
) const
double TwoStageDynamicBayesianNetwork::GetOProbability ( const std::vector< Index > &  A,
const std::vector< Index > &  Y,
const std::vector< Index > &  O 
) const
double TwoStageDynamicBayesianNetwork::GetOProbability ( const std::vector< Index > &  X,
const std::vector< Index > &  A,
const std::vector< Index > &  Y,
const std::vector< Index > &  O 
) const
size_t TwoStageDynamicBayesianNetwork::GetXiiSize_O ( Index  oI) const

returns the nr instantiations of XSoI(o)

References _m_ii_initialized, and _m_Xii_size_O.

size_t TwoStageDynamicBayesianNetwork::GetXiiSize_Y ( Index  yI) const

returns the nr. instantiations of XSoI(y)

References _m_ii_initialized, and _m_Xii_size_Y.

size_t TwoStageDynamicBayesianNetwork::GetYiiSize_O ( Index  oI) const

returns the nr instantiations of YSoI(o)

References _m_ii_initialized, and _m_Yii_size_O.

size_t TwoStageDynamicBayesianNetwork::GetYiiSize_Y ( Index  yI) const

returns the nr instantiations of YSoI(y)

References _m_ii_initialized, and _m_Yii_size_Y.

double TwoStageDynamicBayesianNetwork::GetYOProbability ( const Scope X,
const std::vector< Index > &  Xs,
const Scope A,
const std::vector< Index > &  As,
const Scope Y,
const std::vector< Index > &  Ys,
const Scope O,
const std::vector< Index > &  Os 
) const

Compute the probability P(Ys,Os|Xs,As)

All std::vectors are of specified scopes. When the probability is undefined (because X and A do not contain all necessary vars) an exception is thrown

References _m_O_CPDs, _m_Y_CPDs, GetASoI_O(), GetASoI_Y(), GetOSoI_O(), GetXSoI_O(), GetXSoI_Y(), GetYSoI_O(), GetYSoI_Y(), IndividualToJointOiiIndices(), IndividualToJointYiiIndices(), IndexTools::RestrictIndividualIndicesToNarrowerScope(), and ArgumentHandlers::size().

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetYOProbability().

vector< double > TwoStageDynamicBayesianNetwork::GetYProbabilitiesExactScopes ( const std::vector< Index > &  Xii,
const std::vector< Index > &  Aii,
const std::vector< Index > &  Yii,
const Index yIndex 
) const

Get the probability of all possible values of yIndex given II.

  • yIndex the index of the state factor for which we request the probability of all its possible values.
  • Xii,Aii, Yii are the vectors of influence instantiations of exact scopes. (I.e., Xii, Aii and Yii are of scope as specified by GetXSoI_Y(), GetASoI_Y(), GetYSoI_Y(). )

References _m_madp, _m_Y_CPDs, MultiAgentDecisionProcessDiscreteFactoredStatesInterface::GetNrValuesForFactor(), and IndividualToJointYiiIndices().

Referenced by FactoredDecPOMDPDiscrete::ExportSpuddFile(), and FSAOHDist_NECOF::Update().

double TwoStageDynamicBayesianNetwork::GetYProbability ( const std::vector< Index > &  X,
const std::vector< Index > &  A,
const std::vector< Index > &  Y 
) const
double TwoStageDynamicBayesianNetwork::GetYProbabilityGeneral ( const Scope Xscope,
const std::vector< Index > &  X,
const Scope Ascope,
const std::vector< Index > &  A,
const Scope YIIscope,
const std::vector< Index > &  YII,
const Scope Yscope,
const std::vector< Index > &  Y 
) const

Get the probability of Y given X,A. general version.

We need to discriminate between

  • Y, the vector of next-stage state variables for which we want to know the probability,
  • YII the vector of next-stage that can influence the SFs in Yscope.

YIIscope needs to be a superset of Yscope and YII and Y need to specify the same values for the same NS SFs.

This function returns the probability

\[ \Pr(Y | X, A, (YII \setminus Y) ) \]

References _m_Y_CPDs, GetASoI_Y(), GetXSoI_Y(), GetYSoI_Y(), IndividualToJointYiiIndices(), IndexTools::RestrictIndividualIndicesToNarrowerScope(), and ArgumentHandlers::size().

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), and MultiAgentDecisionProcessDiscreteFactoredStates::MarginalizeTransitionObservationModel().

Index TwoStageDynamicBayesianNetwork::IndividualToJointOiiIndices ( Index  o,
const std::vector< Index > &  A_rest,
const std::vector< Index > &  Y_rest,
const std::vector< Index > &  O_rest 
) const

Computes the joint II index for restricted std::vectors As,Ys,Os.

std::vectors are restricted to only include values in SoI(o)

References _m_IndividualToJointOiiIndices_catVector, _m_nrVals_SoI_O_stepsize, and IndexTools::IndividualToJointIndicesStepSize().

Referenced by GetOProbabilitiesExactScopes(), GetOProbability(), GetYOProbability(), MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), and SampleO().

Index TwoStageDynamicBayesianNetwork::IndividualToJointOiiIndices ( Index  o,
const std::vector< Index > &  X_rest,
const std::vector< Index > &  A_rest,
const std::vector< Index > &  Y_rest,
const std::vector< Index > &  O_rest 
) const
Index TwoStageDynamicBayesianNetwork::IndividualToJointYiiIndices ( Index  y,
const std::vector< Index > &  X_rest,
const std::vector< Index > &  A_rest,
const std::vector< Index > &  Y_rest 
) const
void TwoStageDynamicBayesianNetwork::InitializeStorage ( )
void TwoStageDynamicBayesianNetwork::JointToIndividualOiiIndices ( Index  o,
Index  iiI,
std::vector< Index > &  A_rest,
std::vector< Index > &  Y_rest,
std::vector< Index > &  O_rest 
) const

Computes Xs, As, Ys from the joint iiI denoting a II of SoI(o).

This returns restricted std::vectors (std::vectors restricted to the SoI(o))

References _m_nrVals_ASoI_O, _m_nrVals_OSoI_O, _m_nrVals_SoI_O, _m_nrVals_YSoI_O, GetXSoI_O(), IndexTools::JointToIndividualIndices(), and ArgumentHandlers::size().

void TwoStageDynamicBayesianNetwork::JointToIndividualOiiIndices ( Index  o,
Index  iiI,
std::vector< Index > &  X_rest,
std::vector< Index > &  A_rest,
std::vector< Index > &  Y_rest,
std::vector< Index > &  O_rest 
) const
void TwoStageDynamicBayesianNetwork::JointToIndividualYiiIndices ( Index  y,
Index  iiI,
std::vector< Index > &  X_rest,
std::vector< Index > &  A_rest,
std::vector< Index > &  Y_rest 
) const

Computes Xs, As, Ys from the joint iiI denoting a II of SoI(y).

This returns restricted std::vectors (std::vectors restricted to the SoI(y))

References _m_nrVals_ASoI_Y, _m_nrVals_SoI_Y, _m_nrVals_XSoI_Y, _m_nrVals_YSoI_Y, and IndexTools::JointToIndividualIndices().

std::vector<Index> TwoStageDynamicBayesianNetwork::SampleO ( const std::vector< Index > &  A,
const std::vector< Index > &  Y 
) const
inline
vector< Index > TwoStageDynamicBayesianNetwork::SampleO ( const std::vector< Index > &  X,
const std::vector< Index > &  A,
const std::vector< Index > &  Y 
) const
vector< Index > TwoStageDynamicBayesianNetwork::SampleY ( const std::vector< Index > &  X,
const std::vector< Index > &  A 
) const
void TwoStageDynamicBayesianNetwork::ScopeBackup ( const Scope Y,
const Scope X,
Scope Xout,
Scope Aout 
) const

Perfom the Stat and Agent Scope backup.

this function is called by StateScopeBackup and AgentScopeBackup. If you need both, this is therefore more efficient. Xout and Aout are output arguments containing the backed-up scopes.

References _m_ASoI_O, _m_ASoI_Y, _m_XSoI_O, _m_XSoI_Y, ComputeWithinNextStageClosure(), Scope::Insert(), and Scope::Sort().

Referenced by AgentScopeBackup(), and StateScopeBackup().

void TwoStageDynamicBayesianNetwork::SetSoI_O ( Index  o,
const Scope ASoI,
const Scope YSoI,
const Scope OSoI 
)
void TwoStageDynamicBayesianNetwork::SetSoI_O ( Index  o,
const Scope XSoI,
const Scope ASoI,
const Scope YSoI,
const Scope OSoI 
)

Sets the SoI of an observation o.

References _m_ASoI_O, _m_OSoI_O, _m_SoIStorageInitialized, _m_XSoI_O, and _m_YSoI_O.

void TwoStageDynamicBayesianNetwork::SetSoI_Y ( Index  y,
const Scope XSoI,
const Scope ASoI,
const Scope YSoI 
)
string TwoStageDynamicBayesianNetwork::SoftPrintSoI_O ( Index  agI) const

References _m_ASoI_O, _m_OSoI_O, _m_XSoI_O, and _m_YSoI_O.

Referenced by SoftPrint().

string TwoStageDynamicBayesianNetwork::SoftPrintSoI_Y ( Index  y) const

References _m_ASoI_Y, _m_XSoI_Y, and _m_YSoI_Y.

Referenced by SoftPrint().

Scope TwoStageDynamicBayesianNetwork::StateScopeBackup ( const Scope stateScope,
const Scope agentScope 
) const

Get the state factors that are a ancestor of the arguments.

References ScopeBackup().

Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::StateScopeBackup().

Member Data Documentation

std::vector<std::vector<Index>* > TwoStageDynamicBayesianNetwork::_m_A_restr_perO
private
std::vector<std::vector<Index>* > TwoStageDynamicBayesianNetwork::_m_A_restr_perY
private
std::vector<size_t> TwoStageDynamicBayesianNetwork::_m_Aii_size_O
private

For each O we maintain the number of instantiations of ASoI(O)

Referenced by GetAiiSize_O(), and InitializeIIs().

std::vector<size_t> TwoStageDynamicBayesianNetwork::_m_Aii_size_Y
private

For each Y we maintain the number of instantiations of ASoI(Y)

Referenced by GetAiiSize_Y(), and InitializeIIs().

std::vector< Scope > TwoStageDynamicBayesianNetwork::_m_ASoI_O
private

For each O we maintain the actions, A, in its SoI.

Referenced by InitializeStorage(), ScopeBackup(), SetSoI_O(), and SoftPrintSoI_O().

std::vector< Scope > TwoStageDynamicBayesianNetwork::_m_ASoI_Y
private

For each NS SF we maintain the actions, A, in its SoI.

Referenced by InitializeStorage(), ScopeBackup(), SetSoI_Y(), and SoftPrintSoI_Y().

std::vector<size_t> TwoStageDynamicBayesianNetwork::_m_ii_size_O
private

For each y we maintain the number of II's.

Referenced by GetiiSize_O(), and InitializeIIs().

std::vector<size_t> TwoStageDynamicBayesianNetwork::_m_ii_size_Y
private

For each y we maintain the number of II's.

Referenced by GetiiSize_Y(), and InitializeIIs().

std::vector<Index>* TwoStageDynamicBayesianNetwork::_m_IndividualToJointOiiIndices_catVector
private

Temporary storage used in IndividualToJointOiiIndices.

Referenced by IndividualToJointOiiIndices(), InitializeIIs(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().

std::vector<Index>* TwoStageDynamicBayesianNetwork::_m_IndividualToJointYiiIndices_catVector
private

Temporary storage used in IndividualToJointYiiIndices.

Referenced by IndividualToJointYiiIndices(), InitializeIIs(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().

MultiAgentDecisionProcessDiscreteFactoredStatesInterface* TwoStageDynamicBayesianNetwork::_m_madp
private

pointer to a MultiAgentDecisionProcessFactoredStatesInterface

A TwoStageDynamicBayesianNetwork is not a standalone thing. It is used to represent a MADP with a factored states space.

Referenced by GetOProbabilitiesExactScopes(), GetYProbabilitiesExactScopes(), GetYProbability(), InitializeIIs(), InitializeStorage(), and SoftPrint().

size_t TwoStageDynamicBayesianNetwork::_m_nrO
private

the number of observation factors (i.e., the number of agents)

Referenced by InitializeIIs(), InitializeStorage(), and SampleO().

std::vector< std::vector<size_t> > TwoStageDynamicBayesianNetwork::_m_nrVals_ASoI_O
private

For each O we maintain the number of actions in ASoI(O)

Referenced by GetNrVals_ASoI_O(), InitializeIIs(), and JointToIndividualOiiIndices().

std::vector< std::vector<size_t> > TwoStageDynamicBayesianNetwork::_m_nrVals_ASoI_Y
private

For each NS SF Y we maintain the number of actions in ASoI(Y)

Referenced by GetNrVals_ASoI_Y(), InitializeIIs(), and JointToIndividualYiiIndices().

std::vector< std::vector<size_t> > TwoStageDynamicBayesianNetwork::_m_nrVals_OSoI_O
private

For each O we maintain the number of observations in OSoI(O)

Referenced by GetNrVals_OSoI_O(), InitializeIIs(), and JointToIndividualOiiIndices().

std::vector< std::vector<size_t> > TwoStageDynamicBayesianNetwork::_m_nrVals_SoI_O
private

For each NS SF O we maintain the number of SF values in SoI(O)

This is the concatination of [nrValsASoI, nrValsYSoI, nrValsOSoI] used by IndividualToJointOiiIndices, and JointToIndividualOiiIndices

Referenced by InitializeIIs(), and JointToIndividualOiiIndices().

std::vector<size_t*> TwoStageDynamicBayesianNetwork::_m_nrVals_SoI_O_stepsize
private

Cache the step size for speed.

Referenced by IndividualToJointOiiIndices(), InitializeIIs(), and ~TwoStageDynamicBayesianNetwork().

std::vector< std::vector<size_t> > TwoStageDynamicBayesianNetwork::_m_nrVals_SoI_Y
private

For each NS SF Y we maintain the number of SF values in SoI(Y)

This is the concatination of [nrValsXSoI, nrValsASoI, nrValsYSoI] used by IndividualToJointYiiIndices, and JointToIndividualYiiIndices

Referenced by IndividualToJointYiiIndices(), InitializeIIs(), and JointToIndividualYiiIndices().

std::vector<size_t*> TwoStageDynamicBayesianNetwork::_m_nrVals_SoI_Y_stepsize
private

Cache the step size for speed.

Referenced by IndividualToJointYiiIndices(), InitializeIIs(), and ~TwoStageDynamicBayesianNetwork().

std::vector< std::vector<size_t> > TwoStageDynamicBayesianNetwork::_m_nrVals_XSoI_O
private

For each O we maintain the number of SF values in XSoI(O)

Referenced by GetNrVals_XSoI_O(), InitializeIIs(), and JointToIndividualOiiIndices().

std::vector< std::vector<size_t> > TwoStageDynamicBayesianNetwork::_m_nrVals_XSoI_Y
private

For each NS SF Y we maintain the number of SF values in XSoI(Y)

I.e., For each SF in XSoI(Y) we maintain the number of values it has. This can be used to convert 'local' X indices to joint ones, etc.

Referenced by GetNrVals_XSoI_Y(), InitializeIIs(), and JointToIndividualYiiIndices().

std::vector< std::vector<size_t> > TwoStageDynamicBayesianNetwork::_m_nrVals_YSoI_O
private

For each O we maintain the number of SF values in YSoI(O)

Referenced by GetNrVals_YSoI_O(), InitializeIIs(), and JointToIndividualOiiIndices().

std::vector< std::vector<size_t> > TwoStageDynamicBayesianNetwork::_m_nrVals_YSoI_Y
private

For each NS SF Y we maintain the number of SF values in YSoI(Y)

Referenced by GetNrVals_YSoI_Y(), InitializeIIs(), and JointToIndividualYiiIndices().

size_t TwoStageDynamicBayesianNetwork::_m_nrY
private

the number of state factors

Referenced by InitializeIIs(), InitializeStorage(), and SampleY().

std::vector< CPDDiscreteInterface * > TwoStageDynamicBayesianNetwork::_m_O_CPDs
private
std::vector<std::vector<Index>* > TwoStageDynamicBayesianNetwork::_m_O_restr_perO
private
std::vector<size_t> TwoStageDynamicBayesianNetwork::_m_Oii_size_O
private

For each O we maintain the number of instantiations of OSoI(O)

Referenced by GetOiiSize_O(), and InitializeIIs().

std::vector< Scope > TwoStageDynamicBayesianNetwork::_m_OSoI_O
private

For each O we maintain the observations, O, in its SoI.

Referenced by ComputeWithinNextStageClosure(), InitializeStorage(), SetSoI_O(), and SoftPrintSoI_O().

std::vector<size_t>* TwoStageDynamicBayesianNetwork::_m_SampleNrO
private

Temporary storage used in SampleO.

Referenced by InitializeStorage(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().

std::vector<Index>* TwoStageDynamicBayesianNetwork::_m_SampleO
private

Temporary storage used in SampleO.

Referenced by InitializeStorage(), SampleO(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().

std::vector<Index>* TwoStageDynamicBayesianNetwork::_m_SampleY
private

Temporary storage used in SampleY.

Referenced by InitializeStorage(), SampleY(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().

bool TwoStageDynamicBayesianNetwork::_m_SoIStorageInitialized
private
std::vector<std::vector<Index>* > TwoStageDynamicBayesianNetwork::_m_X_restr_perO
private
std::vector<std::vector<Index>* > TwoStageDynamicBayesianNetwork::_m_X_restr_perY
private
std::vector<size_t> TwoStageDynamicBayesianNetwork::_m_Xii_size_O
private

For each O we maintain the number of instantiations of XSoI(O)

Referenced by GetXiiSize_O(), and InitializeIIs().

std::vector<size_t> TwoStageDynamicBayesianNetwork::_m_Xii_size_Y
private

For each Y we maintain the number of instantiations of XSoI(Y)

Referenced by GetXiiSize_Y(), and InitializeIIs().

std::vector< Scope > TwoStageDynamicBayesianNetwork::_m_XSoI_O
private

For each O we maintain the PS SFs, X, in its SoI.

Referenced by InitializeStorage(), ScopeBackup(), SetSoI_O(), and SoftPrintSoI_O().

std::vector< Scope > TwoStageDynamicBayesianNetwork::_m_XSoI_Y
private

For each NS SF we maintain the PS SFs, X, in its SoI.

Referenced by InitializeStorage(), ScopeBackup(), SetSoI_Y(), and SoftPrintSoI_Y().

std::vector< CPDDiscreteInterface * > TwoStageDynamicBayesianNetwork::_m_Y_CPDs
private
std::vector<std::vector<Index>* > TwoStageDynamicBayesianNetwork::_m_Y_restr_perO
private
std::vector<std::vector<Index>* > TwoStageDynamicBayesianNetwork::_m_Y_restr_perY
private
std::vector<size_t> TwoStageDynamicBayesianNetwork::_m_Yii_size_O
private

For each O we maintain the number of instantiations of YSoI(O)

Referenced by GetYiiSize_O(), and InitializeIIs().

std::vector<size_t> TwoStageDynamicBayesianNetwork::_m_Yii_size_Y
private

For each Y we maintain the number of instantiations of YSoI(Y)

Referenced by GetYiiSize_Y(), and InitializeIIs().

std::vector< Scope > TwoStageDynamicBayesianNetwork::_m_YSoI_O
private

For each O we maintain the NS SFs, Y, in its SoI.

Referenced by ComputeWithinNextStageClosure(), InitializeStorage(), SetSoI_O(), and SoftPrintSoI_O().

std::vector< Scope > TwoStageDynamicBayesianNetwork::_m_YSoI_Y
private

For each NS SF we maintain the NS SFs, Y, in its SoI.

Referenced by ComputeWithinNextStageClosure(), InitializeStorage(), SetSoI_Y(), and SoftPrintSoI_Y().