![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
#include <agrum/FMDP/planning/FunctionGraph/imddi.h>
Public Member Functions | |
| void | insertSetOfVars (MultiDimFunctionGraph< double > *ret) const |
| Size | size () |
Constructor & destructor. | |
| IMDDI (MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, double pairSelectionThreshold, gum::VariableSet attributeListe, const DiscreteVariable *learnedValue) | |
| Variable Learner constructor. | |
| IMDDI (MultiDimFunctionGraph< double > *target, double attributeSelectionThreshold, double pairSelectionThreshold, gum::VariableSet attributeListe) | |
| Reward Learner constructor. | |
| ~IMDDI () | |
| Default destructor. | |
Visit Methods | |
| NodeId | root () const |
| bool | isTerminal (NodeId ni) const |
| const DiscreteVariable * | nodeVar (NodeId ni) const |
| NodeId | nodeSon (NodeId ni, Idx modality) const |
| Idx | nodeNbObservation (NodeId ni) const |
Protected Attributes | |
| MultiDimFunctionGraph< double > * | target_ |
| The final diagram we're building. | |
| gum::VariableSet | setOfVars_ |
| const DiscreteVariable * | value_ |
| Sequence< ValueType > | valueAssumed_ |
| bool | needUpdate_ |
Model handling datastructures | |
| NodeGraphPart | model_ |
| The source of nodeId. | |
| NodeId | root_ |
| The root of the ordered tree. | |
| HashTable< NodeId, const DiscreteVariable * > | nodeVarMap_ |
| Gives for any node its associated variable. | |
| HashTable< NodeId, NodeId * > | nodeSonsMap_ |
| A table giving for any node a table mapping to its son idx is the modality of associated variable. | |
| HashTable< const DiscreteVariable *, LinkedList< NodeId > * > | var2Node_ |
| Associates to any variable the list of all nodes associated to this variable. | |
| HashTable< NodeId, NodeDatabase< AttributeSelection, isScalar > * > | nodeId2Database_ |
| This hashtable binds every node to an associated NodeDatabase which handles every observation that concerns that node. | |
| HashTable< NodeId, Set< const Observation * > * > | leafDatabase_ |
| This hashtable binds to every leaf an associated set of all hte observations compatible with it. | |
Private Types | |
| using | ValueType |
Private Member Functions | |
Constructor & destructor. | |
| void | _clearValue_ () |
| Template function dispatcher. | |
New Observation insertion methods | |
| void | _assumeValue_ (const Observation *obs) |
| Get value assumed by studied variable for current observation. | |
| Idx | _branchObs_ (const Observation *obs, const DiscreteVariable *var) |
| Seek modality assumed in obs for given var. | |
Private Attributes | |
| Sequence< const DiscreteVariable * > | _varOrder_ |
| LeafAggregator | _lg_ |
| HashTable< NodeId, AbstractLeaf * > | _leafMap_ |
| Idx | _nbTotalObservation_ |
| The total number of observation added to this tree. | |
| double | _attributeSelectionThreshold_ |
| The threshold above which we consider variables to be dependant. | |
Incrementals methods | |
| void | addObservation (const Observation *) |
| Adds a new observation to the structure. | |
| void | updateGraph () |
| Updates the tree after a new observation has been added. | |
| void | updateNodeWithObservation_ (const Observation *newObs, NodeId currentNodeId) |
| Adds a new observation to the structure. | |
| NodeId | insertLeafNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, Set< const Observation * > *sonsMap) |
| Adds a new observation to the structure. | |
| void | chgNodeBoundVar_ (NodeId chgedNodeId, const DiscreteVariable *desiredVar) |
| Adds a new observation to the structure. | |
| void | removeNode_ (NodeId removedNodeId) |
| Adds a new observation to the structure. | |
| void | _addLeaf_ (NodeId) |
| Adds a new observation to the structure. | |
| void | _removeLeaf_ (NodeId) |
| Adds a new observation to the structure. | |
Updating private methods | |
| void | updateFunctionGraph () |
| Computes the score of the given variables for the given node. | |
| void | _updateScore_ (const DiscreteVariable *, NodeId, VariableSelector &vs) |
| Computes the score of the given variables for the given node. | |
| void | _downdateScore_ (const DiscreteVariable *, NodeId, VariableSelector &vs) |
| Computes the score of the given variables for the given node. | |
| 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 variable as a test. If so, the node is updated. | |
| void | _rebuildFunctionGraph_ () |
| Computes the score of the given variables for the given node. | |
| NodeId | _insertLeafInFunctionGraph_ (AbstractLeaf *, Int2Type< true >) |
| Computes the score of the given variables for the given node. | |
| NodeId | _insertLeafInFunctionGraph_ (AbstractLeaf *, Int2Type< false >) |
| Computes the score of the given variables for the given node. | |
Graph Structure update methods | |
| virtual void | updateVar (const DiscreteVariable *) |
| If a new modality appears to exists for given variable, call this method to turn every associated node to this variable into leaf. Graph has then indeed to be revised. | |
| 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. | |
| virtual void | transpose_ (NodeId, const DiscreteVariable *) |
| Installs given variable to the given node, ensuring that the variable is not present in its subtree. | |
| virtual NodeId | insertNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar) |
| inserts a new node in internal graph | |
| virtual NodeId | insertInternalNode_ (NodeDatabase< AttributeSelection, isScalar > *nDB, const DiscreteVariable *boundVar, NodeId *sonsMap) |
| inserts a new internal node in internal graph | |
|
privateinherited |
Definition at line 84 of file incrementalGraphLearner.h.
| gum::IMDDI< AttributeSelection, isScalar >::IMDDI | ( | MultiDimFunctionGraph< double > * | target, |
| double | attributeSelectionThreshold, | ||
| double | pairSelectionThreshold, | ||
| gum::VariableSet | attributeListe, | ||
| const DiscreteVariable * | learnedValue ) |
Variable Learner constructor.
Definition at line 74 of file imddi_tpl.h.
References IMDDI(), gum::IncrementalGraphLearner< AttributeSelection, false >::IncrementalGraphLearner(), _addLeaf_(), _attributeSelectionThreshold_, _lg_, _nbTotalObservation_, gum::IncrementalGraphLearner< AttributeSelection, false >::model_, and gum::IncrementalGraphLearner< AttributeSelection, false >::root_.
Referenced by IMDDI(), IMDDI(), and ~IMDDI().
| gum::IMDDI< AttributeSelection, isScalar >::IMDDI | ( | MultiDimFunctionGraph< double > * | target, |
| double | attributeSelectionThreshold, | ||
| double | pairSelectionThreshold, | ||
| gum::VariableSet | attributeListe ) |
Reward Learner constructor.
Definition at line 90 of file imddi_tpl.h.
References IMDDI(), gum::IncrementalGraphLearner< AttributeSelection, false >::IncrementalGraphLearner(), _addLeaf_(), _attributeSelectionThreshold_, _lg_, _nbTotalObservation_, gum::IncrementalGraphLearner< AttributeSelection, false >::model_, and gum::IncrementalGraphLearner< AttributeSelection, false >::root_.
| gum::IMDDI< AttributeSelection, isScalar >::~IMDDI | ( | ) |
Default destructor.
Definition at line 108 of file imddi_tpl.h.
References IMDDI(), and _leafMap_.
|
private |
Adds a new observation to the structure.
Definition at line 297 of file imddi_tpl.h.
References _leafMap_, _lg_, gum::IncrementalGraphLearner< AttributeSelection, false >::nodeId2Database_, and gum::IncrementalGraphLearner< AttributeSelection, false >::valueAssumed_.
Referenced by IMDDI(), IMDDI(), chgNodeBoundVar_(), and insertLeafNode_().
|
inlineprivateinherited |
Get value assumed by studied variable for current observation.
Definition at line 153 of file incrementalGraphLearner.h.
|
inlineprivateinherited |
Seek modality assumed in obs for given var.
Definition at line 168 of file incrementalGraphLearner.h.
Referenced by addObservation(), and insertLeafNode_().
|
inlineprivateinherited |
Template function dispatcher.
Definition at line 117 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner().
|
private |
Computes the score of the given variables for the given node.
Definition at line 200 of file imddi_tpl.h.
References _nbTotalObservation_, gum::VariableSelector::downdateScore(), and gum::IncrementalGraphLearner< AttributeSelection, false >::nodeId2Database_.
Referenced by _updateNodeSet_().
|
private |
Computes the score of the given variables for the given node.
Definition at line 402 of file imddi_tpl.h.
References gum::AbstractLeaf::effectif(), SOA_ALLOCATE, gum::IncrementalGraphLearner< AttributeSelection, false >::target_, gum::AbstractLeaf::total(), and gum::IncrementalGraphLearner< AttributeSelection, false >::value_.
|
private |
Computes the score of the given variables for the given node.
Definition at line 388 of file imddi_tpl.h.
References gum::AbstractLeaf::effectif(), gum::AbstractLeaf::nbModa(), gum::IncrementalGraphLearner< AttributeSelection, false >::target_, gum::AbstractLeaf::total(), and gum::IncrementalGraphLearner< AttributeSelection, false >::valueAssumed_.
Referenced by _rebuildFunctionGraph_().
|
private |
Computes the score of the given variables for the given node.
Definition at line 332 of file imddi_tpl.h.
References _insertLeafInFunctionGraph_(), _lg_, _varOrder_, gum::HashTable< Key, Val >::cbeginSafe(), gum::HashTable< Key, Val >::cendSafe(), gum::HashTable< Key, Val >::exists(), gum::HashTable< Key, Val >::insert(), gum::IncrementalGraphLearner< AttributeSelection, false >::nodeSonsMap_, gum::IncrementalGraphLearner< AttributeSelection, false >::root_, SOA_ALLOCATE, gum::IncrementalGraphLearner< AttributeSelection, false >::target_, gum::IncrementalGraphLearner< AttributeSelection, false >::value_, and gum::IncrementalGraphLearner< AttributeSelection, false >::var2Node_.
Referenced by updateFunctionGraph().
|
private |
Adds a new observation to the structure.
Definition at line 310 of file imddi_tpl.h.
References _leafMap_, and _lg_.
Referenced by chgNodeBoundVar_(), and removeNode_().
|
private |
For each node in the given set, this methods checks whether or not we should installed the given variable as a test. If so, the node is updated.
Definition at line 217 of file imddi_tpl.h.
References _attributeSelectionThreshold_, _downdateScore_(), _updateScore_(), gum::VariableSelector::begin(), gum::Set< Key >::beginSafe(), gum::Set< Key >::clear(), gum::VariableSelector::current(), gum::Set< Key >::endSafe(), gum::VariableSelector::hasNext(), gum::VariableSelector::next(), gum::IncrementalGraphLearner< AttributeSelection, false >::nodeId2Database_, gum::IncrementalGraphLearner< AttributeSelection, false >::nodeSonsMap_, gum::IncrementalGraphLearner< AttributeSelection, false >::nodeVarMap_, and gum::IncrementalGraphLearner< AttributeSelection, false >::transpose_().
Referenced by updateGraph().
|
private |
Computes the score of the given variables for the given node.
Definition at line 188 of file imddi_tpl.h.
References _nbTotalObservation_, gum::IncrementalGraphLearner< AttributeSelection, false >::nodeId2Database_, and gum::VariableSelector::updateScore().
Referenced by _updateNodeSet_(), and updateGraph().
|
virtual |
Adds a new observation to the structure.
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 121 of file imddi_tpl.h.
References _nbTotalObservation_, and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::addObservation().
|
protectedvirtual |
Adds a new observation to the structure.
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 274 of file imddi_tpl.h.
References _addLeaf_(), _removeLeaf_(), gum::IncrementalGraphLearner< AttributeSelection, isScalar >::chgNodeBoundVar_(), gum::IncrementalGraphLearner< AttributeSelection, false >::nodeVarMap_, and gum::IncrementalGraphLearner< AttributeSelection, false >::value_.
|
protectedvirtualinherited |
Turns the given node into a leaf if not already so.
Definition at line 230 of file incrementalGraphLearner_tpl.h.
References chgNodeBoundVar_(), nodeSonsMap_, nodeVarMap_, and value_.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::updateGraph(), and updateNode_().
|
protectedvirtualinherited |
inserts a new internal node in internal graph
| nDB | : the associated database |
| boundVar | : the associated variable |
| sonsMap | : a table giving node's sons node |
Definition at line 258 of file incrementalGraphLearner_tpl.h.
References setOfVars_, and value_.
|
protectedvirtual |
Adds a new observation to the structure.
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 256 of file imddi_tpl.h.
References _addLeaf_(), and gum::IncrementalGraphLearner< AttributeSelection, isScalar >::insertLeafNode_().
|
protectedvirtualinherited |
inserts a new node in internal graph
| nDB | : the associated database |
| boundVar | : the associated variable |
Reimplemented in gum::ITI< AttributeSelection, isScalar >.
Definition at line 246 of file incrementalGraphLearner_tpl.h.
References nodeVarMap_.
|
inlinevirtual |
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 174 of file imddi.h.
References _varOrder_, and gum::MultiDimFunctionGraph< GUM_SCALAR, TerminalNodePolicy >::add().
|
inlinevirtualinherited |
|
inlinevirtualinherited |
|
inlinevirtualinherited |
|
inlinevirtualinherited |
|
protectedvirtual |
Adds a new observation to the structure.
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 288 of file imddi_tpl.h.
References _removeLeaf_(), gum::IncrementalGraphLearner< AttributeSelection, false >::nodeVarMap_, gum::IncrementalGraphLearner< AttributeSelection, isScalar >::removeNode_(), and gum::IncrementalGraphLearner< AttributeSelection, false >::value_.
|
inlinevirtualinherited |
|
inlineinherited |
Definition at line 313 of file incrementalGraphLearner.h.
|
protectedvirtualinherited |
Installs given variable to the given node, ensuring that the variable is not present in its subtree.
Definition at line 236 of file incrementalGraphLearner_tpl.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), and updateVar().
|
virtual |
Computes the score of the given variables for the given node.
Implements gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 321 of file imddi_tpl.h.
References _rebuildFunctionGraph_(), and gum::IncrementalGraphLearner< AttributeSelection, false >::needUpdate_.
|
virtual |
Updates the tree after a new observation has been added.
Implements gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 139 of file imddi_tpl.h.
References _lg_, _updateNodeSet_(), _updateScore_(), _varOrder_, gum::VariableSelector::begin(), gum::Set< Key >::beginSafe(), gum::IncrementalGraphLearner< AttributeSelection, false >::convertNode2Leaf_(), gum::VariableSelector::current(), gum::Set< Key >::endSafe(), gum::VariableSelector::hasNext(), gum::Set< Key >::insert(), gum::VariableSelector::isEmpty(), gum::VariableSelector::next(), gum::IncrementalGraphLearner< AttributeSelection, false >::root_, gum::VariableSelector::select(), and gum::IncrementalGraphLearner< AttributeSelection, false >::setOfVars_.
|
protectedinherited |
From the given sets of node, selects randomly one and installs it on given node.
Chechks of course if node's current variable is not in that set first.
| nody | : the node we update |
| bestVars | : the set of interessting vars to be installed here |
Chechks of course if node's current variable is not in that set first.
| nody | : the node we update |
| bestVar | : the set of interessting vars to be installed here |
Definition at line 225 of file incrementalGraphLearner_tpl.h.
References convertNode2Leaf_(), leafDatabase_, and removeNode_().
Referenced by gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
protectedvirtual |
Adds a new observation to the structure.
Reimplemented from gum::IncrementalGraphLearner< AttributeSelection, false >.
Definition at line 127 of file imddi_tpl.h.
References _leafMap_, _lg_, gum::IncrementalGraphLearner< AttributeSelection, false >::nodeVarMap_, gum::IncrementalGraphLearner< AttributeSelection, isScalar >::updateNodeWithObservation_(), and gum::IncrementalGraphLearner< AttributeSelection, false >::value_.
|
virtualinherited |
If a new modality appears to exists for given variable, call this method to turn every associated node to this variable into leaf. Graph has then indeed to be revised.
Definition at line 207 of file incrementalGraphLearner_tpl.h.
References transpose_().
|
private |
The threshold above which we consider variables to be dependant.
Definition at line 192 of file imddi.h.
Referenced by IMDDI(), IMDDI(), and _updateNodeSet_().
|
private |
Definition at line 186 of file imddi.h.
Referenced by ~IMDDI(), _addLeaf_(), _removeLeaf_(), and updateNodeWithObservation_().
|
private |
Definition at line 184 of file imddi.h.
Referenced by IMDDI(), IMDDI(), _addLeaf_(), _rebuildFunctionGraph_(), _removeLeaf_(), updateGraph(), and updateNodeWithObservation_().
|
private |
The total number of observation added to this tree.
Definition at line 189 of file imddi.h.
Referenced by IMDDI(), IMDDI(), _downdateScore_(), _updateScore_(), and addObservation().
|
private |
Definition at line 182 of file imddi.h.
Referenced by _rebuildFunctionGraph_(), insertSetOfVars(), and updateGraph().
|
protectedinherited |
This hashtable binds to every leaf an associated set of all hte observations compatible with it.
Definition at line 403 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), insertLeafNode_(), and updateNode_().
|
protectedinherited |
The source of nodeId.
Definition at line 369 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::IMDDI(), and gum::IMDDI< AttributeSelection, isScalar >::IMDDI().
|
protectedinherited |
Definition at line 416 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::updateFunctionGraph().
|
protectedinherited |
This hashtable binds every node to an associated NodeDatabase which handles every observation that concerns that node.
Definition at line 397 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_addLeaf_(), gum::IMDDI< AttributeSelection, isScalar >::_downdateScore_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), gum::IMDDI< AttributeSelection, isScalar >::_updateScore_(), and gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
protectedinherited |
A table giving for any node a table mapping to its son idx is the modality of associated variable.
Definition at line 385 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), gum::ITI< AttributeSelection, isScalar >::_insertNodeInFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), addObservation(), convertNode2Leaf_(), removeNode_(), and gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
protectedinherited |
Gives for any node its associated variable.
Definition at line 379 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), gum::ITI< AttributeSelection, isScalar >::_insertNodeInFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_updateNodeSet_(), addObservation(), gum::IMDDI< AttributeSelection, isScalar >::chgNodeBoundVar_(), gum::ITI< AttributeSelection, isScalar >::chgNodeBoundVar_(), convertNode2Leaf_(), insertNode_(), gum::IMDDI< AttributeSelection, isScalar >::removeNode_(), gum::ITI< AttributeSelection, isScalar >::updateGraph(), and gum::IMDDI< AttributeSelection, isScalar >::updateNodeWithObservation_().
|
protectedinherited |
The root of the ordered tree.
Definition at line 374 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::IMDDI(), gum::IMDDI< AttributeSelection, isScalar >::IMDDI(), gum::ITI< AttributeSelection, isScalar >::ITI(), gum::ITI< AttributeSelection, isScalar >::ITI(), gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::updateFunctionGraph(), gum::IMDDI< AttributeSelection, isScalar >::updateGraph(), and gum::ITI< AttributeSelection, isScalar >::updateGraph().
|
protectedinherited |
|
protectedinherited |
The final diagram we're building.
Definition at line 409 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_insertLeafInFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::_insertLeafInFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::_insertNodeInFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_(), and gum::ITI< AttributeSelection, isScalar >::updateFunctionGraph().
|
protectedinherited |
Definition at line 413 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_insertLeafInFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::_insertNodeInFunctionGraph_(), gum::ITI< AttributeSelection, isScalar >::_insertTerminalNode_(), gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_(), gum::IMDDI< AttributeSelection, isScalar >::chgNodeBoundVar_(), chgNodeBoundVar_(), convertNode2Leaf_(), insertInternalNode_(), gum::IMDDI< AttributeSelection, isScalar >::removeNode_(), gum::ITI< AttributeSelection, isScalar >::updateGraph(), and gum::IMDDI< AttributeSelection, isScalar >::updateNodeWithObservation_().
|
protectedinherited |
Definition at line 414 of file incrementalGraphLearner.h.
Referenced by gum::IMDDI< AttributeSelection, isScalar >::_addLeaf_(), and gum::IMDDI< AttributeSelection, isScalar >::_insertLeafInFunctionGraph_().
|
protectedinherited |
Associates to any variable the list of all nodes associated to this variable.
Definition at line 391 of file incrementalGraphLearner.h.
Referenced by ~IncrementalGraphLearner(), and gum::IMDDI< AttributeSelection, isScalar >::_rebuildFunctionGraph_().