aGrUM  0.20.3
a C++ library for (probabilistic) graphical models
gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > Class Template Reference

The basic class for computing the next graph changes possible in a structure learning algorithm. More...

#include <graphChangesGeneratorOnSubDiGraph.h>

+ Inheritance diagram for gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >:
+ Collaboration diagram for gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >:

Public Member Functions

Constructors / Destructors
 GraphChangesGeneratorOnSubDiGraph (STRUCT_CONSTRAINT &constraint)
 default constructor More...
 
 GraphChangesGeneratorOnSubDiGraph (const GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > &from)
 copy constructor More...
 
 GraphChangesGeneratorOnSubDiGraph (GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > &&from)
 move operator More...
 
virtual ~GraphChangesGeneratorOnSubDiGraph ()
 destructor More...
 
Operators
GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > & operator= (const GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > &from)
 copy operator More...
 
GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > & operator= (GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > &&from)
 move operator More...
 
Iterators
iterator begin () const
 returns an (unsafe) iterator on the beginning of the list of operators More...
 
const iteratorend () const
 returns an (unsafe) iterator on the end of the list of operators More...
 
Accessors / Modifiers
STRUCT_CONSTRAINT & constraint () const noexcept
 returns the constraint that is used by the generator More...
 
void setGraph (const DiGraph &graph)
 sets a new graph from which the operator will compute possible changes More...
 
void setTargets (const NodeSet &nodes)
 assign a set of target nodes More...
 
void addTarget (NodeId node)
 adds a new target node More...
 
void eraseTarget (NodeId node)
 removes a target More...
 
void setTails (const NodeSet &nodes)
 assign a set of "tail" nodes More...
 
void setTails (Size nb_nodes)
 assign a set of "tail" nodes from 0 to nb_nodes - 1 More...
 
void addTail (NodeId node)
 adds a new "tail" node More...
 
void eraseTail (NodeId node)
 removes a tail node More...
 
void modifyGraph (const ArcAddition &change)
 notify the operator set of a change applied to the graph More...
 
void modifyGraph (const ArcDeletion &change)
 notify the operator set of a change applied to the graph More...
 
void modifyGraph (const ArcReversal &change)
 notify the operator set of a change applied to the graph More...
 
void modifyGraph (const GraphChange &change)
 notify the operator set of a change applied to the graph More...
 
void clearChanges () noexcept
 empty the set of possible change operators that can be applied More...
 
void notifyGetCompleted ()
 notifies the generator that we have parsed all its legal changes More...
 
void setMaxNbThreads (Size nb) noexcept
 sets the maximum number of threads used to compute the set of changes More...
 

Public Types

using iterator = typename Set< GraphChange >::const_iterator
 the iterator for parsing the list of possible graph change operators More...
 
using const_iterator = iterator
 the const iterator for parsing the list of graph change operators More...
 

Protected Attributes

STRUCT_CONSTRAINT * constraint_
 a reference on the structural constraint used to restrict the changes More...
 
NodeSet target_nodes_
 the set of target nodes More...
 
NodeSet tail_nodes_
 the tail nodes (other extremities than the targets) More...
 
Set< GraphChangelegal_changes_
 the current set of operators More...
 

Protected Member Functions

void createChanges_ ()
 create the set of legal and illegal changes from a given graph More...
 

Detailed Description

template<typename STRUCT_CONSTRAINT>
class gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >

The basic class for computing the next graph changes possible in a structure learning algorithm.

Structure learning algorithm try different modifications of the graph. Class GraphChangesGeneratorOnSubDiGraph provides a simple way to compute those that we wish to perform when we wish to limit the set of changes over a subgraph of the graph we learn. For instance, we may wish to relearn an already partially learnt structure just around nodes A,B,C. In this case, we can set the set of target nodes of the GraphChangesGeneratorOnSubDiGraph to {A,B,C} and the set of "tail" nodes as all the nodes of the graph. In this case, only the arcs whose heads are A, B or C will be trnasmitted to the learning algorithm.

Basically, the idea is to use method setGraph at the beginning of the structure learning in order to initialize the possible set of operators. Then, parse this set using a for ( auto iter = operator_set.begin (); iter != operator_set.end (); ++iter ) loop and compute the scores induced by these changes. When this is done, flush the operator set by calling method clearChanges. Then iterate changes and after each new change applied, used again the iterator for loop, and so on. Note that, whenever you execute method modifyGraph, this will automatically flush the current list of changes and put into the list only the changes that are affected by the graph modification.

Definition at line 94 of file graphChangesGeneratorOnSubDiGraph.h.

Member Typedef Documentation

◆ const_iterator

template<typename STRUCT_CONSTRAINT >
using gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::const_iterator = iterator

the const iterator for parsing the list of graph change operators

Definition at line 100 of file graphChangesGeneratorOnSubDiGraph.h.

◆ iterator

template<typename STRUCT_CONSTRAINT >
using gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::iterator = typename Set< GraphChange >::const_iterator

the iterator for parsing the list of possible graph change operators

