aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
classBayesNet.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2025 by *
5 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
6 * - Christophe GONZALES(_at_AMU) *
7 * *
8 * The aGrUM/pyAgrum library is free software; you can redistribute it *
9 * and/or modify it under the terms of either : *
10 * *
11 * - the GNU Lesser General Public License as published by *
12 * the Free Software Foundation, either version 3 of the License, *
13 * or (at your option) any later version, *
14 * - the MIT license (MIT), *
15 * - or both in dual license, as here. *
16 * *
17 * (see https://agrum.gitlab.io/articles/dual-licenses-lgplv3mit.html) *
18 * *
19 * This aGrUM/pyAgrum library is distributed in the hope that it will be *
20 * useful, but WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
21 * INCLUDING BUT NOT LIMITED TO THE WARRANTIES MERCHANTABILITY or FITNESS *
22 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
23 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
24 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
25 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR *
26 * OTHER DEALINGS IN THE SOFTWARE. *
27 * *
28 * See LICENCES for more details. *
29 * *
30 * SPDX-FileCopyrightText: Copyright 2005-2025 *
31 * - Pierre-Henri WUILLEMIN(_at_LIP6) *
32 * - Christophe GONZALES(_at_AMU) *
33 * SPDX-License-Identifier: LGPL-3.0-or-later OR MIT *
34 * *
35 * Contact : info_at_agrum_dot_org *
36 * homepage : http://agrum.gitlab.io *
37 * gitlab : https://gitlab.com/agrumery/agrum *
38 * *
39 ****************************************************************************/
40
41
48#ifndef GUM_CLASS_BAYESNET_H
49#define GUM_CLASS_BAYESNET_H
50
51#include <list>
52
53#include <agrum/PRM/PRM.h>
54
55namespace gum {
56 namespace prm {
57
58 // clang-format off
76 // clang-format on
77
78 template < typename GUM_SCALAR >
79 class ClassBayesNet: public IBayesNet< GUM_SCALAR > {
80 public:
81 // ========================================================================
83 // ========================================================================
85
90
93
96
98 virtual ~ClassBayesNet();
99
101 // ===========================================================================
103 // ===========================================================================
105
119 virtual const Tensor< GUM_SCALAR >& cpt(NodeId varId) const;
120
122 virtual const VariableNodeMap& variableNodeMap() const;
123
125 virtual const DiscreteVariable& variable(NodeId id) const;
126
128 virtual NodeId nodeId(const DiscreteVariable& var) const;
129
131 virtual NodeId idFromName(const std::string& name) const;
132
134 virtual const DiscreteVariable& variableFromName(const std::string& name) const;
135
137 const NodeProperty< Size >& modalities() const;
138
140 // ===========================================================================
142 // ===========================================================================
145 virtual std::string toDot() const;
146
148
149 private:
152
157
161 const PRMClassElement< GUM_SCALAR >& _get_(const std::string& name) const;
162
165
167
168 void _init_(const PRMClass< GUM_SCALAR >& c);
169 };
170
171
172#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
173 extern template class ClassBayesNet< double >;
174#endif
175
176
177 } /* namespace prm */
178} /* namespace gum */
179
181
182#endif /* GUM_CLASS_BAYESNET_H */
Headers of PRM.
Inline implementation of ClassBayesNet.
Base class for discrete random variable.
The class for generic Hash Tables.
Definition hashTable.h:637
IBayesNet()
Default constructor.
Container used to map discrete variables with nodes.
This class decorates a gum::prm::Class<GUM_SCALAR> has an IBaseBayesNet.
virtual ~ClassBayesNet()
Destructor.
virtual const DiscreteVariable & variableFromName(const std::string &name) const
See gum::IBaseBayesNet::variableFromName().
virtual NodeId nodeId(const DiscreteVariable &var) const
See gum::IBaseBayesNet::nodeId().
const PRMClassElement< GUM_SCALAR > & _get_(NodeId id) const
Private getter with type checking in case the id is not a formal PRMAttribute.
virtual const Tensor< GUM_SCALAR > & cpt(NodeId varId) const
Returns the CPT of a node in this ClassBayesNet<GUM_SCALAR>.
ClassBayesNet(const PRMClass< GUM_SCALAR > &c)
Default constructor.
NodeProperty< Size > _modalities_
HashTable< const DiscreteVariable *, const PRMClassElement< GUM_SCALAR > * > _varNodeMap_
Mapping between DiscreteVariable and their NodeId.
virtual std::string toDot() const
virtual const VariableNodeMap & variableNodeMap() const
See gum::IBaseBayesNet::variableNodeMap().
const NodeProperty< Size > & modalities() const
See gum::IBaseBayesNet::modalities().
virtual NodeId idFromName(const std::string &name) const
See gum::IBaseBayesNet::idFromName().
void _init_(const PRMClass< GUM_SCALAR > &c)
const PRMClass< GUM_SCALAR > * _class_
The PRMClassElementContainer decorated by this.
virtual const DiscreteVariable & variable(NodeId id) const
See gum::IBaseBayesNet::variable().
ClassBayesNet< GUM_SCALAR > & operator=(const ClassBayesNet< GUM_SCALAR > &from)
Copy operator.
Abstract class representing an element of PRM class.
A PRMClass is an object of a PRM representing a fragment of a Bayesian network which can be instantia...
Definition PRMClass.h:75
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46