aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
nodeDatabase.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// =========================================================================
50#ifndef GUM_NODE_DATABASE_H
51#define GUM_NODE_DATABASE_H
52// =========================================================================
54// =========================================================================
59
60// =========================================================================
61// =========================================================================
62
63namespace gum {
64
72
73
74 template < TESTNAME AttributeSelection, bool isScalar >
77
78 template < typename GUM_ELEMENT >
79 using TestPolicy = typename TestSelect< AttributeSelection,
83
84 public:
85 // ==========================================================================
87 // ==========================================================================
89
90 // ###################################################################
92 // ###################################################################
93 NodeDatabase(const gum::VariableSet*, const DiscreteVariable* = nullptr);
94
95 // ###################################################################
97 // ###################################################################
99
100 // ============================================================================
102 // ============================================================================
103 void* operator new(size_t s);
104
105 void operator delete(void* p);
106
108
109 // ==========================================================================
111 // ==========================================================================
113
114 // ###################################################################
121 // ###################################################################
122 void addObservation(const Observation*);
123
124 private:
127
128 public:
129 // ###################################################################
131 // ###################################################################
132 INLINE Idx nbObservation() const;
133
135
136 // ==========================================================================
138 // ==========================================================================
140
141 // ###################################################################
144 // ###################################################################
145 INLINE bool isTestRelevant(const DiscreteVariable* var) const;
146
147 // ###################################################################
150 // ###################################################################
151 INLINE double testValue(const DiscreteVariable* var) const;
152
153 // ###################################################################
156 // ###################################################################
157 INLINE double testOtherCriterion(const DiscreteVariable* var) const;
158
160
161 // ==========================================================================
163 // ==========================================================================
165
166 // ###################################################################
168 // ###################################################################
171
172 // ###################################################################
175 // ###################################################################
176 const TestPolicy< ValueType >* testPolicy(const DiscreteVariable* var) const;
177
178 // ###################################################################
180 // ###################################################################
182
184
186
187 // ###################################################################
189 // ###################################################################
190
191 Idx effectif(Idx moda) const;
192
193 Idx valueDomain() const;
194
195 private:
197
199
200 std::string toString() const;
201
202 private:
205
208
211
214 };
215
216
217} /* namespace gum */
218
220
221#endif // GUM_NODE_DATABASE_H
Headers of the Chi2TestPolicy.
Headers of the GTestPolicy.
<agrum/base/multidim/core/testPolicy/Chi2TestPolicy.h>
Base class for discrete random variable.
<agrum/base/multidim/core/testPolicies/GTestPolicy.h>
Definition GTestPolicy.h:74
The class for generic Hash Tables.
Definition hashTable.h:640
<agrum/base/multidim/core/testPolicy/leastSquareTestPolicy.h>
const TestPolicy< ValueType > * testPolicy(const DiscreteVariable *var) const
Returns a reference to nDB test policy for given variable (so that test policy information can be mer...
NodeDatabase(const gum::VariableSet *, const DiscreteVariable *=nullptr)
Default constructor.
~NodeDatabase()
Default destructor.
INLINE bool isTestRelevant(const DiscreteVariable *var) const
Indicates wether or not, node has sufficient observation so that any statistic is relevant.
typename ValueSelect< isScalar, double, Idx >::type ValueType
INLINE Idx nbObservation() const
Nb observation taken into account by this instance.
const DiscreteVariable * _value_
So does this reference on the value observed.
Idx effectif(Idx moda) const
Idx _valueDomain_(Int2Type< true >) const
typename TestSelect< AttributeSelection, GTestPolicy< GUM_ELEMENT >, Chi2TestPolicy< GUM_ELEMENT >, LeastSquareTestPolicy< GUM_ELEMENT > >::type TestPolicy
const HashTableConstIteratorSafe< ValueType, Idx > cendValues() const
Merges given NodeDatabase informations into current nDB.
void _addObservation_(const Observation *, Int2Type< true >)
Updates database with new observation.
std::string toString() const
HashTable< ValueType, Idx > _valueCount_
INLINE double testValue(const DiscreteVariable *var) const
Returns the performance of given variables according to selection criterion.
INLINE double testOtherCriterion(const DiscreteVariable *var) const
Returns the performance of given variables according to selection secondary criterion (to break ties)...
NodeDatabase< AttributeSelection, isScalar > & operator+=(const NodeDatabase< AttributeSelection, isScalar > &src)
Merges given NodeDatabase informations into current nDB.
HashTable< const DiscreteVariable *, TestPolicy< ValueType > * > _attrTable_
Table giving for every variables its instantiation.
const HashTableConstIteratorSafe< ValueType, Idx > cbeginValues() const
Iterators on value count to recopy correctly its content.
void addObservation(const Observation *)
Nb observation taken into account by this instance.
Size Idx
Type for indexes.
Definition types.h:79
Headers of the LeastSquareTestPolicy.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet
Template implémentations of the NodeDatabase class.
Header file of gum::Sequence, a class for storing (ordered) sequences of objects.
Template trick for efficient development.