aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
gum::BayesNetFragment< GUM_SCALAR > Class Template Reference

Portion of a BN identified by the list of nodes and a BayesNet. More...

#include <agrum/BN/BayesNetFragment.h>

Inheritance diagram for gum::BayesNetFragment< GUM_SCALAR >:
Collaboration diagram for gum::BayesNetFragment< GUM_SCALAR >:

Public Member Functions

gum::BayesNet< GUM_SCALAR > toBN () const
 create a brand new BayesNet from a fragment.
std::vector< std::string > check () const
 Check if the BayesNet is consistent (variables, CPT).
bool operator== (const IBayesNet< GUM_SCALAR > &from) const
 This operator compares 2 BNs !
Size dim () const
 Returns the dimension (the number of free parameters) in this bayes net.
Size maxVarDomainSize () const
GUM_SCALAR minParam () const
GUM_SCALAR maxParam () const
GUM_SCALAR minNonZeroParam () const
GUM_SCALAR maxNonOneParam () const
std::string toString () const
Tensor< GUM_SCALAR > evEq (std::string_view name, double value) const
Tensor< GUM_SCALAR > evIn (std::string_view name, double val1, double val2) const
Tensor< GUM_SCALAR > evLt (std::string_view name, double value) const
Tensor< GUM_SCALAR > evGt (std::string_view name, double value) const
Size memoryFootprint () const
 compute the (approximated) footprint in memory of the model (the footprints of CPTs)
bool hasSameStructure (const DAGmodel &other) const
NodeSet minimalCondSet (NodeId target, const NodeSet &soids) const
NodeSet minimalCondSet (const NodeSet &targets, const NodeSet &soids) const
NodeSet minimalCondSet (std::string_view target, const std::vector< std::string > &soids) const
NodeSet minimalCondSet (const std::vector< std::string > &targets, const std::vector< std::string > &soids) const
const DAGinternalDag () const
 Returns a const reference to the internal (unnamed) DAG. O(1), no copy. Use for stable references or pointers (e.g. graph listeners). For named node access, use dag() instead.
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)
 ~BayesNetFragment () override
signals
void whenNodeAdded (const void *src, NodeId id) final
 the action to take when a new node is inserted into the graph
void whenNodeDeleted (const void *src, NodeId id) final
 the action to take when a node has just been removed from the graph
void whenArcAdded (const void *src, NodeId from, NodeId to) final
 the action to take when a new arc is inserted into the graph
void whenArcDeleted (const void *src, NodeId from, NodeId to) final
 the action to take when an arc has just been removed from the graph
IBayesNet interface
const Tensor< GUM_SCALAR > & cpt (NodeId varId) const final
 Returns the CPT of a variable.
const Tensor< GUM_SCALAR > & cpt (std::string_view name) const
 Returns the CPT of a variable.
const VariableNodeMapvariableNodeMap () const final
 Returns a constant reference to the VariableNodeMap of this BN.
const DiscreteVariablevariable (NodeId id) const final
 Returns a constant reference over a variabe given it's node id.
virtual const DiscreteVariablevariable (std::string_view name) const final
 Returns the CPT of a variable.
NodeId nodeId (const DiscreteVariable &var) const final
 Return id node from discrete var pointer.
NodeId idFromName (std::string_view name) const final
 Getter by name.
const DiscreteVariablevariableFromName (std::string_view name) const final
 Getter by name.
std::string toDot () const final
 creates a dot representing the whole referred BN hilighting the fragment.
API for Fragment
bool isInstalledNode (NodeId id) const
 check if a certain NodeId exists in the fragment
bool isInstalledNode (std::string_view name) const
 check if a certain NodeId exists in the fragment
void installNode (NodeId id)
 install a node referenced by its nodeId
void installNode (std::string_view name)
 check if a certain NodeId exists in the fragment
void installAscendants (NodeId id)
 install a node and all its ascendants
void installAscendants (std::string_view name)
 check if a certain NodeId exists in the fragment
void uninstallNode (NodeId id)
 uninstall a node referenced by its nodeId
void uninstallNode (std::string_view name)
 check if a certain NodeId exists in the fragment
void installMarginal (NodeId id, const Tensor< GUM_SCALAR > &pot)
 install a local marginal BY COPY for a node into the fragment.
void installMarginal (std::string_view name, const Tensor< GUM_SCALAR > &pot)
 check if a certain NodeId exists in the fragment
void installCPT (NodeId id, const Tensor< GUM_SCALAR > &pot)
 install a local cpt BY COPYfor a node into the fragment.
void installCPT (std::string_view name, const Tensor< GUM_SCALAR > &pot)
 check if a certain NodeId exists in the fragment
void uninstallCPT (NodeId id)
 uninstall a local CPT.
void uninstallCPT (std::string_view name)
 check if a certain NodeId exists in the fragment
bool checkConsistency (NodeId id) const
 returns true if the nodeId's (local or not) cpt is consistent with its parents in the fragment
bool checkConsistency (std::string_view name) const
 check if a certain NodeId exists in the fragment
bool checkConsistency () const
 returns true if all nodes in the fragment are consistent
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).
GUM_SCALAR log2JointProbability (const Instantiation &i) const
 Compute a parameter of the log joint probability for the BN (given an instantiation of the vars).
Variable manipulation methods.
DAG dag () const
 Returns a named copy of the internal DAG: each node id is assigned the name of the corresponding variable.
Size size () const final
 Returns the number of variables in this Directed Graphical Model.
Size sizeArcs () const
 Returns the number of arcs in this Directed Graphical Model.
const NodeGraphPartnodes () const final
 Returns a named copy of the internal DAG: each node id is assigned the name of the corresponding variable.
bool exists (NodeId node) const final
 Return true if this node exists in this graphical model.
bool exists (std::string_view name) const final
 Returns a named copy of the internal DAG: each node id is assigned the name of the corresponding variable.
Arc manipulation methods.
const ArcSetarcs () const
 return true if the arc tail->head exists in the DAGmodel
bool existsArc (const NodeId tail, const NodeId head) const
 return true if the arc tail->head exists in the DAGmodel
bool existsArc (std::string_view nametail, std::string_view namehead) const
 return true if the arc tail->head exists in the DAGmodel
const NodeSetparents (const NodeId id) const
 returns the set of nodes with arc ingoing to a given node
const NodeSetparents (std::string_view name) const
 return true if the arc tail->head exists in the DAGmodel
NodeSet parents (const NodeSet &ids) const
 returns the parents of a set of nodes
NodeSet parents (const std::vector< std::string > &names) const
 return true if the arc tail->head exists in the DAGmodel
NodeSet family (const NodeId id) const final
 returns the parents of a node and the node
NodeSet family (std::string_view name) const final
 return true if the arc tail->head exists in the DAGmodel
const NodeSetchildren (const NodeId id) const
 returns the set of nodes with arc outgoing from a given node
const NodeSetchildren (std::string_view name) const
 return true if the arc tail->head exists in the DAGmodel
NodeSet children (const NodeSet &ids) const
 returns the children of a set of nodes
NodeSet children (const std::vector< std::string > &names) const
 return true if the arc tail->head exists in the DAGmodel
NodeSet descendants (const NodeId id) const
 returns the set of nodes with directed path outgoing from a given node
NodeSet descendants (std::string_view name) const
 return true if the arc tail->head exists in the DAGmodel
NodeSet ancestors (const NodeId id) const
 returns the set of nodes with directed path ingoing to a given node
NodeSet ancestors (std::string_view name) const
 return true if the arc tail->head exists in the DAGmodel
Graphical methods
UndiGraph moralizedAncestralGraph (const NodeSet &nodes) const
 build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
UndiGraph moralizedAncestralGraph (const std::vector< std::string > &nodenames) const
 build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
bool isIndependent (NodeId X, NodeId Y, const NodeSet &Z) const final
 check if node X and node Y are independent given nodes Z
bool isIndependent (const NodeSet &X, const NodeSet &Y, const NodeSet &Z) const final
 check if nodes X and nodes Y are independent given nodes Z
bool isIndependent (std::string_view Xname, std::string_view Yname, const std::vector< std::string > &Znames) const
 build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
bool isIndependent (const std::vector< std::string > &Xnames, const std::vector< std::string > &Ynames, const std::vector< std::string > &Znames) const
 build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
UndiGraph moralGraph () const
 The node's id are coherent with the variables and nodes of the topology.
Sequence< NodeIdtopologicalOrder () const
 The topological order stays the same as long as no variable or arcs are added or erased src the topology.
NodeProperty< NodeIdconnectedComponents () const
 Returns the weakly connected components of the underlying DAG. Each node maps to the id of its component root.
Getter and setters
const std::string & property (std::string_view name) const
 Return the value of the property name of this GraphicalModel.
const std::string & propertyWithDefault (std::string_view name, const std::string &byDefault) const
 Return the value of the property name of this GraphicalModel.
void setProperty (std::string_view name, std::string_view value)
 Add or change a property of this GraphicalModel.
std::vector< std::string > properties () const
 List of all the names of property in the Graphical model.
bool existsProperty (std::string_view name) const
 check wether a property exists in this GraphicalModel
void updateMetaData ()
 update the meta data of this Graphical Model (version, creation date, last modification date) This method is called by the writers ONLY before writing the model to a file.
Variable manipulation methods.
virtual bool empty () const
 Return true if this graphical model is empty.
std::vector< std::string > names (const std::vector< NodeId > &ids) const
 transform a vector of NodeId in a vector of names
std::vector< std::string > names (const NodeSet &ids) const
 transform a NodeSet in a vector of names
std::vector< NodeIdids (const std::vector< std::string > &names) const
 transform a vector of names into a vector of nodeId
NodeSet nodeset (const std::vector< std::string > &names) const
 transform a vector of names into a NodeSet
gum::VariableSet variables (const std::vector< std::string > &l) const
 transform a vector of names into a VariableeSet
gum::VariableSet variables (const NodeSet &ids) const
 transform a vector of NodeId into a VariableeSet
Instantiation completeInstantiation () const
 Get an instantiation over all the variables of the model.

Static Public Member Functions

static std::string spaceCplxToString (double dSize, int dim, Size usedMem)
 send to the stream the space complexity with 3 parametrs

Protected Member Functions

void uninstallArc_ (NodeId from, NodeId to)
void installArc_ (NodeId from, NodeId to)
void installCPT_ (NodeId id, const Tensor< GUM_SCALAR > &pot)
void uninstallCPT_ (NodeId id)
 uninstall a local CPT.
void _nameNodes_ (NodeGraphPart &g) const
 Names every node of g using variable(id).name() for each node id in g.

Protected Attributes

DAG dag_
 The DAG of this Directed Graphical Model.
VariableNodeMap varMap_
 Mapping between NodeIds and discrete variables.
DiGraphgraph_
 the graph to listen to

Private Types

using Senders_list = std::vector< __sig__::ISignaler* >
 Alias for the list of signal senders.

Private Member Functions

const HashTable< std::string, std::string > & _properties_ () const
 Return the properties of this Directed Graphical Model.

Private Attributes

const IBayesNet< GUM_SCALAR > & _bn_
 The referred BayesNet.
