![]() |
aGrUM 2.3.2
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 Types | |
| using | GeneratorType = GRAPH_CHANGES_GENERATOR |
| the type of the generator | |
Public Member Functions | |
Constructors / Destructors | |
| GraphChangesSelector4DiGraph (Score &score, STRUCTURAL_CONSTRAINT &constraint, GRAPH_CHANGES_GENERATOR &changes_generator) | |
| default constructor | |
| GraphChangesSelector4DiGraph (const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &from) | |
| copy constructor | |
| GraphChangesSelector4DiGraph (GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &&from) | |
| move constructor | |
| ~GraphChangesSelector4DiGraph () | |
| destructor | |
Operators | |
| GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > & | operator= (const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &from) |
| copy operator | |
| GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > & | operator= (GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &&from) |
| move operator | |
Accessors / Modifiers | |
| GeneratorType & | graphChangeGenerator () const noexcept |
| returns the generator used by the selector | |
| bool | empty () |
| indicates whether the selector still contains graph changes | |
| bool | empty (const NodeId i) |
| indicates whether the selector contains graph changes related to the ith node | |
| const GraphChange & | bestChange () |
| returns the best graph change to examine | |
| const GraphChange & | bestChange (const NodeId i) |
| returns the best graph change to examine related to the ith node | |
| double | bestScore () |
| return the score of the best graph change | |
| double | bestScore (const NodeId i) |
| return the score of the best graph change related to the ith node | |
| void | applyChange (const GraphChange &change) |
| indicate to the selector that a change has been applied | |
| void | applyChangeWithoutScoreUpdate (const GraphChange &change) |
| indicate to the selector that one of serveral changes has been applied | |
| void | updateScoresAfterAppliedChanges () |
| recompute all the scores after the application of several changes | |
| 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 | |
| std::vector< std::pair< NodeId, double > > | nodesSortedByBestScore () const |
| returns the set of queues sorted by decreasing top priority | |
| std::vector< std::pair< NodeId, double > > | nodesUnsortedWithScore () const |
| returns the set of queues top priorities | |
Private Member Functions | |
| bool | _isChangeValid_ (const std::size_t index) const |
| indicates whether a given change is valid or not | |
| void | _invalidateChange_ (const std::size_t change_index) |
| put a change into the illegal set | |
| void | _illegal2LegalChanges_ (Set< std::size_t > &changes_to_recompute) |
| remove the now legal changes from the illegal set | |
| void | _findLegalChangesNeedingUpdate_ (Set< std::size_t > &changes_to_recompute, const NodeId target_node) |
| finds the changes that are affected by a given node modification | |
| void | _updateScores_ (const Set< std::size_t > &changes_to_recompute) |
| perform the necessary updates of the scores | |
| void | _getNewChanges_ () |
| get from the graph change generator a new set of changes | |
Private Attributes | |
| Score * | _score_ |
| the scoring function | |
| STRUCTURAL_CONSTRAINT * | _constraint_ |
| the set of constraints used to determine valid changes | |
| GRAPH_CHANGES_GENERATOR * | _changes_generator_ |
| the generator that returns the set of possible changes | |
| Sequence< GraphChange > | _changes_ |
| a sequence containing all the possible changes | |
| std::vector< std::pair< double, double > > | _change_scores_ |
| the scores for the head and tail of all the changes | |
| NodeProperty< PriorityQueue< std::size_t, double, std::greater< double > > > | _change_queue_per_node_ |
| for each node, a priority queue sorting GraphChanges by decreasing score | |
| PriorityQueue< NodeId, double, std::greater< double > > | _node_queue_ |
| a global priority queue indicating for each node its best score | |
| Set< std::size_t > | _illegal_changes_ |
| the set of changes known to be currently illegal (due to the constraints) | |
| NodeProperty< double > | _node_current_scores_ |
| the current score of each node | |
| NodeProperty< std::vector< NodeId > > | _parents_ |
| the set of parents of each node (speeds-up score computations) | |
| bool | _queues_valid_ {false} |
| indicates whether we need to recompute whether the queue is empty or not | |
| Set< NodeId > | _queues_to_update_ |
| the set of queues to update when applying several changes | |
The mecanism to compute the next available graph changes for directed structure learning search algorithms.
Definition at line 67 of file graphChangesSelector4DiGraph.h.
| using gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::GeneratorType = GRAPH_CHANGES_GENERATOR |
the type of the generator
Definition at line 70 of file graphChangesSelector4DiGraph.h.
| gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::GraphChangesSelector4DiGraph | ( | Score & | score, |
| STRUCTURAL_CONSTRAINT & | constraint, | ||
| GRAPH_CHANGES_GENERATOR & | changes_generator ) |
default constructor
Referenced by GraphChangesSelector4DiGraph(), GraphChangesSelector4DiGraph(), ~GraphChangesSelector4DiGraph(), operator=(), and operator=().
| gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::GraphChangesSelector4DiGraph | ( | const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > & | from | ) |
copy constructor
References GraphChangesSelector4DiGraph().
| gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::GraphChangesSelector4DiGraph | ( | GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > && | from | ) |
move constructor
References GraphChangesSelector4DiGraph().
| gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::~GraphChangesSelector4DiGraph | ( | ) |
|
private |
finds the changes that are affected by a given node modification
|
private |
get from the graph change generator a new set of changes
|
private |
remove the now legal changes from the illegal set
|
private |
put a change into the illegal set
|
private |
indicates whether a given change is valid or not
|
private |
perform the necessary updates of the scores
| void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::applyChange | ( | const GraphChange & | change | ) |
indicate to the selector that a change has been applied
References applyChange().
Referenced by applyChange().
| void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::applyChangeWithoutScoreUpdate | ( | const GraphChange & | change | ) |
indicate to the selector that one of serveral changes has been applied
This function is to be used rather than applyChange when we wish to apply several changes at a time. It is faster than applyChange because it does not recomputes the scores. Then, after applying all changes, we shall compute the scores with function updateScoresAfterAppliedChanges (). See class GreedyHillClimbing for an illustration of the use of this method.
References applyChangeWithoutScoreUpdate().
Referenced by applyChangeWithoutScoreUpdate().
| const GraphChange & gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::bestChange | ( | ) |
returns the best graph change to examine
| NotFound | exception is thrown if the selector is empty |
References bestChange().
Referenced by bestChange(), and bestChange().
| const GraphChange & gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::bestChange | ( | const NodeId | i | ) |
returns the best graph change to examine related to the ith node
The selector computes not only the best change possible but also the best changes impacting the parents' set of each node. This method allows to get the change that is considered the best for modifying the parents' set of the ith node.
| NotFound | exception is thrown if the selector is empty |
References bestChange().
| double gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::bestScore | ( | ) |
return the score of the best graph change
| NotFound | exception is thrown if the selector is empty |
References bestScore().
Referenced by bestScore(), and bestScore().
| double gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::bestScore | ( | const NodeId | i | ) |
return the score of the best graph change related to the ith node
The selector computes not only the best change possible but also the best changes impacting the parents' set of each node. This method allows to get the score of the change that is considered the best for modifying the parents' set of the ith node.
| NotFound | exception is thrown if the selector is empty |
References bestScore().
| bool gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::empty | ( | ) |
| bool gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::empty | ( | const NodeId | i | ) |
indicates whether the selector contains graph changes related to the ith node
References empty().
|
noexcept |
returns the generator used by the selector
| bool gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::isChangeValid | ( | const GraphChange & | change | ) | const |
indicates whether a given change is valid or not
References isChangeValid().
Referenced by isChangeValid().
| std::vector< std::pair< NodeId, double > > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::nodesSortedByBestScore | ( | ) | const |
returns the set of queues sorted by decreasing top priority
References nodesSortedByBestScore().
Referenced by nodesSortedByBestScore().
| std::vector< std::pair< NodeId, double > > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::nodesUnsortedWithScore | ( | ) | const |
returns the set of queues top priorities
References nodesUnsortedWithScore().
Referenced by nodesUnsortedWithScore().
| GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > & gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::operator= | ( | const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > & | from | ) |
| GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > & gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::operator= | ( | GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > && | from | ) |
| void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::setGraph | ( | DiGraph & | graph | ) |
sets the graph from which scores are computed
References setGraph().
Referenced by setGraph().
| void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::updateScoresAfterAppliedChanges | ( | ) |
recompute all the scores after the application of several changes
This method needs COMPULSORILY be used after applications of applyChangeWithoutScoreUpdate in order to ensure the fact that functions bestScore and bestChange return correct answers. See class GreedyHillClimbing for an illustration of the use of this method.
References updateScoresAfterAppliedChanges().
Referenced by updateScoresAfterAppliedChanges().
|
private |
for each node, a priority queue sorting GraphChanges by decreasing score
within each queue, the changes are determined by their index in sequence changes.
Definition at line 206 of file graphChangesSelector4DiGraph.h.
|
private |
the scores for the head and tail of all the changes
the scores are indexed by their index in sequence changes
Definition at line 200 of file graphChangesSelector4DiGraph.h.
|
private |
a sequence containing all the possible changes
Definition at line 196 of file graphChangesSelector4DiGraph.h.
|
private |
the generator that returns the set of possible changes
Definition at line 193 of file graphChangesSelector4DiGraph.h.
|
private |
the set of constraints used to determine valid changes
Definition at line 190 of file graphChangesSelector4DiGraph.h.
|
private |
the set of changes known to be currently illegal (due to the constraints)
within each queue, the changes are determined by their index in sequence changes.
Definition at line 214 of file graphChangesSelector4DiGraph.h.
|
private |
the current score of each node
Definition at line 217 of file graphChangesSelector4DiGraph.h.
|
private |
a global priority queue indicating for each node its best score
Definition at line 209 of file graphChangesSelector4DiGraph.h.
|
private |
the set of parents of each node (speeds-up score computations)
Definition at line 220 of file graphChangesSelector4DiGraph.h.
|
private |
the set of queues to update when applying several changes
Definition at line 226 of file graphChangesSelector4DiGraph.h.
|
private |
indicates whether we need to recompute whether the queue is empty or not
Definition at line 223 of file graphChangesSelector4DiGraph.h.
|
private |
the scoring function
Definition at line 187 of file graphChangesSelector4DiGraph.h.