60 template < TESTNAME AttributeSelection,
bool isScalar >
63 double attributeSelectionThreshold,
67 target, attributeListe, learnedValue),
68 __nbTotalObservation(0),
69 __attributeSelectionThreshold(attributeSelectionThreshold) {
86 template < TESTNAME AttributeSelection,
bool isScalar >
89 double attributeSelectionThreshold,
110 template < TESTNAME AttributeSelection,
bool isScalar >
125 template < TESTNAME AttributeSelection,
bool isScalar >
142 template < TESTNAME AttributeSelection,
bool isScalar >
144 std::vector< NodeId > filo;
145 filo.push_back(this->
_root);
151 while (!filo.empty()) {
152 NodeId currentNodeId = filo.back();
159 for (
auto varIter = potentialVars[currentNodeId]->cbeginSafe();
160 varIter != potentialVars[currentNodeId]->
cendSafe();
165 if (varValue >= bestValue) {
166 if (varValue > bestValue) {
167 bestValue = varValue;
170 bestVars.
insert(*varIter);
179 for (
Idx moda = 0; moda < this->
_nodeVarMap[currentNodeId]->domainSize();
186 filo.push_back(sonId);
187 potentialVars.
insert(sonId, itsPotentialVars);
195 nodeIter != potentialVars.
endSafe();
197 delete nodeIter.val();
209 template < TESTNAME AttributeSelection,
bool isScalar >
228 template < TESTNAME AttributeSelection,
bool isScalar >
231 if (this->
_nodeVarMap[currentNodeId] != desiredVar) {
234 currentNodeId, desiredVar);
245 template < TESTNAME AttributeSelection,
bool isScalar >
260 template < TESTNAME AttributeSelection,
bool isScalar >
275 template < TESTNAME AttributeSelection,
bool isScalar >
290 for (
Idx moda = 0; moda < this->
_nodeVarMap[currentNodeId]->domainSize();
310 template < TESTNAME AttributeSelection,
bool isScalar >
341 template < TESTNAME AttributeSelection,
bool isScalar >
348 value += (
double)valIter.key() * valIter.val();
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
HashTable< NodeId, NodeId *> _nodeSonsMap
A table giving for any node a table mapping to its son idx is the modality of associated variable...
void updateFunctionGraph()
Updates target to currently learned graph structure.
NodeId _insertNode(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar)
inserts a new node in internal graph
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void setSon(const NodeId &node, const Idx &modality, const NodeId &sonNode)
Sets nodes son for given modality to designated son node.
Set< const DiscreteVariable *> _setOfVars
NodeId __insertNodeInFunctionGraph(NodeId src)
Inserts an internal node in the target.
HashTable< NodeId, NodeDatabase< AttributeSelection, isScalar > *> _nodeId2Database
This hashtable binds every node to an associated NodeDatabase which handles every observation that co...
double __attributeSelectionThreshold
The threshold above which we consider variables to be dependant.
Learn a graphical representation of a function as a decision tree.
void setRootNode(const NodeId &root)
Sets root node of decision diagram.
void _updateNode(NodeId nody, Set< const DiscreteVariable * > &bestVars)
From the given sets of node, selects randomly one and installs it on given node.
const iterator_safe & endSafe() noexcept
Returns the safe iterator pointing to the end of the hashtable.
<agrum/FMDP/learning/datastructure/incrementalGraphLearner>
void erase(const Key &key)
Removes a given element from the hash table.
virtual NodeId _insertNode(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar)
inserts a new node in internal graph
HashTable< NodeId, bool > __staleTable
Hashtable indicating if given node has been modified (upon receiving new exemple or through a transpo...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void updateGraph()
Updates the internal graph after a new observation has been added.
NodeId addInternalNode(const DiscreteVariable *var)
Inserts a new non terminal node in graph.
void erase(const Key &k)
Erases an element from the set.
Base class for discrete random variable.
Safe Iterators for hashtables.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
MultiDimFunctionGraph< double > * _target
The final diagram we're building.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
The class for generic Hash Tables.
Idx __nbTotalObservation
The total number of observation added to this tree.
void _updateNodeWithObservation(const Observation *newObs, NodeId currentNodeId)
Will update internal graph's NodeDatabase of given node with the new observation. ...
Representation of a setA Set is a structure that contains arbitrary elements.
ITI(MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, Set< const DiscreteVariable * > attributeListe, const DiscreteVariable *learnedValue)
ITI constructor for functions describing the behaviour of one variable according to a set of other va...
virtual Size domainSize() const =0
virtual void add(const DiscreteVariable &v)
Adds a new var to the variables of the multidimensional matrix.
virtual void addObservation(const Observation *obs)
Inserts a new observation.
const const_iterator_safe & cendSafe() const noexcept
Returns the safe const_iterator pointing to the end of the hashtable.
const DiscreteVariable * _value
void _removeNode(NodeId removedNodeId)
Removes a node from the internal graph.
virtual void _removeNode(NodeId removedNodeId)
Removes a node from the internal graph.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual const Sequence< const DiscreteVariable *> & variablesSequence() const override
Returns a const ref to the sequence of DiscreteVariable*.
virtual void _chgNodeBoundVar(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Changes the associated variable of a node.
iterator_safe beginSafe()
Returns the safe iterator pointing to the beginning of the hashtable.
NodeId __insertTerminalNode(NodeId src)
Insert a terminal node in the target.
NodeId _root
The root of the ordered tree.
void _chgNodeBoundVar(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Changes the associated variable of a node.
NodeId addTerminalNode(const GUM_SCALAR &value)
Adds a value to the MultiDimFunctionGraph.
Size Idx
Type for indexes.
void clear()
Removes all the elements, if any, from the set.
MultiDimFunctionGraphManager< GUM_SCALAR, TerminalNodePolicy > * manager()
Returns a const reference to the manager of this diagram.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
HashTable< NodeId, const DiscreteVariable *> _nodeVarMap
Gives for any node its associated variable.
void addObservation(const Observation *obs)
Inserts a new observation.
Size NodeId
Type for node ids.
void insert(const Key &k)
Inserts a new element into the set.
void clear()
Clears the function graph.
<agrum/FMDP/learning/datastructure/nodeDatabase.h>