aGrUM  0.13.2
gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > Class Template Reference

The mecanism to compute the next available graph changes for directed structure learning search algorithms. More...

#include <graphChangesSelector4DiGraph.h>

+ Collaboration diagram for gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >:

Public Member Functions

Constructors / Destructors
 GraphChangesSelector4DiGraph (SCORE &score, STRUCTURAL_CONSTRAINT &constraint, GRAPH_CHANGES_GENERATOR &changes_generator)
 default constructor More...
 
 GraphChangesSelector4DiGraph (const GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &from)
 copy constructor More...
 
 GraphChangesSelector4DiGraph (GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &&from)
 move constructor More...
 
 ~GraphChangesSelector4DiGraph ()
 destructor More...
 
Operators
GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > & operator= (const GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &from)
 copy operator More...
 
GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > & operator= (GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &&from)
 move operator More...
 
Accessors / Modifiers
GeneratorTypegraphChangeGenerator () const noexcept
 returns the generator used by the selector More...
 
bool empty ()
 indicates whether the selector still contains graph changes More...
 
bool empty (NodeId i)
 indicates whether the selector contains graph changes related to the ith node More...
 
const GraphChangebestChange ()
 returns the best graph change to examine More...
 
const GraphChangebestChange (NodeId i)
 returns the best graph change to examine related to the ith node More...
 
double bestScore ()
 return the score of the best graph change More...
 
double bestScore (NodeId i)
 return the score of the best graph change related to the ith node More...
 
void applyChange (const GraphChange &change)
 indicate to the selector that a change has been applied More...
 
void applyChangeWithoutScoreUpdate (const GraphChange &change)
 indicate to the selector that one of serveral changes has been applied More...
 
void updateScoresAfterAppliedChanges ()
 recompute all the scores after the application of several changes More...
 
bool isChangeValid (const GraphChange &change) const
 indicates whether a given change is valid or not More...
 
void setGraph (DiGraph &graph, const std::vector< Size > &modal)
 sets the graph from which scores are computed More...
 
std::vector< std::pair< NodeId, double > > nodesSortedByBestScore () const
 returns the set of queues sorted by decreasing top priority More...
 
std::vector< std::pair< Idx, double > > nodesUnsortedWithScore () const
 returns the set of queues top priorities More...
 

Public Types

using GeneratorType = GRAPH_CHANGES_GENERATOR
 the type of the generator More...
 

Detailed Description

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
class gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >

The mecanism to compute the next available graph changes for directed structure learning search algorithms.

Definition at line 49 of file graphChangesSelector4DiGraph.h.

Member Typedef Documentation

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
using gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::GeneratorType = GRAPH_CHANGES_GENERATOR

the type of the generator

Definition at line 52 of file graphChangesSelector4DiGraph.h.

Constructor & Destructor Documentation

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::GraphChangesSelector4DiGraph ( SCORE &  score,
STRUCTURAL_CONSTRAINT &  constraint,
GRAPH_CHANGES_GENERATOR &  changes_generator 
)

default constructor

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::GraphChangesSelector4DiGraph ( const GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &  from)

copy constructor

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::GraphChangesSelector4DiGraph ( GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &&  from)

move constructor

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::~GraphChangesSelector4DiGraph ( )

destructor

Member Function Documentation

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__addScoreToCompute ( Idx  change_index) const
private

prepare the next pack of score computations

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__findLegalChangesNeedingUpdate ( Set< Idx > &  changes_to_recompute,
NodeId  target_node 
)
private

finds the changes that are affected by a given node modification

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__getNewChanges ( )
private

get from the graph change generator a new set of changes

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__illegal2LegalChanges ( Set< Idx > &  changes_to_recompute)
private

remove the now legal changes from the illegal set

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__invalidateChange ( Idx  change_index)
private

put a change into the illegal set

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
bool gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__isChangeValid ( Idx  index) const
private

indicates whether a given change is valid or not

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__updateScores ( const Set< Idx > &  changes_to_recompute)
private

perform the necessary updates of the scores

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::applyChange ( const GraphChange change)

indicate to the selector that a change has been applied

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, 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.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
const GraphChange& gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::bestChange ( )

returns the best graph change to examine

Exceptions
NotFoundexception is thrown if the selector is empty
template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
const GraphChange& gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::bestChange ( 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.

Exceptions
NotFoundexception is thrown if the selector is empty
template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
double gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::bestScore ( )

return the score of the best graph change

Exceptions
NotFoundexception is thrown if the selector is empty
template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
double gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::bestScore ( 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.

Exceptions
NotFoundexception is thrown if the selector is empty
template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
bool gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::empty ( )

indicates whether the selector still contains graph changes

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
bool gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::empty ( NodeId  i)

indicates whether the selector contains graph changes related to the ith node

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
GeneratorType& gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::graphChangeGenerator ( ) const
noexcept

returns the generator used by the selector

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
bool gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::isChangeValid ( const GraphChange change) const

indicates whether a given change is valid or not

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
std::vector< std::pair< NodeId, double > > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::nodesSortedByBestScore ( ) const

returns the set of queues sorted by decreasing top priority

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
std::vector< std::pair< Idx, double > > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::nodesUnsortedWithScore ( ) const

returns the set of queues top priorities

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >& gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::operator= ( const GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &  from)

copy operator

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >& gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::operator= ( GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR > &&  from)

move operator

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::setGraph ( DiGraph graph,
const std::vector< Size > &  modal 
)

sets the graph from which scores are computed

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
void gum::learning::GraphChangesSelector4DiGraph< SCORE, 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.

Member Data Documentation

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
std::vector< PriorityQueue< Idx, double, std::greater< double > > > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__change_queue_per_node
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 200 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
std::vector< std::pair< double, double > > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__change_scores
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 193 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
Sequence< GraphChange > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__changes
private

a sequence containing all the possible changes

Definition at line 189 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
GRAPH_CHANGES_GENERATOR* gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__changes_generator
private

the generator that returns the set of possible changes

Definition at line 186 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
STRUCTURAL_CONSTRAINT* gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__constraint
private

the set of constraints used to determine valid changes

Definition at line 183 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
Set< Idx > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__illegal_changes
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 209 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
std::vector< double > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__node_current_scores
private

the current score of each node

Definition at line 212 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
PriorityQueue< NodeId, double, std::greater< double > > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__node_queue
private

a global priority queue indicating for each node its best score

Definition at line 203 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
std::vector< std::vector< Idx > > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__parents
private

the set of parents of each node (speeds-up score computations)

Definition at line 215 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
Set< Idx > gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__queues_to_update
private

the set of queues to update when applying several changes

Definition at line 222 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
bool gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__queues_valid {false}
private

indicates whether we need to recompute whether the queue is empty or not

Definition at line 219 of file graphChangesSelector4DiGraph.h.

template<typename SCORE, typename STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR>
SCORE* gum::learning::GraphChangesSelector4DiGraph< SCORE, STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR >::__score
private

the scoring function

Definition at line 180 of file graphChangesSelector4DiGraph.h.


The documentation for this class was generated from the following file: