![]() |
aGrUM
0.16.0
|
Virtual base class for PGMs using a DAG. More...
#include <agrum/graphicalModels/DAGmodel.h>
Public Member Functions | |
double | log10DomainSize () const |
bool | hasSameStructure (const DAGmodel &other) |
Constructors / Destructors | |
DAGmodel () | |
Default constructor. More... | |
virtual | ~DAGmodel () |
Destructor. More... | |
DAGmodel (const DAGmodel &source) | |
Copy constructor. More... | |
Getter and setters | |
const std::string & | property (const std::string &name) const |
Return the value of the property name of this DAGModel. More... | |
const std::string & | propertyWithDefault (const std::string &name, const std::string &byDefault) const |
Return the value of the property name of this DAGModel. More... | |
void | setProperty (const std::string &name, const std::string &value) |
Add or change a property of this DAGModel. More... | |
Variable manipulation methods. | |
const DAG & | dag () const |
Returns a constant reference to the dag of this Bayes Net. More... | |
virtual const VariableNodeMap & | variableNodeMap () const =0 |
Returns a constant reference to the VariableNodeMap of this Directed Graphical Model. More... | |
Size | size () const |
Returns the number of variables in this Directed Graphical Model. More... | |
Size | sizeArcs () const |
Returns the number of arcs in this Directed Graphical Model. More... | |
bool | empty () const |
Retursn true if this Directed Graphical Model is empty. More... | |
const NodeGraphPart & | nodes () const |
Returns a constant reference to the dag of this Bayes Net. More... | |
virtual const DiscreteVariable & | variable (NodeId id) const =0 |
Returns a constant reference over a variabe given it's node id. More... | |
virtual NodeId | nodeId (const DiscreteVariable &var) const =0 |
Return id node src 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... | |
virtual Instantiation | completeInstantiation () const final |
Get an instantiation over all the variables of the model. More... | |
Arc manipulation methods. | |
const ArcSet & | arcs () const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | parents (const NodeId id) const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | parents (const std::string &name) const |
returns the set of nodes with arc ingoing to a given node More... | |
const NodeSet & | children (const NodeId id) const |
returns the set of nodes with arc outgoing from a given node More... | |
const NodeSet & | children (const std::string &name) const |
returns the set of nodes with arc ingoing to a given node More... | |
Graphical methods | |
const UndiGraph & | moralGraph (bool clear=true) const |
The node's id are coherent with the variables and nodes of the topology. More... | |
const Sequence< NodeId > & | topologicalOrder (bool clear=true) const |
The topological order stays the same as long as no variable or arcs are added or erased src the topology. More... | |
Protected Attributes | |
DAG | _dag |
The DAG of this Directed Graphical Model. More... | |
Protected Member Functions | |
DAGmodel & | operator= (const DAGmodel &source) |
Private copy operator. More... | |
Virtual base class for PGMs using a DAG.
Definition at line 48 of file DAGmodel.h.
gum::DAGmodel::DAGmodel | ( | ) |
Default constructor.
Definition at line 30 of file DAGmodel.cpp.
|
virtual |
Destructor.
Definition at line 44 of file DAGmodel.cpp.
References __mutableMoralGraph, and __propertiesMap.
gum::DAGmodel::DAGmodel | ( | const DAGmodel & | source | ) |
Copy constructor.
Do nothing.
Definition at line 34 of file DAGmodel.cpp.
References __propertiesMap.
|
private |
Returns the moral graph of this DAGModel.
Definition at line 53 of file DAGmodel.cpp.
References __mutableMoralGraph, gum::UndiGraph::addEdge(), arcs(), dag(), nodes(), parents(), and gum::NodeGraphPart::populateNodes().
Referenced by moralGraph().
|
private |
Return the properties of this Directed Graphical Model and initialize the hash table is necessary.
Definition at line 66 of file DAGmodel_inl.h.
References __propertiesMap.
Referenced by property(), propertyWithDefault(), and setProperty().
INLINE const ArcSet & gum::DAGmodel::arcs | ( | ) | const |
returns the set of nodes with arc ingoing to a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the arcs returned are pointing |
Definition at line 104 of file DAGmodel_inl.h.
References _dag, and gum::ArcGraphPart::arcs().
Referenced by gum::EssentialGraph::__buildEssentialGraph(), __moralGraph(), gum::MarkovBlanket::hasSameStructure(), and hasSameStructure().
returns the set of nodes with arc outgoing from a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is outgoing from the given node.
id | the node which is the tail of the arcs returned |
Definition at line 111 of file DAGmodel_inl.h.
References _dag, and gum::ArcGraphPart::children().
Referenced by gum::MarkovBlanket::__buildMarkovBlanket(), parents(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
|
inline |
returns the set of nodes with arc ingoing to a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the arcs returned are pointing |
Definition at line 165 of file DAGmodel.h.
References hasSameStructure(), idFromName(), log10DomainSize(), moralGraph(), operator=(), parents(), and topologicalOrder().
|
finalvirtual |
Get an instantiation over all the variables of the model.
Definition at line 86 of file DAGmodel_inl.h.
References dag(), and variable().
INLINE const DAG & gum::DAGmodel::dag | ( | ) | const |
Returns a constant reference to the dag of this Bayes Net.
Definition at line 63 of file DAGmodel_inl.h.
References _dag.
Referenced by __moralGraph(), completeInstantiation(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::learning::genericBNLearner::Database::Database(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), gum::BayesNetFragment< GUM_SCALAR >::isInstalledNode(), gum::MarginalTargetedInference< GUM_SCALAR >::MarginalTargetedInference(), gum::BayesBall::relevantPotentials(), gum::dSeparation::relevantPotentials(), size(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), topologicalOrder(), gum::InfluenceDiagram< GUM_SCALAR >::toString(), and gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted().
INLINE bool gum::DAGmodel::empty | ( | ) | const |
Retursn true if this Directed Graphical Model is empty.
Definition at line 99 of file DAGmodel_inl.h.
References size().
Definition at line 121 of file DAGmodel.cpp.
References arcs(), gum::Set< Key, Alloc >::exists(), idFromName(), nodes(), size(), sizeArcs(), and variable().
Referenced by children().
|
pure virtual |
Getter by name.
NotFound | if no such name exists in the graph. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::InfluenceDiagram< GUM_SCALAR >, gum::BayesNetFragment< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Referenced by children(), gum::MarkovBlanket::hasSameStructure(), hasSameStructure(), and parents().
INLINE double gum::DAGmodel::log10DomainSize | ( | ) | const |
Definition at line 75 of file DAGmodel_inl.h.
References nodes(), and variable().
Referenced by children(), and gum::InfluenceDiagram< GUM_SCALAR >::toString().
The node's id are coherent with the variables and nodes of the topology.
clear | If false returns the previously created moral graph. |
Definition at line 101 of file DAGmodel.cpp.
References __moralGraph(), __mutableMoralGraph, and gum::UndiGraph::clear().
Referenced by gum::prm::SVED< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodes(), gum::prm::SVED< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVE< GUM_SCALAR >::__eliminateNodesWithEvidence(), gum::prm::SVED< GUM_SCALAR >::__initLiftedNodes(), gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes(), and children().
|
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::InfluenceDiagram< GUM_SCALAR >, gum::BayesNetFragment< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
INLINE const NodeGraphPart & gum::DAGmodel::nodes | ( | ) | const |
Returns a constant reference to the dag of this Bayes Net.
Definition at line 115 of file DAGmodel_inl.h.
References _dag.
Referenced by gum::credal::CredalNet< GUM_SCALAR >::__bnCopy(), gum::EssentialGraph::__buildEssentialGraph(), gum::MarkovBlanket::__buildMarkovBlanket(), __moralGraph(), gum::credal::CredalNet< GUM_SCALAR >::__sort_varType(), gum::credal::CNMonteCarloSampling< GUM_SCALAR, BNInferenceEngine >::__verticesSampling(), gum::ImportanceSampling< GUM_SCALAR >::_unsharpenBN(), gum::BayesNetFactory< GUM_SCALAR >::BayesNetFactory(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), gum::learning::DAG2BNLearner< ALLOC >::createBN(), gum::MCBayesNetGenerator< GUM_SCALAR, ICPTGenerator, ICPTDisturber >::disturbBN(), gum::Estimator< GUM_SCALAR >::Estimator(), gum::getMaxModality(), hasSameStructure(), log10DomainSize(), gum::prm::InstanceBayesNet< GUM_SCALAR >::modalities(), gum::prm::ClassBayesNet< GUM_SCALAR >::modalities(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), gum::prm::ClassBayesNet< GUM_SCALAR >::toDot(), gum::credal::CredalNet< GUM_SCALAR >::toString(), and gum::BayesNetFragment< GUM_SCALAR >::~BayesNetFragment().
Private copy operator.
Definition at line 78 of file DAGmodel.cpp.
References __mutableMoralGraph, __propertiesMap, and _dag.
Referenced by children(), and gum::InfluenceDiagram< GUM_SCALAR >::operator=().
returns the set of nodes with arc ingoing to a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the arcs returned are pointing |
Definition at line 106 of file DAGmodel_inl.h.
References _dag, and gum::ArcGraphPart::parents().
Referenced by gum::MarkovBlanket::__buildMarkovBlanket(), __moralGraph(), gum::BayesNetFragment< GUM_SCALAR >::_installCPT(), gum::BayesNetFragment< GUM_SCALAR >::checkConsistency(), children(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), parents(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
|
inline |
returns the set of nodes with arc ingoing to a given node
Note that the set of arcs returned may be empty if no arc within the ArcGraphPart is ingoing into the given node.
id | the node toward which the arcs returned are pointing |
Definition at line 156 of file DAGmodel.h.
References children(), idFromName(), and parents().
INLINE const std::string & gum::DAGmodel::property | ( | const std::string & | name | ) | const |
Return the value of the property name of this DAGModel.
NotFound | Raised if no name property is found. |
Definition at line 37 of file DAGmodel_inl.h.
References __properties(), and GUM_ERROR.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::toDot().
INLINE const std::string & gum::DAGmodel::propertyWithDefault | ( | const std::string & | name, |
const std::string & | byDefault | ||
) | const |
Return the value of the property name of this DAGModel.
return byDefault if the property name is not found
Definition at line 48 of file DAGmodel_inl.h.
References __properties().
INLINE void gum::DAGmodel::setProperty | ( | const std::string & | name, |
const std::string & | value | ||
) |
Add or change a property of this DAGModel.
Definition at line 56 of file DAGmodel_inl.h.
References __properties(), and gum::HashTable< Key, Val, Alloc >::insert().
Referenced by gum::BayesNet< double >::fastPrototype().
INLINE Size gum::DAGmodel::size | ( | ) | const |
Returns the number of variables in this Directed Graphical Model.
Definition at line 96 of file DAGmodel_inl.h.
References dag(), and gum::NodeGraphPart::size().
Referenced by gum::credal::CredalNet< GUM_SCALAR >::__initCNNets(), gum::InfluenceDiagram< GUM_SCALAR >::decisionNodeSize(), empty(), gum::MarkovBlanket::hasSameStructure(), hasSameStructure(), gum::IBayesNet< double >::operator==(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
INLINE Size gum::DAGmodel::sizeArcs | ( | ) | const |
Returns the number of arcs in this Directed Graphical Model.
Definition at line 102 of file DAGmodel_inl.h.
References _dag, and gum::ArcGraphPart::sizeArcs().
Referenced by gum::MarkovBlanket::hasSameStructure(), hasSameStructure(), and gum::IBayesNet< double >::operator==().
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 117 of file DAGmodel.cpp.
References dag(), and gum::DiGraph::topologicalOrder().
Referenced by gum::EssentialGraph::__buildEssentialGraph(), gum::InfluenceDiagramGenerator< GUM_SCALAR >::__checkTemporalOrder(), children(), gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists(), and gum::InfluenceDiagram< GUM_SCALAR >::getDecisionOrder().
|
pure virtual |
Returns a constant reference over a variabe given it's node id.
NotFound | If no variable's id matches varId. |
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::InfluenceDiagram< GUM_SCALAR >, gum::BayesNetFragment< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
Referenced by completeInstantiation(), gum::MarkovBlanket::hasSameStructure(), hasSameStructure(), log10DomainSize(), gum::MarkovBlanket::toDot(), and gum::EssentialGraph::toDot().
|
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::InfluenceDiagram< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
|
pure virtual |
Returns a constant reference to the VariableNodeMap of this Directed Graphical Model.
Implemented in gum::BayesNet< GUM_SCALAR >, gum::BayesNet< double >, gum::BayesNetFragment< GUM_SCALAR >, gum::InfluenceDiagram< GUM_SCALAR >, gum::IBayesNet< GUM_SCALAR >, gum::IBayesNet< double >, gum::prm::ClassBayesNet< GUM_SCALAR >, and gum::prm::InstanceBayesNet< GUM_SCALAR >.
|
mutableprivate |
The moral graph of this Directed Graphical Model.
Definition at line 211 of file DAGmodel.h.
Referenced by __moralGraph(), moralGraph(), operator=(), and ~DAGmodel().
|
mutableprivate |
The properties of this Directed Graphical Model. Initialized using a lazy instantiation.
Definition at line 215 of file DAGmodel.h.
Referenced by __properties(), DAGmodel(), operator=(), and ~DAGmodel().
|
protected |
The DAG of this Directed Graphical Model.
Definition at line 203 of file DAGmodel.h.
Referenced by gum::prm::ClassBayesNet< GUM_SCALAR >::__get(), gum::InfluenceDiagram< GUM_SCALAR >::_addNode(), gum::InfluenceDiagram< GUM_SCALAR >::_copyTables(), gum::InfluenceDiagram< GUM_SCALAR >::_getChildrenDecision(), gum::BayesNetFragment< GUM_SCALAR >::_installArc(), gum::InfluenceDiagram< GUM_SCALAR >::_moralGraph(), gum::InfluenceDiagram< GUM_SCALAR >::_removeTables(), gum::BayesNetFragment< GUM_SCALAR >::_uninstallArc(), gum::InfluenceDiagram< GUM_SCALAR >::addArc(), arcs(), children(), dag(), gum::InfluenceDiagram< GUM_SCALAR >::erase(), gum::InfluenceDiagram< GUM_SCALAR >::eraseArc(), gum::InfluenceDiagram< GUM_SCALAR >::existsPathBetween(), gum::InfluenceDiagram< GUM_SCALAR >::getDecisionGraph(), gum::InfluenceDiagram< GUM_SCALAR >::getPartialTemporalOrder(), gum::BayesNetFragment< GUM_SCALAR >::installNode(), nodes(), operator=(), parents(), sizeArcs(), gum::InfluenceDiagram< GUM_SCALAR >::toDot(), and gum::BayesNetFragment< GUM_SCALAR >::uninstallNode().