85 template < TESTNAME AttributeSelection,
bool isScalar >
106 template < TESTNAME AttributeSelection,
bool isScalar >
110 delete nodeIter.val();
116 delete varIter.val();
119 delete nodeIter.val();
136 template < TESTNAME AttributeSelection,
bool isScalar >
166 template < TESTNAME AttributeSelection,
bool isScalar >
187 template < TESTNAME AttributeSelection,
bool isScalar >
192 if (varsOfInterest.
empty()) {
199 if (nodeVarMap_.exists(updatedNode) && varsOfInterest.
exists(nodeVarMap_[updatedNode])) {
205 SetConstIteratorSafe< const DiscreteVariable* > varIter;
206 for (varIter = varsOfInterest.
cbeginSafe(), basc = 0;
207 varIter != varsOfInterest.
cendSafe() && basc < randy;
211 transpose_(updatedNode, *varIter);
217 template < TESTNAME AttributeSelection,
bool isScalar >
224 for (
Idx modality = 0; modality <
nodeVarMap_[currentNodeId]->domainSize(); ++modality) {
232 sizeof(
NodeId) * nodeVarMap_[currentNodeId]->domainSize());
233 nodeSonsMap_.erase(currentNodeId);
243 template < TESTNAME AttributeSelection,
bool isScalar >
250 if (
nodeVarMap_[currentNodeId] == desiredVar) {
return; }
267 for (
Idx modality = 0; modality < desiredVar->
domainSize(); ++modality) {
272 = leafDatabase_[currentNodeId]->beginSafe();
273 leafDatabase_[currentNodeId]->endSafe() != obsIter;
275 dbMap[_branchObs_(*obsIter, desiredVar)]->
addObservation(*obsIter);
276 obsetMap[_branchObs_(*obsIter, desiredVar)]->insert(*obsIter);
282 for (
Idx modality = 0; modality < desiredVar->
domainSize(); ++modality)
303 for (
Idx modality = 0; modality <
nodeVarMap_[currentNodeId]->domainSize(); ++modality)
313 for (
Idx desiredVarModality = 0; desiredVarModality < desiredVar->
domainSize();
314 ++desiredVarModality) {
319 for (
Idx currentVarModality = 0;
320 currentVarModality <
nodeVarMap_[currentNodeId]->domainSize();
321 ++currentVarModality) {
322 grandSonsMap[currentVarModality]
327 sonsMap[desiredVarModality]
328 = insertInternalNode_(sonDB, nodeVarMap_[currentNodeId], grandSonsMap);
332 for (Idx currentVarModality = 0; currentVarModality < nodeVarMap_[currentNodeId]->domainSize();
333 ++currentVarModality) {
334 removeNode_(nodeSonsMap_[currentNodeId][currentVarModality]);
339 sizeof(
NodeId) * nodeVarMap_[currentNodeId]->domainSize());
340 nodeSonsMap_[currentNodeId] = sonsMap;
342 chgNodeBoundVar_(currentNodeId, desiredVar);
353 template < TESTNAME AttributeSelection,
bool isScalar >
376 template < TESTNAME AttributeSelection,
bool isScalar >
395 template < TESTNAME AttributeSelection,
bool isScalar >
412 template < TESTNAME AttributeSelection,
bool isScalar >
416 if (
nodeVarMap_[currentNodeId] == desiredVar)
return;
419 var2Node_[desiredVar]->addLink(currentNodeId);
440 template < TESTNAME AttributeSelection,
bool isScalar >
443 model_.eraseNode(currentNodeId);
468 template < TESTNAME AttributeSelection,
bool isScalar >
473 template < TESTNAME AttributeSelection,
bool isScalar >
478 template < TESTNAME AttributeSelection,
bool isScalar >
481 template < TESTNAME AttributeSelection,
bool isScalar >
487 template < TESTNAME AttributeSelection,
bool isScalar >
494 template < TESTNAME AttributeSelection,
bool isScalar >
501 template < TESTNAME AttributeSelection,
bool isScalar >
508 template < TESTNAME AttributeSelection,
bool isScalar >
516 template < TESTNAME AttributeSelection,
bool isScalar >
524 template < TESTNAME AttributeSelection,
bool isScalar >
529 template < TESTNAME AttributeSelection,
bool isScalar >
534 template < TESTNAME AttributeSelection,
bool isScalar >
539 template < TESTNAME AttributeSelection,
bool isScalar >
545 template < TESTNAME AttributeSelection,
bool isScalar >
547 Idx modality)
const {
551 template < TESTNAME AttributeSelection,
bool isScalar >
556 template < TESTNAME AttributeSelection,
bool isScalar >
563 template < TESTNAME AttributeSelection,
bool isScalar >
Headers of the ChiSquare class.
Base class for discrete random variable.
virtual Size domainSize() const =0
virtual void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId)
NodeId nodeSon(NodeId ni, Idx modality) const override
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 updateVar(const DiscreteVariable *)
If a new modality appears to exists for given variable, call this method to turn every associated nod...
virtual NodeId insertLeafNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *obsSet)
inserts a new leaf node in internal graohs
HashTable< const DiscreteVariable *, LinkedList< NodeId > * > var2Node_
Associates to any variable the list of all nodes associated to this variable.
NodeGraphPart model_
The source of nodeId.
Idx _branchObs_(const Observation *obs, const DiscreteVariable *var)
NodeId root_
The root of the ordered tree.
HashTable< NodeId, NodeId * > nodeSonsMap_
HashTable< NodeId, NodeDatabase< AttributeSelection, isScalar > * > nodeId2Database_
This hashtable binds every node to an associated NodeDatabase which handles every observation that co...
const DiscreteVariable * value_
virtual void addObservation(const Observation *obs)
Inserts a new observation.
void updateNode_(NodeId nody, gum::VariableSet &bestVars)
From the given sets of node, selects randomly one and installs it on given node.
virtual void convertNode2Leaf_(NodeId)
Turns the given node into a leaf if not already so.
gum::VariableSet setOfVars_
virtual NodeId insertNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar)
inserts a new node in internal graph
Sequence< ValueType > valueAssumed_
void _assumeValue_(const Observation *obs)
Get value assumed by studied variable for current observation.
const DiscreteVariable * nodeVar(NodeId ni) const override
MultiDimFunctionGraph< double > * target_
The final diagram we're building.
~IncrementalGraphLearner() override
Default destructor.
HashTable< NodeId, Set< const Observation * > * > leafDatabase_
Idx nodeNbObservation(NodeId ni) const override
HashTable< NodeId, const DiscreteVariable * > nodeVarMap_
NodeId root() const override
void insertSetOfVars(MultiDimFunctionGraph< double > *ret) const override
IncrementalGraphLearner(MultiDimFunctionGraph< double > *target, gum::VariableSet attributesSet, const DiscreteVariable *learnVariable)
Default constructor.
virtual void removeNode_(NodeId removedNodeId)
virtual void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
bool isTerminal(NodeId ni) const override
virtual NodeId insertInternalNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, NodeId *sonsMap)
inserts a new internal node in internal graph
const T & element() const
Returns the element stored in this link.
const Link< T > * nextLink() const
Returns next link.
void add(const DiscreteVariable &v) override
Adds a new var to the variables of the multidimensional matrix.
<agrum/FMDP/learning/datastructure/nodeDatabase.h>
void addObservation(const Observation *)
Nb observation taken into account by this instance.
Idx modality(const DiscreteVariable *var) const
Returns the modality assumed by the given variable in this observation.
double reward() const
Returns the modality assumed by the given variable in this observation.
Idx rModality(const DiscreteVariable *var) const
Returns the modality assumed by the given variable in this observation.
Safe iterators for the Set class.
static const const_iterator_safe & cendSafe() noexcept
The usual safe end iterator to parse the set.
bool exists(const Key &k) const
Indicates whether a given elements belong to the set.
bool empty() const noexcept
Indicates whether the set is the empty set.
const_iterator_safe cbeginSafe() const
The usual safe begin iterator to parse the set.
Size size() const noexcept
Returns the number of elements in the set.
Base class for discrete random variable.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Size Idx
Type for indexes.
Size NodeId
Type for node ids.
Idx randomValue(const Size max=2)
Returns a random Idx between 0 and max-1 included.
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
Set< const DiscreteVariable * > VariableSet
#define SOA_DEALLOCATE(x, y)
Provides basic types used in aGrUM.
Contains useful methods for random stuff.