Definition at line 97 of file graphChangesGeneratorOnSubDiGraph.h.

Constructor & Destructor Documentation

◆ GraphChangesGeneratorOnSubDiGraph() [1/3]

template<typename STRUCT_CONSTRAINT >
gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::GraphChangesGeneratorOnSubDiGraph ( STRUCT_CONSTRAINT &  constraint)

default constructor

◆ GraphChangesGeneratorOnSubDiGraph() [2/3]

template<typename STRUCT_CONSTRAINT >
gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::GraphChangesGeneratorOnSubDiGraph ( const GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > &  from)

copy constructor

◆ GraphChangesGeneratorOnSubDiGraph() [3/3]

template<typename STRUCT_CONSTRAINT >
gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::GraphChangesGeneratorOnSubDiGraph ( GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > &&  from)

move operator

◆ ~GraphChangesGeneratorOnSubDiGraph()

template<typename STRUCT_CONSTRAINT >
virtual gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::~GraphChangesGeneratorOnSubDiGraph ( )
virtual

destructor

Member Function Documentation

◆ addTail()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::addTail ( NodeId  node)

adds a new "tail" node

◆ addTarget()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::addTarget ( NodeId  node)

adds a new target node

◆ begin()

template<typename STRUCT_CONSTRAINT >
iterator gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::begin ( ) const
virtual

returns an (unsafe) iterator on the beginning of the list of operators

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ clearChanges()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::clearChanges ( )
virtualnoexcept

empty the set of possible change operators that can be applied

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ constraint()

template<typename STRUCT_CONSTRAINT >
STRUCT_CONSTRAINT& gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::constraint ( ) const
noexcept

returns the constraint that is used by the generator

◆ createChanges_()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::createChanges_ ( )
protected

create the set of legal and illegal changes from a given graph

◆ end()

template<typename STRUCT_CONSTRAINT >
const iterator& gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::end ( ) const
virtual

returns an (unsafe) iterator on the end of the list of operators

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ eraseTail()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::eraseTail ( NodeId  node)

removes a tail node

◆ eraseTarget()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::eraseTarget ( NodeId  node)

removes a target

◆ modifyGraph() [1/4]

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::modifyGraph ( const ArcAddition change)
virtual

notify the operator set of a change applied to the graph

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ modifyGraph() [2/4]

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::modifyGraph ( const ArcDeletion change)
virtual

notify the operator set of a change applied to the graph

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ modifyGraph() [3/4]

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::modifyGraph ( const ArcReversal change)
virtual

notify the operator set of a change applied to the graph

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ modifyGraph() [4/4]

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::modifyGraph ( const GraphChange change)
virtual

notify the operator set of a change applied to the graph

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ notifyGetCompleted()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::notifyGetCompleted ( )
virtual

notifies the generator that we have parsed all its legal changes

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ operator=() [1/2]

template<typename STRUCT_CONSTRAINT >
GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >& gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::operator= ( const GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > &  from)

copy operator

◆ operator=() [2/2]

template<typename STRUCT_CONSTRAINT >
GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >& gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::operator= ( GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > &&  from)

move operator

◆ setGraph()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::setGraph ( const DiGraph graph)
virtual

sets a new graph from which the operator will compute possible changes

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ setMaxNbThreads()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::setMaxNbThreads ( Size  nb)
noexcept

sets the maximum number of threads used to compute the set of changes

◆ setTails() [1/2]

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::setTails ( const NodeSet nodes)

assign a set of "tail" nodes

◆ setTails() [2/2]

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::setTails ( Size  nb_nodes)

assign a set of "tail" nodes from 0 to nb_nodes - 1

◆ setTargets()

template<typename STRUCT_CONSTRAINT >
void gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::setTargets ( const NodeSet nodes)

assign a set of target nodes

Member Data Documentation

◆ _max_threads_number_

template<typename STRUCT_CONSTRAINT >
Size gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::_max_threads_number_ {1}
private

the max number of threads authorized

Definition at line 227 of file graphChangesGeneratorOnSubDiGraph.h.

◆ constraint_

template<typename STRUCT_CONSTRAINT >
STRUCT_CONSTRAINT* gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::constraint_
protected

a reference on the structural constraint used to restrict the changes

Definition at line 208 of file graphChangesGeneratorOnSubDiGraph.h.

◆ legal_changes_

template<typename STRUCT_CONSTRAINT >
Set< GraphChange > gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::legal_changes_
protected

the current set of operators

Definition at line 217 of file graphChangesGeneratorOnSubDiGraph.h.

◆ tail_nodes_

template<typename STRUCT_CONSTRAINT >
NodeSet gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::tail_nodes_
protected

the tail nodes (other extremities than the targets)

Definition at line 214 of file graphChangesGeneratorOnSubDiGraph.h.

◆ target_nodes_

template<typename STRUCT_CONSTRAINT >
NodeSet gum::learning::GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT >::target_nodes_
protected

the set of target nodes

Definition at line 211 of file graphChangesGeneratorOnSubDiGraph.h.


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