60 template < TESTNAME AttributeSelection,
bool isScalar >
66 _setOfVars(varList), _value(value) {
85 template < TESTNAME AttributeSelection,
bool isScalar >
91 delete nodeIter.val();
101 delete varIter.val();
106 delete nodeIter.val();
124 template < TESTNAME AttributeSelection,
bool isScalar >
157 template < TESTNAME AttributeSelection,
bool isScalar >
179 template < TESTNAME AttributeSelection,
bool isScalar >
183 if (varsOfInterest.
empty()) {
196 Idx randy = (
Idx)(std::rand() / RAND_MAX) * varsOfInterest.
size(), basc = 0;
197 SetConstIteratorSafe< const DiscreteVariable* > varIter;
198 for (varIter = varsOfInterest.
cbeginSafe(), basc = 0;
199 varIter != varsOfInterest.
cendSafe() && basc < randy;
210 template < TESTNAME AttributeSelection,
bool isScalar >
217 for (
Idx modality = 0; modality <
_nodeVarMap[currentNodeId]->domainSize();
239 template < TESTNAME AttributeSelection,
bool isScalar >
245 if (
_nodeVarMap[currentNodeId] == desiredVar) {
return; }
264 for (
Idx modality = 0; modality < desiredVar->
domainSize(); ++modality) {
280 for (
Idx modality = 0; modality < desiredVar->
domainSize(); ++modality)
303 for (
Idx modality = 0; modality <
_nodeVarMap[currentNodeId]->domainSize();
314 for (
Idx desiredVarModality = 0; desiredVarModality < desiredVar->
domainSize();
315 ++desiredVarModality) {
320 for (
Idx currentVarModality = 0;
321 currentVarModality <
_nodeVarMap[currentNodeId]->domainSize();
322 ++currentVarModality) {
323 grandSonsMap[currentVarModality] =
325 [desiredVarModality];
329 sonsMap[desiredVarModality] =
334 for (
Idx currentVarModality = 0;
335 currentVarModality <
_nodeVarMap[currentNodeId]->domainSize();
336 ++currentVarModality) {
357 template < TESTNAME AttributeSelection,
bool isScalar >
381 template < TESTNAME AttributeSelection,
bool isScalar >
402 template < TESTNAME AttributeSelection,
bool isScalar >
420 template < TESTNAME AttributeSelection,
bool isScalar >
423 if (
_nodeVarMap[currentNodeId] == desiredVar)
return;
426 _var2Node[desiredVar]->addLink(currentNodeId);
450 template < TESTNAME AttributeSelection,
bool isScalar >
void __assumeValue(const Observation *obs)
Get value assumed by studied variable for current observation.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual void _updateNodeWithObservation(const Observation *newObs, NodeId currentNodeId)
Will update internal graph's NodeDatabase of given node with the new observation. ...
HashTable< NodeId, NodeId *> _nodeSonsMap
A table giving for any node a table mapping to its son idx is the modality of associated variable...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
HashTable< const DiscreteVariable *, LinkedList< NodeId > *> _var2Node
Associates to any variable the list of all nodes associated to this variable.
IncrementalGraphLearner(MultiDimFunctionGraph< double > *target, Set< const DiscreteVariable * > attributesSet, const DiscreteVariable *learnVariable)
Default constructor.
Set< const DiscreteVariable *> _setOfVars
bool empty() const noexcept
Indicates whether the set is the empty set.
HashTable< NodeId, NodeDatabase< AttributeSelection, isScalar > *> _nodeId2Database
This hashtable binds every node to an associated NodeDatabase which handles every observation that co...
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Safe iterators for the Set classDevelopers may consider using Set<x>::iterator_safe instead of SetIte...
virtual NodeId _insertInternalNode(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, NodeId *sonsMap)
inserts a new internal node in internal graph
Idx __branchObs(const Observation *obs, const DiscreteVariable *var)
Seek modality assumed in obs for given var.
<agrum/FMDP/learning/datastructure/incrementalGraphLearner>
virtual ~IncrementalGraphLearner()
Default destructor.
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
#define SOA_DEALLOCATE(x, y)
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.
Base class for discrete random variable.
void __clearValue()
Template function dispatcher.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
virtual NodeId _insertLeafNode(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *obsSet)
inserts a new leaf node in internal graohs
virtual NodeId addNode()
insert a new node and return its id
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Representation of a setA Set is a structure that contains arbitrary elements.
const T & element() const
Returns the element stored in this link.
virtual Size domainSize() const =0
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
virtual void addObservation(const Observation *obs)
Inserts a new observation.
const DiscreteVariable * _value
const const_iterator_safe & cendSafe() const noexcept
The usual safe end iterator to parse the set.
HashTable< NodeId, Set< const Observation *> *> _leafDatabase
This hashtable binds to every leaf an associated set of all hte observations compatible with it...
virtual void _transpose(NodeId, const DiscreteVariable *)
Installs given variable to the given node, ensuring that the variable is not present in its subtree...
virtual void _removeNode(NodeId removedNodeId)
Removes a node from the internal graph.
void addObservation(const Observation *)
Nb observation taken into account by this instance.
Link of a chain list allocated using the SmallObjectAllocator.
const_iterator_safe cbeginSafe() const
The usual safe begin iterator to parse the set.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
Chain list allocated using the SmallObjectAllocator.
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 _root
The root of the ordered tree.
Size Idx
Type for indexes.
virtual void updateVar(const DiscreteVariable *)
If a new modality appears to exists for given variable, call this method to turn every associated nod...
NodeGraphPart _model
The source of nodeId.
Size size() const noexcept
Returns the number of elements in the set.
value_type & insert(const Key &key, const Val &val)
Adds a new element (actually a copy of this element) into the hash table.
const Link< T > * nextLink() const
Returns next link.
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.
virtual void eraseNode(const NodeId id)
erase the node with the given id
<agrum/FMDP/learning/datastructure/nodeDatabase.h>