NodeProperty< const Tensor< GUM_SCALAR > * > _localCPTs_
 Mapping between the variable's id and their CPT specific to this Fragment.
HashTable< std::string, std::string > _propertiesMap_
 The properties of this Directed Graphical Model.
Senders_list _senders_

Detailed Description

template<GUM_Numeric GUM_SCALAR>
class gum::BayesNetFragment< GUM_SCALAR >

Portion of a BN identified by the list of nodes and a BayesNet.

Author
Pierre-Henri WUILLEMIN(_at_LIP6)

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 tensor 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 90 of file BayesNetFragment.h.

Member Typedef Documentation

◆ Senders_list

using gum::Listener::Senders_list = std::vector< __sig__::ISignaler* >
privateinherited

Alias for the list of signal senders.

Definition at line 96 of file listener.h.

Constructor & Destructor Documentation

◆ BayesNetFragment() [1/4]

template<GUM_Numeric GUM_SCALAR>
gum::BayesNetFragment< GUM_SCALAR >::BayesNetFragment ( )
delete

Referenced by BayesNetFragment(), BayesNetFragment(), BayesNetFragment(), and ~BayesNetFragment().

Here is the caller graph for this function:

◆ BayesNetFragment() [2/4]

template<GUM_Numeric GUM_SCALAR>
gum::BayesNetFragment< GUM_SCALAR >::BayesNetFragment ( const BayesNetFragment< GUM_SCALAR > & fragment)
delete

References BayesNetFragment().

Here is the call graph for this function:

◆ BayesNetFragment() [3/4]

template<GUM_Numeric GUM_SCALAR>
gum::BayesNetFragment< GUM_SCALAR >::BayesNetFragment ( BayesNetFragment< GUM_SCALAR > && fragment)
delete

◆ BayesNetFragment() [4/4]

template<GUM_Numeric GUM_SCALAR>
gum::BayesNetFragment< GUM_SCALAR >::BayesNetFragment ( const IBayesNet< GUM_SCALAR > & bn)
explicit

Definition at line 56 of file BayesNetFragment_tpl.h.

56 :
59 }
Portion of a BN identified by the list of nodes and a BayesNet.
const IBayesNet< GUM_SCALAR > & _bn_
The referred BayesNet.
const DAG & internalDag() const
Returns a const reference to the internal (unnamed) DAG. O(1), no copy. Use for stable references or ...
DiGraphListener(const DiGraph *g)
default constructor

References BayesNetFragment(), gum::DiGraphListener::DiGraphListener(), gum::IBayesNet< GUM_SCALAR >::IBayesNet(), _bn_, and gum::DAGmodel::internalDag().

Here is the call graph for this function:

◆ ~BayesNetFragment()

template<GUM_Numeric GUM_SCALAR>
gum::BayesNetFragment< GUM_SCALAR >::~BayesNetFragment ( )
override

Definition at line 62 of file BayesNetFragment_tpl.h.

62 {
64
65 for (auto node: nodes())
66 if (_localCPTs_.exists(node)) uninstallCPT_(node);
67 }
NodeProperty< const Tensor< GUM_SCALAR > * > _localCPTs_
Mapping between the variable's id and their CPT specific to this Fragment.
void uninstallCPT_(NodeId id)
uninstall a local CPT.
const NodeGraphPart & nodes() const final
Returns a named copy of the internal DAG: each node id is assigned the name of the corresponding vari...

References BayesNetFragment(), _localCPTs_, gum::DAGmodel::nodes(), and uninstallCPT_().

Here is the call graph for this function:

Member Function Documentation

◆ _attachSignal_()

INLINE void gum::Listener::_attachSignal_ ( __sig__::ISignaler * sender)
inherited

Definition at line 57 of file listener_inl.h.

57{ _senders_.push_back(sender); }
Senders_list _senders_
Definition listener.h:113

References _senders_.

◆ _detachSignal_()

INLINE void gum::Listener::_detachSignal_ ( __sig__::ISignaler * sender)
inherited

Definition at line 59 of file listener_inl.h.

59 {
60 auto del = std::remove(_senders_.begin(), _senders_.end(), sender);
61
62 if (del != _senders_.end()) _senders_.erase(del, _senders_.end());
63 }

References _senders_.

Referenced by gum::__sig__::BasicSignaler< Args >::detach().

Here is the caller graph for this function:

◆ _nameNodes_()

INLINE void gum::GraphicalModel::_nameNodes_ ( NodeGraphPart & g) const
protectedinherited

Names every node of g using variable(id).name() for each node id in g.

Call this before returning any newly constructed graph from a model method.

Definition at line 175 of file graphicalModel_inl.h.

175 {
176 for (auto id: g)
177 g.setName(id, variable(id).name());
178 }
virtual const DiscreteVariable & variable(NodeId id) const =0
Returns a constant reference over a variable given it's node id.

References gum::NodeGraphPart::setName(), and variable().

Referenced by gum::DAGmodel::dag(), gum::UGmodel::graph(), gum::DAGmodel::moralGraph(), and gum::DAGmodel::moralizedAncestralGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ _properties_()

INLINE const HashTable< std::string, std::string > & gum::GraphicalModel::_properties_ ( ) const
privateinherited

Return the properties of this Directed Graphical Model.

Definition at line 67 of file graphicalModel_inl.h.

67 {
68 return _propertiesMap_;
69 }
HashTable< std::string, std::string > _propertiesMap_
The properties of this Directed Graphical Model.

References _propertiesMap_.

Referenced by property().

Here is the caller graph for this function:

◆ ancestors() [1/2]

INLINE NodeSet gum::DAGmodel::ancestors ( const NodeId id) const
inherited

returns the set of nodes with directed path ingoing to a given node

Note that the set of nodes returned may be empty if no path within the ArcGraphPart is ingoing to the given node.

Parameters
idthe node which is the head of a directed path with the returned nodes
namethe name of the node which is the head of a directed path with the returned nodes

Definition at line 135 of file DAGmodel_inl.h.

135{ return dag_.ancestors(id); }
DAG dag_
The DAG of this Directed Graphical Model.
Definition DAGmodel.h:284

References dag_.

Referenced by ancestors().

Here is the caller graph for this function:

◆ ancestors() [2/2]

INLINE NodeSet gum::DAGmodel::ancestors ( std::string_view name) const
inherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Definition at line 137 of file DAGmodel_inl.h.

137 {
138 return ancestors(idFromName(name));
139 }
NodeSet ancestors(const NodeId id) const
returns the set of nodes with directed path ingoing to a given node
NodeId idFromName(std::string_view name) const override
Returns the NodeId of a variable given its name.

References ancestors(), and gum::DiscreteGraphicalModel::idFromName().

Here is the call graph for this function:

◆ arcs()

INLINE const ArcSet & gum::DAGmodel::arcs ( ) const
inherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Definition at line 73 of file DAGmodel_inl.h.

73{ return dag_.arcs(); }

References dag_.

Referenced by hasSameStructure(), gum::MarkovBlanket::hasSameStructure(), and gum::BayesNetFragment< GUM_SCALAR >::toBN().

Here is the caller graph for this function:

◆ check()

template<GUM_Numeric GUM_SCALAR>
std::vector< std::string > gum::IBayesNet< GUM_SCALAR >::check ( ) const
inherited

Check if the BayesNet is consistent (variables, CPT).

Returns
a list of comments on the consistency of the Bayes Net

Definition at line 322 of file IBayesNet_tpl.h.

322 {
324
325 const double epsilon = 1e-8;
326 const double error_epsilon = 1e-1;
327
328 // CHECKING domain
329 for (const auto i: nodes())
330 if (variable(i).domainSize() < 2) {
332 s << "Variable " << variable(i).name() << ": not consistent (domainSize=1).";
333 comments.push_back(s.str());
334 }
335
336 // CHECKING parameters are probabilities
337 // >0
338 for (const auto i: nodes()) {
339 const auto [amin, minval] = cpt(i).argmin();
340 if (minval < (GUM_SCALAR)0.0) {
342 s << "Variable " << variable(i).name() << " : P(" << *(amin.begin()) << ") < 0.0";
343 comments.push_back(s.str());
344 }
345 }
346 // <1
347 for (const auto i: nodes()) {
348 const auto [amax, maxval] = cpt(i).argmax();
349 if (maxval > (GUM_SCALAR)1.0) {
351 s << "Variable " << variable(i).name() << " : P(" << *(amax.begin()) << ") > 1.0";
352 comments.push_back(s.str());
353 }
354 }
355
356 // CHECKING distributions sum to 1
357 for (const auto i: nodes()) {
358 const auto p = cpt(i).sumOut({&variable(i)});
359 const auto [amin, minval] = p.argmin();
360 if (minval < (GUM_SCALAR)(1.0 - epsilon)) {
362 s << "Variable " << variable(i).name() << " : ";
363 if (!parents(i).empty()) s << "with (at least) parents " << *(amin.begin()) << ", ";
364 s << "the CPT sum to less than 1";
365 if (minval > (GUM_SCALAR)(1.0 - error_epsilon)) s << " (normalization problem ?)";
366 s << ".";
367 comments.push_back(s.str());
368 continue;
369 }
370 const auto [amax, maxval] = p.argmax();
371 if (maxval > (GUM_SCALAR)(1.0 + epsilon)) {
373 s << "Variable " << variable(i).name() << " : ";
374 if (!parents(i).empty()) s << "with (at least) parents " << *(amax.begin()) << ", ";
375 s << "the CPT sum to more than 1";
376 if (maxval < (GUM_SCALAR)(1.0 + error_epsilon)) s << " (normalization problem ?)";
377 s << ".";
378 comments.push_back(s.str());
379 }
380 }
381
382 return comments;
383 }
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
const DiscreteVariable & variable(NodeId id) const override
Returns a constant reference over a variable given its node id.
virtual bool empty() const
Return true if this graphical model is empty.
Class representing the minimal interface for Bayesian network with no numerical data.
Definition IBayesNet.h:75
virtual const Tensor< GUM_SCALAR > & cpt(NodeId varId) const =0
Returns the CPT of a variable.
const std::string & name() const
returns the name of the variable

References cpt(), gum::GraphicalModel::empty(), gum::DAGmodel::nodes(), gum::DAGmodel::parents(), and gum::DiscreteGraphicalModel::variable().

Here is the call graph for this function:

◆ checkConsistency() [1/3]

template<GUM_Numeric GUM_SCALAR>
bool gum::BayesNetFragment< GUM_SCALAR >::checkConsistency ( ) const

returns true if all nodes in the fragment are consistent

Exceptions
gum::OperatioNotAllowedif the fragment is not consistent.

Definition at line 294 of file BayesNetFragment_tpl.h.

294 {
295 for (auto node: nodes())
296 if (!checkConsistency(node)) return false;
297
298 return true;
299 }
bool checkConsistency(NodeId id) const
returns true if the nodeId's (local or not) cpt is consistent with its parents in the fragment

References checkConsistency(), and gum::DAGmodel::nodes().

Here is the call graph for this function:

◆ checkConsistency() [2/3]

template<GUM_Numeric GUM_SCALAR>
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

Exceptions
NotFoundif the id is not in the fragment

Definition at line 279 of file BayesNetFragment_tpl.h.

