50 template < TESTNAME AttributeSelection,
bool isScalar >
53 double attributeSelectionThreshold,
54 double pairSelectionThreshold,
58 target, attributeListe, learnedValue),
59 __lg(&(this->_model), pairSelectionThreshold), __nbTotalObservation(0),
60 __attributeSelectionThreshold(attributeSelectionThreshold) {
61 GUM_CONSTRUCTOR(
IMDDI);
68 template < TESTNAME AttributeSelection,
bool isScalar >
71 double attributeSelectionThreshold,
72 double pairSelectionThreshold,
78 GUM_CONSTRUCTOR(
IMDDI);
85 template < TESTNAME AttributeSelection,
bool isScalar >
87 GUM_DESTRUCTOR(
IMDDI);
92 delete leafIter.val();
100 template < TESTNAME AttributeSelection,
bool isScalar >
107 template < TESTNAME AttributeSelection,
bool isScalar >
121 template < TESTNAME AttributeSelection,
bool isScalar >
149 nodeIter != currentNodeSet.
endSafe();
171 template < TESTNAME AttributeSelection,
bool isScalar >
182 template < TESTNAME AttributeSelection,
bool isScalar >
200 template < TESTNAME AttributeSelection,
bool isScalar >
208 nodeIter != oldNodeSet.
endSafe();
223 for (
Idx modality = 0;
224 modality < this->
_nodeVarMap[*nodeIter]->domainSize();
234 nodeSet << *nodeIter;
243 template < TESTNAME AttributeSelection,
bool isScalar >
250 nDB, boundVar, obsSet);
254 return currentNodeId;
261 template < TESTNAME AttributeSelection,
bool isScalar >
268 currentNodeId, desiredVar);
277 template < TESTNAME AttributeSelection,
bool isScalar >
289 template < TESTNAME AttributeSelection,
bool isScalar >
303 template < TESTNAME AttributeSelection,
bool isScalar >
315 template < TESTNAME AttributeSelection,
bool isScalar >
327 template < TESTNAME AttributeSelection,
bool isScalar >
349 treeNodeIter != treeNode2leaf.
cendSafe();
351 if (!leaf2DGNode.
exists(treeNodeIter.val()))
352 leaf2DGNode.
insert(treeNodeIter.val(),
356 toTarget.
insert(treeNodeIter.key(), leaf2DGNode[treeNodeIter.val()]);
368 curNodeIter = curNodeIter->nextLink()) {
371 for (
Idx modality = 0; modality < (*varIter)->domainSize(); ++modality)
373 toTarget[this->
_nodeSonsMap[curNodeIter->element()][modality]];
375 curNodeIter->element(),
390 template < TESTNAME AttributeSelection,
bool isScalar >
394 for (
Idx moda = 0; moda < leaf->
nbModa(); moda++) {
397 if (leaf->
total()) value /= (
double)leaf->
total();
405 template < TESTNAME AttributeSelection,
bool isScalar >
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...
Safe iterators for Sequence.
void updateGraph()
Updates the tree after a new observation has been added.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
NodeId __insertLeafInFunctionGraph(AbstractLeaf *, Int2Type< true >)
Computes the score of the given variables for the given node.
HashTable< const DiscreteVariable *, LinkedList< NodeId > *> _var2Node
Associates to any variable the list of all nodes associated to this variable.
void __removeLeaf(NodeId)
Adds a new observation to the structure.
virtual double effectif(Idx) const =0
Gaves the leaf effectif for given modality.
Set< const DiscreteVariable *> _setOfVars
void addObservation(const Observation *)
Adds a new observation to the structure.
void _updateNodeWithObservation(const Observation *newObs, NodeId currentNodeId)
Adds a new observation to the structure.
void clean()
Removes var without nodes in the diagram.
HashTable< NodeId, NodeDatabase< AttributeSelection, isScalar > *> _nodeId2Database
This hashtable binds every node to an associated NodeDatabase which handles every observation that co...
void setRootNode(const NodeId &root)
Sets root node of decision diagram.
void _removeNode(NodeId removedNodeId)
Adds a new observation to the structure.
Safe iterators for the Set classDevelopers may consider using Set<x>::iterator_safe instead of SetIte...
void __updateScore(const DiscreteVariable *, NodeId, VariableSelector &vs)
Computes the score of the given variables for the given node.
<agrum/FMDP/learning/datastructure/incrementalGraphLearner>
const_iterator_safe cbeginSafe() const
Returns the safe const_iterator pointing to the beginning of the hashtable.
void updateFunctionGraph()
Computes the score of the given variables for the given node.
<agrum/FMDP/learning/datastructure/leaves/abstractLeaf.h>
Safe Const Iterators for hashtables.
void downdateScore(const DiscreteVariable *var, double score, double secondaryscore)
The set of remaining vars to select among.
virtual void _convertNode2Leaf(NodeId)
Turns the given node into a leaf if not already so.
bool exists(const Key &key) const
Checks whether there exists an element with a given key in the hashtable.
NodeId addInternalNode(const DiscreteVariable *var)
Inserts a new non terminal node in graph.
Base class for discrete random variable.
Safe Iterators for hashtables.
void __rebuildFunctionGraph()
Computes the score of the given variables for the given node.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
MultiDimFunctionGraph< double > * _target
The final diagram we're building.
HashTable< NodeId, AbstractLeaf *> __leafMap
virtual NodeId _insertLeafNode(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *obsSet)
inserts a new leaf node in internal graohs
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Sequence< const DiscreteVariable *> __varOrder
void _chgNodeBoundVar(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Adds a new observation to the structure.
Representation of a setA Set is a structure that contains arbitrary elements.
const iterator_safe & endSafe() const noexcept
The usual safe end iterator to parse the set.
virtual Size domainSize() const =0
void begin()
The set of remaining vars to select among.
virtual Idx nbModa() 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
<agrum/FMDP/learning/datastructure/leaves/concreteLeaf.h>
virtual void _transpose(NodeId, const DiscreteVariable *)
Installs given variable to the given node, ensuring that the variable is not present in its subtree...
~IMDDI()
Default destructor.
bool hasNext()
The set of remaining vars to select among.
void __addLeaf(NodeId)
Adds a new observation to the structure.
virtual void _removeNode(NodeId removedNodeId)
Removes a node from the internal graph.
void __downdateScore(const DiscreteVariable *, NodeId, VariableSelector &vs)
Computes the score of the given variables for the given node.
Sequence< ValueType > _valueAssumed
const DiscreteVariable * select()
Select the most relevant variable.
Link of a chain list allocated using the SmallObjectAllocator.
HashTable< NodeId, AbstractLeaf *> leavesMap()
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
IMDDI(MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, double pairSelectionThreshold, Set< const DiscreteVariable * > attributeListe, const DiscreteVariable *learnedValue)
Variable Learner constructor.
<agrum/FMDP/planning/FunctionGraph/variableselector.h>
virtual void _chgNodeBoundVar(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Changes the associated variable of a node.
iterator_safe beginSafe() const
The usual safe begin iterator to parse the set.
bool isEmpty()
The set of remaining vars to select among.
void updateScore(const DiscreteVariable *var, double score, double secondaryscore)
The set of remaining vars to select among.
NodeId _root
The root of the ordered tree.
double __attributeSelectionThreshold
The threshold above which we consider variables to be dependant.
NodeId addTerminalNode(const GUM_SCALAR &value)
Adds a value to the MultiDimFunctionGraph.
Size Idx
Type for indexes.
void removeLeaf(AbstractLeaf *)
void next()
The set of remaining vars to select among.
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.
NodeGraphPart _model
The source of nodeId.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
virtual double total() const =0
bool updateLeaf(AbstractLeaf *)
NodeId _insertLeafNode(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *sonsMap)
Adds a new observation to the structure.
void addLeaf(AbstractLeaf *)
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
const DiscreteVariable * current()
The set of remaining vars to select among.
HashTable< NodeId, const DiscreteVariable *> _nodeVarMap
Gives for any node its associated variable.
Size NodeId
Type for node ids.
void insert(const Key &k)
Inserts a new element into the set.
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...
void clear()
Clears the function graph.
<agrum/FMDP/learning/datastructure/nodeDatabase.h>
Idx __nbTotalObservation
The total number of observation added to this tree.