aGrUM  0.17.2
a C++ library for (probabilistic) graphical models
graphicalModel_inl.h
Go to the documentation of this file.
1 
33 
34 namespace gum {
35 
36  INLINE
37  const std::string& GraphicalModel::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
48  if (__propertiesMap == nullptr) {
50  }
51 
52  return *__propertiesMap;
53  }
54 
55  INLINE
56  const std::string&
57  GraphicalModel::propertyWithDefault(const std::string& name,
58  const std::string& byDefault) const {
59  try {
60  return __properties()[name];
61  } catch (NotFound&) { return byDefault; }
62  }
63 
64  INLINE
65  void GraphicalModel::setProperty(const std::string& name,
66  const std::string& value) {
67  try {
68  __properties()[name] = value;
69  } catch (NotFound&) { __properties().insert(name, value); }
70  }
71 
72 
73  INLINE
75  double dSize = 0.0;
76 
77  for (const auto node: nodes()) {
78  dSize += std::log10(variable(node).domainSize());
79  }
80 
81  return dSize;
82  }
83 
84  INLINE
86  Instantiation I;
87 
88  for (const auto node: nodes())
89  I << variable(node);
90 
91  return I;
92  }
93 
94  INLINE
95  bool GraphicalModel::empty() const { return size() == 0; }
96 } /* namespace gum */
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
Instantiation completeInstantiation() const
Get an instantiation over all the variables of the model.
HashTable< std::string, std::string > * __propertiesMap
The properties of this Directed Graphical Model. Initialized using a lazy instantiation.
const std::string & propertyWithDefault(const std::string &name, const std::string &byDefault) const
Return the value of the property name of this GraphicalModel.
virtual const NodeGraphPart & nodes() 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.
void setProperty(const std::string &name, const std::string &value)
Add or change a property of this GraphicalModel.
virtual bool empty() const
Retursn true if this Directed Graphical Model is empty.
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
Definition: agrum.h:25
double log10DomainSize() const
Class for assigning/browsing values to tuples of discrete variables.
Definition: instantiation.h:83
virtual const DiscreteVariable & variable(NodeId id) const =0
Returns a constant reference over a variable given it&#39;s node id.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Copyright 2005-2020 Pierre-Henri WUILLEMIN () et Christophe GONZALES () info_at_agrum_dot_org.
const std::string & property(const std::string &name) const
Return the value of the property name of this GraphicalModel.
HashTable< std::string, std::string > & __properties() const
Return the properties of this Directed Graphical Model and initialize the hash table is necessary...
#define GUM_ERROR(type, msg)
Definition: exceptions.h:55