279 {
280 if (!isInstalledNode(id))
281 GUM_ERROR(NotFound, "The node " << id << " is not part of this fragment")
282
283 const auto& node_cpt = this->cpt(id);
285
286 for (Idx i = 1; i < node_cpt.nbrDim(); i++) {
287 cpt_parents.insert(_bn_.idFromName(node_cpt.variable(i).name()));
288 }
289
290 return (this->parents(id) == cpt_parents);
291 }
const DiscreteVariable & variable(NodeId id) const final
Returns a constant reference over a variabe given it's node id.
bool isInstalledNode(NodeId id) const
check if a certain NodeId exists in the fragment
const Tensor< GUM_SCALAR > & cpt(NodeId varId) const final
Returns the CPT of a variable.
#define GUM_ERROR(type, msg)
Definition exceptions.h:76

References _bn_, cpt(), GUM_ERROR, gum::Set< Key >::insert(), isInstalledNode(), and gum::DAGmodel::parents().

Referenced by BayesNetFragment(), checkConsistency(), checkConsistency(), toBN(), and toDot().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ checkConsistency() [3/3]

template<GUM_Numeric GUM_SCALAR>
bool gum::BayesNetFragment< GUM_SCALAR >::checkConsistency ( std::string_view name) const

check if a certain NodeId exists in the fragment

Definition at line 433 of file BayesNetFragment_tpl.h.

433 {
435 }
NodeId idFromName(std::string_view name) const final
Getter by name.

References checkConsistency(), and idFromName().

Here is the call graph for this function:

◆ children() [1/4]

INLINE const NodeSet & gum::DAGmodel::children ( const NodeId id) const
inherited

returns the set of nodes with arc outgoing from a given node

Note that the set of nodes returned may be empty if no node is outgoing from the given node.

Parameters
idthe node which is the tail of an arc with the returned nodes
namethe name of the node which is the tail of an arc with the returned nodes

Definition at line 95 of file DAGmodel_inl.h.

95{ return dag_.children(id); }

References dag_.

Referenced by children(), gum::BayesNet< GUM_SCALAR >::erase(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), and gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot().

Here is the caller graph for this function:

◆ children() [2/4]

INLINE NodeSet gum::DAGmodel::children ( const NodeSet & ids) const
inherited

returns the children of a set of nodes

Definition at line 101 of file DAGmodel_inl.h.

101{ return dag_.children(ids); }
std::vector< NodeId > ids(const std::vector< std::string > &names) const
transform a vector of names into a vector of nodeId

References dag_, and gum::GraphicalModel::ids().

Here is the call graph for this function:

◆ children() [3/4]

INLINE NodeSet gum::DAGmodel::children ( const std::vector< std::string > & names) const
inherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Definition at line 103 of file DAGmodel_inl.h.

103 {
104 return children(nodeset(names));
105 }
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
std::vector< std::string > names(const std::vector< NodeId > &ids) const
transform a vector of NodeId in a vector of names
NodeSet nodeset(const std::vector< std::string > &names) const
transform a vector of names into a NodeSet

References children(), gum::GraphicalModel::names(), and gum::GraphicalModel::nodeset().

Here is the call graph for this function:

◆ children() [4/4]

INLINE const NodeSet & gum::DAGmodel::children ( std::string_view name) const
inherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Definition at line 97 of file DAGmodel_inl.h.

97 {
98 return dag_.children(idFromName(name));
99 }

◆ completeInstantiation()

INLINE Instantiation gum::GraphicalModel::completeInstantiation ( ) const
inherited

Get an instantiation over all the variables of the model.

Definition at line 104 of file graphicalModel_inl.h.

104 {
105 Instantiation I;
106
107 for (const auto node: nodes())
108 I << variable(node);
109
110 return I;
111 }
virtual const NodeGraphPart & nodes() const =0
Returns the number of variables in this Directed Graphical Model.

References nodes(), and variable().

Here is the call graph for this function:

◆ connectedComponents()

INLINE NodeProperty< NodeId > gum::DAGmodel::connectedComponents ( ) const
inherited

Returns the weakly connected components of the underlying DAG. Each node maps to the id of its component root.

Definition at line 125 of file DAGmodel_inl.h.

125 {
126 return dag_.connectedComponents();
127 }

References dag_.

◆ cpt() [1/2]

template<GUM_Numeric GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::BayesNetFragment< GUM_SCALAR >::cpt ( NodeId varId) const
finalvirtual

Returns the CPT of a variable.

Exceptions
NotFoundIf no variable's id matches varId.

Implements gum::IBayesNet< GUM_SCALAR >.

Definition at line 95 of file BayesNetFragment_tpl.h.

95 {
96 if (!isInstalledNode(id)) GUM_ERROR(NotFound, "NodeId " << id << " is not installed")
97
99 else return _bn_.cpt(id);
100 }
bool exists(NodeId node) const final
Return true if this node exists in this graphical model.

References _bn_, _localCPTs_, GUM_ERROR, and isInstalledNode().

Referenced by checkConsistency(), cpt(), toBN(), uninstallCPT(), and gum::ImportanceSampling< GUM_SCALAR >::unsharpenBN_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cpt() [2/2]

template<GUM_Numeric GUM_SCALAR>
const Tensor< GUM_SCALAR > & gum::BayesNetFragment< GUM_SCALAR >::cpt ( std::string_view name) const

Returns the CPT of a variable.

Exceptions
NotFoundIf no variable's id matches varId.

Definition at line 386 of file BayesNetFragment_tpl.h.

386 {
387 return cpt(idFromName(name));
388 }

References cpt(), and idFromName().

Here is the call graph for this function:

◆ dag()

INLINE DAG gum::DAGmodel::dag ( ) const
nodiscardinherited

Returns a named copy of the internal DAG: each node id is assigned the name of the corresponding variable.

O(n) — allocates a new DAG. For a stable reference (listeners, long-lived pointers), use internalDag().

Definition at line 61 of file DAGmodel_inl.h.

61 {
62 DAG g = dag_;
63 _nameNodes_(g);
64 return g;
65 }
void _nameNodes_(NodeGraphPart &g) const
Names every node of g using variable(id).name() for each node id in g.

References gum::GraphicalModel::_nameNodes_(), and dag_.

