![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
Virtual base class for probabilistic graphical models. More...
#include <graphicalModel.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 | |
| GraphicalModel () | |
| Default constructor. | |
| virtual | ~GraphicalModel () |
| Destructor. | |
| GraphicalModel (const GraphicalModel &source) | |
| Copy constructor. | |
| GraphicalModel (GraphicalModel &&source) noexcept | |
| Move constructor. | |
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 const VariableNodeMap & | variableNodeMap () const =0 |
| Returns a constant reference to the VariableNodeMap of this Graphical Model. | |
| 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. | |
| virtual const DiscreteVariable & | variable (NodeId id) const =0 |
| Returns a constant reference over a variable given it's node id. | |
| virtual NodeId | nodeId (const DiscreteVariable &var) const =0 |
| Return id node src discrete var pointer. | |
| virtual NodeId | idFromName (std::string_view name) const =0 |
| Getter by name. | |
| virtual const DiscreteVariable & | variableFromName (std::string_view name) const =0 |
| Getter by name. | |
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 | |
| GraphicalModel & | operator= (const GraphicalModel &source) |
| Private copy operator. | |
| GraphicalModel & | operator= (GraphicalModel &&source) noexcept |
| Move assignment operator. | |
| void | _nameNodes_ (NodeGraphPart &g) const |
| Names every node of g using variable(id).name() for each node id in g. | |
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. | |
Virtual base class for probabilistic graphical models.
Definition at line 64 of file graphicalModel.h.
| gum::GraphicalModel::GraphicalModel | ( | ) |
Default constructor.
Definition at line 51 of file graphicalModel.cpp.
References GraphicalModel().
Referenced by gum::DiscreteGraphicalModel::DiscreteGraphicalModel(), gum::DiscreteGraphicalModel::DiscreteGraphicalModel(), GraphicalModel(), GraphicalModel(), GraphicalModel(), ~GraphicalModel(), family(), operator=(), and operator=().
|
virtual |
Destructor.
Definition at line 63 of file graphicalModel.cpp.
References GraphicalModel().
| gum::GraphicalModel::GraphicalModel | ( | const GraphicalModel & | source | ) |
Copy constructor.
Do nothing.
Definition at line 53 of file graphicalModel.cpp.
References GraphicalModel(), and _propertiesMap_.
|
noexcept |
Move constructor.
Do nothing.
Definition at line 58 of file graphicalModel.cpp.
References GraphicalModel(), and _propertiesMap_.
|
protected |
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().
|
private |
Return the properties of this Directed Graphical Model.
Definition at line 67 of file graphicalModel_inl.h.
References _propertiesMap_.
Referenced by property().
| INLINE Instantiation gum::GraphicalModel::completeInstantiation | ( | ) | const |
Get an instantiation over all the variables of the model.
Definition at line 104 of file graphicalModel_inl.h.
References nodes(), and variable().
|
virtual |
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 virtual |
Returns the number of variables in this Directed Graphical Model.
Implemented in gum::DAGmodel, and gum::UGmodel.
References ids(), and names().
| INLINE bool gum::GraphicalModel::existsProperty | ( | std::string_view | name | ) | const |
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 virtual |
Implemented in gum::DAGmodel, and gum::UGmodel.
References GraphicalModel().
|
pure virtual |
Getter by name.
| NotFound | if no such name exists in the graph. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::DiscreteGraphicalModel, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Referenced by nodeset().
| INLINE std::vector< NodeId > gum::GraphicalModel::ids | ( | const std::vector< std::string > & | names | ) | const |
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 virtual |
check if nodes X and nodes Y are independent given nodes Z
Implemented in gum::DAGmodel, and gum::UGmodel.
|
pure virtual |
check if node X and node Y are independent given nodes Z
Implemented in gum::DAGmodel, and gum::UGmodel.
| INLINE double gum::GraphicalModel::log10DomainSize | ( | ) | const |
Definition at line 93 of file graphicalModel_inl.h.
References nodes().
Referenced by gum::IMarkovRandomField< GUM_SCALAR >::toString(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().
| INLINE std::vector< std::string > gum::GraphicalModel::names | ( | const NodeSet & | ids | ) | const |
transform a NodeSet in a vector of names
Definition at line 129 of file graphicalModel_inl.h.
References ids(), gum::VariableNodeMap::name(), and variableNodeMap().
| INLINE std::vector< std::string > gum::GraphicalModel::names | ( | const std::vector< NodeId > & | ids | ) | const |
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().
|
pure virtual |
Return id node src discrete var pointer.
| NotFound | If no variable matches var. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::DiscreteGraphicalModel, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
|
pure virtual |
Returns the number of variables in this Directed Graphical Model.
Implemented in gum::DAGmodel, and gum::UGmodel.
Referenced by completeInstantiation(), and log10DomainSize().
| NodeSet gum::GraphicalModel::nodeset | ( | const std::vector< std::string > & | names | ) | const |
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 |
Private copy operator.
Definition at line 65 of file graphicalModel.cpp.
References GraphicalModel(), and _propertiesMap_.
Referenced by gum::DiscreteGraphicalModel::operator=(), and gum::DiscreteGraphicalModel::operator=().
|
protectednoexcept |
Move assignment operator.
Definition at line 73 of file graphicalModel.cpp.
References GraphicalModel(), and _propertiesMap_.
| INLINE std::vector< std::string > gum::GraphicalModel::properties | ( | ) | const |
List of all the names of property in the Graphical model.
Definition at line 79 of file graphicalModel_inl.h.
References _propertiesMap_.
| INLINE const std::string & gum::GraphicalModel::property | ( | std::string_view | name | ) | const |
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().
| INLINE const std::string & gum::GraphicalModel::propertyWithDefault | ( | std::string_view | name, |
| const std::string & | byDefault ) const |
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().
| INLINE void gum::GraphicalModel::setProperty | ( | std::string_view | name, |
| std::string_view | value ) |
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(), gum::BayesNet< GUM_SCALAR >::fastPrototype(), and gum::InfluenceDiagram< GUM_SCALAR >::fastPrototype().
|
pure virtual |
Returns the number of variables in this Directed Graphical Model.
Implemented in gum::DAGmodel, and gum::UGmodel.
Referenced by empty().
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.
| void gum::GraphicalModel::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.
Definition at line 81 of file graphicalModel.cpp.
References _propertiesMap_.
|
pure virtual |
Returns a constant reference over a variable given it's node id.
| NotFound | If no variable's id matches varId. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::DiscreteGraphicalModel, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Referenced by _nameNodes_(), and completeInstantiation().
|
pure virtual |
Getter by name.
| NotFound | if no such name exists in the graph. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::DiscreteGraphicalModel, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
|
pure virtual |
Returns a constant reference to the VariableNodeMap of this Graphical Model.
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::DiscreteGraphicalModel, gum::InfluenceDiagram< GUM_SCALAR >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Referenced by ids(), names(), and variables().
| INLINE VariableSet gum::GraphicalModel::variables | ( | const NodeSet & | ids | ) | const |
transform a vector of NodeId into a VariableeSet
Definition at line 160 of file graphicalModel_inl.h.
| INLINE VariableSet gum::GraphicalModel::variables | ( | const std::vector< std::string > & | l | ) | const |
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().
|
private |
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().