![]() |
aGrUM 3.1.1
a C++ library for (probabilistic) graphical models
|
The mecanism to compute the next available graph changes for directed structure learning search algorithms. More...
#include <graphChangesSelector4DiGraph.h>
Public Member Functions | |
Constructors / Destructors | |
| GraphChangesSelector4DiGraph (Score &score, INVARIABLE_CONSTRAINT_TYPE &invariable_constraints, VARIABLE_CONSTRAINT_TYPE &variable_constraints) | |
| default constructor | |
| GraphChangesSelector4DiGraph (const GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > &from) | |
| copy constructor | |
| GraphChangesSelector4DiGraph (GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > &&from) | |
| move constructor | |
| ~GraphChangesSelector4DiGraph () | |
| destructor | |
Operators | |
| GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > & | operator= (const GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > &from) |
| copy operator | |
| GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > & | operator= (GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > &&from) |
| move operator | |
Accessors / Modifiers | |
| const GraphChange & | bestChange () |
| returns the best graph change to examine | |
| double | bestDeltaScore () |
| return the score of the best graph change | |
| double | deltaScore (const GraphChange &change, const bool internal_change=false) const |
| return the score of a given change | |
| double | score (const NodeId node) const |
| returns the current score of a node | |
| void | applyChange (const GraphChange &change) |
| indicate to the selector that a change has been applied | |
| bool | isChangeValid (const GraphChange &change) const |
| indicates whether a given change is valid or not | |
| void | setGraph (DiGraph &graph) |
| sets the graph from which scores are computed | |
| void | finalizeGraph (DiGraph &graph) |
| adds some nodes that were removed because they did not belong to the database | |
| void | useArcAdditions (bool use) |
| sets whether or not the selector allows the application of arc additions | |
| void | useArcDeletions (bool use) |
| sets whether or not the selector allows the application of arc deletions | |
| void | useArcReversals (bool use) |
| sets whether or not the selector allows the application of arc reversals | |
| void | useArcTriangleDeletions (bool use) |
| sets whether or not the selector allows the application of arc triangle deletions | |
| bool | arcAdditionsEnabled () const |
| indicates whether the selector allows the application of arc additions | |
| bool | arcDeletionsEnabled () const |
| indicates whether the selector allows the application of arc deletions | |
| bool | arcReversalsEnabled () const |
| indicates whether the selector allows the application of arc reversals | |
| bool | arcTriangleDeletionsEnabled () const |
| indicates whether the selector allows the application of arc triangle deletions | |
| INVARIABLE_CONSTRAINT_TYPE & | invariableConstraints () |
| returns the set of invariable constraints used by the selector | |
| VARIABLE_CONSTRAINT_TYPE & | variableConstraints () |
| returns the set of variable constraints used by the selector | |
Private Member Functions | |
| double | _scoreAfterAddingParent_ (const NodeId node, const NodeId new_parent) |
| computes the new score of node given that we added it a new parent | |
| double | _scoreAfterAddingParents_ (const NodeId node, const NodeId new_parent1, const NodeId new_parent2) |
| computes the new score of node given that we added it two new parents | |
| double | _scoreAfterRemovingParent_ (const NodeId node, const NodeId parent) |
| computes the new score of node given that we removed a parent | |
| double | _scoreAfterRemovingParents_ (const NodeId node, const NodeId parent1, const NodeId parent2) |
| computes the new score of node given that we removed two parents | |
| void | _addArcAdditionToSortedChanges_ (const ArcAddition &change) |
| adds an ArcAddition to sorted_changes if possible | |
| void | _addArcDeletionToSortedChanges_ (const ArcDeletion &change) |
| adds an ArcDeletion to sorted_changes if possible | |
| void | _addArcReversalToSortedChanges_ (const ArcReversal &change) |
| adds an ArcReversal to sorted_changes if possible | |
| void | _addArcTriangleDeletion1ToSortedChanges_ (const ArcTriangleDeletion1 &change) |
| adds an ArcTriangleDeletion1 to sorted_changes if possible | |
| void | _addArcTriangleDeletion2ToSortedChanges_ (const ArcTriangleDeletion2 &change) |
| adds an ArcTriangleDeletion2 to sorted_changes if possible | |
| void | _updateArcAdditionScore_ (const NodeId tail, const NodeId head) |
| updates the score of a given ArcAddition | |
| void | _updateArcDeletionScore_ (const NodeId tail, const NodeId head) |
| updates the score of a given ArcDeletion | |
| void | _updateArcReversalScore_ (const NodeId tail, const NodeId head) |
| updates the score of a given ArcReversal | |
| void | _updateTriangleDeletionsScoresFromNeighborhood_ (const NodeId changed_node) |
| update the score of the triangle deletions which contain a node whose neighborhood has changed | |
| void | _initSortedChangesWithArcAdditions_ (const DiGraph &graph) |
| add all the possible ArcAdditions to initialize sorted_changes | |
| void | _initSortedChangesWithArcDeletions_ (const DiGraph &graph) |
| add all the possible ArcDeletions to initialize sorted_changes | |
| void | _initSortedChangesWithArcReversals_ (const DiGraph &graph) |
| add all the possible ArcReversals to initialize sorted_changes | |
| void | _initSortedChangesWithArcTriangleDeletions_ (const DiGraph &graph) |
| add all the possible ArcTriangleDeletions to initialize sorted_changes | |
| void | _applyArcAddition_ (const ArcAddition &change, bool update_contraints) |
| indicate to the selector that an ArcAddition has been applied | |
| void | _applyArcDeletion_ (const ArcDeletion &change, bool update_contraints) |
| indicate to the selector that an ArcDeletion has been applied | |
| void | _applyArcReversal_ (const ArcReversal &change, bool update_contraints) |
| indicate to the selector that an ArcReversal has been applied | |
| void | _applyArcTriangleDeletion1_ (const ArcTriangleDeletion1 &change, bool update_contraints) |
| indicate to the selector that an ArcTriangleDeletion1 has been applied | |
| void | _applyArcTriangleDeletion2_ (const ArcTriangleDeletion2 &change, bool update_contraints) |
| indicate to the selector that an ArcTriangleDeletion2 has been applied | |
Private Attributes | |
| Score * | _score_ |
| the scoring function | |
| INVARIABLE_CONSTRAINT_TYPE * | _invariable_constraints_ |
| the set of constraints which, for a given change, always return the same output | |
| VARIABLE_CONSTRAINT_TYPE * | _variable_constraints_ |
| the set of constraints whose outputs can change depending on the current graph | |
| DiGraph * | _graph_ {nullptr} |
| the graph that we learn | |
| NodeProperty< double > | _node_scores_ |
| the current score of each node | |
| NodeProperty< std::vector< NodeId > > | _node_parents_ |
| the set of parents of each node (speeds-up score computations) | |
| SortedPriorityQueue< GraphChange, double > | _sorted_changes_ |
| the graph changes sorted by decreasing delta score value | |
| NodeSet | _removed_nodes_ |
| the set of nodes removed from the graph passed in argument to the selector because they do not appear in the database | |
| bool | _use_arc_additions_ {true} |
| bool | _use_arc_deletions_ {true} |
| bool | _use_arc_reversals_ {true} |
| bool | _use_arc_triangle_deletions_ {true} |
The mecanism to compute the next available graph changes for directed structure learning search algorithms.
| INVARIABLE_CONSTRAINT_TYPE | invariable constraints are those constraints whose satisfaction does not depend on the current DiGraph. For instance topological ordering constraints always yield the same results whatever the digraph. |
| VARIABLE_CONSTRAINT_TYPE | variable constraints are those constraints that require examining the current DiGraph to determine whether they are satisfied or not. For instance, limits on the indegrees of the nodes can be reached or not depending on the DiGraph of interest. |
Definition at line 75 of file graphChangesSelector4DiGraph.h.
| gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::GraphChangesSelector4DiGraph | ( | Score & | score, |
| INVARIABLE_CONSTRAINT_TYPE & | invariable_constraints, | ||
| VARIABLE_CONSTRAINT_TYPE & | variable_constraints ) |
default constructor
| score | the score used to select the best next change |
| invariable_constraints | |
| variable_constraints | |
| changes_generator |
References score().
Referenced by GraphChangesSelector4DiGraph(), GraphChangesSelector4DiGraph(), ~GraphChangesSelector4DiGraph(), operator=(), and operator=().
| gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::GraphChangesSelector4DiGraph | ( | const GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > & | from | ) |
copy constructor
References GraphChangesSelector4DiGraph().
| gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::GraphChangesSelector4DiGraph | ( | GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > && | from | ) |
move constructor
References GraphChangesSelector4DiGraph().
| gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::~GraphChangesSelector4DiGraph | ( | ) |
|
private |
adds an ArcAddition to sorted_changes if possible
|
private |
adds an ArcDeletion to sorted_changes if possible
|
private |
adds an ArcReversal to sorted_changes if possible
|
private |
adds an ArcTriangleDeletion1 to sorted_changes if possible
|
private |
adds an ArcTriangleDeletion2 to sorted_changes if possible
|
private |
indicate to the selector that an ArcAddition has been applied
|
private |
indicate to the selector that an ArcDeletion has been applied
|
private |
indicate to the selector that an ArcReversal has been applied
|
private |
indicate to the selector that an ArcTriangleDeletion1 has been applied
|
private |
indicate to the selector that an ArcTriangleDeletion2 has been applied
|
private |
add all the possible ArcAdditions to initialize sorted_changes
|
private |
add all the possible ArcDeletions to initialize sorted_changes
|
private |
add all the possible ArcReversals to initialize sorted_changes
|
private |
add all the possible ArcTriangleDeletions to initialize sorted_changes
|
private |
computes the new score of node given that we added it a new parent
|
private |
computes the new score of node given that we added it two new parents
|
private |
computes the new score of node given that we removed a parent
|
private |
computes the new score of node given that we removed two parents
|
private |
updates the score of a given ArcAddition
|
private |
updates the score of a given ArcDeletion
|
private |
updates the score of a given ArcReversal
|
private |
update the score of the triangle deletions which contain a node whose neighborhood has changed
| void gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::applyChange | ( | const GraphChange & | change | ) |
indicate to the selector that a change has been applied
| bool gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::arcAdditionsEnabled | ( | ) | const |
indicates whether the selector allows the application of arc additions
| bool gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::arcDeletionsEnabled | ( | ) | const |
indicates whether the selector allows the application of arc deletions
| bool gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::arcReversalsEnabled | ( | ) | const |
indicates whether the selector allows the application of arc reversals
| bool gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::arcTriangleDeletionsEnabled | ( | ) | const |
indicates whether the selector allows the application of arc triangle deletions
| const GraphChange & gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::bestChange | ( | ) |
returns the best graph change to examine
| NotFound | exception is thrown if the selector is empty |
| double gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::bestDeltaScore | ( | ) |
return the score of the best graph change
| NotFound | exception is thrown if the selector is empty |
| double gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::deltaScore | ( | const GraphChange & | change, |
| const bool | internal_change = false ) const |
return the score of a given change
| change | the GraphChange whose delta score we want |
| internal_change | If the change is stored in memory within the selector (essentially, it results from a call to method bestChange), then set internal_change to true. This will speed-up the computations. Otherwise, set it to false. |
| NotFound | exception is thrown if the selector is empty |
| void gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::finalizeGraph | ( | DiGraph & | graph | ) |
adds some nodes that were removed because they did not belong to the database
This function should be called at the end of the learning in order to add to the learnt graph all the nodes that were removed from it because we had no data over them
| INVARIABLE_CONSTRAINT_TYPE & gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::invariableConstraints | ( | ) |
returns the set of invariable constraints used by the selector
| bool gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::isChangeValid | ( | const GraphChange & | change | ) | const |
indicates whether a given change is valid or not
| GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > & gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::operator= | ( | const GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > & | from | ) |
| GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > & gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::operator= | ( | GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE > && | from | ) |
| double gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::score | ( | const NodeId | node | ) | const |
returns the current score of a node
Referenced by GraphChangesSelector4DiGraph().
| void gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::setGraph | ( | DiGraph & | graph | ) |
sets the graph from which scores are computed
| void gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::useArcAdditions | ( | bool | use | ) |
sets whether or not the selector allows the application of arc additions
Referenced by gum::learning::IBNLearner::learnDag_().
| void gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::useArcDeletions | ( | bool | use | ) |
sets whether or not the selector allows the application of arc deletions
Referenced by gum::learning::IBNLearner::learnDag_().
| void gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::useArcReversals | ( | bool | use | ) |
sets whether or not the selector allows the application of arc reversals
Referenced by gum::learning::IBNLearner::learnDag_().
| void gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::useArcTriangleDeletions | ( | bool | use | ) |
sets whether or not the selector allows the application of arc triangle deletions
Referenced by gum::learning::IBNLearner::learnDag_().
| VARIABLE_CONSTRAINT_TYPE & gum::learning::GraphChangesSelector4DiGraph< INVARIABLE_CONSTRAINT_TYPE, VARIABLE_CONSTRAINT_TYPE >::variableConstraints | ( | ) |
returns the set of variable constraints used by the selector
|
private |
the graph that we learn
Definition at line 231 of file graphChangesSelector4DiGraph.h.
|
private |
the set of constraints which, for a given change, always return the same output
An example of such a constraint is the slice order constraint: if x and y are in slices 1 and 2 respectively, it will always be impossible to add an arc y->x, whatever the current graph. Mandatory arcs and forbidden arcs are also constraints of this type.
Definition at line 218 of file graphChangesSelector4DiGraph.h.
|
private |
the set of parents of each node (speeds-up score computations)
Definition at line 237 of file graphChangesSelector4DiGraph.h.
|
private |
the current score of each node
Definition at line 234 of file graphChangesSelector4DiGraph.h.
|
private |
the set of nodes removed from the graph passed in argument to the selector because they do not appear in the database
Definition at line 257 of file graphChangesSelector4DiGraph.h.
|
private |
the scoring function
Definition at line 207 of file graphChangesSelector4DiGraph.h.
|
private |
the graph changes sorted by decreasing delta score value
The graph changes in this queue are those that are allowed according to the invariable_constraints. Their priority corresponds to the delta that should be added to the overall score of the graph if the graph change is applied.
Definition at line 251 of file graphChangesSelector4DiGraph.h.
|
private |
Definition at line 259 of file graphChangesSelector4DiGraph.h.
|
private |
Definition at line 260 of file graphChangesSelector4DiGraph.h.
|
private |
Definition at line 261 of file graphChangesSelector4DiGraph.h.
|
private |
Definition at line 262 of file graphChangesSelector4DiGraph.h.
|
private |
the set of constraints whose outputs can change depending on the current graph
An example of such a constraint is the indegree constraint: depending on the current number of parents of node x, it may or may not be possible to add a new arc incoming into x.
Definition at line 227 of file graphChangesSelector4DiGraph.h.