aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > 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< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >:

Public Member Functions

Constructors / Destructors
 GraphChangesSelector4DiGraph (Score< ALLOC > &score, STRUCTURAL_CONSTRAINT &constraint, GRAPH_CHANGES_GENERATOR &changes_generator)
 default constructor More...
 
 GraphChangesSelector4DiGraph (const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &from)
 copy constructor More...
 
 GraphChangesSelector4DiGraph (GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &&from)
 move constructor More...
 
 ~GraphChangesSelector4DiGraph ()
 destructor More...
 
Operators
GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > & operator= (const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &from)
 copy operator More...
 
GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > & operator= (GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &&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 (const 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 (const 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 (const 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)
 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< NodeId, 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 STRUCTURAL_CONSTRAINT, typename GRAPH_CHANGES_GENERATOR, template< typename > class ALLOC = std::allocator>
class gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >

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

Definition at line 53 of file graphChangesSelector4DiGraph.h.

Member Typedef Documentation

◆ GeneratorType

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
using gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::GeneratorType = GRAPH_CHANGES_GENERATOR

the type of the generator

Definition at line 56 of file graphChangesSelector4DiGraph.h.

Constructor & Destructor Documentation

◆ GraphChangesSelector4DiGraph() [1/3]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::GraphChangesSelector4DiGraph ( Score< ALLOC > &  score,
STRUCTURAL_CONSTRAINT &  constraint,
GRAPH_CHANGES_GENERATOR &  changes_generator 
)

default constructor

◆ GraphChangesSelector4DiGraph() [2/3]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::GraphChangesSelector4DiGraph ( const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &  from)

copy constructor

◆ GraphChangesSelector4DiGraph() [3/3]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::GraphChangesSelector4DiGraph ( GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &&  from)

move constructor

◆ ~GraphChangesSelector4DiGraph()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::~GraphChangesSelector4DiGraph ( )

destructor

Member Function Documentation

◆ _findLegalChangesNeedingUpdate_()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_findLegalChangesNeedingUpdate_ ( Set< std::size_t > &  changes_to_recompute,
const NodeId  target_node 
)
private

finds the changes that are affected by a given node modification

◆ _getNewChanges_()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_getNewChanges_ ( )
private

get from the graph change generator a new set of changes

◆ _illegal2LegalChanges_()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_illegal2LegalChanges_ ( Set< std::size_t > &  changes_to_recompute)
private

remove the now legal changes from the illegal set

◆ _invalidateChange_()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_invalidateChange_ ( const std::size_t  change_index)
private

put a change into the illegal set

◆ _isChangeValid_()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
bool gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_isChangeValid_ ( const std::size_t  index) const
private

indicates whether a given change is valid or not

◆ _updateScores_()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_updateScores_ ( const Set< std::size_t > &  changes_to_recompute)
private

perform the necessary updates of the scores

◆ applyChange()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::applyChange ( const GraphChange change)

indicate to the selector that a change has been applied

◆ applyChangeWithoutScoreUpdate()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::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.

◆ bestChange() [1/2]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
const GraphChange& gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::bestChange ( )

returns the best graph change to examine

Exceptions
NotFoundexception is thrown if the selector is empty

◆ bestChange() [2/2]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
const GraphChange& gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::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.

Exceptions
NotFoundexception is thrown if the selector is empty

◆ bestScore() [1/2]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
double gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::bestScore ( )

return the score of the best graph change

Exceptions
NotFoundexception is thrown if the selector is empty

◆ bestScore() [2/2]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
double gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::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.

Exceptions
NotFoundexception is thrown if the selector is empty

◆ empty() [1/2]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
bool gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::empty ( )

indicates whether the selector still contains graph changes

◆ empty() [2/2]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
bool gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::empty ( const NodeId  i)

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

◆ graphChangeGenerator()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
GeneratorType& gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::graphChangeGenerator ( ) const
noexcept

returns the generator used by the selector

◆ isChangeValid()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
bool gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::isChangeValid ( const GraphChange change) const

indicates whether a given change is valid or not

◆ nodesSortedByBestScore()

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

returns the set of queues sorted by decreasing top priority

◆ nodesUnsortedWithScore()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
std::vector< std::pair< NodeId, double > > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::nodesUnsortedWithScore ( ) const

returns the set of queues top priorities

◆ operator=() [1/2]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >& gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::operator= ( const GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &  from)

copy operator

◆ operator=() [2/2]

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >& gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::operator= ( GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC > &&  from)

move operator

◆ setGraph()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::setGraph ( DiGraph graph)

sets the graph from which scores are computed

◆ updateScoresAfterAppliedChanges()

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
void gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::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

◆ _change_queue_per_node_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
NodeProperty< PriorityQueue< std::size_t, double, std::greater< double > > > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_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 196 of file graphChangesSelector4DiGraph.h.

◆ _change_scores_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
std::vector< std::pair< double, double > > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_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 190 of file graphChangesSelector4DiGraph.h.

◆ _changes_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
Sequence< GraphChange > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_changes_
private

a sequence containing all the possible changes

Definition at line 186 of file graphChangesSelector4DiGraph.h.

◆ _changes_generator_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
GRAPH_CHANGES_GENERATOR* gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_changes_generator_
private

the generator that returns the set of possible changes

Definition at line 183 of file graphChangesSelector4DiGraph.h.

◆ _constraint_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
STRUCTURAL_CONSTRAINT* gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_constraint_
private

the set of constraints used to determine valid changes

Definition at line 180 of file graphChangesSelector4DiGraph.h.

◆ _illegal_changes_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
Set< std::size_t > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_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 204 of file graphChangesSelector4DiGraph.h.

◆ _node_current_scores_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
NodeProperty< double > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_node_current_scores_
private

the current score of each node

Definition at line 207 of file graphChangesSelector4DiGraph.h.

◆ _node_queue_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
PriorityQueue< NodeId, double, std::greater< double > > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_node_queue_
private

a global priority queue indicating for each node its best score

Definition at line 199 of file graphChangesSelector4DiGraph.h.

◆ _parents_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
NodeProperty< std::vector< NodeId, ALLOC< NodeId > > > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_parents_
private

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

Definition at line 210 of file graphChangesSelector4DiGraph.h.

◆ _queues_to_update_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
Set< NodeId > gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_queues_to_update_
private

the set of queues to update when applying several changes

Definition at line 216 of file graphChangesSelector4DiGraph.h.

◆ _queues_valid_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
bool gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_queues_valid_ {false}
private

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

Definition at line 213 of file graphChangesSelector4DiGraph.h.

◆ _score_

template<typename STRUCTURAL_CONSTRAINT , typename GRAPH_CHANGES_GENERATOR , template< typename > class ALLOC = std::allocator>
Score< ALLOC >* gum::learning::GraphChangesSelector4DiGraph< STRUCTURAL_CONSTRAINT, GRAPH_CHANGES_GENERATOR, ALLOC >::_score_
private

the scoring function

Definition at line 177 of file graphChangesSelector4DiGraph.h.


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