aGrUM  0.16.0
DAGmodel_inl.h
Go to the documentation of this file.
1 
31 #include <agrum/core/math/math.h>
33 
34 namespace gum {
35 
36  INLINE
37  const std::string& DAGmodel::property(const std::string& name) const {
38  try {
39  return __properties()[name];
40  } catch (NotFound&) {
41  std::string msg = "The following property does not exists: ";
42  GUM_ERROR(NotFound, msg + name);
43  }
44  }
45 
46  INLINE
47  const std::string&
48  DAGmodel::propertyWithDefault(const std::string& name,
49  const std::string& byDefault) const {
50  try {
51  return __properties()[name];
52  } catch (NotFound&) { return byDefault; }
53  }
54 
55  INLINE
56  void DAGmodel::setProperty(const std::string& name, const std::string& value) {
57  try {
58  __properties()[name] = value;
59  } catch (NotFound&) { __properties().insert(name, value); }
60  }
61 
62  INLINE
63  const DAG& DAGmodel::dag() const { return _dag; }
64 
65  INLINE
67  if (__propertiesMap == nullptr) {
69  }
70 
71  return *__propertiesMap;
72  }
73 
74  INLINE
75  double DAGmodel::log10DomainSize() const {
76  double dSize = 0.0;
77 
78  for (const auto node : nodes()) {
79  dSize += std::log10(variable(node).domainSize());
80  }
81 
82  return dSize;
83  }
84 
85  INLINE
87  Instantiation I;
88 
89  for (const auto node : dag())
90  I << variable(node);
91 
92  return I;
93  }
94 
95  INLINE
96  Size DAGmodel::size() const { return dag().size(); }
97 
98  INLINE
99  bool DAGmodel::empty() const { return size() == 0; }
100 
101  INLINE
102  Size DAGmodel::sizeArcs() const { return _dag.sizeArcs(); }
103 
104  INLINE const ArcSet& DAGmodel::arcs() const { return _dag.arcs(); }
105 
106  INLINE const NodeSet& DAGmodel::parents(const NodeId id) const {
107  return _dag.parents(id);
108  }
109 
110 
111  INLINE const NodeSet& DAGmodel::children(const NodeId id) const {
112  return _dag.children(id);
113  }
114 
115  INLINE const NodeGraphPart& DAGmodel::nodes() const {
116  return (NodeGraphPart&)_dag;
117  }
118 } /* namespace gum */
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const ArcSet & arcs() const
returns the set of nodes with arc ingoing to a given node
Definition: DAGmodel_inl.h:104
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
Definition: DAGmodel_inl.h:111
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
Definition: DAGmodel_inl.h:106
Size sizeArcs() const
Returns the number of arcs in this Directed Graphical Model.
Definition: DAGmodel_inl.h:102
Size size() const
alias for sizeNodes
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Definition: agrum.h:25
HashTable< std::string, std::string > * __propertiesMap
The properties of this Directed Graphical Model. Initialized using a lazy instantiation.
Definition: DAGmodel.h:215
Size size() const
Returns the number of variables in this Directed Graphical Model.
Definition: DAGmodel_inl.h:96
DAG _dag
The DAG of this Directed Graphical Model.
Definition: DAGmodel.h:203
const std::string & property(const std::string &name) const
Return the value of the property name of this DAGModel.
Definition: DAGmodel_inl.h:37
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Size sizeArcs() const
indicates the number of arcs stored within the ArcGraphPart
void setProperty(const std::string &name, const std::string &value)
Add or change a property of this DAGModel.
Definition: DAGmodel_inl.h:56
const NodeGraphPart & nodes() const
Returns a constant reference to the dag of this Bayes Net.
Definition: DAGmodel_inl.h:115
const NodeSet & parents(const NodeId id) const
returns the set of nodes with arc ingoing to a given node
virtual const DiscreteVariable & variable(NodeId id) const =0
Returns a constant reference over a variabe given it&#39;s node id.
Class for node sets in graph.
const std::string & propertyWithDefault(const std::string &name, const std::string &byDefault) const
Return the value of the property name of this DAGModel.
Definition: DAGmodel_inl.h:48
virtual Instantiation completeInstantiation() const final
Get an instantiation over all the variables of the model.
Definition: DAGmodel_inl.h:86
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
const NodeSet & children(const NodeId id) const
returns the set of nodes with arc outgoing from a given node
bool empty() const
Retursn true if this Directed Graphical Model is empty.
Definition: DAGmodel_inl.h:99
const ArcSet & arcs() const
returns the set of arcs stored within the ArcGraphPart
HashTable< std::string, std::string > & __properties() const
Return the properties of this Directed Graphical Model and initialize the hash table is necessary...
Definition: DAGmodel_inl.h:66
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:48
double log10DomainSize() const
Definition: DAGmodel_inl.h:75
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Base class for dag.
Definition: DAG.h:102
const DAG & dag() const
Returns a constant reference to the dag of this Bayes Net.
Definition: DAGmodel_inl.h:63
Size NodeId
Type for node ids.
Definition: graphElements.h:98
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55