31 #ifndef GUM_INCREMENTAL_GRAPH_LEARNER_H 32 #define GUM_INCREMENTAL_GRAPH_LEARNER_H 35 #include <agrum/tools/multidim/implementations/multiDimFunctionGraph.h> 37 #include <agrum/FMDP/learning/core/templateStrategy.h> 38 #include <agrum/FMDP/learning/datastructure/IVisitableGraphLearner.h> 39 #include <agrum/FMDP/learning/datastructure/nodeDatabase.h> 41 #include <agrum/tools/multidim/utils/FunctionGraphUtilities/link.h> 64 template < TESTNAME AttributeSelection,
bool isScalar =
false >
87 Set<
const DiscreteVariable* > attributesSet,
88 const DiscreteVariable* learnVariable);
134 void _assumeValue_(
const Observation* obs) { _assumeValue_(obs, Int2Type< isScalar >()); }
136 if (!valueAssumed_.exists(obs->reward())) valueAssumed_ << obs->reward();
139 if (!valueAssumed_.exists(obs->modality(value_))) valueAssumed_ << obs->modality(value_);
149 return _branchObs_(obs, var, Int2Type< isScalar >());
152 return obs->rModality(var);
155 return obs->modality(var);
168 nodeId2Database_[currentNodeId]->addObservation(newObs);
203 void updateNode_(NodeId nody, Set<
const DiscreteVariable* >& bestVars);
260 virtual void chgNodeBoundVar_(NodeId chgedNodeId,
const DiscreteVariable* desiredVar);
306 bool isTerminal(NodeId ni)
const {
return !
this->nodeSonsMap_.exists(ni); }
327 for (SetIteratorSafe<
const DiscreteVariable* > varIter = setOfVars_.beginSafe();
328 varIter != setOfVars_.endSafe();
398 #include <agrum/FMDP/learning/datastructure/incrementalGraphLearner_tpl.h> virtual void updateFunctionGraph()=0
Updates target to currently learned graph structure.
Idx nodeNbObservation(NodeId ni) const
Idx _branchObs_(const Observation *obs, const DiscreteVariable *var, Int2Type< false >)
Inserts a new observation.
void _clearValue_(Int2Type< false >)
In case where we're learning function of variable behaviour, this should do nothing.
void updateNode_(NodeId nody, Set< const DiscreteVariable * > &bestVars)
From the given sets of node, selects randomly one and installs it on given node.
IncrementalGraphLearner(MultiDimFunctionGraph< double > *target, Set< const DiscreteVariable * > attributesSet, const DiscreteVariable *learnVariable)
Default constructor.
MultiDimFunctionGraph< double > * target_
The final diagram we're building.
virtual void convertNode2Leaf_(NodeId)
Turns the given node into a leaf if not already so.
INLINE void emplace(Args &&... args)
virtual ~IncrementalGraphLearner()
Default destructor.
void _clearValue_()
Template function dispatcher.
virtual void removeNode_(NodeId removedNodeId)
Removes a node from the internal graph.
NodeId root_
The root of the ordered tree.
virtual NodeId insertInternalNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, NodeId *sonsMap)
inserts a new internal node in internal graph
virtual void transpose_(NodeId, const DiscreteVariable *)
Installs given variable to the given node, ensuring that the variable is not present in its subtree...
Idx _branchObs_(const Observation *obs, const DiscreteVariable *var)
Seek modality assumed in obs for given var.
virtual void addObservation(const Observation *obs)
Inserts a new observation.
const DiscreteVariable * value_
void _assumeValue_(const Observation *obs, Int2Type< false >)
Inserts a new observation.
virtual void chgNodeBoundVar_(NodeId chgedNodeId, const DiscreteVariable *desiredVar)
Changes the associated variable of a node.
virtual void updateGraph()=0
Updates the tree after a new observation has been added.
Set< const DiscreteVariable *> setOfVars_
virtual NodeId insertNode_(NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar)
inserts a new node in internal graph
HashTable< NodeId, NodeId *> nodeSonsMap_
A table giving for any node a table mapping to its son idx is the modality of associated variable...
NodeGraphPart model_
The source of nodeId.
HashTable< NodeId, Set< const Observation *> *> leafDatabase_
This hashtable binds to every leaf an associated set of all hte observations compatible with it...
const DiscreteVariable * nodeVar(NodeId ni) const
void _assumeValue_(const Observation *obs)
Get value assumed by studied variable for current observation.
virtual void insertSetOfVars(MultiDimFunctionGraph< double > *ret) const
Sequence< ValueType > valueAssumed_
NodeId nodeSon(NodeId ni, Idx modality) const
virtual void updateNodeWithObservation_(const Observation *newObs, NodeId currentNodeId)
Will update internal graph's NodeDatabase of given node with the new observation. ...
HashTable< NodeId, const DiscreteVariable *> nodeVarMap_
Gives for any node its associated variable.
bool isTerminal(NodeId ni) const
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