Referenced by gum::BayesNetFragment< GUM_SCALAR >::BayesNetFragment(), gum::MarginalTargetedInference< GUM_SCALAR >::MarginalTargetedInference(), gum::BayesNet< GUM_SCALAR >::add(), gum::BayesNet< GUM_SCALAR >::reverseArc(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ descendants() [1/2]

INLINE NodeSet gum::DAGmodel::descendants ( const NodeId id) const
inherited

returns the set of nodes with directed path outgoing from a given node

Note that the set of nodes returned may be empty if no path within the ArcGraphPart is outgoing from the given node.

Parameters
idthe node which is the tail of a directed path with the returned nodes
namethe name of the node which is the tail of a directed path with the returned nodes

Definition at line 129 of file DAGmodel_inl.h.

129{ return dag_.descendants(id); }

References dag_.

◆ descendants() [2/2]

INLINE NodeSet gum::DAGmodel::descendants ( std::string_view name) const
inherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Definition at line 131 of file DAGmodel_inl.h.

131 {
132 return descendants(idFromName(name));
133 }
NodeSet descendants(const NodeId id) const
returns the set of nodes with directed path outgoing from a given node

◆ dim()

template<GUM_Numeric GUM_SCALAR>
Size gum::IBayesNet< GUM_SCALAR >::dim ( ) const
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 114 of file IBayesNet_tpl.h.

114 {
115 Size dim = 0;
116
117 for (auto node: nodes()) {
118 Size q = 1;
119
120 for (auto parent: parents(node))
122
123 dim += (variable(node).domainSize() - 1) * q;
124 }
125
126 return dim;
127 }
virtual Size domainSize() const =0
Size dim() const
Returns the dimension (the number of free parameters) in this bayes net.

References dim(), gum::DAGmodel::nodes(), gum::DAGmodel::parents(), and gum::DiscreteGraphicalModel::variable().

Referenced by dim().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ empty()

INLINE bool gum::GraphicalModel::empty ( ) const
virtualinherited

Return true if this graphical model is empty.

Definition at line 114 of file graphicalModel_inl.h.

114{ return size() == 0; }
virtual Size size() const =0
Returns the number of variables in this Directed Graphical Model.

References size().

Referenced by gum::IBayesNet< GUM_SCALAR >::check(), and gum::BayesNet< GUM_SCALAR >::clear().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ evEq()

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > gum::IBayesNet< GUM_SCALAR >::evEq ( std::string_view name,
double value ) const
inherited
Returns
a Tensor for a (numerical) discrete variable representing an evidence with a float as observed value

Definition at line 386 of file IBayesNet_tpl.h.

386 {
388 }
const DiscreteVariable & variableFromName(std::string_view name) const override
Returns a constant reference over a variable given its name.
static Tensor< GUM_SCALAR > evEq(const DiscreteVariable &v, double val)
numerical evidence generator

References gum::Tensor< GUM_SCALAR >::evEq(), and gum::DiscreteGraphicalModel::variableFromName().

Here is the call graph for this function:

◆ evGt()

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > gum::IBayesNet< GUM_SCALAR >::evGt ( std::string_view name,
double value ) const
inherited
Returns
a Tensor for a (numerical) discrete variable representing an evidence with an observed value greater than the parameter

Definition at line 397 of file IBayesNet_tpl.h.

397 {
399 }
static Tensor< GUM_SCALAR > evGt(const DiscreteVariable &v, double val)
numerical evidence generator

References gum::Tensor< GUM_SCALAR >::evGt(), and gum::DiscreteGraphicalModel::variableFromName().

Here is the call graph for this function:

◆ evIn()

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > gum::IBayesNet< GUM_SCALAR >::evIn ( std::string_view name,
double val1,
double val2 ) const
inherited
Returns
a Tensor for a (numerical) discrete variable representing an evidence with a interval of float as observed value

Definition at line 392 of file IBayesNet_tpl.h.

392 {
394 }
static Tensor< GUM_SCALAR > evIn(const DiscreteVariable &v, double val1, double val2)
numerical evidence generator

References gum::Tensor< GUM_SCALAR >::evIn(), and gum::DiscreteGraphicalModel::variableFromName().

Here is the call graph for this function:

◆ evLt()

template<GUM_Numeric GUM_SCALAR>
Tensor< GUM_SCALAR > gum::IBayesNet< GUM_SCALAR >::evLt ( std::string_view name,
double value ) const
inherited
Returns
a Tensor for a (numerical) discrete variable representing an evidence with an observed value less than the parameter

Definition at line 402 of file IBayesNet_tpl.h.

402 {
404 }
static Tensor< GUM_SCALAR > evLt(const DiscreteVariable &v, double val)
numerical evidence generator

References gum::Tensor< GUM_SCALAR >::evLt(), and gum::DiscreteGraphicalModel::variableFromName().

Here is the call graph for this function:

◆ exists() [1/2]

INLINE bool gum::DAGmodel::exists ( NodeId node) const
finalvirtualinherited

Return true if this node exists in this graphical model.

Implements gum::GraphicalModel.

Definition at line 113 of file DAGmodel_inl.h.

113{ return dag_.exists(node); }

References dag_.

Referenced by gum::build_node(), gum::build_node_for_ID(), hasSameStructure(), gum::MarkovBlanket::hasSameStructure(), gum::IBayesNet< GUM_SCALAR >::operator==(), and gum::InfluenceDiagram< GUM_SCALAR >::operator==().

Here is the caller graph for this function:

◆ exists() [2/2]

INLINE bool gum::DAGmodel::exists ( std::string_view name) const
finalvirtualinherited

Returns a named copy of the internal DAG: each node id is assigned the name of the corresponding variable.

O(n) — allocates a new DAG. For a stable reference (listeners, long-lived pointers), use internalDag().

Implements gum::GraphicalModel.

Definition at line 115 of file DAGmodel_inl.h.

115 {
116 return variableNodeMap().exists(name);
117 }
const VariableNodeMap & variableNodeMap() const override
Returns a constant reference to the VariableNodeMap of this model.
bool exists(NodeId id) const
Return true if id matches a node.

◆ existsArc() [1/2]

INLINE bool gum::DAGmodel::existsArc ( const NodeId tail,
const NodeId head ) const
inherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Definition at line 75 of file DAGmodel_inl.h.

75 {
76 return dag_.existsArc(tail, head);
77 }

References dag_.

Referenced by existsArc(), gum::BayesNet< GUM_SCALAR >::reverseArc(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), and gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted().

Here is the caller graph for this function:

◆ existsArc() [2/2]

INLINE bool gum::DAGmodel::existsArc ( std::string_view nametail,
std::string_view namehead ) const
inherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Definition at line 79 of file DAGmodel_inl.h.

79 {
80 return existsArc(idFromName(nametail), idFromName(namehead));
81 }
bool existsArc(const NodeId tail, const NodeId head) const
return true if the arc tail->head exists in the DAGmodel

References existsArc(), and gum::DiscreteGraphicalModel::idFromName().

Here is the call graph for this function:

◆ existsProperty()

INLINE bool gum::GraphicalModel::existsProperty ( std::string_view name) const
inherited

check wether a property exists in this GraphicalModel

Definition at line 170 of file graphicalModel_inl.h.

170 {
171 return _propertiesMap_.exists(name);
172 }

References _propertiesMap_.

◆ family() [1/2]

INLINE NodeSet gum::DAGmodel::family ( const NodeId id) const
finalvirtualinherited

returns the parents of a node and the node

Parameters
idthe node which is the head of an arc with the returned nodes
namethe name of the node the node which is the head of an arc with the returned nodes

Implements gum::GraphicalModel.

Definition at line 89 of file DAGmodel_inl.h.

89{ return dag_.family(id); }

References dag_.

◆ family() [2/2]

INLINE NodeSet gum::DAGmodel::family ( std::string_view name) const
finalvirtualinherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Implements gum::GraphicalModel.

Definition at line 91 of file DAGmodel_inl.h.

91 {
92 return dag_.family(idFromName(name));
93 }

References dag_, and gum::DiscreteGraphicalModel::idFromName().

Here is the call graph for this function:

◆ hasSameStructure()

bool gum::DAGmodel::hasSameStructure ( const DAGmodel & other) const
inherited
Returns
true if all the named node are the same and all the named arcs are the same

Definition at line 87 of file DAGmodel.cpp.

87 {
88 if (this == &other) return true;
89
90 if (size() != other.size()) return false;
91
92 if (sizeArcs() != other.sizeArcs()) return false;
93
94 for (const auto& nid: nodes()) {
95 if (!other.exists(variable(nid).name())) return false;
96 }
97
98 for (const auto& arc: arcs()) {
99 if (!other.arcs().exists(Arc(other.idFromName(variable(arc.tail()).name()),
100 other.idFromName(variable(arc.head()).name()))))
101 return false;
102 }
103
104 return true;
105 }
const ArcSet & arcs() const
return true if the arc tail->head exists in the DAGmodel
Size size() const final
Returns the number of variables in this Directed Graphical Model.
Size sizeArcs() const
Returns the number of arcs in this Directed Graphical Model.

References DAGmodel(), arcs(), exists(), gum::Set< Key >::exists(), gum::DiscreteGraphicalModel::idFromName(), nodes(), size(), sizeArcs(), and gum::DiscreteGraphicalModel::variable().

Here is the call graph for this function:

◆ idFromName()

template<GUM_Numeric GUM_SCALAR>
NodeId gum::BayesNetFragment< GUM_SCALAR >::idFromName ( std::string_view name) const
finalvirtual

Getter by name.

Exceptions
NotFoundif no such name exists in the graph.

Implements gum::GraphicalModel.

Definition at line 124 of file BayesNetFragment_tpl.h.

124 {
125 NodeId id = _bn_.idFromName(name);
126
127 if (!isInstalledNode(id)) GUM_ERROR(NotFound, "variable " << name << " is not installed")
128
129 return id;
130 }

References _bn_, GUM_ERROR, and isInstalledNode().

Referenced by BayesNetFragment(), checkConsistency(), cpt(), isInstalledNode(), uninstallCPT(), uninstallNode(), variable(), and variableFromName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ids()

INLINE std::vector< NodeId > gum::GraphicalModel::ids ( const std::vector< std::string > & names) const
inherited

transform a vector of names into a vector of nodeId

Returns
the vector of names

Definition at line 139 of file graphicalModel_inl.h.

139 {
140 std::vector< NodeId > res;
141 const VariableNodeMap& v = variableNodeMap();
142 std::transform(names.cbegin(),
143 names.cend(),
144 std::back_inserter(res),
145 [&v](const std::string& n) { return v.idFromName(n); });
146 return res;
147 }
virtual const VariableNodeMap & variableNodeMap() const =0
Returns a constant reference to the VariableNodeMap of this Graphical Model.

References names(), and variableNodeMap().

Referenced by gum::DAGmodel::children(), exists(), names(), names(), and gum::DAGmodel::parents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installArc_()

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installArc_ ( NodeId from,
NodeId to )
protected

Definition at line 191 of file BayesNetFragment_tpl.h.

191 {
192 this->dag_.addArc(from, to);
193 }

References gum::DAGmodel::dag_.

Referenced by BayesNetFragment(), installCPT_(), and uninstallCPT().

Here is the caller graph for this function:

◆ installAscendants() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installAscendants ( NodeId id)

install a node and all its ascendants

Exceptions
NotFoundif the node does not exist in the referred BN
Warning
nothing happens if the node is already installed

Definition at line 169 of file BayesNetFragment_tpl.h.

169 {
170 installNode(id);
171
172 // bn is a dag => this will have an end ...
173 for (auto pa: this->_bn_.parents(id))
175 }
void installNode(NodeId id)
install a node referenced by its nodeId
void installAscendants(NodeId id)
install a node and all its ascendants

References _bn_, installAscendants(), and installNode().

Referenced by BayesNetFragment(), installAscendants(), and installAscendants().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installAscendants() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installAscendants ( std::string_view name)

check if a certain NodeId exists in the fragment

Definition at line 406 of file BayesNetFragment_tpl.h.

406 {
407 installAscendants(_bn_.idFromName(name));
408 }

References _bn_, and installAscendants().

Here is the call graph for this function:

◆ installCPT() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installCPT ( NodeId id,
const Tensor< 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 tensor.

Parameters
idthe nodeId
potthe tensor to be copied
Exceptions
NotFoundif the id is not in the fragment
OperationNotAllowedif the tensor is not compliant with the variable or if a variable in the CPT is not a parent in the referred bn.

Definition at line 216 of file BayesNetFragment_tpl.h.

216 {
217 if (!this->internalDag().existsNode(id))
218 GUM_ERROR(NotFound, "Node " << id << " is not installed in the fragment")
219
220 if (&(pot.variable(0)) != &(variable(id))) {
222 "The tensor is not a marginal for _bn_.variable <" << variable(id).name() << ">")
223 }
224
225 const NodeSet& parents = _bn_.parents(id);
226
227 for (Idx i = 1; i < pot.nbrDim(); i++) {
228 if (!parents.contains(_bn_.idFromName(pot.variable(i).name())))
230 "Variable <" << pot.variable(i).name() << "> is not in the parents of node "
231 << id)
232 }
233
234 installCPT_(id, pot);
235 }
void installCPT_(NodeId id, const Tensor< GUM_SCALAR > &pot)

References _bn_, GUM_ERROR, installCPT_(), gum::DAGmodel::internalDag(), gum::DAGmodel::parents(), and variable().

Referenced by BayesNetFragment(), installCPT(), gum::ImportanceSampling< GUM_SCALAR >::onContextualize_(), and gum::ImportanceSampling< GUM_SCALAR >::unsharpenBN_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installCPT() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installCPT ( std::string_view name,
const Tensor< GUM_SCALAR > & pot )

check if a certain NodeId exists in the fragment

Definition at line 422 of file BayesNetFragment_tpl.h.

423 {
424 installCPT(_bn_.idFromName(name), pot);
425 }
void installCPT(NodeId id, const Tensor< GUM_SCALAR > &pot)
install a local cpt BY COPYfor a node into the fragment.

References _bn_, and installCPT().

Here is the call graph for this function:

◆ installCPT_()

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installCPT_ ( NodeId id,
const Tensor< GUM_SCALAR > & pot )
protected

Definition at line 196 of file BayesNetFragment_tpl.h.

196 {
197 // topology
198 const auto& parents = this->parents(id);
199 for (auto node_it = parents.beginSafe(); node_it != parents.endSafe();
200 ++node_it) // safe iterator needed here
202
203 for (Idx i = 1; i < pot.nbrDim(); i++) {
204 NodeId parent = _bn_.idFromName(pot.variable(i).name());
205
207 }
208
209 // local cpt
210 if (_localCPTs_.exists(id)) uninstallCPT_(id);
211
213 }
void uninstallArc_(NodeId from, NodeId to)
void installArc_(NodeId from, NodeId to)

References _bn_, _localCPTs_, installArc_(), isInstalledNode(), gum::DAGmodel::parents(), uninstallArc_(), and uninstallCPT_().

Referenced by BayesNetFragment(), installCPT(), and installMarginal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installMarginal() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installMarginal ( NodeId id,
const Tensor< 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.

Parameters
idthe nodeId
potthe tensor
Exceptions
NotFoundif the id is not in the fragment
OperationNotAllowedif the tensor is not compliant with the variable (or is not a marginal)

Definition at line 260 of file BayesNetFragment_tpl.h.

260 {
261 if (!isInstalledNode(id)) {
262 GUM_ERROR(NotFound, "The node " << id << " is not part of this fragment")
263 }
264
265 if (pot.nbrDim() > 1) {
266 GUM_ERROR(OperationNotAllowed, "The tensor is not a marginal :" << pot)
267 }
268
269 if (&(pot.variable(0)) != &(_bn_.variable(id))) {
271 "The tensor is not a marginal for _bn_.variable <" << _bn_.variable(id).name()
272 << ">")
273 }
274
275 installCPT_(id, pot);
276 }

References _bn_, GUM_ERROR, installCPT_(), and isInstalledNode().

Referenced by BayesNetFragment(), and installMarginal().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installMarginal() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installMarginal ( std::string_view name,
const Tensor< GUM_SCALAR > & pot )

