![]() |
aGrUM 3.0.0
a C++ library for (probabilistic) graphical models
|
<agrum/base/graphicalModels/discreteGraphicalModel.h> More...
#include <discreteGraphicalModel.h>
Public Member Functions | |
| double | log10DomainSize () const |
| virtual bool | isIndependent (NodeId X, NodeId Y, const NodeSet &Z) const =0 |
| check if node X and node Y are independent given nodes Z | |
| virtual bool | isIndependent (const NodeSet &X, const NodeSet &Y, const NodeSet &Z) const =0 |
| check if nodes X and nodes Y are independent given nodes Z | |
| virtual NodeSet | family (const NodeId id) const =0 |
| returns the family of a noe (parents or neighbours) of a node and the node | |
| virtual NodeSet | family (std::string_view name) const =0 |
Constructors / Destructors | |
| DiscreteGraphicalModel () | |
| ~DiscreteGraphicalModel () override | |
| DiscreteGraphicalModel (const DiscreteGraphicalModel &source) | |
| DiscreteGraphicalModel (DiscreteGraphicalModel &&source) | |
Variable accessor methods | |
| const VariableNodeMap & | variableNodeMap () const override |
| Returns a constant reference to the VariableNodeMap of this model. | |
| const DiscreteVariable & | variable (NodeId id) const override |
| Returns a constant reference over a variable given its node id. | |
| NodeId | nodeId (const DiscreteVariable &var) const override |
| Returns the NodeId of a variable. | |
| NodeId | idFromName (std::string_view name) const override |
| Returns the NodeId of a variable given its name. | |
| const DiscreteVariable & | variableFromName (std::string_view name) const override |
| Returns a constant reference over a variable given its name. | |
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 Size | size () const =0 |
| Returns the number of variables in this Directed Graphical Model. | |
| virtual bool | empty () const |
| Return true if this graphical model is empty. | |
| virtual bool | exists (NodeId node) const =0 |
| Return true if this node exists in this graphical model. | |
| virtual bool | exists (std::string_view name) const =0 |
| Returns the number of variables in this Directed Graphical Model. | |
| 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 | |
| virtual const NodeGraphPart & | nodes () const =0 |
| Returns the number of variables in this Directed Graphical Model. | |
| 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 | |
| DiscreteGraphicalModel & | operator= (const DiscreteGraphicalModel &source) |
| DiscreteGraphicalModel & | operator= (DiscreteGraphicalModel &&source) |
| void | _nameNodes_ (NodeGraphPart &g) const |
| Names every node of g using variable(id).name() for each node id in g. | |
Protected Attributes | |
| VariableNodeMap | varMap_ |
| Mapping between NodeIds and discrete variables. | |
Private Member Functions | |
| const HashTable< std::string, std::string > & | _properties_ () const |
| Return the properties of this Directed Graphical Model. | |
Private Attributes | |
| HashTable< std::string, std::string > | _propertiesMap_ |
| The properties of this Directed Graphical Model. | |
<agrum/base/graphicalModels/discreteGraphicalModel.h>
Intermediate base class for graphical models over discrete variables.
Owns a VariableNodeMap and provides concrete implementations of the five variable-accessor methods declared pure virtual in GraphicalModel (variableNodeMap, variable, nodeId, idFromName, variableFromName). All concrete models (BayesNet, MarkovRandomField, InfluenceDiagram, …) inherit from this class via DAGmodel or UGmodel.
Definition at line 69 of file discreteGraphicalModel.h.
| gum::DiscreteGraphicalModel::DiscreteGraphicalModel | ( | ) |
Definition at line 50 of file discreteGraphicalModel.cpp.
References DiscreteGraphicalModel().
Referenced by gum::DAGmodel::DAGmodel(), gum::DAGmodel::DAGmodel(), DiscreteGraphicalModel(), DiscreteGraphicalModel(), DiscreteGraphicalModel(), gum::UGmodel::UGmodel(), gum::UGmodel::UGmodel(), ~DiscreteGraphicalModel(), operator=(), and operator=().
|
override |
Definition at line 62 of file discreteGraphicalModel.cpp.
References DiscreteGraphicalModel().
| gum::DiscreteGraphicalModel::DiscreteGraphicalModel | ( | const DiscreteGraphicalModel & | source | ) |
Definition at line 52 of file discreteGraphicalModel.cpp.
References DiscreteGraphicalModel(), gum::GraphicalModel::GraphicalModel(), and varMap_.
| gum::DiscreteGraphicalModel::DiscreteGraphicalModel | ( | DiscreteGraphicalModel && | source | ) |
Definition at line 57 of file discreteGraphicalModel.cpp.
References DiscreteGraphicalModel(), gum::GraphicalModel::GraphicalModel(), and varMap_.
|
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.
References gum::NodeGraphPart::setName(), and variable().
Referenced by gum::DAGmodel::dag(), gum::UGmodel::graph(), gum::DAGmodel::moralGraph(), and gum::DAGmodel::moralizedAncestralGraph().
|
privateinherited |
Return the properties of this Directed Graphical Model.
Definition at line 67 of file graphicalModel_inl.h.
References _propertiesMap_.
Referenced by property().
|
inherited |
Get an instantiation over all the variables of the model.
Definition at line 104 of file graphicalModel_inl.h.
References nodes(), and variable().
|
virtualinherited |
Return true if this graphical model is empty.
Definition at line 114 of file graphicalModel_inl.h.
References size().
Referenced by gum::IBayesNet< GUM_SCALAR >::check(), and gum::BayesNet< GUM_SCALAR >::clear().
Return true if this node exists in this graphical model.
Implemented in gum::DAGmodel, and gum::UGmodel.
|
pure virtualinherited |
Returns the number of variables in this Directed Graphical Model.
Implemented in gum::DAGmodel, and gum::UGmodel.
References ids(), and names().
|
inherited |
check wether a property exists in this GraphicalModel
Definition at line 170 of file graphicalModel_inl.h.
References _propertiesMap_.
returns the family of a noe (parents or neighbours) 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 |
Implemented in gum::DAGmodel, and gum::UGmodel.
|
pure virtualinherited |
Implemented in gum::DAGmodel, and gum::UGmodel.
References GraphicalModel().
|
overridevirtual |
Returns the NodeId of a variable given its name.
| NotFound | if no such name exists in the model. |
Implements gum::GraphicalModel.
Reimplemented in gum::InfluenceDiagram< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Definition at line 61 of file discreteGraphicalModel_inl.h.
References varMap_.
Referenced by gum::ASTposteriorProba< GUM_SCALAR >::_compute_knw_from_bn(), gum::DAGmodel::ancestors(), gum::InfluenceDiagram< GUM_SCALAR >::clear(), gum::ASTjointProba< GUM_SCALAR >::eval(), gum::ASTposteriorProba< GUM_SCALAR >::eval(), gum::ASTsum< GUM_SCALAR >::eval(), gum::UGmodel::exists(), gum::DAGmodel::existsArc(), gum::UGmodel::existsEdge(), gum::DAGmodel::family(), gum::UGmodel::family(), gum::DAGmodel::hasSameStructure(), gum::MarkovBlanket::hasSameStructure(), gum::UGmodel::hasSameStructure(), gum::DAGmodel::isIndependent(), gum::UGmodel::isIndependent(), gum::DAGmodel::minimalCondSet(), gum::UGmodel::neighbours(), gum::IBayesNet< GUM_SCALAR >::operator==(), gum::IMarkovRandomField< GUM_SCALAR >::operator==(), gum::DAGmodel::parents(), and gum::IMarkovRandomField< GUM_SCALAR >::smallestFactorFromNode().
|
inherited |
transform a vector of names into a vector of nodeId
Definition at line 139 of file graphicalModel_inl.h.
References names(), and variableNodeMap().
Referenced by gum::DAGmodel::children(), exists(), names(), names(), and gum::DAGmodel::parents().
|
pure virtualinherited |
check if nodes X and nodes Y are independent given nodes Z
Implemented in gum::DAGmodel, and gum::UGmodel.
|
pure virtualinherited |
check if node X and node Y are independent given nodes Z
Implemented in gum::DAGmodel, and gum::UGmodel.
|
inherited |
Definition at line 93 of file graphicalModel_inl.h.
References nodes().
Referenced by gum::IMarkovRandomField< GUM_SCALAR >::toString(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().
|
inherited |
transform a NodeSet in a vector of names
Definition at line 129 of file graphicalModel_inl.h.
References ids(), gum::VariableNodeMap::name(), and variableNodeMap().
|
inherited |
transform a vector of NodeId in a vector of names
Definition at line 117 of file graphicalModel_inl.h.
References ids().
Referenced by gum::DAGmodel::children(), exists(), ids(), nodeset(), and gum::DAGmodel::parents().
|
overridevirtual |
Returns the NodeId of a variable.
| NotFound | if no variable matches var. |
Implements gum::GraphicalModel.
Reimplemented in gum::InfluenceDiagram< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Definition at line 56 of file discreteGraphicalModel_inl.h.
References varMap_.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::clear(), gum::BayesBall::relevantTensors(), and gum::dSeparationAlgorithm::relevantTensors().
|
pure virtualinherited |
Returns the number of variables in this Directed Graphical Model.
Implemented in gum::DAGmodel, and gum::UGmodel.
Referenced by completeInstantiation(), and log10DomainSize().
|
inherited |
transform a vector of names into a NodeSet
Definition at line 102 of file graphicalModel.cpp.
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().
|
protected |
Definition at line 64 of file discreteGraphicalModel.cpp.
References DiscreteGraphicalModel(), gum::GraphicalModel::operator=(), and varMap_.
Referenced by gum::DAGmodel::operator=(), gum::DAGmodel::operator=(), gum::UGmodel::operator=(), and gum::UGmodel::operator=().
|
protected |
Definition at line 73 of file discreteGraphicalModel.cpp.
References DiscreteGraphicalModel(), gum::GraphicalModel::operator=(), and varMap_.
|
inherited |
List of all the names of property in the Graphical model.
Definition at line 79 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_(), GUM_ERROR, and gum::HashTable< Key, Val >::tryGet().
|
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.
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().
|
inherited |
Add or change a property of this GraphicalModel.
Definition at line 87 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().
|
pure virtualinherited |
Returns the number of variables in this Directed Graphical Model.
Implemented in gum::DAGmodel, and gum::UGmodel.
Referenced by empty().
|
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 110 of file graphicalModel.cpp.
|
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.
References _propertiesMap_.
|
overridevirtual |
Returns a constant reference over a variable given its node id.
| NotFound | if no variable's id matches id. |
Implements gum::GraphicalModel.
Reimplemented in gum::InfluenceDiagram< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Definition at line 51 of file discreteGraphicalModel_inl.h.
References varMap_.
Referenced by gum::Estimator< GUM_SCALAR >::Estimator(), gum::ASTposteriorProba< GUM_SCALAR >::_compute_knw_from_bn(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_insertEvidence_(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::_verticesSampling_(), gum::IBayesNet< GUM_SCALAR >::check(), gum::InfluenceDiagram< GUM_SCALAR >::clear(), gum::IBayesNet< GUM_SCALAR >::dim(), gum::ASTsum< GUM_SCALAR >::eval(), gum::DAGmodel::hasSameStructure(), gum::UGmodel::hasSameStructure(), gum::IBayesNet< GUM_SCALAR >::maxVarDomainSize(), gum::IMarkovRandomField< GUM_SCALAR >::maxVarDomainSize(), gum::IBayesNet< GUM_SCALAR >::operator==(), gum::IMarkovRandomField< GUM_SCALAR >::operator==(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::IMarkovRandomField< GUM_SCALAR >::toDot(), and gum::IMarkovRandomField< GUM_SCALAR >::toDotAsFactorGraph().
|
overridevirtual |
Returns a constant reference over a variable given its name.
| NotFound | if no such name exists in the model. |
Implements gum::GraphicalModel.
Reimplemented in gum::InfluenceDiagram< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Definition at line 66 of file discreteGraphicalModel_inl.h.
References varMap_.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::clear(), gum::IBayesNet< GUM_SCALAR >::evEq(), gum::IBayesNet< GUM_SCALAR >::evGt(), gum::IBayesNet< GUM_SCALAR >::evIn(), gum::IBayesNet< GUM_SCALAR >::evLt(), gum::IBayesNet< GUM_SCALAR >::operator==(), and gum::IMarkovRandomField< GUM_SCALAR >::operator==().
|
overridevirtual |
Returns a constant reference to the VariableNodeMap of this model.
Implements gum::GraphicalModel.
Reimplemented in gum::InfluenceDiagram< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Definition at line 48 of file discreteGraphicalModel_inl.h.
References varMap_.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::clear().
|
inherited |
transform a vector of NodeId into a VariableeSet
Definition at line 160 of file graphicalModel_inl.h.
|
inherited |
transform a vector of names into a VariableeSet
Definition at line 150 of file graphicalModel_inl.h.
References gum::Set< Key >::insert(), gum::VariableNodeMap::variableFromName(), and variableNodeMap().
|
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().
|
protected |
Mapping between NodeIds and discrete variables.
Definition at line 119 of file discreteGraphicalModel.h.
Referenced by DiscreteGraphicalModel(), DiscreteGraphicalModel(), gum::BayesNet< GUM_SCALAR >::add(), gum::InfluenceDiagram< GUM_SCALAR >::addNode_(), gum::BayesNet< GUM_SCALAR >::changeVariableName(), gum::InfluenceDiagram< GUM_SCALAR >::changeVariableName(), gum::BayesNet< GUM_SCALAR >::erase(), gum::BayesNet< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::BayesNet< GUM_SCALAR >::eraseArc(), idFromName(), nodeId(), operator=(), operator=(), gum::BayesNet< GUM_SCALAR >::reverseArc(), variable(), variableFromName(), and variableNodeMap().