aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
GTestPolicy.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
50#ifndef GUM_MULTI_DIM_FUNCTION_GRAPH_G_TEST_POLICY_H
51#define GUM_MULTI_DIM_FUNCTION_GRAPH_G_TEST_POLICY_H
52// ============================================================================
57
58// ============================================================================
59
60namespace gum {
61
62 // template <typename GUM_ELEMENT>
63 // using ConTab = ContingencyTable<Idx, GUM_ELEMENT>;
64
73 template < typename GUM_ELEMENT >
74 class GTestPolicy final: public ITestPolicy< GUM_ELEMENT > {
75 public:
76 // ############################################################################
78 // ############################################################################
80
81 // ============================================================================
83 // ============================================================================
85
86 // ============================================================================
88 // ============================================================================
89 ~GTestPolicy() override;
90
91 // ============================================================================
93 // ============================================================================
94 void* operator new(size_t s);
95
96 void operator delete(void* p);
97
99
100 // ############################################################################
102 // ############################################################################
104
105 // ============================================================================
107 // ============================================================================
108 void addObservation(Idx iattr, GUM_ELEMENT ivalue) override;
109
111
112
113 // ############################################################################
115 // ############################################################################
117
118 // ============================================================================
121 // ============================================================================
122 bool isTestRelevant() const override;
123
124 // ============================================================================
126 // ============================================================================
127 void computeScore() const override;
128
129 // ============================================================================
131 // ============================================================================
132 double score() const override;
133
134 // ============================================================================
136 // ============================================================================
137 double secondaryscore() const override;
138
139
141
142
143 // ############################################################################
145 // ############################################################################
147
148 // ============================================================================
150 // ============================================================================
151 void add(const GTestPolicy< GUM_ELEMENT >& src);
152
153 // ============================================================================
156 // ============================================================================
158
160
161
162 // ############################################################################
164 // ############################################################################
166
167 std::string toString() const;
168
170
171 private:
174 mutable double _GStat_;
175 };
176
177} // End of namespace gum
178
180
181#endif /* GUM_MULTI_DIM_FUNCTION_GRAPH_G_TEST_POLICY_H */
Template implementations for the GTestPolicy class.
Headers of the ITestPolicy.
Headers of the ChiSquare class.
double score() const override
Returns the performance of current variable according to the test.
bool isTestRelevant() const override
Returns true if enough observation were made so that the test can be relevant.
GTestPolicy()
Constructor.
~GTestPolicy() override
Destructor.
void addObservation(Idx iattr, GUM_ELEMENT ivalue) override
Comptabilizes the new observation.
ContingencyTable< Idx, GUM_ELEMENT > _conTab_
The contingency table used to keeps records of all observation.
std::string toString() const
double secondaryscore() const override
Returns a second criterion to severe ties.
void computeScore() const override
Computes the GStat of current variable according to the test.
void add(const GTestPolicy< GUM_ELEMENT > &src)
Performs the merging of current GTestPolicy instance with given instance.
const ContingencyTable< Idx, GUM_ELEMENT > & ct() const
Returns contingency table (needed for the merging of GTestPolicy instances).
ITestPolicy()
Allocators and Deallocators redefinition.
Headers of the ContingencyTable class.
Size Idx
Type for indexes.
Definition types.h:79
gum is the global namespace for all aGrUM entities
Definition agrum.h:46