aGrUM  0.16.0
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 54 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 57 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 203 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 197 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 193 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 190 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 187 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 211 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 214 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 206 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 217 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 223 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 220 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 184 of file graphChangesSelector4DiGraph.h.


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