![]() |
aGrUM
0.20.3
a C++ library for (probabilistic) graphical models
|
Class representing the minimal interface for Markov Network. More...
#include <agrum/BN/IMarkovNet.h>
Public Member Functions | |
bool | operator== (const IMarkovNet< GUM_SCALAR > &from) const |
This operator compares 2 BNs ! More... | |
bool | operator!= (const IMarkovNet< GUM_SCALAR > &from) const |
Size | dim () const |
Returns the dimension (the number of free parameters) in this bayes net. More... | |
Size | maxVarDomainSize () const |
GUM_SCALAR | minParam () const |
GUM_SCALAR | maxParam () const |
GUM_SCALAR | minNonZeroParam () const |
GUM_SCALAR | maxNonOneParam () const |
virtual std::string | toDot () const |
virtual std::string | toDotAsFactorGraph () const |
std::string | toString () const |
NodeSet | minimalCondSet (NodeId target, const NodeSet &soids) const |
NodeSet | minimalCondSet (const NodeSet &targets, const NodeSet &soids) const |
bool | hasSameStructure (const UGmodel &other) |
check if nodes X and nodes Y are independent given nodes Z More... | |
double | log10DomainSize () const |
Constructors / Destructors | |
IMarkovNet () | |
Default constructor. More... | |
IMarkovNet (std::string name) | |
Default constructor. More... | |
virtual | ~IMarkovNet () |
Destructor. More... | |
IMarkovNet (const IMarkovNet< GUM_SCALAR > &source) | |
Copy constructor. More... | |
IMarkovNet< GUM_SCALAR > & | operator= (const IMarkovNet< GUM_SCALAR > &source) |
Copy operator. More... | |
Pure Virtual methods | |
virtual const Potential< GUM_SCALAR > & | factor (const NodeSet &varIds) const =0 |
Returns the factor of a set of variable. More... | |
virtual const NodeSet & | smallestFactorFromNode (NodeId node) const =0 |
Returns the smallest factor that contains this variable. More... | |
virtual const NodeSet & | smallestFactorFromNode (const std::string &name) const |
Returns the smallest factor that contains this variable. More... | |
virtual const FactorTable< GUM_SCALAR > & | factors () const =0 |
Returns the set of factors as a IMarkovNet::FactorTable. More... | |
virtual const VariableNodeMap & | variableNodeMap () const =0 |
Returns a constant reference to the VariableNodeMap of thisBN. More... | |
virtual const DiscreteVariable & | variable (NodeId id) const =0 |
Returns a constant reference over a variable given it's node id. More... | |
virtual NodeId | nodeId (const DiscreteVariable &var) const =0 |
Return id node from discrete var pointer. More... | |
virtual NodeId | idFromName (const std::string &name) const =0 |
Getter by name. More... | |
virtual const DiscreteVariable & | variableFromName (const std::string &name) const =0 |
Getter by name. More... | |
Variable manipulation methods. | |
const UndiGraph & | graph () const |
Returns a constant reference to the dag of this Bayes Net. More... | |
virtual Size | size () const final |
Returns the number of variables in this Directed Graphical Model. More... | |
Size | sizeEdges () const |
Returns the number of arcs in this Directed Graphical Model. More... | |
const NodeGraphPart & | nodes () const final |
Returns a constant reference to the dag of this Bayes Net. More... | |
bool | exists (NodeId node) const final |
Return true if this node exists in this graphical model. More... | |
Variable manipulation methods. | |
bool | exists (const std::string &name) const |
Return true if this graphical model is empty. More... | |
virtual bool | empty () const |
Return true if this graphical model is empty. More... | |
std::vector< std::string > | names (const std::vector< NodeId > &ids) const |
transform a vector of NodeId in a vector of names More... | |
std::vector< std::string > | names (const NodeSet &ids) const |
transform a NodeSet in a vector of names More... | |
std::vector< NodeId > | ids (const std::vector< std::string > &names) const |
transform a vector of names into a vector of nodeId More... | |
NodeSet | nodeset (const std::vector< std::string > &names) const |
transform a vector of names into a NodeSet More... | |
Instantiation | completeInstantiation () const |
Get an instantiation over all the variables of the model. More... | |
Edge manipulation methods. | |
const EdgeSet & | edges () const |
return true if the edge node1-node2 exists in the UGModel More... | |
bool | existsEdge (const NodeId node1, const NodeId node2) const |
return true if the edge node1-node2 exists in the UGModel More... | |
bool | existsEdge (const std::string &name1, const std::string &name2) const |
return true if the edge node1-node2 exists in the UGModel More... | |
const NodeSet & | neighbours (const NodeId id) const |
returns the neighbours of a node as set of nodes More... | |
const NodeSet & | neighbours (const std::string &name) const |
return true if the edge node1-node2 exists in the UGModel More... | |
virtual bool | isIndependent (NodeId X, NodeId Y, const NodeSet &Z) const final |
check if X and Y are independent given Z More... | |
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 More... | |
bool | isIndependent (const std::string &Xname, const std::string &Yname, const std::vector< std::string > &Znames) const |
return true if the edge node1-node2 exists in the UGModel More... | |
bool | isIndependent (const std::vector< std::string > &Xnames, const std::vector< std::string > &Ynames, const std::vector< std::string > &Znames) const |
return true if the edge node1-node2 exists in the UGModel More... | |
Getter and setters | |
const std::string & | property (const std::string &name) const |
Return the value of the property name of this GraphicalModel. More... | |
const std::string & | propertyWithDefault (const std::string &name, const std::string &byDefault) const |
Return the value of the property name of this GraphicalModel. More... | |
void | setProperty (const std::string &name, const std::string &value) |
Add or change a property of this GraphicalModel. More... | |
Protected Attributes | |
UndiGraph | graph_ |
The DAG of this Directed Graphical Model. More... | |
Class representing the minimal interface for Markov Network.
This class is used as a base class for different versions of Markov Networks. No data (except the graph herited from UGModel are included in this class. Many algorithms (inference for instance) may use this class when a simple MN is needed.
Definition at line 60 of file IMarkovNet.h.
INLINE gum::IMarkovNet< GUM_SCALAR >::IMarkovNet | ( | ) |
Default constructor.
Definition at line 40 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
explicit |
Default constructor.
Definition at line 45 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Destructor.
Definition at line 64 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
gum::IMarkovNet< GUM_SCALAR >::IMarkovNet | ( | const IMarkovNet< GUM_SCALAR > & | source | ) |
Copy constructor.
Definition at line 51 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
private |
Definition at line 309 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Get an instantiation over all the variables of the model.
Definition at line 84 of file graphicalModel_inl.h.
INLINE Size gum::IMarkovNet< GUM_SCALAR >::dim | ( | ) | const |
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 69 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
return true if the edge node1-node2 exists in the UGModel
node1 | the nodeId (or the name) of the node1 |
node2 | the nodeId (or the name) of the node2 |
Definition at line 43 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtualinherited |
Return true if this graphical model is empty.
Definition at line 94 of file graphicalModel_inl.h.
Return true if this node exists in this graphical model.
Implements gum::GraphicalModel.
Definition at line 58 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlineinherited |
Return true if this graphical model is empty.
Definition at line 112 of file graphicalModel.h.
return true if the edge node1-node2 exists in the UGModel
node1 | the nodeId (or the name) of the node1 |
node2 | the nodeId (or the name) of the node2 |
Definition at line 45 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
return true if the edge node1-node2 exists in the UGModel
node1 | the nodeId (or the name) of the node1 |
node2 | the nodeId (or the name) of the node2 |
Definition at line 49 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
pure virtual |
Returns the factor of a set of variable.
NotFound | If no variable's id matches varId. |
|
pure virtual |
Returns the set of factors as a IMarkovNet::FactorTable.
|
inherited |
Returns a constant reference to the dag of this Bayes Net.
Definition at line 35 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
check if nodes X and nodes Y are independent given nodes Z
Definition at line 50 of file UGmodel.cpp.
References gum::Set< Key, Alloc >::emplace().
|
pure virtual |
Getter by name.
NotFound | if no such name exists in the graph. |
Implements gum::GraphicalModel.
|
inherited |
transform a vector of names into a vector of nodeId
Definition at line 117 of file graphicalModel_inl.h.
|
finalvirtualinherited |
check if X and Y are independent given Z
Implements gum::GraphicalModel.
Definition at line 62 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
finalvirtualinherited |
check if nodes X and nodes Y are independent given nodes Z
Implements gum::GraphicalModel.
Definition at line 66 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inlineinherited |
return true if the edge node1-node2 exists in the UGModel
node1 | the nodeId (or the name) of the node1 |
node2 | the nodeId (or the name) of the node2 |
Definition at line 125 of file UGmodel.h.
|
inlineinherited |
return true if the edge node1-node2 exists in the UGModel
node1 | the nodeId (or the name) of the node1 |
node2 | the nodeId (or the name) of the node2 |
Definition at line 130 of file UGmodel.h.
|
inherited |
Definition at line 73 of file graphicalModel_inl.h.
INLINE GUM_SCALAR gum::IMarkovNet< GUM_SCALAR >::maxNonOneParam | ( | ) | const |
Definition at line 118 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE GUM_SCALAR gum::IMarkovNet< GUM_SCALAR >::maxParam | ( | ) | const |
Definition at line 98 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE Size gum::IMarkovNet< GUM_SCALAR >::maxVarDomainSize | ( | ) | const |
Definition at line 78 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
NodeSet gum::IMarkovNet< GUM_SCALAR >::minimalCondSet | ( | NodeId | target, |
const NodeSet & | soids | ||
) | const |
Definition at line 326 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
NodeSet gum::IMarkovNet< GUM_SCALAR >::minimalCondSet | ( | const NodeSet & | targets, |
const NodeSet & | soids | ||
) | const |
Definition at line 339 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE GUM_SCALAR gum::IMarkovNet< GUM_SCALAR >::minNonZeroParam | ( | ) | const |
Definition at line 108 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE GUM_SCALAR gum::IMarkovNet< GUM_SCALAR >::minParam | ( | ) | const |
Definition at line 88 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
transform a vector of NodeId in a vector of names
Definition at line 97 of file graphicalModel_inl.h.
|
inherited |
transform a NodeSet in a vector of names
Definition at line 107 of file graphicalModel_inl.h.
returns the neighbours of a node as set of nodes
Note that the set of nodes returned may be empty if no edge within the EdgeGraphPart contains the given node.
id | the node toward which the edge returned are pointing |
Definition at line 53 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
return true if the edge node1-node2 exists in the UGModel
node1 | the nodeId (or the name) of the node1 |
node2 | the nodeId (or the name) of the node2 |
Definition at line 54 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
pure virtual |
Return id node from discrete var pointer.
NotFound | If no variable matches var. |
Implements gum::GraphicalModel.
|
finalvirtualinherited |
Returns a constant reference to the dag of this Bayes Net.
Implements gum::GraphicalModel.
Definition at line 60 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
transform a vector of names into a NodeSet
Definition at line 58 of file graphicalModel.cpp.
References gum::Set< Key, Alloc >::emplace().
INLINE bool gum::IMarkovNet< GUM_SCALAR >::operator!= | ( | const IMarkovNet< GUM_SCALAR > & | from | ) | const |
Definition at line 289 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
IMarkovNet< GUM_SCALAR > & gum::IMarkovNet< GUM_SCALAR >::operator= | ( | const IMarkovNet< GUM_SCALAR > & | source | ) |
Copy operator.
Definition at line 57 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
bool gum::IMarkovNet< GUM_SCALAR >::operator== | ( | const IMarkovNet< GUM_SCALAR > & | from | ) | const |
This operator compares 2 BNs !
Definition at line 243 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Return the value of the property name of this GraphicalModel.
NotFound | Raised if no name property is found. |
Definition at line 38 of file graphicalModel_inl.h.
|
inherited |
Return the value of the property name of this GraphicalModel.
return byDefault if the property name is not found
Definition at line 57 of file graphicalModel_inl.h.
|
inherited |
Add or change a property of this GraphicalModel.
Definition at line 65 of file graphicalModel_inl.h.
|
finalvirtualinherited |
Returns the number of variables in this Directed Graphical Model.
Implements gum::GraphicalModel.
Definition at line 38 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
inherited |
Returns the number of arcs in this Directed Graphical Model.
Definition at line 41 of file UGmodel_inl.h.
References gum::Set< Key, Alloc >::emplace().
|
pure virtual |
Returns the smallest factor that contains this variable.
NotFound | If no variable's id matches varId. |
|
virtual |
Returns the smallest factor that contains this variable.
NotFound | If no variable's id matches varId. |
Definition at line 301 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Definition at line 149 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
virtual |
Definition at line 191 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
INLINE std::string gum::IMarkovNet< GUM_SCALAR >::toString | ( | ) | const |
Definition at line 128 of file IMarkovNet_tpl.h.
References gum::Set< Key, Alloc >::emplace().
|
pure virtual |
Returns a constant reference over a variable given it's node id.
NotFound | If no variable's id matches varId. |
Implements gum::GraphicalModel.
|
pure virtual |
Getter by name.
NotFound | if no such name exists in the graph. |
Implements gum::GraphicalModel.
|
pure virtual |
Returns a constant reference to the VariableNodeMap of thisBN.
Implements gum::GraphicalModel.
|
protectedinherited |