aGrUM 2.3.2
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-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
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 < typename GUM_SCALAR >
74 class InstanceBayesNet: public IBayesNet< GUM_SCALAR > {
75 public:
76 // ========================================================================
78 // ========================================================================
80
85
88
91
93 virtual ~InstanceBayesNet();
94
96 // ===========================================================================
98 // ===========================================================================
100
102 virtual const Tensor< GUM_SCALAR >& cpt(NodeId varId) const;
103
105 virtual const VariableNodeMap& variableNodeMap() const;
106
108 virtual const DiscreteVariable& variable(NodeId id) const;
109
111 virtual NodeId nodeId(const DiscreteVariable& var) const;
112
114 virtual NodeId idFromName(const std::string& name) const;
115
117 virtual const DiscreteVariable& variableFromName(const std::string& name) const;
118
119 const NodeProperty< Size >& modalities() const;
120
122 // ===========================================================================
124 // ===========================================================================
127 virtual std::string toDot() const;
128
130
131 private:
134
139
140 const PRMClassElement< GUM_SCALAR >& _get_(const std::string& 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:637
IBayesNet()
Default constructor.
Container used to map discrete variables with nodes.
This class decorates an PRMInstance<GUM_SCALAR> as an IBaseBayesNet.
NodeProperty< Size > _modalities_
const PRMClassElement< GUM_SCALAR > & _get_(NodeId id) const
Private getter with type checking in case the id is not a formal PRMAttribute<GUM_SCALAR>.
virtual ~InstanceBayesNet()
Destructor.
virtual const VariableNodeMap & variableNodeMap() const
See gum::IBaseBayesNet::variableNodeMap().
void _init_(const PRMInstance< GUM_SCALAR > &i)
InstanceBayesNet(const PRMInstance< GUM_SCALAR > &i)
Default constructor.
virtual const Tensor< GUM_SCALAR > & cpt(NodeId varId) const
See gum::IBaseBayesNet::cpt().
virtual std::string toDot() const
virtual NodeId nodeId(const DiscreteVariable &var) const
See gum::IBaseBayesNet::nodeId().
HashTable< const DiscreteVariable *, const PRMAttribute< GUM_SCALAR > * > _varNodeMap_
Mapping between DiscreteVariable and their NodeId.
virtual const DiscreteVariable & variableFromName(const std::string &name) const
See gum::IBaseBayesNet::variableFromName().
virtual NodeId idFromName(const std::string &name) const
See gum::IBaseBayesNet::idFromName().
virtual const DiscreteVariable & variable(NodeId id) const
See gum::IBaseBayesNet::variable().
const NodeProperty< Size > & modalities() const
See gum::IBaseBayesNet::cpt().
InstanceBayesNet & operator=(const InstanceBayesNet &from)
Copy operator.
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