![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
Class representing a Bayesian network. More...
#include <agrum/BN/BayesNet.h>
Public Member Functions | |
| NodeId | addNoisyAND (const DiscreteVariable &var, GUM_SCALAR external_weight, NodeId id) |
| Add a variable, its associate node and a noisyAND implementation. | |
| NodeId | addNoisyAND (const DiscreteVariable &var, GUM_SCALAR external_weight) |
| Add a variable, its associate node and a noisyAND implementation. | |
| NodeId | addLogit (const DiscreteVariable &var, GUM_SCALAR external_weight, NodeId id) |
| Add a variable, its associate node and a Logit implementation. | |
| NodeId | addLogit (const DiscreteVariable &var, GUM_SCALAR external_weight) |
| Add a variable, its associate node and a Logit implementation. | |
| NodeId | addOR (const DiscreteVariable &var) |
| Add a variable, it's associate node and an OR implementation. | |
| NodeId | addAND (const DiscreteVariable &var) |
| Add a variable, it's associate node and an AND implementation. | |
| void | addWeightedArc (NodeId tail, NodeId head, GUM_SCALAR causalWeight) |
| Add an arc in the BN, and update arc.head's CPT. | |
| void | addWeightedArc (const std::string &tail, const std::string &head, GUM_SCALAR causalWeight) |
| Add an arc in the BN, and update arc.head's CPT. | |
| void | generateCPTs () const |
| randomly generates CPTs for a given structure | |
| void | generateCPT (NodeId node) const |
| randomly generate CPT for a given node in a given structure | |
| void | generateCPT (const std::string &name) const |
| void | changeTensor (NodeId id, Tensor< GUM_SCALAR > *newPot) |
| change the CPT associated to nodeId to newPot delete the old CPT associated to nodeId. | |
| void | changeTensor (const std::string &name, Tensor< GUM_SCALAR > *newPot) |
| BayesNet< GUM_SCALAR > | contextualize (const gum::Instantiation &observations, const gum::Instantiation &interventions) const |
| create a contextual BN from this and a set of hard observations and hard interventions. | |
| 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 ! | |
| bool | operator!= (const IBayesNet< GUM_SCALAR > &from) const |
| 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 |
| virtual std::string | toDot () const |
| std::string | toString () const |
| Tensor< GUM_SCALAR > | evEq (const std::string &name, double value) const |
| Tensor< GUM_SCALAR > | evIn (const std::string &name, double val1, double val2) const |
| Tensor< GUM_SCALAR > | evLt (const std::string &name, double value) const |
| Tensor< GUM_SCALAR > | evGt (const std::string &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) |
| NodeSet | minimalCondSet (NodeId target, const NodeSet &soids) const |
| NodeSet | minimalCondSet (const NodeSet &targets, const NodeSet &soids) const |
| NodeSet | minimalCondSet (const std::string &target, const std::vector< std::string > &soids) const |
| NodeSet | minimalCondSet (const std::vector< std::string > &targets, const std::vector< std::string > &soids) const |
| double | log10DomainSize () const |
Constructors and Destructor | |
| BayesNet () | |
| Default constructor. | |
| BayesNet (std::string name) | |
| Default constructor. | |
| virtual | ~BayesNet () |
| Destructor. | |
| BayesNet (const BayesNet< GUM_SCALAR > &source) | |
| Copy constructor. | |
Operators | |
| BayesNet< GUM_SCALAR > & | operator= (const BayesNet< GUM_SCALAR > &source) |
| Copy operator. | |
Variable manipulation methods | |
| const Tensor< GUM_SCALAR > & | cpt (NodeId varId) const final |
| Returns the CPT of a variable. | |
| const Tensor< GUM_SCALAR > & | cpt (const std::string &name) const |
| Returns the CPT of a variable. | |
| const VariableNodeMap & | variableNodeMap () const final |
| Returns a map between variables and nodes of this gum::BayesNet. | |
| NodeId | add (const DiscreteVariable &var) |
| Add a variable to the gum::BayesNet. | |
| NodeId | add (const std::string &fast_description, unsigned int default_nbrmod=2) |
| Use "fast" syntax to add a variable in the BayesNet. | |
| NodeId | add (const DiscreteVariable &var, MultiDimImplementation< GUM_SCALAR > *aContent) |
| Add a variable to the gum::BayesNet. | |
| NodeId | add (const DiscreteVariable &var, NodeId id) |
| Add a variable to the gum::BayesNet. | |
| NodeId | add (const DiscreteVariable &var, MultiDimImplementation< GUM_SCALAR > *aContent, NodeId id) |
| Add a variable to the gum::BayesNet. | |
| void | clear () |
| clear the whole Bayes net * | |
| void | erase (NodeId varId) |
| Remove a variable from the gum::BayesNet. | |
| void | erase (const std::string &name) |
| Removes a variable from the gum::BayesNet. | |
| void | erase (const DiscreteVariable &var) |
| Remove a variable from the gum::BayesNet. | |
| const DiscreteVariable & | variable (NodeId id) const final |
| Returns a gum::DiscreteVariable given its gum::NodeId in the gum::BayesNet. | |
| const DiscreteVariable & | variable (const std::string &name) const |
| Returns a gum::DiscreteVariable given its gum::NodeId in the gum::BayesNet. | |
| void | changeVariableName (NodeId id, const std::string &new_name) |
| Changes a variable's name in the gum::BayesNet. | |
| void | changeVariableName (const std::string &name, const std::string &new_name) |
| Changes a variable's name. | |
| void | changeVariableLabel (NodeId id, const std::string &old_label, const std::string &new_label) |
| Changes a variable's label in the gum::BayesNet. | |
| void | changeVariableLabel (const std::string &name, const std::string &old_label, const std::string &new_label) |
| Changes a variable's name. | |
| NodeId | nodeId (const DiscreteVariable &var) const final |
| Returns a variable's id in the gum::BayesNet. | |
| NodeId | idFromName (const std::string &name) const final |
| Returns a variable's id given its name in the gum::BayesNet. | |
| const DiscreteVariable & | variableFromName (const std::string &name) const final |
| Returns a variable given its name in the gum::BayesNet. | |
Arc manipulation methods. | |
| void | addArc (NodeId tail, NodeId head) |
| Add an arc in the BN, and update arc.head's CPT. | |
| void | addArc (const std::string &tail, const std::string &head) |
| Add an arc in the BN, and update arc.head's CPT. | |
| void | eraseArc (const Arc &arc) |
| Removes an arc in the BN, and update head's CTP. | |
| void | eraseArc (NodeId tail, NodeId head) |
| Removes an arc in the BN, and update head's CTP. | |
| void | eraseArc (const std::string &tail, const std::string &head) |
| Removes an arc in the BN, and update head's CTP. | |
| void | beginTopologyTransformation () |
| When inserting/removing arcs, node CPTs change their dimension with a cost in time. | |
| void | endTopologyTransformation () |
| terminates a sequence of insertions/deletions of arcs by adjusting all CPTs dimensions. | |
| void | reverseArc (NodeId tail, NodeId head) |
| Reverses an arc while preserving the same joint distribution. | |
| void | reverseArc (const std::string &tail, const std::string &head) |
| Reverses an arc while preserving the same joint distribution. | |
| void | reverseArc (const Arc &arc) |
| Reverses an arc while preserving the same joint distribution. | |
Accessors for nodes with CI or logical implementation | |
| NodeId | addNoisyOR (const DiscreteVariable &var, GUM_SCALAR external_weight) |
| Add a variable, it's associate node and a gum::noisyOR implementation. | |
| NodeId | addNoisyORNet (const DiscreteVariable &var, GUM_SCALAR external_weight) |
| Add a variable, it's associate node and a gum::noisyOR implementation. | |
| NodeId | addNoisyORCompound (const DiscreteVariable &var, GUM_SCALAR external_weight) |
| Add a variable, it's associate node and a gum::noisyOR implementation. | |
| NodeId | addNoisyOR (const DiscreteVariable &var, GUM_SCALAR external_weight, NodeId id) |
| Add a variable, its associate node and a noisyOR implementation. | |
| NodeId | addNoisyORNet (const DiscreteVariable &var, GUM_SCALAR external_weight, NodeId id) |
| Add a variable, its associate node and a noisyOR implementation. | |
| NodeId | addNoisyORCompound (const DiscreteVariable &var, GUM_SCALAR external_weight, NodeId id) |
| Add a variable, its associate node and a noisyOR implementation. | |
| NodeId | addAMPLITUDE (const DiscreteVariable &var) |
| Others aggregators. | |
| NodeId | addCOUNT (const DiscreteVariable &var, Idx value=1) |
| Others aggregators. | |
| NodeId | addEXISTS (const DiscreteVariable &var, Idx value=1) |
| Others aggregators. | |
| NodeId | addFORALL (const DiscreteVariable &var, Idx value=1) |
| Others aggregators. | |
| NodeId | addMAX (const DiscreteVariable &var) |
| Others aggregators. | |
| NodeId | addMEDIAN (const DiscreteVariable &var) |
| Others aggregators. | |
| NodeId | addMIN (const DiscreteVariable &var) |
| Others aggregators. | |
| NodeId | addSUM (const DiscreteVariable &var) |
| Others aggregators. | |
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. | |
| const DAG & | dag () const |
| Returns a constant reference to the dag of this Bayes Net. | |
| virtual 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 NodeGraphPart & | nodes () const final |
| Returns a constant reference to the dag of this Bayes Net. | |
| bool | exists (NodeId node) const final |
| Return true if this node exists in this graphical model. | |
| bool | exists (const std::string &name) const final |
| Returns a constant reference to the dag of this Bayes Net. | |
Arc manipulation methods. | |
| const ArcSet & | arcs () 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 (const std::string &nametail, const std::string &namehead) const |
| return true if the arc tail->head exists in the DAGmodel | |
| const NodeSet & | parents (const NodeId id) const |
| returns the set of nodes with arc ingoing to a given node | |
| const NodeSet & | parents (const std::string &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 (const std::string &name) const final |
| return true if the arc tail->head exists in the DAGmodel | |
| const NodeSet & | children (const NodeId id) const |
| returns the set of nodes with arc outgoing from a given node | |
| const NodeSet & | children (const std::string &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 (const std::string &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 (const std::string &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 (const std::string &Xname, const std::string &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< NodeId > | topologicalOrder () const |
| The topological order stays the same as long as no variable or arcs are added or erased src the topology. | |
Getter and setters | |
| const std::string & | property (const std::string &name) const |
| Return the value of the property name of this GraphicalModel. | |
| const std::string & | propertyWithDefault (const std::string &name, const std::string &byDefault) const |
| Return the value of the property name of this GraphicalModel. | |
| void | setProperty (const std::string &name, const std::string &value) |
| Add or change a property of this GraphicalModel. | |
| std::vector< std::string > | properties () const |
| List of all the properties. | |
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< NodeId > | ids (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 BayesNet< GUM_SCALAR > | fastPrototype (const std::string &dotlike, Size domainSize) |
| Create a Bayesian network with a dot-like syntax which specifies: | |
| static BayesNet< GUM_SCALAR > | fastPrototype (const std::string &dotlike, const std::string &domainSize="[2]") |
| static void | spaceCplxToStream (std::stringstream &s, double dSize, int dim, Size usedMem) |
| send to the stream the space complexity with 3 parametrs | |
Protected Attributes | |
| DAG | dag_ |
| The DAG of this Directed Graphical Model. | |
Private Member Functions | |
| void | _clearTensors_ () |
| clear all tensors | |
| void | _copyTensors_ (const BayesNet< GUM_SCALAR > &source) |
| copy of tensors from a BN to another, using names of vars as ref. | |
| void | _unsafeChangeTensor_ (NodeId id, Tensor< GUM_SCALAR > *newPot) |
| change the CPT associated to nodeId to newPot delete the old CPT associated to nodeId. | |
| const HashTable< std::string, std::string > & | _properties_ () const |
| Return the properties of this Directed Graphical Model. | |
Private Attributes | |
| VariableNodeMap | _varMap_ |
| the map between variable and id | |
| NodeProperty< Tensor< GUM_SCALAR > * > | _probaMap_ |
| Mapping between the variable's id and their CPT. | |
| HashTable< std::string, std::string > | _propertiesMap_ |
| The properties of this Directed Graphical Model. | |
Friends | |
| class | BayesNetFactory< GUM_SCALAR > |
Class representing a Bayesian network.
Bayesian networks are a probabilistic graphical model in which nodes are random variables and the probability distribution is defined by the product:
where \(\pi(X_i)\) is the parent of \(X_i\).
The probability distribution can be represented as a directed acyclic graph (DAG) where:
After a variable is added to the BN, it's domain cannot change. But it arcs are added, the data in its CPT are lost.
You should look a the gum::BayesNetFactory class which can help build Bayesian networks.
You can print a BayesNet using gum::operator<<(std::ostream&, const BayesNet<GUM_SCALAR>&).
Definition at line 93 of file BayesNet.h.
| INLINE gum::BayesNet< GUM_SCALAR >::BayesNet | ( | ) |
Default constructor.
Definition at line 128 of file BayesNet_tpl.h.
References BayesNet(), and gum::IBayesNet< GUM_SCALAR >::IBayesNet().
Referenced by BayesNet(), BayesNet(), BayesNet(), ~BayesNet(), and add().
|
explicit |
Default constructor.
| name | The BayesNet's name. |
Definition at line 133 of file BayesNet_tpl.h.
References BayesNet(), and gum::IBayesNet< GUM_SCALAR >::IBayesNet().
|
virtual |
Destructor.
Definition at line 159 of file BayesNet_tpl.h.
References BayesNet(), and _probaMap_.
| gum::BayesNet< GUM_SCALAR >::BayesNet | ( | const BayesNet< GUM_SCALAR > & | source | ) |
Copy constructor.
Definition at line 138 of file BayesNet_tpl.h.
References BayesNet(), gum::IBayesNet< GUM_SCALAR >::IBayesNet(), _copyTensors_(), and _varMap_.
|
private |
clear all tensors
Definition at line 568 of file BayesNet_tpl.h.
References _probaMap_.
Referenced by operator=().
|
private |
copy of tensors from a BN to another, using names of vars as ref.
Definition at line 579 of file BayesNet_tpl.h.
References _probaMap_, and variableFromName().
Referenced by BayesNet(), and operator=().
|
privateinherited |
Return the properties of this Directed Graphical Model.
Definition at line 70 of file graphicalModel_inl.h.
References _propertiesMap_.
Referenced by property().
|
private |
change the CPT associated to nodeId to newPot delete the old CPT associated to nodeId.
Definition at line 631 of file BayesNet_tpl.h.
References _probaMap_.
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::add | ( | const DiscreteVariable & | var | ) |
Add a variable to the gum::BayesNet.
Add a gum::DiscreteVariable, it's associated gum::NodeId and it's gum::Tensor.
The variable is added by copy to the gum::BayesNet. The variable's gum::Tensor implementation will be a gum::MultiDimArray.
| var | The variable added by copy. |
| DuplicateLabel | Raised if variable.name() is already used in this gum::BayesNet. |
Definition at line 195 of file BayesNet_tpl.h.
References add().
Referenced by add(), add(), add(), addAMPLITUDE(), addAND(), addCOUNT(), addEXISTS(), addFORALL(), addLogit(), addLogit(), addMAX(), addMEDIAN(), addMIN(), addNoisyAND(), addNoisyAND(), addNoisyORCompound(), addNoisyORCompound(), addNoisyORNet(), addNoisyORNet(), addOR(), addSUM(), gum::build_node(), and gum::BayesNetFragment< GUM_SCALAR >::toBN().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::add | ( | const DiscreteVariable & | var, |
| MultiDimImplementation< GUM_SCALAR > * | aContent ) |
Add a variable to the gum::BayesNet.
Add a gum::DiscreteVariable, it's associated gum::NodeId and it's gum::Tensor.
The variable is added by copy to the gum::BayesNet.
| var | The variable added by copy. |
| aContent | The gum::MultiDimImplementation to use for this variable's gum::Tensor implementation. |
| DuplicateLabel | Raised if variable.name() is already used in this gum::BayesNet. |
Definition at line 214 of file BayesNet_tpl.h.
References BayesNet(), add(), and gum::DAGmodel::dag().
| NodeId gum::BayesNet< GUM_SCALAR >::add | ( | const DiscreteVariable & | var, |
| MultiDimImplementation< GUM_SCALAR > * | aContent, | ||
| NodeId | id ) |
Add a variable to the gum::BayesNet.
Add a gum::DiscreteVariable, it's associated gum::NodeId and it's gum::Tensor.
| var | The variable added by copy. |
| aContent | The gum::MultiDimImplementation to use for this variable's gum::Tensor implementation. |
| id | The variable's forced gum::NodeId in the gum::BayesNet. |
| DuplicateElement | Raised id is already used. |
| DuplicateLabel | Raised if variable.name() is already used in this gum::BayesNet. |
Definition at line 234 of file BayesNet_tpl.h.
References _probaMap_, _varMap_, cpt(), gum::DAGmodel::dag_, and variable().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::add | ( | const DiscreteVariable & | var, |
| NodeId | id ) |
Add a variable to the gum::BayesNet.
Add a gum::DiscreteVariable, it's associated gum::NodeId and it's gum::Tensor.
The variable is added by copy to the gum::BayesNet. The variable's gum::Tensor implementation will be a gum::MultiDimArray.
| var | The variable added by copy. |
| id | The variable's forced gum::NodeId in the gum::BayesNet. |
| DuplicateElement | Raised id is already used. |
| DuplicateLabel | Raised if variable.name() is already used in this gum::BayesNet. |
Definition at line 222 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::add | ( | const std::string & | fast_description, |
| unsigned int | default_nbrmod = 2 ) |
Use "fast" syntax to add a variable in the BayesNet.
| fast_description( | str) following "fast" syntax description |
| default_nbrmod( | int) nbr of modality if fast_description do not indicate it. default_nbrmod=1 is the way to create a variable with only one value (for instance for reward in influence diagram). |
| DuplicateLabel | Raised if variable.name() is already used in this gum::BayesNet. |
| NotAllowed | if nbrmod<2 |
Definition at line 206 of file BayesNet_tpl.h.
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addAMPLITUDE | ( | const DiscreteVariable & | var | ) |
Others aggregators.
Definition at line 406 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addAND | ( | const DiscreteVariable & | var | ) |
Add a variable, it's associate node and an AND implementation.
The id of the new variable is automatically generated.
| var | The variable added by copy. |
| SizeError | if variable.domainSize()>2 |
Definition at line 411 of file BayesNet_tpl.h.
References add(), gum::DiscreteVariable::domainSize(), and GUM_ERROR.
| INLINE void gum::BayesNet< GUM_SCALAR >::addArc | ( | const std::string & | tail, |
| const std::string & | head ) |
Add an arc in the BN, and update arc.head's CPT.
| gum::DuplicateElement | if the arc already exists |
Definition at line 310 of file BayesNet_tpl.h.
References addArc(), GUM_ERROR, and idFromName().
| INLINE void gum::BayesNet< GUM_SCALAR >::addArc | ( | NodeId | tail, |
| NodeId | head ) |
Add an arc in the BN, and update arc.head's CPT.
| head | and |
| tail | as NodeId |
| InvalidEdge | If arc.tail and/or arc.head are not in the BN. |
| DuplicateElement | if the arc already exists |
Definition at line 299 of file BayesNet_tpl.h.
References _probaMap_, gum::DAGmodel::dag_, GUM_ERROR, and variable().
Referenced by addArc(), addWeightedArc(), fastPrototype(), and gum::BayesNetFragment< GUM_SCALAR >::toBN().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addCOUNT | ( | const DiscreteVariable & | var, |
| Idx | value = 1 ) |
Others aggregators.
Definition at line 418 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addEXISTS | ( | const DiscreteVariable & | var, |
| Idx | value = 1 ) |
Others aggregators.
Definition at line 423 of file BayesNet_tpl.h.
References add(), gum::DiscreteVariable::domainSize(), and GUM_ERROR.
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addFORALL | ( | const DiscreteVariable & | var, |
| Idx | value = 1 ) |
Others aggregators.
Definition at line 430 of file BayesNet_tpl.h.
References add(), gum::DiscreteVariable::domainSize(), and GUM_ERROR.
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addLogit | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight ) |
Add a variable, its associate node and a Logit implementation.
The id of the new variable is automatically generated.
| var | The variable added by copy. |
| external_weight | see gum::MultiDimLogit |
Definition at line 491 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addLogit | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight, | ||
| NodeId | id ) |
Add a variable, its associate node and a Logit implementation.
| var | The variable added by copy |
| external_weight | see gum::MultiDimLogit |
| id | proposed gum::nodeId for the variable |
Definition at line 511 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addMAX | ( | const DiscreteVariable & | var | ) |
Others aggregators.
Definition at line 437 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addMEDIAN | ( | const DiscreteVariable & | var | ) |
Others aggregators.
Definition at line 442 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addMIN | ( | const DiscreteVariable & | var | ) |
Others aggregators.
Definition at line 447 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addNoisyAND | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight ) |
Add a variable, its associate node and a noisyAND implementation.
The id of the new variable is automatically generated.
| var | The variable added by copy. |
| external_weight | see gum::MultiDimNoisyAND |
Definition at line 485 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addNoisyAND | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight, | ||
| NodeId | id ) |
Add a variable, its associate node and a noisyAND implementation.
| var | The variable added by copy |
| external_weight | see gum::MultiDimNoisyAND |
| id | proposed gum::nodeId for the variable |
Definition at line 504 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addNoisyOR | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight ) |
Add a variable, it's associate node and a gum::noisyOR implementation.
The id of the new variable is automatically generated. Since it seems that the 'classical' noisyOR is the Compound noisyOR, we keep the gum::BayesNet::addNoisyOR as an alias for gum::BayesNet::addNoisyORCompound
| var | The variable added by copy. |
| external_weight | see ref gum::MultiDimNoisyORNet,gum::MultiDimNoisyORCompound |
Definition at line 467 of file BayesNet_tpl.h.
References addNoisyORCompound().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addNoisyOR | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight, | ||
| NodeId | id ) |
Add a variable, its associate node and a noisyOR implementation.
Since it seems that the 'classical' noisyOR is the Compound noisyOR, we keep the addNoisyOR as an alias for addNoisyORCompound.
| var | The variable added by copy. |
| external_weight | see gum::MultiDimNoisyORNet, gum::MultiDimNoisyORCompound |
| id | The chosen id |
| DuplicateElement | if id is already used |
Definition at line 497 of file BayesNet_tpl.h.
References addNoisyORCompound().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addNoisyORCompound | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight ) |
Add a variable, it's associate node and a gum::noisyOR implementation.
The id of the new variable is automatically generated. Since it seems that the 'classical' noisyOR is the Compound noisyOR, we keep the gum::BayesNet::addNoisyOR as an alias for gum::BayesNet::addNoisyORCompound
| var | The variable added by copy. |
| external_weight | see ref gum::MultiDimNoisyORNet,gum::MultiDimNoisyORCompound |
Definition at line 473 of file BayesNet_tpl.h.
References add().
Referenced by addNoisyOR(), and addNoisyOR().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addNoisyORCompound | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight, | ||
| NodeId | id ) |
Add a variable, its associate node and a noisyOR implementation.
Since it seems that the 'classical' noisyOR is the Compound noisyOR, we keep the addNoisyOR as an alias for addNoisyORCompound.
| var | The variable added by copy. |
| external_weight | see gum::MultiDimNoisyORNet, gum::MultiDimNoisyORCompound |
| id | The chosen id |
| DuplicateElement | if id is already used |
Definition at line 518 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addNoisyORNet | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight ) |
Add a variable, it's associate node and a gum::noisyOR implementation.
The id of the new variable is automatically generated. Since it seems that the 'classical' noisyOR is the Compound noisyOR, we keep the gum::BayesNet::addNoisyOR as an alias for gum::BayesNet::addNoisyORCompound
| var | The variable added by copy. |
| external_weight | see ref gum::MultiDimNoisyORNet,gum::MultiDimNoisyORCompound |
Definition at line 479 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addNoisyORNet | ( | const DiscreteVariable & | var, |
| GUM_SCALAR | external_weight, | ||
| NodeId | id ) |
Add a variable, its associate node and a noisyOR implementation.
Since it seems that the 'classical' noisyOR is the Compound noisyOR, we keep the addNoisyOR as an alias for addNoisyORCompound.
| var | The variable added by copy. |
| external_weight | see gum::MultiDimNoisyORNet, gum::MultiDimNoisyORCompound |
| id | The chosen id |
| DuplicateElement | if id is already used |
Definition at line 525 of file BayesNet_tpl.h.
References add().
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addOR | ( | const DiscreteVariable & | var | ) |
Add a variable, it's associate node and an OR implementation.
The id of the new variable is automatically generated.
| var | The variable added by copy. |
| SizeError | if variable.domainSize()>2 |
Definition at line 452 of file BayesNet_tpl.h.
References add(), gum::DiscreteVariable::domainSize(), and GUM_ERROR.
| INLINE NodeId gum::BayesNet< GUM_SCALAR >::addSUM | ( | const DiscreteVariable & | var | ) |
Others aggregators.
Definition at line 459 of file BayesNet_tpl.h.
References add().
|
inline |
Add an arc in the BN, and update arc.head's CPT.
| head | and |
| tail | as std::string |
| causalWeight | see gum::MultiDimICIModel |
| NotFound | if no node with sun names is found |
| InvalidArc | If arc.tail and/or arc.head are not in the BN. |
| InvalidArc | If variable in arc.head is not a NoisyOR variable. |
Definition at line 647 of file BayesNet.h.
References addWeightedArc(), and idFromName().
| void gum::BayesNet< GUM_SCALAR >::addWeightedArc | ( | NodeId | tail, |
| NodeId | head, | ||
| GUM_SCALAR | causalWeight ) |
Add an arc in the BN, and update arc.head's CPT.
| head | and |
| tail | as NodeId |
| causalWeight | see gum::MultiDimICIModel |
| InvalidArc | If arc.tail and/or arc.head are not in the BN. |
| InvalidArc | If variable in arc.head is not a NoisyOR variable. |
Definition at line 532 of file BayesNet_tpl.h.
References addArc(), cpt(), GUM_ERROR, and variable().
Referenced by addWeightedArc().
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.
| id | the node which is the head of a directed path with the returned nodes |
| name | the name of the node which is the head of a directed path with the returned nodes |
Definition at line 123 of file DAGmodel_inl.h.
References gum::ArcGraphPart::ancestors(), and dag().
Referenced by ancestors().
|
inherited |
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Definition at line 125 of file DAGmodel_inl.h.
References ancestors(), and gum::GraphicalModel::idFromName().
|
inherited |
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Definition at line 65 of file DAGmodel_inl.h.
References dag_.
Referenced by hasSameStructure(), gum::MarkovBlanket::hasSameStructure(), and gum::BayesNetFragment< GUM_SCALAR >::toBN().
| void gum::BayesNet< GUM_SCALAR >::beginTopologyTransformation | ( | ) |
When inserting/removing arcs, node CPTs change their dimension with a cost in time.
begin Multiple Change for all CPTs
These functions delay the CPTs change to be done just once at the end of a sequence of topology modification. begins a sequence of insertions/deletions of arcs without changing the dimensions of the CPTs.
Definition at line 554 of file BayesNet_tpl.h.
References _probaMap_, and gum::DAGmodel::nodes().
| void gum::BayesNet< GUM_SCALAR >::changeTensor | ( | const std::string & | name, |
| Tensor< GUM_SCALAR > * | newPot ) |
Definition at line 637 of file BayesNet_tpl.h.
References changeTensor(), and idFromName().
| void gum::BayesNet< GUM_SCALAR >::changeTensor | ( | NodeId | id, |
| Tensor< GUM_SCALAR > * | newPot ) |
change the CPT associated to nodeId to newPot delete the old CPT associated to nodeId.
| NotAllowed | if newPot has not the same signature as probaMap[NodeId] |
Definition at line 611 of file BayesNet_tpl.h.
References cpt(), and GUM_ERROR.
Referenced by changeTensor().
|
inline |
Changes a variable's name.
Definition at line 371 of file BayesNet.h.
References changeVariableLabel(), and idFromName().
| INLINE void gum::BayesNet< GUM_SCALAR >::changeVariableLabel | ( | NodeId | id, |
| const std::string & | old_label, | ||
| const std::string & | new_label ) |
Changes a variable's label in the gum::BayesNet.
This will change the gum::LabelizedVariable names in the gum::BayesNet.
| DuplicateLabel | Raised if new_label is already used in this gum::LabelizedVariable. |
| NotFound | Raised if no variable matches id or if the variable is not a LabelizedVariable |
Definition at line 177 of file BayesNet_tpl.h.
References gum::LabelizedVariable::changeLabel(), GUM_ERROR, gum::LABELIZED, gum::LabelizedVariable::posLabel(), and variable().
Referenced by changeVariableLabel().
|
inline |
Changes a variable's name.
Definition at line 352 of file BayesNet.h.
References changeVariableName(), and idFromName().
| INLINE void gum::BayesNet< GUM_SCALAR >::changeVariableName | ( | NodeId | id, |
| const std::string & | new_name ) |
Changes a variable's name in the gum::BayesNet.
This will change the gum::DiscreteVariable names in the gum::BayesNet.
| DuplicateLabel | Raised if newName is already used in this gum::BayesNet. |
| NotFound | Raised if no variable matches id. |
Definition at line 172 of file BayesNet_tpl.h.
References _varMap_.
Referenced by changeVariableName().
|
inherited |
Check if the BayesNet is consistent (variables, CPT).
Definition at line 314 of file IBayesNet_tpl.h.
References cpt(), gum::GraphicalModel::empty(), gum::DAGmodel::nodes(), gum::DAGmodel::parents(), and variable().
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.
| id | the node which is the tail of an arc with the returned nodes |
| name | the name of the node which is the tail of an arc with the returned nodes |
Definition at line 87 of file DAGmodel_inl.h.
References dag_.
Referenced by gum::BayesNet< GUM_SCALAR >::erase(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), and gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot().
returns the children of a set of nodes
Definition at line 93 of file DAGmodel_inl.h.
References dag_, and gum::GraphicalModel::ids().
|
inherited |
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Definition at line 89 of file DAGmodel_inl.h.
References dag_, and gum::GraphicalModel::idFromName().
|
inherited |
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Definition at line 95 of file DAGmodel_inl.h.
References gum::GraphicalModel::names().
| void gum::BayesNet< GUM_SCALAR >::clear | ( | ) |
clear the whole Bayes net *
Definition at line 289 of file BayesNet_tpl.h.
References gum::GraphicalModel::empty(), erase(), and gum::DAGmodel::nodes().
|
inherited |
Get an instantiation over all the variables of the model.
Definition at line 106 of file graphicalModel_inl.h.
References nodes().
| BayesNet< GUM_SCALAR > gum::BayesNet< GUM_SCALAR >::contextualize | ( | const gum::Instantiation & | observations, |
| const gum::Instantiation & | interventions ) const |
create a contextual BN from this and a set of hard observations and hard interventions.
| observations | the hard observations |
| interventions | the hard interventions |
| ArgumentError | if the observations and interventions are not mutually exclusive |
Definition at line 643 of file BayesNet_tpl.h.
References gum::Instantiation::add(), gum::Instantiation::contains(), GUM_ERROR, gum::Instantiation::nbrDim(), and gum::Instantiation::variable().
|
inline |
Returns the CPT of a variable.
Definition at line 182 of file BayesNet.h.
References cpt(), and idFromName().
|
finalvirtual |
Returns the CPT of a variable.
| varId | A variable's id in the gum::BayesNet. |
| NotFound | If no variable's id matches varId. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 258 of file BayesNet_tpl.h.
References _probaMap_.
Referenced by gum::BayesNet< double >::_copyTensors_(), add(), addWeightedArc(), changeTensor(), cpt(), generateCPT(), and gum::BayesNetFragment< GUM_SCALAR >::toBN().
|
inherited |
Returns a constant reference to the dag of this Bayes Net.
Definition at line 57 of file DAGmodel_inl.h.
References dag_.
Referenced by gum::BayesNetFragment< GUM_SCALAR >::BayesNetFragment(), gum::MarginalTargetedInference< GUM_SCALAR >::MarginalTargetedInference(), gum::BayesNet< GUM_SCALAR >::add(), ancestors(), gum::IBayesNet< double >::arcs(), descendants(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), isIndependent(), isIndependent(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), moralGraph(), moralizedAncestralGraph(), gum::BayesBall::relevantTensors(), gum::dSeparationAlgorithm::relevantTensors(), gum::BayesNet< GUM_SCALAR >::reverseArc(), size(), gum::BayesNetFragment< GUM_SCALAR >::toBN(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), gum::IBayesNet< GUM_SCALAR >::toString(), gum::InfluenceDiagram< GUM_SCALAR >::toString(), and gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted().
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.
| id | the node which is the tail of a directed path with the returned nodes |
| name | the name of the node which is the tail of a directed path with the returned nodes |
Definition at line 117 of file DAGmodel_inl.h.
References dag(), and gum::ArcGraphPart::descendants().
Referenced by descendants().
|
inherited |
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Definition at line 119 of file DAGmodel_inl.h.
References descendants(), and gum::GraphicalModel::idFromName().
|
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 95 of file IBayesNet_tpl.h.
References dim(), and gum::DAGmodel::nodes().
Referenced by dim(), and toString().
|
virtualinherited |
Return true if this graphical model is empty.
Definition at line 116 of file graphicalModel_inl.h.
References size().
Referenced by gum::IBayesNet< GUM_SCALAR >::check(), and gum::BayesNet< GUM_SCALAR >::clear().
| void gum::BayesNet< GUM_SCALAR >::endTopologyTransformation | ( | ) |
terminates a sequence of insertions/deletions of arcs by adjusting all CPTs dimensions.
end Multiple Change for all CPTs
Definition at line 561 of file BayesNet_tpl.h.
References _probaMap_, and gum::DAGmodel::nodes().
| INLINE void gum::BayesNet< GUM_SCALAR >::erase | ( | const DiscreteVariable & | var | ) |
Remove a variable from the gum::BayesNet.
Removes the corresponding variable from the gum::BayesNet and from all of it's children gum::Tensor.
If no variable matches the given variable, then nothing is done.
| var | A reference on the variable to remove. |
Definition at line 268 of file BayesNet_tpl.h.
References _varMap_, and erase().
|
inline |
Removes a variable from the gum::BayesNet.
Definition at line 304 of file BayesNet.h.
References erase(), erase(), and idFromName().
Referenced by erase().
| void gum::BayesNet< GUM_SCALAR >::erase | ( | NodeId | varId | ) |
Remove a variable from the gum::BayesNet.
Removes the corresponding variable from the gum::BayesNet and from all of it's children gum::Tensor.
If no variable matches the given id, then nothing is done.
| varId | The variable's id to remove. |
Definition at line 273 of file BayesNet_tpl.h.
References _probaMap_, _varMap_, gum::DAGmodel::children(), gum::DAGmodel::dag_, and variable().
Referenced by clear(), erase(), and erase().
| INLINE void gum::BayesNet< GUM_SCALAR >::eraseArc | ( | const Arc & | arc | ) |
Removes an arc in the BN, and update head's CTP.
If (tail, head) doesn't exist, the nothing happens.
| arc | The arc removed. |
Definition at line 319 of file BayesNet_tpl.h.
References _probaMap_, _varMap_, gum::DAGmodel::dag_, gum::Arc::head(), gum::Arc::tail(), and variable().
Referenced by eraseArc(), and eraseArc().
|
inline |
Removes an arc in the BN, and update head's CTP.
Definition at line 451 of file BayesNet.h.
References eraseArc(), and idFromName().
| INLINE void gum::BayesNet< GUM_SCALAR >::eraseArc | ( | NodeId | tail, |
| NodeId | head ) |
Removes an arc in the BN, and update head's CTP.
If (tail, head) doesn't exist, the nothing happens.
| head | and |
| tail | as NodeId |
Definition at line 330 of file BayesNet_tpl.h.
References eraseArc().
|
inherited |
Definition at line 378 of file IBayesNet_tpl.h.
References gum::Tensor< GUM_SCALAR >::evEq(), and variableFromName().
|
inherited |
Definition at line 389 of file IBayesNet_tpl.h.
References gum::Tensor< GUM_SCALAR >::evGt(), and variableFromName().
|
inherited |
Definition at line 384 of file IBayesNet_tpl.h.
References gum::Tensor< GUM_SCALAR >::evIn(), and variableFromName().
|
inherited |
Definition at line 394 of file IBayesNet_tpl.h.
References gum::Tensor< GUM_SCALAR >::evLt(), and variableFromName().
|
finalvirtualinherited |
Returns a constant reference to the dag of this Bayes Net.
Implements gum::GraphicalModel.
Definition at line 107 of file DAGmodel_inl.h.
Return true if this node exists in this graphical model.
Implements gum::GraphicalModel.
Definition at line 105 of file DAGmodel_inl.h.
References dag_.
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Definition at line 67 of file DAGmodel_inl.h.
References dag_.
Referenced by existsArc(), gum::BayesNet< GUM_SCALAR >::reverseArc(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), and gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted().
|
inherited |
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Definition at line 71 of file DAGmodel_inl.h.
References existsArc(), and gum::GraphicalModel::idFromName().
returns the parents of a node and the node
| id | the node which is the head of an arc with the returned nodes |
| name | the name of the node the node which is the head of an arc with the returned nodes |
Implements gum::GraphicalModel.
Definition at line 81 of file DAGmodel_inl.h.
References dag_.
|
finalvirtualinherited |
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Implements gum::GraphicalModel.
Definition at line 83 of file DAGmodel_inl.h.
References dag_, and gum::GraphicalModel::idFromName().
|
static |
Definition at line 96 of file BayesNet_tpl.h.
References addArc(), gum::build_node(), gum::remove_newline(), and gum::split().
|
static |
Create a Bayesian network with a dot-like syntax which specifies:
Note that if the dot-like string contains such a specification more than once for a variable, the first specification will be used.
| dotlike | the string containing the specification |
| domainSize | the default domain size for variables |
Definition at line 90 of file BayesNet_tpl.h.
References fastPrototype().
Referenced by fastPrototype().
|
inline |
Definition at line 659 of file BayesNet.h.
References generateCPT(), and idFromName().
Referenced by generateCPT().
| INLINE void gum::BayesNet< GUM_SCALAR >::generateCPT | ( | NodeId | node | ) | const |
randomly generate CPT for a given node in a given structure
Definition at line 604 of file BayesNet_tpl.h.
References cpt(), and variable().
Referenced by generateCPTs().
| INLINE void gum::BayesNet< GUM_SCALAR >::generateCPTs | ( | ) | const |
randomly generates CPTs for a given structure
Definition at line 598 of file BayesNet_tpl.h.
References generateCPT(), and gum::DAGmodel::nodes().
Definition at line 66 of file DAGmodel.cpp.
References DAGmodel(), arcs(), gum::Set< Key >::exists(), gum::GraphicalModel::idFromName(), nodes(), size(), sizeArcs(), and gum::GraphicalModel::variable().
|
finalvirtual |
Returns a variable's id given its name in the gum::BayesNet.
| name | The variable's name from which the gum::NodeId is returned. |
| NotFound | Raised if name does not match a variable in the gum::BayesNet. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 247 of file BayesNet_tpl.h.
References _varMap_.
Referenced by gum::BayesNet< double >::_copyTensors_(), addArc(), addWeightedArc(), gum::build_node(), changeTensor(), changeVariableLabel(), changeVariableName(), cpt(), erase(), eraseArc(), generateCPT(), reverseArc(), and variable().
|
inherited |
transform a vector of names into a vector of nodeId
Definition at line 139 of file graphicalModel_inl.h.
References names().
Referenced by gum::DAGmodel::children(), exists(), names(), and gum::DAGmodel::parents().
|
finalvirtualinherited |
check if nodes X and nodes Y are independent given nodes Z
Implements gum::GraphicalModel.
Definition at line 142 of file DAGmodel_inl.h.
References dag(), and gum::DAG::dSeparation().
|
inlineinherited |
build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
| nodes | the set of nodeId |
| nodenames | the vector of names of nodes |
Definition at line 202 of file DAGmodel.h.
References gum::GraphicalModel::idFromName(), isIndependent(), and gum::GraphicalModel::nodeset().
|
inlineinherited |
build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
| nodes | the set of nodeId |
| nodenames | the vector of names of nodes |
Definition at line 208 of file DAGmodel.h.
References isIndependent(), and gum::GraphicalModel::nodeset().
|
finalvirtualinherited |
check if node X and node Y are independent given nodes Z
Implements gum::GraphicalModel.
Definition at line 138 of file DAGmodel_inl.h.
References dag(), and gum::DAG::dSeparation().
Referenced by isIndependent(), and isIndependent().
|
inherited |
Compute a parameter of the joint probability for the BN (given an instantiation of the vars).
Definition at line 221 of file IBayesNet_tpl.h.
References cpt(), and gum::DAGmodel::nodes().
|
inherited |
Definition at line 95 of file graphicalModel_inl.h.
References nodes().
Referenced by gum::IBayesNet< GUM_SCALAR >::toString(), gum::IMarkovRandomField< GUM_SCALAR >::toString(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().
|
inherited |
Compute a parameter of the log joint probability for the BN (given an instantiation of the vars).
Compute a parameter of the joint probability for the BN (given an instantiation of the vars).
Definition at line 239 of file IBayesNet_tpl.h.
|
inherited |
Definition at line 151 of file IBayesNet_tpl.h.
References cpt(), and gum::DAGmodel::nodes().
|
inherited |
Definition at line 131 of file IBayesNet_tpl.h.
References cpt(), and gum::DAGmodel::nodes().
|
inherited |
Definition at line 111 of file IBayesNet_tpl.h.
References gum::DAGmodel::nodes(), and variable().
Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_().
|
inherited |
compute the (approximated) footprint in memory of the model (the footprints of CPTs)
Definition at line 161 of file IBayesNet_tpl.h.
References gum::DAGmodel::nodes().
Referenced by toString().
|
inherited |
Definition at line 150 of file DAGmodel_inl.h.
References dag_.
|
inherited |
Definition at line 154 of file DAGmodel_inl.h.
|
inherited |
Definition at line 159 of file DAGmodel_inl.h.
|
inherited |
Definition at line 146 of file DAGmodel_inl.h.
|
inherited |
Definition at line 141 of file IBayesNet_tpl.h.
References cpt(), and gum::DAGmodel::nodes().
Referenced by gum::ImportanceSampling< GUM_SCALAR >::onContextualize_().
|
inherited |
Definition at line 121 of file IBayesNet_tpl.h.
References cpt(), and gum::DAGmodel::nodes().
|
inherited |
The node's id are coherent with the variables and nodes of the topology.
Definition at line 64 of file DAGmodel.cpp.
References dag(), and gum::DAG::moralGraph().
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_().
build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
| nodes | the set of nodeId |
| nodenames | the vector of names of nodes |
Definition at line 134 of file DAGmodel_inl.h.
References dag(), gum::DAG::moralizedAncestralGraph(), and nodes().
Referenced by moralizedAncestralGraph().
|
inherited |
build a UndiGraph by moralizing the Ancestral Graph of a set of Nodes
| nodes | the set of nodeId |
| nodenames | the vector of names of nodes |
Definition at line 130 of file DAGmodel_inl.h.
References moralizedAncestralGraph(), and gum::GraphicalModel::nodeset().
|
inherited |
transform a NodeSet in a vector of names
Definition at line 129 of file graphicalModel_inl.h.
|
inherited |
transform a vector of NodeId in a vector of names
Definition at line 119 of file graphicalModel_inl.h.
References ids(), and variableNodeMap().
Referenced by gum::DAGmodel::children(), exists(), ids(), nodeset(), and gum::DAGmodel::parents().
|
finalvirtual |
Returns a variable's id in the gum::BayesNet.
| var | The variable from which the gum::NodeId is returned. |
| NotFound | If var is not in the gum::BayesNet. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 190 of file BayesNet_tpl.h.
|
finalvirtualinherited |
Returns a constant reference to the dag of this Bayes Net.
Implements gum::GraphicalModel.
Definition at line 113 of file DAGmodel_inl.h.
References dag_.
Referenced by 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 >::jointProbability(), gum::IBayesNet< GUM_SCALAR >::maxNonOneParam(), gum::IBayesNet< GUM_SCALAR >::maxParam(), gum::IBayesNet< GUM_SCALAR >::maxVarDomainSize(), gum::IBayesNet< GUM_SCALAR >::memoryFootprint(), gum::IBayesNet< GUM_SCALAR >::minNonZeroParam(), gum::IBayesNet< GUM_SCALAR >::minParam(), gum::prm::ClassBayesNet< GUM_SCALAR >::modalities(), gum::prm::InstanceBayesNet< GUM_SCALAR >::modalities(), moralizedAncestralGraph(), 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_().
|
inherited |
transform a vector of names into a NodeSet
Definition at line 60 of file graphicalModel.cpp.
References idFromName(), gum::Set< Key >::insert(), and names().
Referenced by gum::IBayesNet< double >::children(), gum::IBayesNet< double >::children(), gum::DAGmodel::isIndependent(), gum::DAGmodel::isIndependent(), gum::UGmodel::isIndependent(), gum::UGmodel::isIndependent(), gum::DAGmodel::moralizedAncestralGraph(), and gum::DAGmodel::parents().
|
inherited |
Definition at line 303 of file IBayesNet_tpl.h.
References IBayesNet(), and gum::operator==().
| BayesNet< GUM_SCALAR > & gum::BayesNet< GUM_SCALAR >::operator= | ( | const BayesNet< GUM_SCALAR > & | source | ) |
Copy operator.
| source | The copied BayesNet. |
Definition at line 146 of file BayesNet_tpl.h.
References _clearTensors_(), _copyTensors_(), _varMap_, and gum::IBayesNet< GUM_SCALAR >::operator=().
|
inherited |
This operator compares 2 BNs !
Definition at line 256 of file IBayesNet_tpl.h.
References IBayesNet(), and gum::DAGmodel::size().
returns the set of nodes with arc ingoing to a given node
Note that the set of nodes returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
| id | the node which is the head of an arc with the returned nodes |
| name | the name of the node the node which is the head of an arc with the returned nodes |
Definition at line 75 of file DAGmodel_inl.h.
References dag_.
Referenced by gum::IBayesNet< GUM_SCALAR >::check(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::InfluenceDiagram< GUM_SCALAR >::copyStructureAndTables_(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::BayesNetFragment< GUM_SCALAR >::installCPT_(), parents(), parents(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), and gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot().
returns the parents of a set of nodes
Definition at line 99 of file DAGmodel_inl.h.
References dag_, and gum::GraphicalModel::ids().
|
inherited |
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Definition at line 77 of file DAGmodel_inl.h.
References gum::GraphicalModel::idFromName(), and parents().
|
inherited |
return true if the arc tail->head exists in the DAGmodel
| tail | the nodeId (or the name) of the tail in tail->head |
| head | the nodeId (or the name) of the head in tail->head |
Definition at line 101 of file DAGmodel_inl.h.
References gum::GraphicalModel::names(), gum::GraphicalModel::nodeset(), and parents().
|
inherited |
List of all the properties.
Definition at line 81 of file graphicalModel_inl.h.
References _propertiesMap_.
|
inherited |
Return the value of the property name of this GraphicalModel.
| NotFound | Raised if no name property is found. |
Definition at line 60 of file graphicalModel_inl.h.
References _properties_(), and GUM_ERROR.
Referenced by gum::IMarkovRandomField< GUM_SCALAR >::toDot(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), and gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().
|
inherited |
Return the value of the property name of this GraphicalModel.
return byDefault if the property name is not found
Definition at line 75 of file graphicalModel_inl.h.
References _propertiesMap_.
| void gum::BayesNet< GUM_SCALAR >::reverseArc | ( | const Arc & | arc | ) |
Reverses an arc while preserving the same joint distribution.
This method uses Shachter's 1986 algorithm for reversing an arc in the Bayes net while preserving the same joint distribution. By performing this reversal, we also add new arcs (required to not alter the joint distribution)
| InvalidArc | exception if the arc does not exist or if its reversal would induce a directed cycle. |
Definition at line 335 of file BayesNet_tpl.h.
References _varMap_, gum::DAGmodel::dag(), gum::DAGmodel::existsArc(), GUM_ERROR, gum::Arc::head(), and gum::Arc::tail().
|
inline |
Reverses an arc while preserving the same joint distribution.
This method uses Shachter's 1986 algorithm for reversing an arc in the Bayes net while preserving the same joint distribution. By performing this reversal, we also add new arcs (required to not alter the joint distribution)
| InvalidArc | exception if the arc does not exist or if its reversal would induce a directed cycle. |
Definition at line 485 of file BayesNet.h.
References idFromName(), and reverseArc().
| INLINE void gum::BayesNet< GUM_SCALAR >::reverseArc | ( | NodeId | tail, |
| NodeId | head ) |
Reverses an arc while preserving the same joint distribution.
This method uses Shachter's 1986 algorithm for reversing an arc in the Bayes net while preserving the same joint distribution. By performing this reversal, we also add new arcs (required to not alter the joint distribution)
| InvalidArc | exception if the arc does not exist or if its reversal would induce a directed cycle. |
Definition at line 398 of file BayesNet_tpl.h.
References reverseArc().
Referenced by reverseArc(), and reverseArc().
|
inherited |
Add or change a property of this GraphicalModel.
Definition at line 89 of file graphicalModel_inl.h.
References _propertiesMap_.
Referenced by gum::IBayesNet< GUM_SCALAR >::IBayesNet(), gum::IMarkovRandomField< GUM_SCALAR >::IMarkovRandomField(), and gum::InfluenceDiagram< GUM_SCALAR >::fastPrototype().
|
finalvirtualinherited |
Returns the number of variables in this Directed Graphical Model.
Implements gum::GraphicalModel.
Definition at line 60 of file DAGmodel_inl.h.
References dag(), and gum::NodeGraphPart::size().
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(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::IBayesNet< GUM_SCALAR >::toString().
|
inherited |
Returns the number of arcs in this Directed Graphical Model.
Definition at line 63 of file DAGmodel_inl.h.
References dag_.
Referenced by hasSameStructure(), gum::MarkovBlanket::hasSameStructure(), and gum::InfluenceDiagram< GUM_SCALAR >::operator==().
|
staticinherited |
send to the stream the space complexity with 3 parametrs
| s | the stream |
| dSize | the log10domainSize |
| dim | the dimension |
| usedMem | the memory needed for the params |
Definition at line 69 of file graphicalModel.cpp.
Referenced by gum::IBayesNet< GUM_SCALAR >::toString().
|
virtualinherited |
Reimplemented in gum::BayesNetFragment< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Definition at line 179 of file IBayesNet_tpl.h.
The topological order stays the same as long as no variable or arcs are added or erased src the topology.
| clear | If false returns the previously created topology. |
Definition at line 115 of file DAGmodel_inl.h.
Referenced by gum::InfluenceDiagramGenerator< GUM_SCALAR >::_checkTemporalOrder_(), gum::InfluenceDiagram< GUM_SCALAR >::decisionOrder(), and gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists().
|
inherited |
Definition at line 170 of file IBayesNet_tpl.h.
References gum::DAGmodel::dag(), dim(), gum::GraphicalModel::log10DomainSize(), memoryFootprint(), gum::DAGmodel::size(), and gum::GraphicalModel::spaceCplxToStream().
Referenced by gum::operator<<().
|
inline |
Returns a gum::DiscreteVariable given its gum::NodeId in the gum::BayesNet.
Definition at line 334 of file BayesNet.h.
References idFromName(), and variable().
|
finalvirtual |
Returns a gum::DiscreteVariable given its gum::NodeId in the gum::BayesNet.
| id | The variable's id to return. |
| NotFound | Raised if id does not match a a variable in the gum::BayesNet. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 167 of file BayesNet_tpl.h.
References _varMap_.
Referenced by add(), addArc(), addWeightedArc(), changeVariableLabel(), erase(), eraseArc(), generateCPT(), gum::getMaxModality(), and variable().
|
finalvirtual |
Returns a variable given its name in the gum::BayesNet.
| name | The variable's name in the gum::BayesNet. |
| NotFound | Raised if name does not match a variable in the gum::BayesNet. |
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 253 of file BayesNet_tpl.h.
References _varMap_.
Referenced by _copyTensors_().
|
finalvirtual |
Returns a map between variables and nodes of this gum::BayesNet.
Implements gum::IBayesNet< GUM_SCALAR >.
Definition at line 263 of file BayesNet_tpl.h.
References _varMap_.
|
inherited |
transform a vector of NodeId into a VariableeSet
Definition at line 160 of file graphicalModel_inl.h.
References gum::VariableNodeMap::get(), gum::Set< Key >::insert(), and variableNodeMap().
|
inherited |
transform a vector of names into a VariableeSet
Definition at line 150 of file graphicalModel_inl.h.
References variableNodeMap().
|
friend |
Definition at line 714 of file BayesNet.h.
|
private |
Mapping between the variable's id and their CPT.
Definition at line 693 of file BayesNet.h.
Referenced by ~BayesNet(), _clearTensors_(), _copyTensors_(), _unsafeChangeTensor_(), add(), addArc(), beginTopologyTransformation(), cpt(), endTopologyTransformation(), erase(), and eraseArc().
|
privateinherited |
The properties of this Directed Graphical Model.
Definition at line 236 of file graphicalModel.h.
Referenced by _properties_(), operator=(), properties(), propertyWithDefault(), and setProperty().
|
private |
the map between variable and id
Definition at line 690 of file BayesNet.h.
Referenced by BayesNet(), add(), changeVariableName(), erase(), erase(), eraseArc(), idFromName(), operator=(), reverseArc(), variable(), variableFromName(), and variableNodeMap().
|
protectedinherited |
The DAG of this Directed Graphical Model.
Definition at line 272 of file DAGmodel.h.
Referenced by DAGmodel(), gum::prm::ClassBayesNet< GUM_SCALAR >::_get_(), gum::prm::ClassBayesNet< GUM_SCALAR >::_init_(), gum::prm::InstanceBayesNet< GUM_SCALAR >::_init_(), gum::BayesNet< GUM_SCALAR >::add(), gum::BayesNet< GUM_SCALAR >::addArc(), gum::InfluenceDiagram< GUM_SCALAR >::addArc(), gum::InfluenceDiagram< GUM_SCALAR >::addNode_(), arcs(), children(), children(), children(), dag(), gum::BayesNet< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::BayesNet< GUM_SCALAR >::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), exists(), existsArc(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), family(), family(), gum::InfluenceDiagram< GUM_SCALAR >::getChildrenDecision_(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::BayesNetFragment< GUM_SCALAR >::installArc_(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), minimalCondSet(), gum::InfluenceDiagram< GUM_SCALAR >::moralGraph_(), nodes(), operator=(), parents(), parents(), gum::InfluenceDiagram< GUM_SCALAR >::removeTables_(), sizeArcs(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), gum::BayesNetFragment< GUM_SCALAR >::uninstallArc_(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().