57 template < TESTNAME AttributeSelection,
bool isScalar >
63 _setOfVars(varList), _value(value) {
82 template < TESTNAME AttributeSelection,
bool isScalar >
88 delete nodeIter.val();
103 delete nodeIter.val();
121 template < TESTNAME AttributeSelection,
bool isScalar >
154 template < TESTNAME AttributeSelection,
bool isScalar >
176 template < TESTNAME AttributeSelection,
bool isScalar >
180 if (varsOfInterest.
empty()) {
193 Idx randy = (
Idx)(std::rand() / RAND_MAX) * varsOfInterest.
size(), basc = 0;
194 SetConstIteratorSafe< const DiscreteVariable* > varIter;
195 for (varIter = varsOfInterest.
cbeginSafe(), basc = 0;
196 varIter != varsOfInterest.
cendSafe() && basc < randy;
207 template < TESTNAME AttributeSelection,
bool isScalar >
214 for (
Idx modality = 0; modality <
_nodeVarMap[currentNodeId]->domainSize();
236 template < TESTNAME AttributeSelection,
bool isScalar >
242 if (
_nodeVarMap[currentNodeId] == desiredVar) {
return; }
261 for (
Idx modality = 0; modality < desiredVar->
domainSize(); ++modality) {
277 for (
Idx modality = 0; modality < desiredVar->
domainSize(); ++modality)
300 for (
Idx modality = 0; modality <
_nodeVarMap[currentNodeId]->domainSize();
311 for (
Idx desiredVarModality = 0; desiredVarModality < desiredVar->
domainSize();
312 ++desiredVarModality) {
317 for (
Idx currentVarModality = 0;
318 currentVarModality <
_nodeVarMap[currentNodeId]->domainSize();
319 ++currentVarModality) {
320 grandSonsMap[currentVarModality] =
322 [desiredVarModality];
326 sonsMap[desiredVarModality] =
331 for (
Idx currentVarModality = 0;
332 currentVarModality <
_nodeVarMap[currentNodeId]->domainSize();
333 ++currentVarModality) {
354 template < TESTNAME AttributeSelection,
bool isScalar >
378 template < TESTNAME AttributeSelection,
bool isScalar >
399 template < TESTNAME AttributeSelection,
bool isScalar >
417 template < TESTNAME AttributeSelection,
bool isScalar >
420 if (
_nodeVarMap[currentNodeId] == desiredVar)
return;
423 _var2Node[desiredVar]->addLink(currentNodeId);
447 template < TESTNAME AttributeSelection,
bool isScalar >
void __assumeValue(const Observation *obs)
Get value assumed by studied variable for current observation.
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...
Priority queues in which the same element can appear several times.
Provides basic types used in aGrUM.
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...
Base class for discrete random variable.
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.
gum is the global namespace for all aGrUM entities
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
Headers of the ChiSquare class.
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.
Headers of the interface specifying functions to be implemented by any incremental learner...
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>