check if a certain NodeId exists in the fragment

Definition at line 416 of file BayesNetFragment_tpl.h.

417 {
418 installMarginal(_bn_.idFromName(name), pot);
419 }
void installMarginal(NodeId id, const Tensor< GUM_SCALAR > &pot)
install a local marginal BY COPY for a node into the fragment.

References _bn_, and installMarginal().

Here is the call graph for this function:

◆ installNode() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installNode ( NodeId id)

install a node referenced by its nodeId

Exceptions
NotFoundif the node does not exist in the referred BN
Warning
nothing happens if the node is already installed

Definition at line 150 of file BayesNetFragment_tpl.h.

150 {
151 if (!_bn_.internalDag().existsNode(id))
152 GUM_ERROR(NotFound, "Node " << id << " does not exist in referred BayesNet")
153
154 if (!isInstalledNode(id)) {
155 this->dag_.addNodeWithId(id);
156
157 // adding arcs with id as a tail
158 for (auto pa: this->_bn_.parents(id)) {
159 if (isInstalledNode(pa)) this->dag_.addArc(pa, id);
160 }
161
162 // adding arcs with id as a head
163 for (auto son: this->_bn_.children(id))
164 if (isInstalledNode(son)) this->dag_.addArc(id, son);
165 }
166 }

References _bn_, gum::DAGmodel::dag_, GUM_ERROR, and isInstalledNode().

Referenced by BayesNetFragment(), installAscendants(), and installNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ installNode() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::installNode ( std::string_view name)

check if a certain NodeId exists in the fragment

Definition at line 401 of file BayesNetFragment_tpl.h.

401 {
402 installNode(_bn_.idFromName(name));
403 }

References _bn_, and installNode().

Here is the call graph for this function:

◆ internalDag()

INLINE const DAG & gum::DAGmodel::internalDag ( ) const
inherited

Returns a const reference to the internal (unnamed) DAG. O(1), no copy. Use for stable references or pointers (e.g. graph listeners). For named node access, use dag() instead.

Definition at line 58 of file DAGmodel_inl.h.

58{ return dag_; }

References dag_.

