aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
iti.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_ITI_H
51#define GUM_ITI_H
52// =========================================================================
54// =========================================================================
55// =========================================================================
57
58// =========================================================================
59// =========================================================================
60
61namespace gum {
62
77
78 template < TESTNAME AttributeSelection, bool isScalar = false >
79 class ITI: public IncrementalGraphLearner< AttributeSelection, isScalar > {
80 public:
81 // ###################################################################
83 // ###################################################################
85
86 // ==========================================================================
98 // ==========================================================================
100 double attributeSelectionThreshold,
101 gum::VariableSet attributeListe,
102 const DiscreteVariable* learnedValue);
103
104 // ==========================================================================
114 // ==========================================================================
116 double attributeSelectionThreshold,
117 gum::VariableSet attributeListe);
118
119 // ==========================================================================
121 // ==========================================================================
123 GUM_DESTRUCTOR(ITI);
124 ;
125 }
126
128
129 // ###################################################################
131 // ###################################################################
133
134 public:
135 // ==========================================================================
140 // ==========================================================================
141 void addObservation(const Observation* obs);
142
143 protected:
144 // ==========================================================================
151 // ==========================================================================
152 void updateNodeWithObservation_(const Observation* newObs, NodeId currentNodeId);
153
155
156 // ###################################################################
158 // ###################################################################
160
161 public:
162 // ==========================================================================
164 // ==========================================================================
165 void updateGraph();
166
167 protected:
168 // ==========================================================================
175 // ==========================================================================
177 const DiscreteVariable* boundVar);
178
179 // ==========================================================================
185 // ==========================================================================
186 void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable* desiredVar);
187
188 // ==========================================================================
193 // ==========================================================================
194 void removeNode_(NodeId removedNodeId);
195
197
198 public:
199 // ###################################################################
201 // ###################################################################
203
204 // ==========================================================================
206 // ==========================================================================
207 void updateFunctionGraph();
208
209 private:
210 // ==========================================================================
216 // ==========================================================================
218
219 // ==========================================================================
228 // ==========================================================================
232
233 // ==========================================================================
241 // ==========================================================================
243
244 // ==========================================================================
252 // ==========================================================================
254
256
257
258 protected:
259 // ==========================================================================
264 // ==========================================================================
266 for (SetIteratorSafe< const DiscreteVariable* > varIter = this->setOfVars_.beginSafe();
267 varIter != this->setOfVars_.endSafe();
268 ++varIter)
269 ret->add(**varIter);
270 }
271
272 private:
277
280
283 };
284
285
286} /* namespace gum */
287
289
290#endif // GUM_ITI_H
Base class for discrete random variable.
void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Changes the associated variable of a node.
Definition iti_tpl.h:237
NodeId _insertTerminalNode_(NodeId src)
Insert a terminal node in the target.
Definition iti.h:229
~ITI()
Default destructor.
Definition iti.h:122
double _attributeSelectionThreshold_
The threshold above which we consider variables to be dependant.
Definition iti.h:282
void removeNode_(NodeId removedNodeId)
Removes a node from the internal graph.
Definition iti_tpl.h:253
HashTable< NodeId, bool > _staleTable_
Hashtable indicating if given node has been modified (upon receiving new exemple or through a transpo...
Definition iti.h:276
NodeId insertNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar)
inserts a new node in internal graph
Definition iti_tpl.h:221
NodeId _insertNodeInFunctionGraph_(NodeId src)
Inserts an internal node in the target.
Definition iti_tpl.h:279
void updateGraph()
Updates the internal graph after a new observation has been added.
Definition iti_tpl.h:160
void updateFunctionGraph()
Updates target to currently learned graph structure.
Definition iti_tpl.h:266
Idx _nbTotalObservation_
The total number of observation added to this tree.
Definition iti.h:279
void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId)
Will update internal graph's NodeDatabase of given node with the new observation.
Definition iti_tpl.h:144
ITI(MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, gum::VariableSet attributeListe, const DiscreteVariable *learnedValue)
ITI constructor for functions describing the behaviour of one variable according to a set of other va...
Definition iti_tpl.h:84
void addObservation(const Observation *obs)
Inserts a new observation.
Definition iti_tpl.h:130
void insertSetOfVars_(MultiDimFunctionGraph< double > *ret)
insertSetOfVars_
Definition iti.h:265
IncrementalGraphLearner(MultiDimFunctionGraph< double > *target, gum::VariableSet attributesSet, const DiscreteVariable *learnVariable)
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 the Set class.
Definition set.h:601
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.
Priority queues in which the same element can appear several times.
gum is the global namespace for all aGrUM entities
Definition agrum.h:46
Set< const DiscreteVariable * > VariableSet