aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
imddi.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_IMDDI_H
51#define GUM_IMDDI_H
52// =========================================================================
53// =========================================================================
57
58// =========================================================================
59// =========================================================================
60
61namespace gum {
62
72
73 template < TESTNAME AttributeSelection, bool isScalar = false >
74 class IMDDI final: public IncrementalGraphLearner< AttributeSelection, isScalar > {
75 public:
76 // ###################################################################
78 // ###################################################################
80
81 // ==========================================================================
83 // ==========================================================================
85 double attributeSelectionThreshold,
86 double pairSelectionThreshold,
87 gum::VariableSet attributeListe,
88 const DiscreteVariable* learnedValue);
89
90 // ==========================================================================
92 // ==========================================================================
94 double attributeSelectionThreshold,
95 double pairSelectionThreshold,
96 gum::VariableSet attributeListe);
97
98 // ==========================================================================
100 // ==========================================================================
101 ~IMDDI() override;
102
104
105 // ###################################################################
107 // ###################################################################
109
110 // ==========================================================================
112 // ==========================================================================
113 void addObservation(const Observation*) override;
114
115 protected:
116 void updateNodeWithObservation_(const Observation* newObs, NodeId currentNodeId) override;
117
118 public:
119 // ==========================================================================
121 // ==========================================================================
122 void updateGraph() override;
123
124 protected:
126 const DiscreteVariable* boundVar,
127 Set< const Observation* >* sonsMap) override;
128
129 void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable* desiredVar) override;
130
131 void removeNode_(NodeId removedNodeId) override;
132
133 private:
134 void _addLeaf_(NodeId);
135 void _removeLeaf_(NodeId);
136
138
139 private:
140 // ###################################################################
142 // ###################################################################
144
145 // ==========================================================================
147 // ==========================================================================
150
151 // ==========================================================================
155 // ==========================================================================
157
158
159 public:
160 // ==========================================================================
162 // ==========================================================================
163 void updateFunctionGraph() override;
164
165 private:
169
172
173 public:
174 void insertSetOfVars(MultiDimFunctionGraph< double >* ret) const override;
175
176 private:
178
180
182
185
188
191 // double _pairSelectionThreshold_;
192 };
193
194
195} /* namespace gum */
196
198
199#endif // GUM_IMDDI_H
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Base class for discrete random variable.
The class for generic Hash Tables.
Definition hashTable.h:640
void _addLeaf_(NodeId)
Adds a new observation to the structure.
Definition imddi_tpl.h:298
NodeId _insertLeafInFunctionGraph_(AbstractLeaf *, Int2Type< true >)
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:389
void _updateNodeSet_(Set< NodeId > &, const DiscreteVariable *, VariableSelector &)
For each node in the given set, this methods checks whether or not we should installed the given vari...
Definition imddi_tpl.h:218
Idx _nbTotalObservation_
The total number of observation added to this tree.
Definition imddi.h:184
IMDDI(MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, double pairSelectionThreshold, gum::VariableSet attributeListe, const DiscreteVariable *learnedValue)
Variable Learner constructor.
Definition imddi_tpl.h:75
void _removeLeaf_(NodeId)
Adds a new observation to the structure.
Definition imddi_tpl.h:311
void addObservation(const Observation *) override
Adds a new observation to the structure.
Definition imddi_tpl.h:122
void _updateScore_(const DiscreteVariable *, NodeId, VariableSelector &vs)
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:189
LeafAggregator _lg_
Definition imddi.h:179
Sequence< const DiscreteVariable * > _varOrder_
Definition imddi.h:177
void _downdateScore_(const DiscreteVariable *, NodeId, VariableSelector &vs)
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:201
double _attributeSelectionThreshold_
The threshold above which we consider variables to be dependant.
Definition imddi.h:187
void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable *desiredVar) override
Adds a new observation to the structure.
Definition imddi_tpl.h:275
NodeId insertLeafNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *sonsMap) override
Adds a new observation to the structure.
Definition imddi_tpl.h:257
void removeNode_(NodeId removedNodeId) override
Adds a new observation to the structure.
Definition imddi_tpl.h:289
HashTable< NodeId, AbstractLeaf * > _leafMap_
Definition imddi.h:181
void insertSetOfVars(MultiDimFunctionGraph< double > *ret) const override
Definition imddi_tpl.h:416
~IMDDI() override
Default destructor.
Definition imddi_tpl.h:109
void _rebuildFunctionGraph_()
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:333
void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId) override
Adds a new observation to the structure.
Definition imddi_tpl.h:128
void updateGraph() override
Updates the tree after a new observation has been added.
Definition imddi_tpl.h:140
void updateFunctionGraph() override
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:322
IncrementalGraphLearner(MultiDimFunctionGraph< double > *target, gum::VariableSet attributesSet, const DiscreteVariable *learnVariable)
<agrum/FMDP/learning/FunctionGraph/leafAggregator.h>
<agrum/FMDP/learning/datastructure/nodeDatabase.h>
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:994
Representation of a set.
Definition set.h:129
<agrum/FMDP/planning/FunctionGraph/variableselector.h>
Size Idx
Type for indexes.
Definition types.h:79
Size NodeId
Type for node ids.
Headers of the interface specifying functions to be implemented by any incremental learner.
Headers of the Leaf Aggregator class.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet
Headers of the Variable Selector class.