![]() |
aGrUM
0.17.2
a C++ library for (probabilistic) graphical models
|
Portion of a BN identified by the list of nodes and a BayesNet. More...
#include <agrum/BN/BayesNetFragment.h>
Public Member Functions | |
gum::BayesNet< GUM_SCALAR > | toBN () const |
create a brand new BayesNet from a fragment. More... | |
bool | operator== (const IBayesNet< GUM_SCALAR > &from) const |
This operator compares 2 BNs ! More... | |
bool | operator!= (const IBayesNet< GUM_SCALAR > &from) const |
Size | dim () const |
Returns the dimension (the number of free parameters) in this bayes net. More... | |
Size | maxVarDomainSize () const |
GUM_SCALAR | minParam () const |
GUM_SCALAR | maxParam () const |
GUM_SCALAR | minNonZeroParam () const |
GUM_SCALAR | maxNonOneParam () const |
std::string | toString () const |
NodeSet | minimalCondSet (NodeId target, const NodeSet &soids) const |
NodeSet | minimalCondSet (const NodeSet &targets, const NodeSet &soids) const |
bool | hasSameStructure (const DAGmodel &other) |
double | log10DomainSize () const |
void | attachSignal__ (__sig__::ISignaler *sender) |
void | detachSignal__ (__sig__::ISignaler *sender) |
Constructors / Destructors | |
BayesNetFragment ()=delete | |
BayesNetFragment (const BayesNetFragment< GUM_SCALAR > &fragment)=delete | |
BayesNetFragment (BayesNetFragment< GUM_SCALAR > &&fragment)=delete | |
BayesNetFragment (const IBayesNet< GUM_SCALAR > &bn) | |
virtual | ~BayesNetFragment () |
signals | |
virtual void | whenNodeAdded (const void *src, NodeId id) final |
the action to take when a new node is inserted into the graph More... | |
virtual void | whenNodeDeleted (const void *src, NodeId id) final |
the action to take when a node has just been removed from the graph More... | |
virtual void | whenArcAdded (const void *src, NodeId from, NodeId to) final |
the action to take when a new arc is inserted into the graph More... | |
virtual void | whenArcDeleted (const void *src, NodeId from, NodeId to) final |
the action to take when an arc has just been removed from the graph More... | |
IBayesNet interface | |
virtual const Potential< GUM_SCALAR > & | cpt (NodeId varId) const final |
Returns the CPT of a variable. More... | |
virtual const Potential< GUM_SCALAR > & | cpt (const std::string &name) const |
Returns the CPT of a variable. More... | |
virtual const VariableNodeMap & | variableNodeMap () const final |
Returns a constant reference to the VariableNodeMap of this BN. More... | |
virtual const DiscreteVariable & | variable (NodeId id) const final |
Returns a constant reference over a variabe given it's node id. More... | |
virtual const DiscreteVariable & | variable (const std::string &name) const final |
Returns the CPT of a variable. More... | |
virtual NodeId | nodeId (const DiscreteVariable &var) const final |
Return id node from discrete var pointer. More... | |
virtual NodeId | idFromName (const std::string &name) const final |
Getter by name. More... | |
virtual const DiscreteVariable & | variableFromName (const std::string &name) const final |
Getter by name. More... | |
virtual std::string | toDot () const final |
creates a dot representing the whole referred BN hilighting the fragment. More... | |
API for Fragment | |
bool | isInstalledNode (NodeId id) const |
check if a certain NodeId exists in the fragment More... | |
bool | isInstalledNode (const std::string &name) const |
check if a certain NodeId exists in the fragment More... | |
void | installNode (NodeId id) |
install a node referenced by its nodeId More... | |
void | installNode (const std::string &name) |
check if a certain NodeId exists in the fragment More... | |
void | installAscendants (NodeId id) |
install a node and all its ascendants More... | |
void | installAscendants (const std::string &name) |
check if a certain NodeId exists in the fragment More... | |
void | uninstallNode (NodeId id) |
uninstall a node referenced by its nodeId More... | |
void | uninstallNode (const std::string &name) |
check if a certain NodeId exists in the fragment More... | |
void | installMarginal (NodeId id, const Potential< GUM_SCALAR > &pot) |
install a local marginal BY COPY for a node into the fragment. More... | |
void | installMarginal (const std::string &name, const Potential< GUM_SCALAR > &pot) |
check if a certain NodeId exists in the fragment More... | |
void | installCPT (NodeId id, const Potential< GUM_SCALAR > &pot) |
install a local cpt BY COPYfor a node into the fragment. More... | |
void | installCPT (const std::string &name, const Potential< GUM_SCALAR > &pot) |
check if a certain NodeId exists in the fragment More... | |
void | uninstallCPT (NodeId id) |
uninstall a local CPT. More... | |
void | uninstallCPT (const std::string &name) |
check if a certain NodeId exists in the fragment More... | |
bool | checkConsistency (NodeId id) const |
returns true if the nodeId's (local or not) cpt is consistent with its parents in the fragment More... | |
bool | checkConsistency (const std::string &name) const |
check if a certain NodeId exists in the fragment More... | |
bool | checkConsistency () const |
returns true if all nodes in the fragment are consistent More... | |
Joint Probability manipulation methods | |
GUM_SCALAR | jointProbability (const Instantiation &i) const |
Compute a parameter of the joint probability for the BN (given an instantiation of the vars) More... | |
GUM_SCALAR | log2JointProbability (const Instantiation &i) const |
Compute a parameter of the log joint probability for the BN (given an instantiation of the vars) More... | |
Variable manipulation methods. | |
const DAG & | dag () const |
Returns a constant reference to the dag of this Bayes Net. More... | |
virtual Size | size () const final |
Returns the number of variables in this Directed Graphical Model. More... | |
Size | sizeArcs () const |
Returns the number of arcs in this Directed Graphical Model. More... | |
const NodeGraphPart & | nodes () const |
Returns a constant reference to the dag of this Bayes Net. More... | |
Arc manipulation methods. | |
const ArcSet & | arcs () const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | parents (const NodeId id) const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | parents (const std::string &name) const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | children (const NodeId id) const |
returns the set of nodes with arc outgoing from a given node More... | |
const NodeSet & | children (const std::string &name) const |
returns the set of nodes with arc ingoing to a given node More... | |
Graphical methods | |
const UndiGraph & | moralGraph (bool clear=true) const |
The node's id are coherent with the variables and nodes of the topology. More... | |
const Sequence< NodeId > & | topologicalOrder (bool clear=true) const |
The topological order stays the same as long as no variable or arcs are added or erased src the topology. More... | |
Getter and setters | |
const std::string & | property (const std::string &name) const |
Return the value of the property name of this GraphicalModel. More... | |
const std::string & | propertyWithDefault (const std::string &name, const std::string &byDefault) const |
Return the value of the property name of this GraphicalModel. More... | |
void | setProperty (const std::string &name, const std::string &value) |
Add or change a property of this GraphicalModel. More... | |
Variable manipulation methods. | |
virtual bool | empty () const |
Retursn true if this Directed Graphical Model is empty. More... | |
Instantiation | completeInstantiation () const |
Get an instantiation over all the variables of the model. More... | |
Protected Attributes | |
DAG | _dag |
The DAG of this Directed Graphical Model. More... | |
DiGraph * | _graph |
the graph to listen to More... | |
Protected Member Functions | |
void | _uninstallArc (NodeId from, NodeId to) |
void | _installArc (NodeId from, NodeId to) |
void | _installCPT (NodeId id, const Potential< GUM_SCALAR > &pot) |
void | _uninstallCPT (NodeId id) |
uninstall a local CPT. More... | |
Portion of a BN identified by the list of nodes and a BayesNet.
This class is a decorator of a BayesNet implementing the IBayesNet interface. CPTs can be shared with the BN or can be specific to the Fragment if different.
BayesNetFragment is a DiGraphListener in order to be synchronized (especially when removing nodes or arcs).
In a BayesNetFragment, one can install or remove nodes. An arc can be in the fragment if and only if its head and tail are installed in the fragment. *When installing a node, all the arcs that can be added in the fragment are *effectively installed (resp. *when uninstalling a node, etc.).
A BayesNetFragment can redefine potential for node. The main reason is to be able to install a node without installing all its parents (and its ascendants). So local CPT to the node can be installed. However, it is not done automatically.
If a cpt is not locally defined, the fragment uses the cpt defined in the referred BN. The checkConsistency() method verifies that, for all installed nodes, either all the parents are installed or a local CPT is defined.
Definition at line 73 of file BayesNetFragment.h.
|
delete |
|
delete |
|
delete |
|
explicit |
Definition at line 35 of file BayesNetFragment_tpl.h.
|
virtual |
Definition at line 43 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__localCPTs, gum::BayesNetFragment< GUM_SCALAR >::_uninstallCPT(), and gum::DAGmodel::nodes().
|
protected |
Definition at line 189 of file BayesNetFragment_tpl.h.
References gum::DAGmodel::_dag, and gum::DAG::addArc().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT().
|
protected |
Definition at line 194 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, gum::BayesNetFragment< GUM_SCALAR >::__localCPTs, gum::BayesNetFragment< GUM_SCALAR >::_installArc(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallArc(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallCPT(), gum::Set< Key, Alloc >::beginSafe(), gum::Set< Key, Alloc >::endSafe(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), gum::DAGmodel::parents(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), and gum::BayesNetFragment< GUM_SCALAR >::installMarginal().
|
protected |
Definition at line 183 of file BayesNetFragment_tpl.h.
References gum::DAGmodel::_dag, and gum::ArcGraphPart::eraseArc().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), and gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted().
|
protected |
uninstall a local CPT.
Does nothing if no local CPT for this nodeId No check. No change in the topology. Checks are made in public methods.
Definition at line 239 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__localCPTs.
Referenced by gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT(), and gum::BayesNetFragment< GUM_SCALAR >::~BayesNetFragment().
|
inherited |
returns the set of nodes with arc ingoing to a given node
Note that the set of nodes returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the nodes returned share an arc |
Definition at line 44 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag, and gum::ArcGraphPart::arcs().
Referenced by gum::EssentialGraph::__buildEssentialGraph(), gum::DAGmodel::__moralGraph(), gum::MarkovBlanket::hasSameStructure(), gum::DAGmodel::hasSameStructure(), and gum::BayesNetFragment< GUM_SCALAR >::toBN().
|
inherited |
bool gum::BayesNetFragment< GUM_SCALAR >::checkConsistency | ( | NodeId | id | ) | const |
returns true if the nodeId's (local or not) cpt is consistent with its parents in the fragment
NotFound | if the id is not in the fragment |
Definition at line 281 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, gum::BayesNetFragment< GUM_SCALAR >::cpt(), GUM_ERROR, gum::Set< Key, Alloc >::insert(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), and gum::DAGmodel::parents().
|
inline |
check if a certain NodeId exists in the fragment
Definition at line 273 of file BayesNetFragment.h.
References gum::BayesNetFragment< GUM_SCALAR >::_installArc(), gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallArc(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallCPT(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::idFromName(), and gum::BayesNetFragment< GUM_SCALAR >::toBN().
INLINE bool gum::BayesNetFragment< GUM_SCALAR >::checkConsistency | ( | ) | const |
returns true if all nodes in the fragment are consistent
gum::OperatioNotAllowed | if the fragment is not consistent. |
Definition at line 296 of file BayesNetFragment_tpl.h.
References gum::DAGmodel::nodes().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::toBN(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT().
returns the set of nodes with arc outgoing from a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is outgoing from the given node.
id | the node which is the tail of the arcs returned |
Definition at line 53 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag, and gum::ArcGraphPart::children().
Referenced by gum::MarkovBlanket::__buildMarkovBlanket(), gum::MarkovBlanket::MarkovBlanket(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
|
inherited |
returns the set of nodes with arc ingoing to a given node
Note that the set of nodes returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the nodes returned share an arc |
Definition at line 56 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag, gum::ArcGraphPart::children(), and gum::DAGmodel::idFromName().
|
inherited |
Get an instantiation over all the variables of the model.
Definition at line 85 of file graphicalModel_inl.h.
References gum::GraphicalModel::nodes(), and gum::GraphicalModel::variable().
|
finalvirtual |
Returns the CPT of a variable.
NotFound | If no variable's id matches varId. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 80 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, gum::BayesNetFragment< GUM_SCALAR >::__localCPTs, GUM_ERROR, and gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode().
Referenced by gum::ImportanceSampling< GUM_SCALAR >::_unsharpenBN(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::cpt(), gum::BayesNetFragment< GUM_SCALAR >::toBN(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT().
|
inlinevirtual |
Returns the CPT of a variable.
NotFound | If no variable's id matches varId. |
Definition at line 131 of file BayesNetFragment.h.
References gum::BayesNetFragment< GUM_SCALAR >::cpt(), gum::BayesNetFragment< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::variable(), and gum::BayesNetFragment< GUM_SCALAR >::variableNodeMap().
|
inherited |
Returns a constant reference to the dag of this Bayes Net.
Definition at line 36 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag.
Referenced by gum::DAGmodel::__moralGraph(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::genericBNLearner::Database::Database(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::MarginalTargetedInference< GUM_SCALAR >::MarginalTargetedInference(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), gum::DAGmodel::size(), gum::BayesNetFragment< GUM_SCALAR >::toBN(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::DAGmodel::topologicalOrder(), gum::InfluenceDiagram< GUM_SCALAR >::toString(), and gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted().
|
inherited |
|
inherited |
Returns the dimension (the number of free parameters) in this bayes net.
\( dim(G)=\sum_{i \in nodes} ((r_i-1)\cdot q_i) \) where \( r_i \) is the number of instantiations of node \( i \) and \( q_i \) is the number of instantiations of its parents.
Definition at line 79 of file IBayesNet_tpl.h.
|
virtualinherited |
Retursn true if this Directed Graphical Model is empty.
Definition at line 95 of file graphicalModel_inl.h.
References gum::GraphicalModel::size().
Definition at line 103 of file DAGmodel.cpp.
References gum::DAGmodel::arcs(), gum::Set< Key, Alloc >::exists(), gum::DAGmodel::idFromName(), gum::DAGmodel::nodes(), gum::DAGmodel::size(), gum::DAGmodel::sizeArcs(), and gum::DAGmodel::variable().
|
finalvirtual |
Getter by name.
NotFound | if no such name exists in the graph. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 119 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, GUM_ERROR, and gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::cpt(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT(), gum::BayesNetFragment< GUM_SCALAR >::uninstallNode(), gum::BayesNetFragment< GUM_SCALAR >::variable(), and gum::BayesNetFragment< GUM_SCALAR >::variableFromName().
INLINE void gum::BayesNetFragment< GUM_SCALAR >::installAscendants | ( | NodeId | id | ) |
install a node and all its ascendants
NotFound | if the node does not exist in the referred BN |
Definition at line 166 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, and gum::BayesNetFragment< GUM_SCALAR >::installNode().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::installAscendants(), and gum::BayesNetFragment< GUM_SCALAR >::installNode().
|
inline |
check if a certain NodeId exists in the fragment
Definition at line 209 of file BayesNetFragment.h.
References gum::IBayesNet< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::installAscendants(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().
void gum::BayesNetFragment< GUM_SCALAR >::installCPT | ( | NodeId | id, |
const Potential< GUM_SCALAR > & | pot | ||
) |
install a local cpt BY COPYfor a node into the fragment.
This function will change the arcs from the parents to the node in order to be consistent with the new local potential.
id | the nodeId |
pot | the potential to be copied |
NotFound | if the id is not in the fragment |
OperationNotAllowed | if the potential is not compliant with the variable or if a variable in the CPT is not a parent in the referred bn. |
Definition at line 215 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::Set< Key, Alloc >::contains(), gum::DAGmodel::dag(), GUM_ERROR, gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), gum::DAGmodel::parents(), gum::MultiDimDecorator< GUM_SCALAR >::variable(), and gum::BayesNetFragment< GUM_SCALAR >::variable().
Referenced by gum::ImportanceSampling< GUM_SCALAR >::_onContextualize(), gum::ImportanceSampling< GUM_SCALAR >::_unsharpenBN(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), and gum::BayesNetFragment< GUM_SCALAR >::installMarginal().
|
inline |
check if a certain NodeId exists in the fragment
Definition at line 252 of file BayesNetFragment.h.
References gum::IBayesNet< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT().
void gum::BayesNetFragment< GUM_SCALAR >::installMarginal | ( | NodeId | id, |
const Potential< GUM_SCALAR > & | pot | ||
) |
install a local marginal BY COPY for a node into the fragment.
This function will remove all the arcs from the parents to the node.
id | the nodeId |
pot | the potential |
NotFound | if the id is not in the fragment |
OperationNotAllowed | if the potential is not compliant with the variable (or is not a marginal) |
Definition at line 261 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), GUM_ERROR, gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::installMarginal(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().
|
inline |
check if a certain NodeId exists in the fragment
Definition at line 234 of file BayesNetFragment.h.
References gum::IBayesNet< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), and gum::BayesNetFragment< GUM_SCALAR >::installMarginal().
void gum::BayesNetFragment< GUM_SCALAR >::installNode | ( | NodeId | id | ) |
install a node referenced by its nodeId
NotFound | if the node does not exist in the referred BN |
Definition at line 147 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, gum::DAGmodel::_dag, gum::DAG::addArc(), gum::NodeGraphPart::addNodeWithId(), GUM_ERROR, and gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::installAscendants(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), and gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode().
|
inline |
check if a certain NodeId exists in the fragment
Definition at line 198 of file BayesNetFragment.h.
References gum::IBayesNet< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::installAscendants(), and gum::BayesNetFragment< GUM_SCALAR >::installNode().
INLINE bool gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode | ( | NodeId | id | ) | const |
check if a certain NodeId exists in the fragment
Definition at line 142 of file BayesNetFragment_tpl.h.
References gum::DAGmodel::dag(), and gum::NodeGraphPart::existsNode().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::cpt(), gum::BayesNetFragment< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::installMarginal(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT(), gum::BayesNetFragment< GUM_SCALAR >::uninstallNode(), gum::BayesNetFragment< GUM_SCALAR >::variable(), and gum::BayesNetFragment< GUM_SCALAR >::variableFromName().
|
inline |
check if a certain NodeId exists in the fragment
Definition at line 187 of file BayesNetFragment.h.
References gum::BayesNetFragment< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), and gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode().
|
inherited |
Compute a parameter of the joint probability for the BN (given an instantiation of the vars)
Definition at line 211 of file IBayesNet_tpl.h.
|
inherited |
Definition at line 74 of file graphicalModel_inl.h.
References gum::GraphicalModel::nodes(), and gum::GraphicalModel::variable().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::toString(), and gum::IMarkovNet< GUM_SCALAR >::toString().
|
inherited |
Compute a parameter of the log joint probability for the BN (given an instantiation of the vars)
Compute a parameter of the joint probability for the BN (given an instantiation of the vars)
Definition at line 230 of file IBayesNet_tpl.h.
|
inherited |
Definition at line 135 of file IBayesNet_tpl.h.
|
inherited |
Definition at line 115 of file IBayesNet_tpl.h.
|
inherited |
Definition at line 95 of file IBayesNet_tpl.h.
Referenced by gum::ImportanceSampling< GUM_SCALAR >::_onContextualize().
|
inherited |
Definition at line 346 of file IBayesNet_tpl.h.
|
inherited |
Definition at line 366 of file IBayesNet_tpl.h.
|
inherited |
Definition at line 125 of file IBayesNet_tpl.h.
Referenced by gum::ImportanceSampling< GUM_SCALAR >::_onContextualize().
|
inherited |
Definition at line 105 of file IBayesNet_tpl.h.
The node's id are coherent with the variables and nodes of the topology.
clear | If false returns the previously created moral graph. |
Definition at line 83 of file DAGmodel.cpp.
References gum::DAGmodel::__moralGraph(), gum::DAGmodel::__mutableMoralGraph, and gum::UndiGraph::clear().
Referenced by gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), and gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes().
|
finalvirtual |
Return id node from discrete var pointer.
NotFound | If no variable matches var. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 108 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, GUM_ERROR, gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), and gum::Variable::name().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::variable().
|
virtualinherited |
Returns a constant reference to the dag of this Bayes Net.
Implements gum::GraphicalModel.
Definition at line 60 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag.
Referenced by gum::credal::CredalNet< GUM_SCALAR >::__bnCopy(), gum::EssentialGraph::__buildEssentialGraph(), gum::MarkovBlanket::__buildMarkovBlanket(), gum::DAGmodel::__moralGraph(), gum::credal::CredalNet< GUM_SCALAR >::__sort_varType(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__verticesSampling(), gum::ImportanceSampling< GUM_SCALAR >::_unsharpenBN(), gum::BayesNetFactory< GUM_SCALAR >::BayesNetFactory(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbBN(), gum::Estimator< GUM_SCALAR >::Estimator(), gum::getMaxModality(), gum::DAGmodel::hasSameStructure(), gum::prm::InstanceBayesNet< GUM_SCALAR >::modalities(), gum::prm::ClassBayesNet< GUM_SCALAR >::modalities(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::BayesNetFragment< GUM_SCALAR >::toBN(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toString(), and gum::BayesNetFragment< GUM_SCALAR >::~BayesNetFragment().
|
inherited |
Definition at line 294 of file IBayesNet_tpl.h.
|
inherited |
This operator compares 2 BNs !
Definition at line 247 of file IBayesNet_tpl.h.
returns the set of nodes with arc ingoing to a given node
Note that the set of nodes returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the nodes returned share an arc |
Definition at line 46 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag, and gum::ArcGraphPart::parents().
Referenced by gum::MarkovBlanket::__buildMarkovBlanket(), gum::DAGmodel::__moralGraph(), gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::DAGmodel::parents(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
|
inherited |
returns the set of nodes with arc ingoing to a given node
Note that the set of nodes returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the nodes returned share an arc |
Definition at line 49 of file DAGmodel_inl.h.
References gum::DAGmodel::idFromName(), and gum::DAGmodel::parents().
|
inherited |
Return the value of the property name of this GraphicalModel.
NotFound | Raised if no name property is found. |
Definition at line 37 of file graphicalModel_inl.h.
References gum::GraphicalModel::__properties(), and GUM_ERROR.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::toDot().
|
inherited |
Return the value of the property name of this GraphicalModel.
return byDefault if the property name is not found
Definition at line 57 of file graphicalModel_inl.h.
References gum::GraphicalModel::__properties().
|
inherited |
Add or change a property of this GraphicalModel.
Definition at line 65 of file graphicalModel_inl.h.
References gum::GraphicalModel::__properties(), and gum::HashTable< Key, Val, Alloc >::insert().
Referenced by gum::BayesNet< double >::fastPrototype(), and gum::IMarkovNet< GUM_SCALAR >::IMarkovNet().
|
finalvirtualinherited |
Returns the number of variables in this Directed Graphical Model.
Implements gum::GraphicalModel.
Definition at line 39 of file DAGmodel_inl.h.
References gum::DAGmodel::dag(), and gum::NodeGraphPart::size().
Referenced by gum::credal::CredalNet< GUM_SCALAR >::__initCNNets(), gum::InfluenceDiagram< GUM_SCALAR >::decisionNodeSize(), gum::MarkovBlanket::hasSameStructure(), gum::DAGmodel::hasSameStructure(), gum::IBayesNet< double >::operator==(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
|
inherited |
Returns the number of arcs in this Directed Graphical Model.
Definition at line 42 of file DAGmodel_inl.h.
References gum::DAGmodel::_dag, and gum::ArcGraphPart::sizeArcs().
Referenced by gum::MarkovBlanket::hasSameStructure(), gum::DAGmodel::hasSameStructure(), and gum::IBayesNet< double >::operator==().
gum::BayesNet< GUM_SCALAR > gum::BayesNetFragment< GUM_SCALAR >::toBN | ( | ) | const |
create a brand new BayesNet from a fragment.
Definition at line 377 of file BayesNetFragment_tpl.h.
References gum::BayesNet< GUM_SCALAR >::add(), gum::BayesNet< GUM_SCALAR >::addArc(), gum::DAGmodel::arcs(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::cpt(), gum::BayesNet< GUM_SCALAR >::cpt(), gum::DAGmodel::dag(), GUM_ERROR, gum::DAGmodel::nodes(), and gum::BayesNetFragment< GUM_SCALAR >::variable().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::checkConsistency().
|
finalvirtual |
creates a dot representing the whole referred BN hilighting the fragment.
Reimplemented from gum::IBayesNet< GUM_SCALAR >.
Definition at line 304 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, gum::BayesNetFragment< GUM_SCALAR >::__localCPTs, gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::DAGmodel::dag(), and gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::variable().
The topological order stays the same as long as no variable or arcs are added or erased src the topology.
clear | If false returns the previously created topology. |
Definition at line 99 of file DAGmodel.cpp.
References gum::DAGmodel::dag(), and gum::DiGraph::topologicalOrder().
Referenced by gum::EssentialGraph::__buildEssentialGraph(), gum::InfluenceDiagramGenerator< GUM_SCALAR >::__checkTemporalOrder(), gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists(), and gum::InfluenceDiagram< GUM_SCALAR >::getDecisionOrder().
|
inherited |
Definition at line 145 of file IBayesNet_tpl.h.
Referenced by gum::operator<<().
INLINE void gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT | ( | NodeId | id | ) |
uninstall a local CPT.
Definition at line 245 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, gum::BayesNetFragment< GUM_SCALAR >::__localCPTs, gum::BayesNetFragment< GUM_SCALAR >::_installArc(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallCPT(), gum::BayesNetFragment< GUM_SCALAR >::cpt(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::MultiDimDecorator< GUM_SCALAR >::nbrDim(), and gum::MultiDimDecorator< GUM_SCALAR >::variable().
Referenced by gum::ImportanceSampling< GUM_SCALAR >::_onContextualize(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().
|
inline |
check if a certain NodeId exists in the fragment
Definition at line 264 of file BayesNetFragment.h.
References gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::idFromName(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT().
INLINE void gum::BayesNetFragment< GUM_SCALAR >::uninstallNode | ( | NodeId | id | ) |
uninstall a node referenced by its nodeId
Definition at line 175 of file BayesNetFragment_tpl.h.
References gum::DAGmodel::_dag, gum::DiGraph::eraseNode(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::installAscendants(), gum::BayesNetFragment< GUM_SCALAR >::uninstallNode(), and gum::BayesNetFragment< GUM_SCALAR >::whenNodeDeleted().
|
inline |
check if a certain NodeId exists in the fragment
Definition at line 219 of file BayesNetFragment.h.
References gum::BayesNetFragment< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::installMarginal(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().
|
finalvirtual |
Returns a constant reference over a variabe given it's node id.
NotFound | If no variable's id matches varId. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 99 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, GUM_ERROR, and gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::cpt(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::BayesNetFragment< GUM_SCALAR >::toBN(), and gum::BayesNetFragment< GUM_SCALAR >::variable().
|
inlinefinalvirtual |
Returns the CPT of a variable.
NotFound | If no variable's id matches varId. |
Definition at line 146 of file BayesNetFragment.h.
References gum::BayesNetFragment< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::BayesNetFragment< GUM_SCALAR >::variable(), and gum::BayesNetFragment< GUM_SCALAR >::variableFromName().
|
finalvirtual |
Getter by name.
NotFound | if no such name exists in the graph. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 129 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::__bn, GUM_ERROR, gum::BayesNetFragment< GUM_SCALAR >::idFromName(), and gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode().
Referenced by gum::BayesNetFragment< GUM_SCALAR >::variable().
|
finalvirtual |
Returns a constant reference to the VariableNodeMap of this BN.
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 92 of file BayesNetFragment_tpl.h.
References GUM_ERROR.
Referenced by gum::BayesNetFragment< GUM_SCALAR >::cpt().
|
finalvirtual |
the action to take when a new arc is inserted into the graph
src | the object that sent the signal |
from | the id of tail of the new arc inserted into the graph |
to | the id of head of the new arc inserted into the graph |
Implements gum::DiGraphListener.
Definition at line 63 of file BayesNetFragment_tpl.h.
|
finalvirtual |
the action to take when an arc has just been removed from the graph
src | the object that sent the signal |
from | the id of tail of the arc removed from the graph |
to | the id of head of the arc removed from the graph |
Implements gum::DiGraphListener.
Definition at line 69 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::_uninstallArc(), and gum::DAGmodel::dag().
|
finalvirtual |
the action to take when a new node is inserted into the graph
src | the object that sent the signal |
id | the id of the new node inserted into the graph |
Implements gum::DiGraphListener.
Definition at line 53 of file BayesNetFragment_tpl.h.
|
finalvirtual |
the action to take when a node has just been removed from the graph
src | the object that sent the signal |
id | the id of the node has just been removed from the graph |
Implements gum::DiGraphListener.
Definition at line 58 of file BayesNetFragment_tpl.h.
References gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().
|
private |
The referred BayesNet.
Definition at line 78 of file BayesNetFragment.h.
Referenced by gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNetFragment< GUM_SCALAR >::cpt(), gum::BayesNetFragment< GUM_SCALAR >::idFromName(), gum::BayesNetFragment< GUM_SCALAR >::installAscendants(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::BayesNetFragment< GUM_SCALAR >::installMarginal(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), gum::BayesNetFragment< GUM_SCALAR >::nodeId(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT(), gum::BayesNetFragment< GUM_SCALAR >::variable(), and gum::BayesNetFragment< GUM_SCALAR >::variableFromName().
|
private |
Mapping between the variable's id and their CPT specific to this Fragment.
Definition at line 82 of file BayesNetFragment.h.
Referenced by gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallCPT(), gum::BayesNetFragment< GUM_SCALAR >::cpt(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT(), and gum::BayesNetFragment< GUM_SCALAR >::~BayesNetFragment().
|
protectedinherited |
The DAG of this Directed Graphical Model.
Definition at line 162 of file DAGmodel.h.
Referenced by gum::prm::ClassBayesNet< GUM_SCALAR >::__get(), gum::InfluenceDiagram< GUM_SCALAR >::_addNode(), gum::InfluenceDiagram< GUM_SCALAR >::_copyTables(), gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::BayesNetFragment< GUM_SCALAR >::_installArc(), gum::InfluenceDiagram< GUM_SCALAR >::_moralGraph(), gum::InfluenceDiagram< GUM_SCALAR >::_removeTables(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallArc(), gum::InfluenceDiagram< GUM_SCALAR >::addArc(), gum::DAGmodel::arcs(), gum::DAGmodel::children(), gum::DAGmodel::dag(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), gum::DAGmodel::nodes(), gum::DAGmodel::operator=(), gum::DAGmodel::parents(), gum::DAGmodel::sizeArcs(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().
|
protectedinherited |
the graph to listen to
Definition at line 99 of file diGraphListener.h.
Referenced by gum::DiGraphListener::DiGraphListener().