![]() |
aGrUM
0.17.2
a C++ library for (probabilistic) graphical models
|
Virtual base class for PGMs using a DAG. More...
#include <agrum/tools/graphicalModels/DAGmodel.h>
Public Member Functions | |
bool | hasSameStructure (const DAGmodel &other) |
double | log10DomainSize () const |
Constructors / Destructors | |
DAGmodel () | |
Default constructor. More... | |
virtual | ~DAGmodel () |
Destructor. More... | |
DAGmodel (const DAGmodel &source) | |
Copy constructor. More... | |
Variable manipulation methods. | |
const DAG & | dag () 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 | sizeArcs () const |
Returns the number of arcs in this Directed Graphical Model. 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 variable 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... | |
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... | |
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... | |
Variable manipulation methods. | |
virtual const VariableNodeMap & | variableNodeMap () const =0 |
Returns a constant reference to the VariableNodeMap of this Graphical Model. More... | |
virtual bool | empty () const |
Retursn true if this Directed Graphical Model is empty. More... | |
Instantiation | completeInstantiation () const |
Get an instantiation over all the variables of the model. 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 47 of file DAGmodel.h.
gum::DAGmodel::DAGmodel | ( | ) |
Default constructor.
Definition at line 30 of file DAGmodel.cpp.
|
virtual |
Destructor.
Definition at line 39 of file DAGmodel.cpp.
References __mutableMoralGraph.
gum::DAGmodel::DAGmodel | ( | const DAGmodel & | source | ) |
Copy constructor.
Do nothing.
Definition at line 34 of file DAGmodel.cpp.
|
private |
Returns the moral graph of this DAGModel.
Definition at line 44 of file DAGmodel.cpp.
References __mutableMoralGraph, gum::UndiGraph::addEdge(), arcs(), dag(), nodes(), parents(), and gum::NodeGraphPart::populateNodes().
Referenced by moralGraph().
INLINE const ArcSet & gum::DAGmodel::arcs | ( | ) | const |
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 toward which the nodes returned share an arc |
Definition at line 44 of file DAGmodel_inl.h.
References _dag, and gum::ArcGraphPart::arcs().
Referenced by gum::EssentialGraph::__buildEssentialGraph(), __moralGraph(), gum::MarkovBlanket::hasSameStructure(), hasSameStructure(), and gum::BayesNetFragment< GUM_SCALAR >::toBN().
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 53 of file DAGmodel_inl.h.
References _dag, and gum::ArcGraphPart::children().
Referenced by gum::MarkovBlanket::__buildMarkovBlanket(), gum::MarkovBlanket::MarkovBlanket(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
INLINE const NodeSet & gum::DAGmodel::children | ( | const std::string & | name | ) | const |
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 toward which the nodes returned share an arc |
Definition at line 56 of file DAGmodel_inl.h.
References _dag, gum::ArcGraphPart::children(), and idFromName().
|
inherited |
Get an instantiation over all the variables of the model.
Definition at line 85 of file graphicalModel_inl.h.
References gum::GraphicalModel::nodes(), and gum::GraphicalModel::variable().
INLINE const DAG & gum::DAGmodel::dag | ( | ) | const |
Returns a constant reference to the dag of this Bayes Net.
Definition at line 36 of file DAGmodel_inl.h.
References _dag.
Referenced by __moralGraph(), 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 >::toBN(), gum::BayesNetFragment< GUM_SCALAR >::toDot(), topologicalOrder(), gum::InfluenceDiagram< GUM_SCALAR >::toString(), and gum::BayesNetFragment< GUM_SCALAR >::whenArcDeleted().
|
virtualinherited |
Retursn true if this Directed Graphical Model is empty.
Definition at line 95 of file graphicalModel_inl.h.
References gum::GraphicalModel::size().
Definition at line 103 of file DAGmodel.cpp.
References arcs(), gum::Set< Key, Alloc >::exists(), idFromName(), nodes(), size(), sizeArcs(), and variable().
|
pure virtual |
Getter by name.
NotFound | if no such name exists in the graph. |
Implements gum::GraphicalModel.
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().
|
inherited |
Definition at line 74 of file graphicalModel_inl.h.
References gum::GraphicalModel::nodes(), and gum::GraphicalModel::variable().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::toString(), and gum::IMarkovNet< 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 83 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(), and gum::prm::SVE< GUM_SCALAR >::__initLiftedNodes().
|
pure virtual |
Return id node src discrete var pointer.
NotFound | If no variable matches var. |
Implements gum::GraphicalModel.
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 >.
|
virtual |
Returns a constant reference to the dag of this Bayes Net.
Implements gum::GraphicalModel.
Definition at line 60 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(), gum::prm::InstanceBayesNet< GUM_SCALAR >::modalities(), gum::prm::ClassBayesNet< GUM_SCALAR >::modalities(), gum::Estimator< GUM_SCALAR >::setFromBN(), gum::BayesNetFragment< GUM_SCALAR >::toBN(), 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 69 of file DAGmodel.cpp.
References __mutableMoralGraph, _dag, and gum::GraphicalModel::operator=().
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::operator=().
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 toward which the nodes returned share an arc |
Definition at line 46 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(), gum::BayesNetFragment< GUM_SCALAR >::installCPT(), parents(), gum::prm::InstanceBayesNet< GUM_SCALAR >::toDot(), and gum::prm::ClassBayesNet< GUM_SCALAR >::toDot().
INLINE const NodeSet & gum::DAGmodel::parents | ( | const std::string & | name | ) | const |
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 toward which the nodes returned share an arc |
Definition at line 49 of file DAGmodel_inl.h.
References idFromName(), and parents().
|
inherited |
Return the value of the property name of this GraphicalModel.
NotFound | Raised if no name property is found. |
Definition at line 37 of file graphicalModel_inl.h.
References gum::GraphicalModel::__properties(), and GUM_ERROR.
Referenced by gum::InfluenceDiagram< GUM_SCALAR >::toDot().
|
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.
References gum::GraphicalModel::__properties().
|
inherited |
Add or change a property of this GraphicalModel.
Definition at line 65 of file graphicalModel_inl.h.
References gum::GraphicalModel::__properties(), and gum::HashTable< Key, Val, Alloc >::insert().
Referenced by gum::BayesNet< double >::fastPrototype(), and gum::IMarkovNet< GUM_SCALAR >::IMarkovNet().
|
finalvirtual |
Returns the number of variables in this Directed Graphical Model.
Implements gum::GraphicalModel.
Definition at line 39 of file DAGmodel_inl.h.
References dag(), and gum::NodeGraphPart::size().
Referenced by gum::credal::CredalNet< GUM_SCALAR >::__initCNNets(), gum::InfluenceDiagram< GUM_SCALAR >::decisionNodeSize(), 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 42 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 99 of file DAGmodel.cpp.
References dag(), and gum::DiGraph::topologicalOrder().
Referenced by gum::EssentialGraph::__buildEssentialGraph(), gum::InfluenceDiagramGenerator< GUM_SCALAR >::__checkTemporalOrder(), gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists(), and gum::InfluenceDiagram< GUM_SCALAR >::getDecisionOrder().
|
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.
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 gum::MarkovBlanket::hasSameStructure(), hasSameStructure(), gum::MarkovBlanket::toDot(), and gum::EssentialGraph::toDot().
|
pure virtual |
Getter by name.
NotFound | if no such name exists in the graph. |
Implements gum::GraphicalModel.
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 >.
|
pure virtualinherited |
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::IMarkovNet< 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 170 of file DAGmodel.h.
Referenced by __moralGraph(), moralGraph(), operator=(), and ~DAGmodel().
|
protected |
The DAG of this Directed Graphical Model.
Definition at line 162 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().