aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
instanceBayesNet.h
Go to the documentation of this file.
1/****************************************************************************
2 * This file is part of the aGrUM/pyAgrum library. *
3 * *
4 * Copyright (c) 2005-2026 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-2026 *
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
49#ifndef GUM_INSTANCE_BAYESNET_H
50#define GUM_INSTANCE_BAYESNET_H
51
52#include <list>
53
54#include <agrum/PRM/PRM.h>
55
56namespace gum {
57 namespace prm {
58
73 template < GUM_Numeric GUM_SCALAR >
74 class InstanceBayesNet: public IBayesNet< GUM_SCALAR > {
75 public:
76 // ========================================================================
78 // ========================================================================
80
85
88
91
93 ~InstanceBayesNet() override;
94
96 // ===========================================================================
98 // ===========================================================================
100
102 const Tensor< GUM_SCALAR >& cpt(NodeId varId) const override;
103
105 const VariableNodeMap& variableNodeMap() const override;
106
108 const DiscreteVariable& variable(NodeId id) const override;
109
111 NodeId nodeId(const DiscreteVariable& var) const override;
112
114 NodeId idFromName(std::string_view name) const override;
115
117 const DiscreteVariable& variableFromName(std::string_view name) const override;
118
119 const NodeProperty< Size >& modalities() const;
120
122 // ===========================================================================
124 // ===========================================================================
127 std::string toDot() const override;
128
130
131 private:
134
139
140 const PRMClassElement< GUM_SCALAR >& _get_(std::string_view name) const;
141
144
146
147 void _init_(const PRMInstance< GUM_SCALAR >& i);
148 };
149
150
151#ifndef GUM_NO_EXTERN_TEMPLATE_CLASS
152 extern template class InstanceBayesNet< double >;
153#endif
154
155
156 } /* namespace prm */
157} /* namespace gum */
158
160
161#endif /* GUM_INSTANCE_BAYESNET_H */
Headers of PRM.
Base class for discrete random variable.
The class for generic Hash Tables.
Definition hashTable.h:640
IBayesNet()
Default constructor.
Container used to map discrete variables with nodes.
This class decorates an PRMInstance<GUM_SCALAR> as an IBaseBayesNet.
std::string toDot() const override
NodeProperty< Size > _modalities_
InstanceBayesNet(const PRMInstance< GUM_SCALAR > &i)
Default constructor.
void _init_(const PRMInstance< GUM_SCALAR > &i)
const VariableNodeMap & variableNodeMap() const override
See gum::IBaseBayesNet::variableNodeMap().
~InstanceBayesNet() override
Destructor.
const NodeProperty< Size > & modalities() const
See gum::IBaseBayesNet::cpt().
const DiscreteVariable & variable(NodeId id) const override
See gum::IBaseBayesNet::variable().
HashTable< const DiscreteVariable *, const PRMAttribute< GUM_SCALAR > * > _varNodeMap_
Mapping between DiscreteVariable and their NodeId.
const Tensor< GUM_SCALAR > & cpt(NodeId varId) const override
See gum::IBaseBayesNet::cpt().
const PRMClassElement< GUM_SCALAR > & _get_(NodeId id) const
Private getter with type checking in case the id is not a formal PRMAttribute<GUM_SCALAR>.
const DiscreteVariable & variableFromName(std::string_view name) const override
See gum::IBaseBayesNet::variableFromName().
InstanceBayesNet & operator=(const InstanceBayesNet &from)
Copy operator.
NodeId idFromName(std::string_view name) const override
See gum::IBaseBayesNet::idFromName().
NodeId nodeId(const DiscreteVariable &var) const override
See gum::IBaseBayesNet::nodeId().
const PRMInstance< GUM_SCALAR > * _inst_
The PRMClassElementContainer decorated by this.
Abstract class representing an element of PRM class.
An PRMInstance is a Bayesian network fragment defined by a Class and used in a PRMSystem.
Definition PRMInstance.h:79
Size NodeId
Type for node ids.
HashTable< NodeId, VAL > NodeProperty
Property on graph elements.
Inline implementation of InstanceBayesNet.
namespace for all probabilistic relational models entities
Definition agrum.h:68
gum is the global namespace for all aGrUM entities
Definition agrum.h:46