MultiAgentDecisionProcess
|
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 Scope & | GetASoI_O (Index o) const |
const Scope & | GetASoI_Y (Index y) const |
CPDDiscreteInterface * | GetCPD_O (Index oI) |
Set the CPDDiscreteInterface for O. More... | |
CPDDiscreteInterface * | GetCPD_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 Scope & | GetOSoI_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 Scope & | GetXSoI_O (Index o) const |
const Scope & | GetXSoI_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 Scope & | GetYSoI_O (Index o) const |
const Scope & | GetYSoI_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< Index > | SampleO (const std::vector< Index > &A, const std::vector< Index > &Y) const |
Sample an observation. More... | |
std::vector< Index > | SampleO (const std::vector< Index > &X, const std::vector< Index > &A, const std::vector< Index > &Y) const |
Sample an observation. More... | |
std::vector< Index > | SampleY (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... | |
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)
A TwoStageDynamicBayesianNetwork is composed of the
There are causal connections of the following forms
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
Computing joint probabilities
--------------------------—
Joint probabilities can now be computed as illustrated here:
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...)
TwoStageDynamicBayesianNetwork::TwoStageDynamicBayesianNetwork | ( | MultiAgentDecisionProcessDiscreteFactoredStatesInterface & | madp | ) |
(default) Constructor
References _m_IndividualToJointOiiIndices_catVector, _m_IndividualToJointYiiIndices_catVector, _m_SampleNrO, _m_SampleO, _m_SampleY, and _m_SoIStorageInitialized.
TwoStageDynamicBayesianNetwork::~TwoStageDynamicBayesianNetwork | ( | ) |
Copy constructor.
Destructor.
References _m_A_restr_perO, _m_A_restr_perY, _m_IndividualToJointOiiIndices_catVector, _m_IndividualToJointYiiIndices_catVector, _m_nrVals_SoI_O_stepsize, _m_nrVals_SoI_Y_stepsize, _m_O_CPDs, _m_O_restr_perO, _m_SampleNrO, _m_SampleO, _m_SampleY, _m_X_restr_perO, _m_X_restr_perY, _m_Y_CPDs, _m_Y_restr_perO, and _m_Y_restr_perY.
void TwoStageDynamicBayesianNetwork::AddCPDForO | ( | Index | o | ) |
Add a CPD for an observation o.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::CreateNewObservationModel().
void TwoStageDynamicBayesianNetwork::AddCPDForY | ( | Index | y | ) |
Add a CPD for a NS SF y.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::CreateNewTransitionModel().
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().
|
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.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetASoI_O(), GetOProbability(), GetYOProbability(), MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), InitializeIIs(), MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), SampleO(), and FSAOHDist_NECOF::Update().
Referenced by FactoredDecPOMDPDiscrete::ExportSpuddFile(), MultiAgentDecisionProcessDiscreteFactoredStates::GetASoI_Y(), GetYOProbability(), GetYProbability(), GetYProbabilityGeneral(), MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), InitializeIIs(), MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), SampleY(), and FSAOHDist_NECOF::Update().
|
inline |
Set the CPDDiscreteInterface for O.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor().
|
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 |
returns the total number of IIs
References _m_ii_initialized, and _m_ii_size_Y.
Referenced by IndividualToJointYiiIndices(), and MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN().
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.
References _m_madp, _m_O_CPDs, MultiAgentDecisionProcessDiscreteInterface::GetNrObservations(), GetXSoI_O(), IndividualToJointOiiIndices(), and ArgumentHandlers::size().
Referenced by FSAOHDist_NECOF::Update().
double TwoStageDynamicBayesianNetwork::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.
References _m_O_CPDs, GetASoI_O(), GetOSoI_O(), GetXSoI_O(), GetYSoI_O(), IndividualToJointOiiIndices(), IndexTools::RestrictIndividualIndicesToScope(), and ArgumentHandlers::size().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetObservationProbability(), and MultiAgentDecisionProcessDiscreteFactoredStates::MarginalizeTransitionObservationModel().
Referenced by GetOProbability(), MultiAgentDecisionProcessDiscreteFactoredStates::GetOSoI_O(), GetYOProbability(), MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), InitializeIIs(), MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), SampleO(), and FSAOHDist_NECOF::Update().
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.
Referenced by GetOProbabilitiesExactScopes(), GetOProbability(), MultiAgentDecisionProcessDiscreteFactoredStates::GetXSoI_O(), GetYOProbability(), MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), InitializeIIs(), JointToIndividualOiiIndices(), MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), and SampleO().
Referenced by FactoredDecPOMDPDiscrete::ExportSpuddFile(), MultiAgentDecisionProcessDiscreteFactoredStates::GetXSoI_Y(), GetYOProbability(), GetYProbability(), GetYProbabilityGeneral(), MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), InitializeIIs(), MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), SampleY(), and FSAOHDist_NECOF::Update().
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.
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 |
Get the probability of Y given X,A. All are full-length.
because all factors are included, we do not need to discriminate Yii and Y.
References _m_madp, _m_Y_CPDs, GetASoI_Y(), MultiAgentDecisionProcessInterface::GetNrAgents(), MultiAgentDecisionProcessDiscreteFactoredStatesInterface::GetNrStateFactors(), GetXSoI_Y(), GetYSoI_Y(), IndividualToJointYiiIndices(), IndexTools::RestrictIndividualIndicesToScope(), and ArgumentHandlers::size().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::GetTransitionProbability(), and MultiAgentDecisionProcessDiscreteFactoredStates::MarginalizeTransitionObservationModel().
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
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
References _m_Y_CPDs, GetASoI_Y(), GetXSoI_Y(), GetYSoI_Y(), IndividualToJointYiiIndices(), IndexTools::RestrictIndividualIndicesToNarrowerScope(), and ArgumentHandlers::size().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), and MultiAgentDecisionProcessDiscreteFactoredStates::MarginalizeTransitionObservationModel().
Referenced by FSAOHDist_NECOF::FSAOHDist_NECOF(), GetOProbability(), GetYOProbability(), MultiAgentDecisionProcessDiscreteFactoredStates::GetYSoI_O(), MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), InitializeIIs(), MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), SampleO(), and FSAOHDist_NECOF::Update().
Referenced by GetYOProbability(), GetYProbability(), GetYProbabilityGeneral(), MultiAgentDecisionProcessDiscreteFactoredStates::GetYSoI_Y(), MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), InitializeIIs(), MultiAgentDecisionProcessDiscreteFactoredStates::MarginalizeTransitionObservationModel(), MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), and SampleY().
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::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.
std::vectors are restricted to only include values in SoI(y)
References _m_IndividualToJointYiiIndices_catVector, _m_nrVals_SoI_Y, _m_nrVals_SoI_Y_stepsize, GetiiSize_Y(), IndexTools::IndividualToJointIndices(), and IndexTools::IndividualToJointIndicesStepSize().
Referenced by GetYOProbability(), GetYProbabilitiesExactScopes(), GetYProbability(), GetYProbabilityGeneral(), MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), and SampleY().
void TwoStageDynamicBayesianNetwork::InitializeIIs | ( | ) |
Computes some administrative things necessary for II functions.
This should be called after all SoI's have been defined. When not using any II functions, this may be skipped?! (I think)
References _m_A_restr_perO, _m_A_restr_perY, _m_Aii_size_O, _m_Aii_size_Y, _m_ii_initialized, _m_ii_size_O, _m_ii_size_Y, _m_IndividualToJointOiiIndices_catVector, _m_IndividualToJointYiiIndices_catVector, _m_madp, _m_nrO, _m_nrVals_ASoI_O, _m_nrVals_ASoI_Y, _m_nrVals_OSoI_O, _m_nrVals_SoI_O, _m_nrVals_SoI_O_stepsize, _m_nrVals_SoI_Y, _m_nrVals_SoI_Y_stepsize, _m_nrVals_XSoI_O, _m_nrVals_XSoI_Y, _m_nrVals_YSoI_O, _m_nrVals_YSoI_Y, _m_nrY, _m_O_restr_perO, _m_Oii_size_O, _m_X_restr_perO, _m_X_restr_perY, _m_Xii_size_O, _m_Xii_size_Y, _m_Y_restr_perO, _m_Y_restr_perY, _m_Yii_size_O, _m_Yii_size_Y, IndexTools::CalculateStepSize(), GetASoI_O(), GetASoI_Y(), MultiAgentDecisionProcessDiscreteInterface::GetNrActions(), MultiAgentDecisionProcessDiscreteInterface::GetNrObservations(), MultiAgentDecisionProcessDiscreteFactoredStatesInterface::GetNrValuesPerFactor(), GetOSoI_O(), GetXSoI_O(), GetXSoI_Y(), GetYSoI_O(), GetYSoI_Y(), IndexTools::RestrictIndividualIndicesToScope(), and ArgumentHandlers::size().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), and MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor().
void TwoStageDynamicBayesianNetwork::InitializeStorage | ( | ) |
Copy assignment operator.
Sets the SoI vectors to appropriate size and containing empty scopes. this function should be called after adding all state factors, but before trying to add the connections (by setting the SoI's)
References _m_ASoI_O, _m_ASoI_Y, _m_madp, _m_nrO, _m_nrY, _m_O_CPDs, _m_OSoI_O, _m_SampleNrO, _m_SampleO, _m_SampleY, _m_SoIStorageInitialized, _m_XSoI_O, _m_XSoI_Y, _m_Y_CPDs, _m_YSoI_O, _m_YSoI_Y, MultiAgentDecisionProcessInterface::GetNrAgents(), MultiAgentDecisionProcessDiscreteInterface::GetNrObservations(), MultiAgentDecisionProcessDiscreteFactoredStatesInterface::GetNrStateFactors(), and SoftPrint().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), and MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor().
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::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().
|
inline |
Sample an observation.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::SampleJointObservation().
vector< Index > TwoStageDynamicBayesianNetwork::SampleO | ( | const std::vector< Index > & | X, |
const std::vector< Index > & | A, | ||
const std::vector< Index > & | Y | ||
) | const |
Sample an observation.
References _m_A_restr_perO, _m_nrO, _m_O_CPDs, _m_O_restr_perO, _m_SampleO, _m_X_restr_perO, _m_Y_restr_perO, GetASoI_O(), GetOSoI_O(), GetXSoI_O(), GetYSoI_O(), IndividualToJointOiiIndices(), and IndexTools::RestrictIndividualIndicesToScope().
vector< Index > TwoStageDynamicBayesianNetwork::SampleY | ( | const std::vector< Index > & | X, |
const std::vector< Index > & | A | ||
) | const |
Sample a NS state.
References _m_A_restr_perY, _m_nrY, _m_SampleY, _m_X_restr_perY, _m_Y_CPDs, _m_Y_restr_perY, GetASoI_Y(), GetXSoI_Y(), GetYSoI_Y(), IndividualToJointYiiIndices(), and IndexTools::RestrictIndividualIndicesToScope().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::SampleSuccessorState().
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().
|
inline |
|
inline |
void TwoStageDynamicBayesianNetwork::SetSoI_O | ( | Index | o, |
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, and _m_YSoI_O.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), and MultiAgentDecisionProcessDiscreteFactoredStates::SetSoI_O().
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 | ||
) |
Sets the SoI of a NS SF y.
References _m_ASoI_Y, _m_SoIStorageInitialized, _m_XSoI_Y, and _m_YSoI_Y.
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::RemoveStateFactor(), and MultiAgentDecisionProcessDiscreteFactoredStates::SetSoI_Y().
string TwoStageDynamicBayesianNetwork::SoftPrint | ( | ) | const |
References _m_madp, _m_SoIStorageInitialized, MultiAgentDecisionProcessInterface::GetNrAgents(), MultiAgentDecisionProcessDiscreteFactoredStatesInterface::GetNrStateFactors(), SoftPrintSoI_O(), and SoftPrintSoI_Y().
Referenced by MultiAgentDecisionProcessDiscreteFactoredStates::Initialize2DBN(), ProblemFOBSFireFightingFactored::InitializePFFF(), ProblemFireFightingFactored::InitializePFFF(), InitializeStorage(), and MultiAgentDecisionProcessDiscreteFactoredStates::SoftPrint().
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().
|
private |
Referenced by InitializeIIs(), SampleO(), and ~TwoStageDynamicBayesianNetwork().
|
private |
Referenced by InitializeIIs(), SampleY(), and ~TwoStageDynamicBayesianNetwork().
|
private |
For each O we maintain the number of instantiations of ASoI(O)
Referenced by GetAiiSize_O(), and InitializeIIs().
|
private |
For each Y we maintain the number of instantiations of ASoI(Y)
Referenced by GetAiiSize_Y(), and InitializeIIs().
|
private |
For each O we maintain the actions, A, in its SoI.
Referenced by InitializeStorage(), ScopeBackup(), SetSoI_O(), and SoftPrintSoI_O().
|
private |
For each NS SF we maintain the actions, A, in its SoI.
Referenced by InitializeStorage(), ScopeBackup(), SetSoI_Y(), and SoftPrintSoI_Y().
|
private |
Boolean that is set when all ii info is initialized.
Referenced by GetAiiSize_O(), GetAiiSize_Y(), GetiiSize_O(), GetiiSize_Y(), GetNrVals_ASoI_O(), GetNrVals_ASoI_Y(), GetNrVals_OSoI_O(), GetNrVals_XSoI_O(), GetNrVals_XSoI_Y(), GetNrVals_YSoI_O(), GetNrVals_YSoI_Y(), GetOiiSize_O(), GetXiiSize_O(), GetXiiSize_Y(), GetYiiSize_O(), GetYiiSize_Y(), and InitializeIIs().
|
private |
For each y we maintain the number of II's.
Referenced by GetiiSize_O(), and InitializeIIs().
|
private |
For each y we maintain the number of II's.
Referenced by GetiiSize_Y(), and InitializeIIs().
|
private |
Temporary storage used in IndividualToJointOiiIndices.
Referenced by IndividualToJointOiiIndices(), InitializeIIs(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().
|
private |
Temporary storage used in IndividualToJointYiiIndices.
Referenced by IndividualToJointYiiIndices(), InitializeIIs(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().
|
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().
|
private |
the number of observation factors (i.e., the number of agents)
Referenced by InitializeIIs(), InitializeStorage(), and SampleO().
|
private |
For each O we maintain the number of actions in ASoI(O)
Referenced by GetNrVals_ASoI_O(), InitializeIIs(), and JointToIndividualOiiIndices().
|
private |
For each NS SF Y we maintain the number of actions in ASoI(Y)
Referenced by GetNrVals_ASoI_Y(), InitializeIIs(), and JointToIndividualYiiIndices().
|
private |
For each O we maintain the number of observations in OSoI(O)
Referenced by GetNrVals_OSoI_O(), InitializeIIs(), and JointToIndividualOiiIndices().
|
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().
|
private |
Cache the step size for speed.
Referenced by IndividualToJointOiiIndices(), InitializeIIs(), and ~TwoStageDynamicBayesianNetwork().
|
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().
|
private |
Cache the step size for speed.
Referenced by IndividualToJointYiiIndices(), InitializeIIs(), and ~TwoStageDynamicBayesianNetwork().
|
private |
For each O we maintain the number of SF values in XSoI(O)
Referenced by GetNrVals_XSoI_O(), InitializeIIs(), and JointToIndividualOiiIndices().
|
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().
|
private |
For each O we maintain the number of SF values in YSoI(O)
Referenced by GetNrVals_YSoI_O(), InitializeIIs(), and JointToIndividualOiiIndices().
|
private |
For each NS SF Y we maintain the number of SF values in YSoI(Y)
Referenced by GetNrVals_YSoI_Y(), InitializeIIs(), and JointToIndividualYiiIndices().
|
private |
the number of state factors
Referenced by InitializeIIs(), InitializeStorage(), and SampleY().
|
private |
For each observation we maintain a CPD.
Referenced by GetOProbabilitiesExactScopes(), GetOProbability(), GetYOProbability(), InitializeStorage(), SampleO(), and ~TwoStageDynamicBayesianNetwork().
|
private |
Referenced by InitializeIIs(), SampleO(), and ~TwoStageDynamicBayesianNetwork().
|
private |
For each O we maintain the number of instantiations of OSoI(O)
Referenced by GetOiiSize_O(), and InitializeIIs().
|
private |
For each O we maintain the observations, O, in its SoI.
Referenced by ComputeWithinNextStageClosure(), InitializeStorage(), SetSoI_O(), and SoftPrintSoI_O().
|
private |
Temporary storage used in SampleO.
Referenced by InitializeStorage(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().
|
private |
Temporary storage used in SampleO.
Referenced by InitializeStorage(), SampleO(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().
|
private |
Temporary storage used in SampleY.
Referenced by InitializeStorage(), SampleY(), TwoStageDynamicBayesianNetwork(), and ~TwoStageDynamicBayesianNetwork().
|
private |
Referenced by InitializeStorage(), SetSoI_O(), SetSoI_Y(), SoftPrint(), and TwoStageDynamicBayesianNetwork().
|
private |
Referenced by InitializeIIs(), SampleO(), and ~TwoStageDynamicBayesianNetwork().
|
private |
Referenced by InitializeIIs(), SampleY(), and ~TwoStageDynamicBayesianNetwork().
|
private |
For each O we maintain the number of instantiations of XSoI(O)
Referenced by GetXiiSize_O(), and InitializeIIs().
|
private |
For each Y we maintain the number of instantiations of XSoI(Y)
Referenced by GetXiiSize_Y(), and InitializeIIs().
|
private |
For each O we maintain the PS SFs, X, in its SoI.
Referenced by InitializeStorage(), ScopeBackup(), SetSoI_O(), and SoftPrintSoI_O().
|
private |
For each NS SF we maintain the PS SFs, X, in its SoI.
Referenced by InitializeStorage(), ScopeBackup(), SetSoI_Y(), and SoftPrintSoI_Y().
|
private |
For each next-stage state variable y we maintain a CPD.
Referenced by GetYOProbability(), GetYProbabilitiesExactScopes(), GetYProbability(), GetYProbabilityGeneral(), InitializeStorage(), SampleY(), and ~TwoStageDynamicBayesianNetwork().
|
private |
Referenced by InitializeIIs(), SampleO(), and ~TwoStageDynamicBayesianNetwork().
|
private |
Referenced by InitializeIIs(), SampleY(), and ~TwoStageDynamicBayesianNetwork().
|
private |
For each O we maintain the number of instantiations of YSoI(O)
Referenced by GetYiiSize_O(), and InitializeIIs().
|
private |
For each Y we maintain the number of instantiations of YSoI(Y)
Referenced by GetYiiSize_Y(), and InitializeIIs().
|
private |
For each O we maintain the NS SFs, Y, in its SoI.
Referenced by ComputeWithinNextStageClosure(), InitializeStorage(), SetSoI_O(), and SoftPrintSoI_O().
|
private |
For each NS SF we maintain the NS SFs, Y, in its SoI.
Referenced by ComputeWithinNextStageClosure(), InitializeStorage(), SetSoI_Y(), and SoftPrintSoI_Y().