aGrUM 2.3.2
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-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// =========================================================================
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();
102
104
105 // ###################################################################
107 // ###################################################################
109
110 // ==========================================================================
112 // ==========================================================================
113 void addObservation(const Observation*);
114
115 protected:
116 void updateNodeWithObservation_(const Observation* newObs, NodeId currentNodeId);
117
118 public:
119 // ==========================================================================
121 // ==========================================================================
122 void updateGraph();
123
124 protected:
126 const DiscreteVariable* boundVar,
128
129 void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable* desiredVar);
130
131 void removeNode_(NodeId removedNodeId);
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();
164
165 private:
169
172
173 public:
176 varIter != _varOrder_.endSafe();
177 ++varIter)
178 ret->add(**varIter);
179 }
180
181 private:
183
185
187
190
193
196 // double _pairSelectionThreshold_;
197 };
198
199
200} /* namespace gum */
201
203
204#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:637
void _addLeaf_(NodeId)
Adds a new observation to the structure.
Definition imddi_tpl.h:297
NodeId _insertLeafInFunctionGraph_(AbstractLeaf *, Int2Type< true >)
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:388
void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId)
Adds a new observation to the structure.
Definition imddi_tpl.h:127
void updateFunctionGraph()
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:321
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:217
Idx _nbTotalObservation_
The total number of observation added to this tree.
Definition imddi.h:189
IMDDI(MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, double pairSelectionThreshold, gum::VariableSet attributeListe, const DiscreteVariable *learnedValue)
Variable Learner constructor.
Definition imddi_tpl.h:74
void _removeLeaf_(NodeId)
Adds a new observation to the structure.
Definition imddi_tpl.h:310
~IMDDI()
Default destructor.
Definition imddi_tpl.h:108
void _updateScore_(const DiscreteVariable *, NodeId, VariableSelector &vs)
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:188
LeafAggregator _lg_
Definition imddi.h:184
void removeNode_(NodeId removedNodeId)
Adds a new observation to the structure.
Definition imddi_tpl.h:288
Sequence< const DiscreteVariable * > _varOrder_
Definition imddi.h:182
void _downdateScore_(const DiscreteVariable *, NodeId, VariableSelector &vs)
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:200
double _attributeSelectionThreshold_
The threshold above which we consider variables to be dependant.
Definition imddi.h:192
void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Adds a new observation to the structure.
Definition imddi_tpl.h:274
HashTable< NodeId, AbstractLeaf * > _leafMap_
Definition imddi.h:186
void updateGraph()
Updates the tree after a new observation has been added.
Definition imddi_tpl.h:139
void insertSetOfVars(MultiDimFunctionGraph< double > *ret) const
Definition imddi.h:174
void _rebuildFunctionGraph_()
Computes the score of the given variables for the given node.
Definition imddi_tpl.h:332
NodeId insertLeafNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *sonsMap)
Adds a new observation to the structure.
Definition imddi_tpl.h:256
void addObservation(const Observation *)
Adds a new observation to the structure.
Definition imddi_tpl.h:121
IncrementalGraphLearner(MultiDimFunctionGraph< double > *target, gum::VariableSet attributesSet, const DiscreteVariable *learnVariable)
<agrum/FMDP/learning/FunctionGraph/leafAggregator.h>
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
<agrum/FMDP/learning/datastructure/nodeDatabase.h>
Safe iterators for Sequence.
Definition sequence.h:1134
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:972
Representation of a set.
Definition set.h:131
<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.