Referenced by gum::BayesNetFragment< GUM_SCALAR >::BayesNetFragment(), gum::MarkovBlanket::MarkovBlanket(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::BayesBall::relevantTensors(), gum::dSeparationAlgorithm::relevantTensors(), gum::BayesNetFragment< GUM_SCALAR >::toBN(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), and gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted().

Here is the caller graph for this function:

◆ isIndependent() [1/4]

INLINE bool gum::DAGmodel::isIndependent ( const NodeSet & X,
const NodeSet & Y,
const NodeSet & Z ) const
finalvirtualinherited

check if nodes X and nodes Y are independent given nodes Z

Implements gum::GraphicalModel.

Definition at line 156 of file DAGmodel_inl.h.

156 {
157 return dag_.dSeparation(X, Y, Z);
158 }

References dag_.

◆ isIndependent() [2/4]

INLINE bool gum::DAGmodel::isIndependent ( const std::vector< std::string > & Xnames,
const std::vector< std::string > & Ynames,
const std::vector< std::string > & Znames ) const
inherited

build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes

Parameters
nodesthe set of nodeId
nodenamesthe vector of names of nodes
Returns
the moralized ancestral graph

Definition at line 184 of file DAGmodel_inl.h.

186 {
187 return isIndependent(nodeset(Xnames), nodeset(Ynames), nodeset(Znames));
188 }
bool isIndependent(NodeId X, NodeId Y, const NodeSet &Z) const final
check if node X and node Y are independent given nodes Z

◆ isIndependent() [3/4]

INLINE bool gum::DAGmodel::isIndependent ( NodeId X,
NodeId Y,
const NodeSet & Z ) const
finalvirtualinherited

check if node X and node Y are independent given nodes Z

Implements gum::GraphicalModel.

Definition at line 152 of file DAGmodel_inl.h.

152 {
153 return dag_.dSeparation(X, Y, Z);
154 }

Referenced by gum::BayesNet< double >::ancestors(), and isIndependent().

Here is the caller graph for this function:

◆ isIndependent() [4/4]

INLINE bool gum::DAGmodel::isIndependent ( std::string_view Xname,
std::string_view Yname,
const std::vector< std::string > & Znames ) const
inherited

build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes

Parameters
nodesthe set of nodeId
nodenamesthe vector of names of nodes
Returns
the moralized ancestral graph

Definition at line 178 of file DAGmodel_inl.h.

180 {
181 return isIndependent(idFromName(Xname), idFromName(Yname), nodeset(Znames));
182 }

References gum::DiscreteGraphicalModel::idFromName(), isIndependent(), and gum::GraphicalModel::nodeset().

Here is the call graph for this function:

◆ isInstalledNode() [1/2]

template<GUM_Numeric GUM_SCALAR>
bool gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode ( NodeId id) const

check if a certain NodeId exists in the fragment

Definition at line 145 of file BayesNetFragment_tpl.h.

145 {
146 return this->internalDag().existsNode(id);
147 }
bool existsNode(const NodeId id) const
returns true iff the NodeGraphPart contains the given nodeId

References gum::DAGmodel::internalDag().

Referenced by BayesNetFragment(), checkConsistency(), cpt(), idFromName(), installCPT_(), installMarginal(), installNode(), isInstalledNode(), nodeId(), toDot(), uninstallCPT(), uninstallNode(), variable(), and variableFromName().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ isInstalledNode() [2/2]

template<GUM_Numeric GUM_SCALAR>
bool gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode ( std::string_view name) const

check if a certain NodeId exists in the fragment

Definition at line 396 of file BayesNetFragment_tpl.h.

396 {
398 }

References idFromName(), and isInstalledNode().

Here is the call graph for this function:

◆ jointProbability()

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::IBayesNet< GUM_SCALAR >::jointProbability ( const Instantiation & i) const
inherited

Compute a parameter of the joint probability for the BN (given an instantiation of the vars).

Warning
a variable not present in the instantiation is assumed to be instantiated to 0.

Definition at line 238 of file IBayesNet_tpl.h.

238 {
239 auto value = (GUM_SCALAR)1.0;
240
242
243 for (auto node: nodes()) {
244 if ((tmp = cpt(node)[i]) == (GUM_SCALAR)0) { return (GUM_SCALAR)0; }
245
246 value *= tmp;
247 }
248
249 return value;
250 }

◆ log10DomainSize()

INLINE double gum::GraphicalModel::log10DomainSize ( ) const
inherited

Definition at line 93 of file graphicalModel_inl.h.

93 {
94 double dSize = 0.0;
95
96 for (const auto node: nodes()) {
97 dSize += std::log10(variable(node).domainSize());
98 }
99
100 return dSize;
101 }

References nodes().

Referenced by gum::IMarkovRandomField< GUM_SCALAR >::toString(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ log2JointProbability()

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::IBayesNet< GUM_SCALAR >::log2JointProbability ( const Instantiation & i) const
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).

Warning
a variable not present in the instantiation is assumed to be instantiated to 0.

Definition at line 256 of file IBayesNet_tpl.h.

256 {
257 auto value = (GUM_SCALAR)0.0;
258
260
261 for (auto node: nodes()) {
262 if ((tmp = cpt(node)[i]) == (GUM_SCALAR)0) {
264 }
265
266 value += std::log2(cpt(node)[i]);
267 }
268
269 return value;
270 }

References cpt(), and gum::DAGmodel::nodes().

Here is the call graph for this function:

◆ maxNonOneParam()

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::IBayesNet< GUM_SCALAR >::maxNonOneParam ( ) const
inherited
Returns
the biggest value (not equal to 1) in the CPTs of *this
Warning
can return one if no other value in the CPTs than one....

Definition at line 170 of file IBayesNet_tpl.h.

170 {
171 GUM_SCALAR res = 0.0;
172 for (auto node: nodes()) {
173 auto v = cpt(node).maxNonOne();
174 if (v > res) { res = v; }
175 }
176 return res;
177 }

◆ maxParam()

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::IBayesNet< GUM_SCALAR >::maxParam ( ) const
inherited
Returns
the biggest value in the CPTs of *this

Definition at line 150 of file IBayesNet_tpl.h.

150 {
151 GUM_SCALAR res = 1.0;
152 for (auto node: nodes()) {
153 auto v = cpt(node).max();
154 if (v > res) { res = v; }
155 }
156 return res;
157 }

References gum::DAGmodel::nodes().

Here is the call graph for this function:

◆ maxVarDomainSize()

template<GUM_Numeric GUM_SCALAR>
Size gum::IBayesNet< GUM_SCALAR >::maxVarDomainSize ( ) const
inherited
Returns
the biggest domainSize among the variables of *this

Definition at line 130 of file IBayesNet_tpl.h.

130 {
131 Size res = 0;
132 for (auto node: nodes()) {
133 auto v = variable(node).domainSize();
134 if (v > res) { res = v; }
135 }
136 return res;
137 }

References gum::DAGmodel::nodes(), and gum::DiscreteGraphicalModel::variable().

Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ memoryFootprint()

template<GUM_Numeric GUM_SCALAR>
Size gum::IBayesNet< GUM_SCALAR >::memoryFootprint ( ) const
inherited

compute the (approximated) footprint in memory of the model (the footprints of CPTs)

Returns
the size in bytes

Definition at line 180 of file IBayesNet_tpl.h.

180 {
181 Size usedMem = 0;
182
183 for (auto node: nodes())
184 usedMem += cpt(node).memoryFootprint();
185 return usedMem;
186 }

◆ minimalCondSet() [1/4]

INLINE NodeSet gum::DAGmodel::minimalCondSet ( const NodeSet & targets,
const NodeSet & soids ) const
inherited

Definition at line 164 of file DAGmodel_inl.h.

164 {
165 return dag_.minimalCondSet(targets, soids);
166 }

◆ minimalCondSet() [2/4]

INLINE NodeSet gum::DAGmodel::minimalCondSet ( const std::vector< std::string > & targets,
const std::vector< std::string > & soids ) const
inherited

Definition at line 173 of file DAGmodel_inl.h.

174 {
175 return dag_.minimalCondSet(nodeset(targets), nodeset(soids));
176 }

◆ minimalCondSet() [3/4]

INLINE NodeSet gum::DAGmodel::minimalCondSet ( NodeId target,
const NodeSet & soids ) const
inherited

Definition at line 160 of file DAGmodel_inl.h.

160 {
161 return dag_.minimalCondSet(target, soids);
162 }

Referenced by gum::ASTposteriorProba< GUM_SCALAR >::_compute_knw_from_bn().

Here is the caller graph for this function:

◆ minimalCondSet() [4/4]

INLINE NodeSet gum::DAGmodel::minimalCondSet ( std::string_view target,
const std::vector< std::string > & soids ) const
inherited

Definition at line 168 of file DAGmodel_inl.h.

169 {
170 return dag_.minimalCondSet(idFromName(target), nodeset(soids));
171 }

References dag_, gum::DiscreteGraphicalModel::idFromName(), and gum::GraphicalModel::nodeset().

Here is the call graph for this function:

◆ minNonZeroParam()

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::IBayesNet< GUM_SCALAR >::minNonZeroParam ( ) const
inherited
Returns
the smallest value (not equal to 0) in the CPTs of *this
Warning
can return 0 if no other value in the CPTs than 0...

Definition at line 160 of file IBayesNet_tpl.h.

160 {
161 GUM_SCALAR res = 1.0;
162 for (auto node: nodes()) {
163 auto v = cpt(node).minNonZero();
164 if (v < res) { res = v; }
165 }
166 return res;
167 }

Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_().

Here is the caller graph for this function:

◆ minParam()

template<GUM_Numeric GUM_SCALAR>
GUM_SCALAR gum::IBayesNet< GUM_SCALAR >::minParam ( ) const
inherited
Returns
the smallest value in the CPTs of *this

Definition at line 140 of file IBayesNet_tpl.h.

140 {
141 GUM_SCALAR res = 1.0;
142 for (auto node: nodes()) {
143 auto v = cpt(node).min();
144 if (v < res) { res = v; }
145 }
146 return res;
147 }

References gum::DAGmodel::nodes().

Here is the call graph for this function:

◆ moralGraph()

UndiGraph gum::DAGmodel::moralGraph ( ) const
inherited

The node's id are coherent with the variables and nodes of the topology.

Definition at line 81 of file DAGmodel.cpp.

81 {
82 auto g = dag_.moralGraph();
83 _nameNodes_(g);
84 return g;
85 }

References gum::GraphicalModel::_nameNodes_(), and dag_.

Referenced by gum::prm::SVE< GUM_SCALAR >::_eliminateNodes_(), gum::prm::SVED< GUM_SCALAR >::_eliminateNodes_(), gum::prm::SVE< GUM_SCALAR >::_eliminateNodesWithEvidence_(), gum::prm::SVED< GUM_SCALAR >::_eliminateNodesWithEvidence_(), gum::prm::SVE< GUM_SCALAR >::_initLiftedNodes_(), and gum::prm::SVED< GUM_SCALAR >::_initLiftedNodes_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ moralizedAncestralGraph() [1/2]

INLINE UndiGraph gum::DAGmodel::moralizedAncestralGraph ( const NodeSet & nodes) const
inherited

build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes

Parameters
nodesthe set of nodeId
nodenamesthe vector of names of nodes
Returns
the moralized ancestral graph

Definition at line 146 of file DAGmodel_inl.h.

146 {
147 auto g = dag_.moralizedAncestralGraph(nodes);
148 _nameNodes_(g);
149 return g;
150 }

References gum::GraphicalModel::_nameNodes_(), dag_, and nodes().

Referenced by moralizedAncestralGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ moralizedAncestralGraph() [2/2]

INLINE UndiGraph gum::DAGmodel::moralizedAncestralGraph ( const std::vector< std::string > & nodenames) const
inherited

build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes

Parameters
nodesthe set of nodeId
nodenamesthe vector of names of nodes
Returns
the moralized ancestral graph

Definition at line 142 of file DAGmodel_inl.h.

142 {
143 return moralizedAncestralGraph(nodeset(nodenames));
144 }
UndiGraph moralizedAncestralGraph(const NodeSet &nodes) const
build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes

References moralizedAncestralGraph(), and gum::GraphicalModel::nodeset().

Here is the call graph for this function:

◆ names() [1/2]

INLINE std::vector< std::string > gum::GraphicalModel::names ( const NodeSet & ids) const
inherited

transform a NodeSet in a vector of names

Returns
the vector of names

Definition at line 129 of file graphicalModel_inl.h.

129 {
130 const VariableNodeMap& v = variableNodeMap();
131 std::vector< std::string > res;
132 for (auto n: ids) {
133 res.push_back(v.name(n));
134 }
135 return res;
136 }

References ids(), gum::VariableNodeMap::name(), and variableNodeMap().

Here is the call graph for this function:

◆ names() [2/2]

INLINE std::vector< std::string > gum::GraphicalModel::names ( const std::vector< NodeId > & ids) const
inherited

transform a vector of NodeId in a vector of names

Returns
the vector of names

Definition at line 117 of file graphicalModel_inl.h.

117 {
118 std::vector< std::string > res;
119 const VariableNodeMap& v = variableNodeMap();
120
121 std::ranges::transform(ids, std::back_inserter(res), [&v](const NodeId n) {
122 return v[n].name();
123 });
124
125 return res;
126 }
Size NodeId
Type for node ids.

References ids().

Referenced by gum::DAGmodel::children(), exists(), ids(), nodeset(), and gum::DAGmodel::parents().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nodeId()

template<GUM_Numeric GUM_SCALAR>
NodeId gum::BayesNetFragment< GUM_SCALAR >::nodeId ( const DiscreteVariable & var) const
finalvirtual

Return id node from discrete var pointer.

Exceptions
NotFoundIf no variable match var.

Implements gum::GraphicalModel.

Definition at line 115 of file BayesNetFragment_tpl.h.

115 {
116 NodeId id = _bn_.nodeId(var);
117
118 if (!isInstalledNode(id)) GUM_ERROR(NotFound, "variable " << var.name() << " is not installed")
119
120 return id;
121 }

References _bn_, GUM_ERROR, isInstalledNode(), and gum::Variable::name().

Referenced by BayesNetFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nodes()

INLINE const NodeGraphPart & gum::DAGmodel::nodes ( ) const
finalvirtualinherited

Returns a named copy of the internal DAG: each node id is assigned the name of the corresponding variable.

O(n) — allocates a new DAG. For a stable reference (listeners, long-lived pointers), use internalDag().

Implements gum::GraphicalModel.

Definition at line 119 of file DAGmodel_inl.h.

119 {
120 return static_cast< const NodeGraphPart& >(dag_);
121 }

References dag_.

Referenced by gum::BayesNetFragment< GUM_SCALAR >::BayesNetFragment(), gum::Estimator< GUM_SCALAR >::Estimator(), gum::BayesNetFragment< GUM_SCALAR >::~BayesNetFragment(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_verticesSampling_(), gum::BayesNet< GUM_SCALAR >::beginTopologyTransformation(), gum::InfluenceDiagram< GUM_SCALAR >::beginTopologyTransformation(), gum::IBayesNet< GUM_SCALAR >::check(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::BayesNet< GUM_SCALAR >::clear(), gum::InfluenceDiagram< GUM_SCALAR >::copyStructureAndTables_(), gum::IBayesNet< GUM_SCALAR >::dim(), gum::BayesNet< GUM_SCALAR >::endTopologyTransformation(), gum::InfluenceDiagram< GUM_SCALAR >::endTopologyTransformation(), gum::InfluenceDiagram< GUM_SCALAR >::fastPrototype(), gum::BayesNet< GUM_SCALAR >::generateCPTs(), gum::getMaxModality(), hasSameStructure(), gum::IBayesNet< GUM_SCALAR >::log2JointProbability(), gum::IBayesNet< GUM_SCALAR >::maxParam(), gum::IBayesNet< GUM_SCALAR >::maxVarDomainSize(), gum::IBayesNet< GUM_SCALAR >::minParam(), gum::prm::ClassBayesNet< GUM_SCALAR >::modalities(), gum::prm::InstanceBayesNet< GUM_SCALAR >::modalities(), moralizedAncestralGraph(), gum::IBayesNet< GUM_SCALAR >::operator==(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::BayesNetFragment< GUM_SCALAR >::toBN(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::ImportanceSampling< GUM_SCALAR >::unsharpenBN_().

◆ nodeset()

NodeSet gum::GraphicalModel::nodeset ( const std::vector< std::string > & names) const
inherited

transform a vector of names into a NodeSet

Returns
NodeSet

Definition at line 102 of file graphicalModel.cpp.

102 {
103 NodeSet res;
104 for (const auto& name: names) {
105 res.insert(idFromName(name));
106 }
107 return res;
108 }
virtual NodeId idFromName(std::string_view name) const =0
Getter by name.
Set< NodeId > NodeSet
Some typdefs and define for shortcuts ...

References idFromName(), gum::Set< Key >::insert(), and names().

Referenced by gum::BayesNet< double >::ancestors(), gum::DAGmodel::children(), gum::DAGmodel::isIndependent(), gum::UGmodel::isIndependent(), gum::UGmodel::isIndependent(), gum::DAGmodel::minimalCondSet(), and gum::DAGmodel::moralizedAncestralGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator==()

template<GUM_Numeric GUM_SCALAR>
bool gum::IBayesNet< GUM_SCALAR >::operator== ( const IBayesNet< GUM_SCALAR > & from) const
inherited

This operator compares 2 BNs !

Warning
To identify nodes between BNs, it is assumed that they share the same name.
Returns
true if the src and this are equal.

Definition at line 273 of file IBayesNet_tpl.h.

273 {
274 if (size() != from.size()) { return false; }
275
276 if (sizeArcs() != from.sizeArcs()) { return false; }
277
278 for (auto node: nodes()) {
279 const auto& v1 = variable(node);
280 if (!from.exists(v1.name())) { return false; }
281 const auto& v2 = from.variableFromName(v1.name());
282 if (v1 != v2) { return false; }
283 }
284
285 for (auto node: nodes()) {
287
288 if (cpt(node).nbrDim() != from.cpt(fromnode).nbrDim()) { return false; }
289
290 if (cpt(node).domainSize() != from.cpt(fromnode).domainSize()) { return false; }
291
292 for (Idx i = 0; i < cpt(node).nbrDim(); ++i) {
293 if (!from.cpt(fromnode).contains(from.variableFromName(cpt(node).variable(i).name()))) {
294 return false;
295 }
296 }
297
300
302 for (i.setFirst(); !i.end(); i.inc()) {
303 for (Idx indice = 0; indice < cpt(node).nbrDim(); ++indice) {
304 const DiscreteVariable* p = &(i.variable(indice));
305 j.chgVal(j.pos(from.variableFromName(p->name())), i.val(*p));
306 }
307
308 if (cmp(cpt(node).get(i), from.cpt(fromnode).get(j))) { return false; }
309 }
310 }
311
312 return true;
313 }

References IBayesNet(), gum::Instantiation::chgVal(), cpt(), gum::Instantiation::end(), gum::DAGmodel::exists(), gum::DiscreteGraphicalModel::idFromName(), gum::Instantiation::inc(), gum::Variable::name(), gum::DAGmodel::nodes(), gum::Instantiation::pos(), gum::Instantiation::setFirst(), gum::DAGmodel::size(), gum::DAGmodel::sizeArcs(), gum::Instantiation::val(), gum::DiscreteGraphicalModel::variable(), gum::Instantiation::variable(), and gum::DiscreteGraphicalModel::variableFromName().

Here is the call graph for this function:

◆ parents() [1/4]

INLINE const NodeSet & gum::DAGmodel::parents ( const NodeId id) const
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.

Parameters
idthe node which is the head of an arc with the returned nodes
namethe name of the node the node which is the head of an arc with the returned nodes

Definition at line 83 of file DAGmodel_inl.h.

83{ return dag_.parents(id); }

References dag_.

Referenced by gum::IBayesNet< GUM_SCALAR >::check(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::InfluenceDiagram< GUM_SCALAR >::copyStructureAndTables_(), gum::IBayesNet< GUM_SCALAR >::dim(), gum::ASTposteriorProba< GUM_SCALAR >::eval(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::BayesNetFragment< GUM_SCALAR >::installCPT_(), parents(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), and gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot().

Here is the caller graph for this function:

◆ parents() [2/4]

INLINE NodeSet gum::DAGmodel::parents ( const NodeSet & ids) const
inherited

returns the parents of a set of nodes

Definition at line 107 of file DAGmodel_inl.h.

107{ return dag_.parents(ids); }

References dag_, and gum::GraphicalModel::ids().

Here is the call graph for this function:

◆ parents() [3/4]

INLINE NodeSet gum::DAGmodel::parents ( const std::vector< std::string > & names) const
inherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Definition at line 109 of file DAGmodel_inl.h.

109 {
110 return parents(nodeset(names));
111 }

References gum::GraphicalModel::names().

Here is the call graph for this function:

◆ parents() [4/4]

INLINE const NodeSet & gum::DAGmodel::parents ( std::string_view name) const
inherited

return true if the arc tail->head exists in the DAGmodel

Parameters
tailthe nodeId (or the name) of the tail in tail->head
headthe nodeId (or the name) of the head in tail->head
Returns
true if the arc exists

Definition at line 85 of file DAGmodel_inl.h.

85 {
86 return parents(idFromName(name));
87 }

References gum::DiscreteGraphicalModel::idFromName(), and parents().

Here is the call graph for this function:

◆ properties()

INLINE std::vector< std::string > gum::GraphicalModel::properties ( ) const
inherited

List of all the names of property in the Graphical model.

Definition at line 79 of file graphicalModel_inl.h.

79 {
80 std::vector< std::string > prop;
81 for (const auto& [p, v]: _propertiesMap_)
82 prop.push_back(p);
83 return prop;
84 }

References _propertiesMap_.

◆ property()

INLINE const std::string & gum::GraphicalModel::property ( std::string_view name) const
inherited

Return the value of the property name of this GraphicalModel.

Exceptions
NotFoundRaised if no name property is found.

Definition at line 60 of file graphicalModel_inl.h.

60 {
61 auto p = _properties_().tryGet(name);
62 if (!p) { GUM_ERROR(NotFound, "The following property does not exists: " << name) }
63 return *p;
64 }
const HashTable< std::string, std::string > & _properties_() const
Return the properties of this Directed Graphical Model.
optional_ref< Val > tryGet(const Key &key)
Returns a pointer to the value associated with a given key, or nullptr if the key does not exist.

References _properties_(), GUM_ERROR, and gum::HashTable< Key, Val >::tryGet().

Here is the call graph for this function:

◆ propertyWithDefault()

INLINE const std::string & gum::GraphicalModel::propertyWithDefault ( std::string_view name,
const std::string & byDefault ) const
inherited

Return the value of the property name of this GraphicalModel.

return byDefault if the property name is not found

Definition at line 72 of file graphicalModel_inl.h.

73 {
74 auto p = _propertiesMap_.tryGet(name);
75 return p ? *p : byDefault;
76 }

References _propertiesMap_.

Referenced by gum::IBayesNet< GUM_SCALAR >::toDot(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), and gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().

Here is the caller graph for this function:

◆ setProperty()

INLINE void gum::GraphicalModel::setProperty ( std::string_view name,
std::string_view value )
inherited

Add or change a property of this GraphicalModel.

Definition at line 87 of file graphicalModel_inl.h.

87 {
88 if (auto p = _propertiesMap_.tryGet(name)) *p = value;
89 else _propertiesMap_.insert(std::string(name), std::string(value));
90 }

References _propertiesMap_.

Referenced by gum::IBayesNet< GUM_SCALAR >::IBayesNet(), gum::IMarkovRandomField< GUM_SCALAR >::IMarkovRandomField(), and gum::InfluenceDiagram< GUM_SCALAR >::fastPrototype().

Here is the caller graph for this function:

◆ size()

INLINE Size gum::DAGmodel::size ( ) const
finalvirtualinherited

Returns the number of variables in this Directed Graphical Model.

Implements gum::GraphicalModel.

Definition at line 68 of file DAGmodel_inl.h.

68{ return dag_.size(); }

References dag_.

Referenced by gum::InfluenceDiagram< GUM_SCALAR >::copyStructureAndTables_(), gum::InfluenceDiagram< GUM_SCALAR >::decisionNodeSize(), hasSameStructure(), gum::MarkovBlanket::hasSameStructure(), gum::IBayesNet< GUM_SCALAR >::operator==(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), and gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot().

Here is the caller graph for this function:

◆ sizeArcs()

INLINE Size gum::DAGmodel::sizeArcs ( ) const
inherited

Returns the number of arcs in this Directed Graphical Model.

Definition at line 71 of file DAGmodel_inl.h.

71{ return dag_.sizeArcs(); }

References dag_.

Referenced by hasSameStructure(), gum::MarkovBlanket::hasSameStructure(), gum::IBayesNet< GUM_SCALAR >::operator==(), gum::InfluenceDiagram< GUM_SCALAR >::operator==(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().

Here is the caller graph for this function:

◆ spaceCplxToString()

std::string gum::GraphicalModel::spaceCplxToString ( double dSize,
int dim,
Size usedMem )
staticinherited

send to the stream the space complexity with 3 parametrs

Parameters
sthe stream
dSizethe log10domainSize
dimthe dimension
usedMemthe memory needed for the params

Definition at line 110 of file graphicalModel.cpp.

110 {
111 std::string result;
112 if (dSize > 6) result = std::format("domainSize: 10^{:.6g}", dSize);
113 else result = std::format("domainSize: {}", (long long)std::round(std::pow(10.0, dSize)));
114
115 result += std::format(", dim: {}, mem: ", dim);
116
117 if (const Size go = usedMem / (1024 * 1024 * 1024); go > 0) result += std::format("{}Go ", go);
118 if (const Size mo = (usedMem / (1024 * 1024)) % 1024; mo > 0)
119 result += std::format("{}Mo ", mo);
120 if (const Size ko = (usedMem / 1024) % 1024; ko > 0) result += std::format("{}Ko ", ko);
121 result += std::format("{}o", usedMem % 1024);
122 return result;
123 }
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

◆ toBN()

template<GUM_Numeric GUM_SCALAR>
gum::BayesNet< GUM_SCALAR > gum::BayesNetFragment< GUM_SCALAR >::toBN ( ) const

create a brand new BayesNet from a fragment.

Returns
the new BayesNet<GUM_SCALAR>

Definition at line 367 of file BayesNetFragment_tpl.h.

367 {
368 if (!checkConsistency()) {
369 GUM_ERROR(OperationNotAllowed, "The fragment contains un-consistent node(s)")
370 }
372 for (const auto nod: nodes()) {
373 res.add(variable(nod), nod);
374 }
375 for (const auto& arc: this->internalDag().arcs()) {
376 res.addArc(arc.tail(), arc.head());
377 }
378 for (const auto nod: nodes()) {
379 res.cpt(nod).fillWith(cpt(nod));
380 }
381
382 return res;
383 }

References gum::BayesNet< GUM_SCALAR >::add(), gum::BayesNet< GUM_SCALAR >::addArc(), gum::DAGmodel::arcs(), checkConsistency(), gum::BayesNet< GUM_SCALAR >::cpt(), cpt(), GUM_ERROR, gum::DAGmodel::internalDag(), gum::DAGmodel::nodes(), and variable().

Referenced by BayesNetFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ toDot()

template<GUM_Numeric GUM_SCALAR>
std::string gum::BayesNetFragment< GUM_SCALAR >::toDot ( ) const
finalvirtual

creates a dot representing the whole referred BN hilighting the fragment.

Returns
Returns a dot representation of this fragment

Reimplemented from gum::IBayesNet< GUM_SCALAR >.

Definition at line 302 of file BayesNetFragment_tpl.h.

302 {
304
306
307 static std::string inFragmentStyle = "fillcolor=\"#ffffaa\","
308 "color=\"#000000\","
309 "fontcolor=\"#000000\"";
310 static std::string styleWithLocalCPT = "fillcolor=\"#ffddaa\","
311 "color=\"#000000\","
312 "fontcolor=\"#000000\"";
313 static std::string notConsistantStyle = "fillcolor=\"#ff0000\","
314 "color=\"#000000\","
315 "fontcolor=\"#ffff00\"";
316 static std::string outFragmentStyle = "fillcolor=\"#f0f0f0\","
317 "color=\"#f0f0f0\","
318 "fontcolor=\"#000000\"";
319
320 bn_name = _bn_.propertyWithDefault("name", "no_name");
321
322 bn_name = "Fragment of " + bn_name;
323
324 output << std::format("digraph \"{}\" {{\n", bn_name);
325 output << std::format(" graph [bgcolor=transparent,label=\"{}\"];\n", bn_name);
326 output << " node [style=filled];" << std::endl << std::endl;
327
328 for (auto node: _bn_.nodes()) {
329 output << "\"" << _bn_.variable(node).name() << "\" [comment=\"" << node << ":"
330 << _bn_.variable(node) << ", \"";
331
332 if (isInstalledNode(node)) {
333 if (!checkConsistency(node)) {
335 } else if (_localCPTs_.exists(node)) output << styleWithLocalCPT;
336 else output << inFragmentStyle;
337 } else output << outFragmentStyle;
338
339 output << "];" << std::endl;
340 }
341
342 output << std::endl;
343
344 std::string tab = " ";
345
346 for (auto node: _bn_.nodes()) {
347 if (_bn_.children(node).size() > 0) {
348 for (auto child: _bn_.children(node)) {
349 output << std::format(" \"{}\" -> \"{}\" [",
350 _bn_.variable(node).name(),
351 _bn_.variable(child).name());
352
354 else output << outFragmentStyle;
355
356 output << "];" << std::endl;
357 }
358 }
359 }
360
361 output << "}" << std::endl;
362
363 return output.str();
364 }

References _bn_, _localCPTs_, checkConsistency(), gum::DAGmodel::existsArc(), gum::DAGmodel::internalDag(), and isInstalledNode().

Referenced by BayesNetFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ topologicalOrder()

INLINE Sequence< NodeId > gum::DAGmodel::topologicalOrder ( ) const
inherited

The topological order stays the same as long as no variable or arcs are added or erased src the topology.

Parameters
clearIf false returns the previously created topology.

Definition at line 123 of file DAGmodel_inl.h.

123{ return dag_.topologicalOrder(); }

References dag_.

Referenced by gum::InfluenceDiagramGenerator< GUM_SCALAR >::_checkTemporalOrder_(), gum::InfluenceDiagram< GUM_SCALAR >::decisionOrder(), and gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists().

Here is the caller graph for this function:

◆ toString()

template<GUM_Numeric GUM_SCALAR>
std::string gum::IBayesNet< GUM_SCALAR >::toString ( ) const
inherited
Returns
Returns a string representation of this IBayesNet.

Definition at line 189 of file IBayesNet_tpl.h.

189 {
191 s << std::format("BN{{nodes: {}, arcs: {}, ", size(), dag().sizeArcs());
193 s << "}";
194 return s.str();
195 }
DAG dag() const
Returns a named copy of the internal DAG: each node id is assigned the name of the corresponding vari...
double log10DomainSize() const
static std::string spaceCplxToString(double dSize, int dim, Size usedMem)
send to the stream the space complexity with 3 parametrs
Size memoryFootprint() const
compute the (approximated) footprint in memory of the model (the footprints of CPTs)

Referenced by gum::operator<<().

Here is the caller graph for this function:

◆ uninstallArc_()

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::uninstallArc_ ( NodeId from,
NodeId to )
protected

Definition at line 186 of file BayesNetFragment_tpl.h.

186 {
187 this->dag_.eraseArc(Arc(from, to));
188 }

References gum::DAGmodel::dag_.

Referenced by BayesNetFragment(), installCPT_(), and whenArcDeleted().

Here is the caller graph for this function:

◆ uninstallCPT() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT ( NodeId id)

uninstall a local CPT.

Warning
Nothing happens if no local CPT for this nodeId or if the node is not installed.

Definition at line 244 of file BayesNetFragment_tpl.h.

244 {
245 if (_localCPTs_.exists(id)) {
246 uninstallCPT_(id);
247
248 // re-create arcs from referred tensor
249 const Tensor< GUM_SCALAR >& pot = cpt(id);
250
251 for (Idx i = 1; i < pot.nbrDim(); i++) {
252 NodeId parent = _bn_.idFromName(pot.variable(i).name());
253
255 }
256 }
257 }

References _bn_, _localCPTs_, cpt(), installArc_(), isInstalledNode(), and uninstallCPT_().

Referenced by BayesNetFragment(), gum::ImportanceSampling< GUM_SCALAR >::onContextualize_(), uninstallCPT(), and uninstallNode().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uninstallCPT() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT ( std::string_view name)

check if a certain NodeId exists in the fragment

Definition at line 428 of file BayesNetFragment_tpl.h.

428 {
430 }
void uninstallCPT(NodeId id)
uninstall a local CPT.

References idFromName(), and uninstallCPT().

Here is the call graph for this function:

◆ uninstallCPT_()

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::uninstallCPT_ ( NodeId id)
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 238 of file BayesNetFragment_tpl.h.

238 {
239 delete _localCPTs_[id];
240 _localCPTs_.erase(id);
241 }

References _localCPTs_.

Referenced by BayesNetFragment(), ~BayesNetFragment(), installCPT_(), and uninstallCPT().

Here is the caller graph for this function:

◆ uninstallNode() [1/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::uninstallNode ( NodeId id)

uninstall a node referenced by its nodeId

Warning
nothing happens if the node is not installed

Definition at line 178 of file BayesNetFragment_tpl.h.

178 {
179 if (isInstalledNode(id)) {
180 uninstallCPT(id);
181 this->dag_.eraseNode(id);
182 }
183 }

References gum::DAGmodel::dag_, isInstalledNode(), and uninstallCPT().

Referenced by BayesNetFragment(), uninstallNode(), and whenNodeDeleted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ uninstallNode() [2/2]

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::uninstallNode ( std::string_view name)

check if a certain NodeId exists in the fragment

Definition at line 411 of file BayesNetFragment_tpl.h.

411 {
413 }
void uninstallNode(NodeId id)
uninstall a node referenced by its nodeId

References idFromName(), and uninstallNode().

Here is the call graph for this function:

◆ updateMetaData()

void gum::GraphicalModel::updateMetaData ( )
inherited

update the meta data of this Graphical Model (version, creation date, last modification date) This method is called by the writers ONLY before writing the model to a file.

Definition at line 81 of file graphicalModel.cpp.

81 {
82 auto const time = std::chrono::time_point_cast< std::chrono::milliseconds >(
83 std::chrono::system_clock::now());
84 auto const currentdate = std::format("{:%Y-%m-%d %T}", time);
85
86 const std::string currentSoftware = "aGrUM " GUM_VERSION;
87 if (auto software = _propertiesMap_.tryGet("software")) {
88 *software = currentSoftware;
89 } else {
90 _propertiesMap_.insert("software", currentSoftware);
91 }
92
93 if (!_propertiesMap_.tryGet("creation")) { _propertiesMap_.insert("creation", currentdate); }
94
95 if (auto lastModification = _propertiesMap_.tryGet("lastModification")) {
96 *lastModification = currentdate;
97 } else {
98 _propertiesMap_.insert("lastModification", currentdate);
99 }
100 }

References _propertiesMap_.

◆ variable() [1/2]

template<GUM_Numeric GUM_SCALAR>
const DiscreteVariable & gum::BayesNetFragment< GUM_SCALAR >::variable ( NodeId id) const
finalvirtual

Returns a constant reference over a variabe given it's node id.

Exceptions
NotFoundIf no variable's id matches varId.

Implements gum::GraphicalModel.

Definition at line 108 of file BayesNetFragment_tpl.h.

108 {
109 if (!isInstalledNode(id)) GUM_ERROR(NotFound, "NodeId " << id << " is not installed")
110
111 return _bn_.variable(id);
112 }

References _bn_, GUM_ERROR, and isInstalledNode().

Referenced by BayesNetFragment(), installCPT(), toBN(), and variable().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ variable() [2/2]

template<GUM_Numeric GUM_SCALAR>
const DiscreteVariable & gum::BayesNetFragment< GUM_SCALAR >::variable ( std::string_view name) const
finalvirtual

Returns the CPT of a variable.

Exceptions
NotFoundIf no variable's id matches varId.

Definition at line 391 of file BayesNetFragment_tpl.h.

391 {
392 return variable(idFromName(name));
393 }

References idFromName(), and variable().

Here is the call graph for this function:

◆ variableFromName()

template<GUM_Numeric GUM_SCALAR>
const DiscreteVariable & gum::BayesNetFragment< GUM_SCALAR >::variableFromName ( std::string_view name) const
finalvirtual

Getter by name.

Exceptions
NotFoundif no such name exists in the graph.

Implements gum::GraphicalModel.

Definition at line 134 of file BayesNetFragment_tpl.h.

134 {
135 NodeId id = idFromName(name);
136
137 if (!isInstalledNode(id)) GUM_ERROR(NotFound, "variable " << name << " is not installed")
138
139 return _bn_.variable(id);
140 }

References _bn_, GUM_ERROR, idFromName(), and isInstalledNode().

Referenced by BayesNetFragment().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ variableNodeMap()

template<GUM_Numeric GUM_SCALAR>
const VariableNodeMap & gum::BayesNetFragment< GUM_SCALAR >::variableNodeMap ( ) const
finalvirtual

Returns a constant reference to the VariableNodeMap of this BN.

Implements gum::GraphicalModel.

Definition at line 103 of file BayesNetFragment_tpl.h.

103 {
104 return this->_bn_.variableNodeMap();
105 }

References _bn_.

◆ variables() [1/2]

INLINE VariableSet gum::GraphicalModel::variables ( const NodeSet & ids) const
inherited

transform a vector of NodeId into a VariableeSet

Returns
NodeSet

Definition at line 160 of file graphicalModel_inl.h.

160 {
161 VariableSet s;
162 const VariableNodeMap& v = variableNodeMap();
163 for (const auto& node: l) {
164 s.insert(&v.get(node));
165 }
166 return s;
167 }
Set< const DiscreteVariable * > VariableSet

◆ variables() [2/2]

INLINE VariableSet gum::GraphicalModel::variables ( const std::vector< std::string > & l) const
inherited

transform a vector of names into a VariableeSet

Returns
NodeSet

Definition at line 150 of file graphicalModel_inl.h.

150 {
151 VariableSet s;
152 const VariableNodeMap& v = variableNodeMap();
153 for (const auto& name: l) {
154 s.insert(&v.variableFromName(name));
155 }
156 return s;
157 }

References gum::Set< Key >::insert(), gum::VariableNodeMap::variableFromName(), and variableNodeMap().

Here is the call graph for this function:

◆ whenArcAdded()

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::whenArcAdded ( const void * src,
NodeId from,
NodeId to )
finalvirtual

the action to take when a new arc is inserted into the graph

Parameters
srcthe object that sent the signal
fromthe id of tail of the new arc inserted into the graph
tothe id of head of the new arc inserted into the graph

Implements gum::DiGraphListener.

Definition at line 82 of file BayesNetFragment_tpl.h.

82 {
83 // nothing to do
84 }

◆ whenArcDeleted()

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted ( const void * src,
NodeId from,
NodeId to )
finalvirtual

the action to take when an arc has just been removed from the graph

Parameters
srcthe object that sent the signal
fromthe id of tail of the arc removed from the graph
tothe id of head of the arc removed from the graph

Implements gum::DiGraphListener.

Definition at line 87 of file BayesNetFragment_tpl.h.

87 {
89 }

References gum::DAGmodel::existsArc(), gum::DAGmodel::internalDag(), and uninstallArc_().

Here is the call graph for this function:

◆ whenNodeAdded()

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::whenNodeAdded ( const void * src,
NodeId id )
finalvirtual

the action to take when a new node is inserted into the graph

Parameters
srcthe object that sent the signal
idthe id of the new node inserted into the graph

Implements gum::DiGraphListener.

Definition at line 72 of file BayesNetFragment_tpl.h.

72 {
73 // nothing to do
74 }

◆ whenNodeDeleted()

template<GUM_Numeric GUM_SCALAR>
void gum::BayesNetFragment< GUM_SCALAR >::whenNodeDeleted ( const void * src,
NodeId id )
finalvirtual

the action to take when a node has just been removed from the graph

Parameters
srcthe object that sent the signal
idthe id of the node has just been removed from the graph

Implements gum::DiGraphListener.

Definition at line 77 of file BayesNetFragment_tpl.h.

77 {
78 uninstallNode(id);
79 }

References uninstallNode().

Here is the call graph for this function:

Member Data Documentation

◆ _bn_

◆ _localCPTs_

template<GUM_Numeric GUM_SCALAR>
NodeProperty< const Tensor< GUM_SCALAR >* > gum::BayesNetFragment< GUM_SCALAR >::_localCPTs_
private

Mapping between the variable's id and their CPT specific to this Fragment.

Definition at line 96 of file BayesNetFragment.h.

Referenced by ~BayesNetFragment(), cpt(), installCPT_(), toDot(), uninstallCPT(), and uninstallCPT_().

◆ _propertiesMap_

HashTable< std::string, std::string > gum::GraphicalModel::_propertiesMap_
privateinherited

The properties of this Directed Graphical Model.

Definition at line 262 of file graphicalModel.h.

Referenced by GraphicalModel(), GraphicalModel(), _properties_(), existsProperty(), operator=(), operator=(), properties(), propertyWithDefault(), setProperty(), and updateMetaData().

◆ _senders_

Senders_list gum::Listener::_senders_
privateinherited

Definition at line 113 of file listener.h.

Referenced by Listener(), ~Listener(), _attachSignal_(), and _detachSignal_().

◆ dag_

DAG gum::DAGmodel::dag_
protectedinherited

◆ graph_

DiGraph* gum::DiGraphListener::graph_
protectedinherited

the graph to listen to

Definition at line 117 of file diGraphListener.h.

Referenced by DiGraphListener().

◆ varMap_


The documentation for this class was generated from the following files: