aGrUM  0.14.2
classBayesNet.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}_at_lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
26 #ifndef GUM_CLASS_BAYESNET_H
27 #define GUM_CLASS_BAYESNET_H
28 
29 #include <list>
30 
31 #include <agrum/BN/IBayesNet.h>
32 
33 #include <agrum/PRM/PRM.h>
34 namespace gum {
35  namespace prm {
36 
37  // clang-format off
55  // clang-format on
56  template < typename GUM_SCALAR >
57  class ClassBayesNet : public IBayesNet< GUM_SCALAR > {
58  public:
59  // ========================================================================
61  // ========================================================================
63 
68 
71 
75 
77  virtual ~ClassBayesNet< GUM_SCALAR >();
78 
80  // ===========================================================================
82  // ===========================================================================
84 
98  virtual const Potential< GUM_SCALAR >& cpt(NodeId varId) const;
99 
101  virtual const VariableNodeMap& variableNodeMap() const;
102 
104  virtual const DiscreteVariable& variable(NodeId id) const;
105 
107  virtual NodeId nodeId(const DiscreteVariable& var) const;
108 
110  virtual NodeId idFromName(const std::string& name) const;
111 
113  virtual const DiscreteVariable&
114  variableFromName(const std::string& name) const;
115 
117  const NodeProperty< Size >& modalities() const;
118 
120  // ===========================================================================
122  // ===========================================================================
125  virtual std::string toDot() const;
126 
128  private:
132 
136  const PRMClassElement< GUM_SCALAR >& __get(NodeId id) const;
137 
141  const PRMClassElement< GUM_SCALAR >& __get(const std::string& name) const;
142 
145 
147 
148  void __init(const PRMClass< GUM_SCALAR >& c);
149  };
150 
151 
152 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
153  extern template class ClassBayesNet< double >;
154 #endif
155 
156 
157  } /* namespace prm */
158 } /* namespace gum */
159 
161 
162 #endif /* GUM_CLASS_BAYESNET_H */
aGrUM&#39;s Potential is a multi-dimensional array with tensor operators.
Definition: potential.h:57
virtual const VariableNodeMap & variableNodeMap() const
See gum::IBaseBayesNet::variableNodeMap().
virtual const DiscreteVariable & variable(NodeId id) const
See gum::IBaseBayesNet::variable().
void __init(const PRMClass< GUM_SCALAR > &c)
Container used to map discrete variables with nodes.
Abstract class representing an element of PRM class.
Headers of PRM.
Class representing Bayesian networks.
const PRMClassElement< GUM_SCALAR > & __get(NodeId id) const
Private getter with type checking in case the id is not a formal PRMAttribute.
const PRMClass< GUM_SCALAR > * __class
The PRMClassElementContainer decorated by this.
NodeProperty< Size > __modalities
Base class for discrete random variable.
Class representing the minimal interface for Bayesian Network.
Definition: IBayesNet.h:59
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
virtual const DiscreteVariable & variableFromName(const std::string &name) const
See gum::IBaseBayesNet::variableFromName().
The class for generic Hash Tables.
Definition: hashTable.h:676
This class decorates a gum::prm::Class<GUM_SCALAR> has an IBaseBayesNet.
Definition: classBayesNet.h:57
virtual NodeId nodeId(const DiscreteVariable &var) const
See gum::IBaseBayesNet::nodeId().
A PRMClass is an object of a PRM representing a fragment of a Bayesian Network which can be instantia...
Definition: PRMClass.h:63
virtual std::string toDot() const
Inline implementation of ClassBayesNet.
ClassBayesNet< GUM_SCALAR > & operator=(const ClassBayesNet< GUM_SCALAR > &from)
Copy operator.
virtual NodeId idFromName(const std::string &name) const
See gum::IBaseBayesNet::idFromName().
Size NodeId
Type for node ids.
Definition: graphElements.h:97
const NodeProperty< Size > & modalities() const
See gum::IBaseBayesNet::modalities().
HashTable< const DiscreteVariable *, const PRMClassElement< GUM_SCALAR > *> __varNodeMap
Mapping between DiscreteVariable and their NodeId.
virtual const Potential< GUM_SCALAR > & cpt(NodeId varId) const
Returns the CPT of a node in this ClassBayesNet<GUM_SCALAR>.