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

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

#include <graphChangesGenerator4DiGraph.h>

Inheritance diagram for gum::learning::GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT >:
Collaboration diagram for gum::learning::GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT >:

Public Types

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

Public Member Functions

Constructors / Destructors
 GraphChangesGenerator4DiGraph (STRUCT_CONSTRAINT &constraint)
 default constructor
 GraphChangesGenerator4DiGraph (const GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT > &from)
 copy constructor
 GraphChangesGenerator4DiGraph (GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT > &&from)
 move operator
virtual ~GraphChangesGenerator4DiGraph ()
 destructor
Operators
GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT > & operator= (const GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT > &from)
 copy operator
GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT > & operator= (GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT > &&from)
 move operator
Iterators
iterator begin () const
 returns an (unsafe) iterator on the beginning of the list of operators
const iteratorend () const
 returns an (unsafe) iterator on the end of the list of operators
Accessors / Modifiers
STRUCT_CONSTRAINT & constraint () const noexcept
 returns the constraint that is used by the generator
void setGraph (const DiGraph &graph)
 sets a new graph from which the generator will compute possible changes
void modifyGraph (const ArcAddition &change)
 notify the generator of a change applied to the graph
void modifyGraph (const ArcDeletion &change)
 notify the generator of a change applied to the graph
void modifyGraph (const ArcReversal &change)
 notify the generator of a change applied to the graph
void modifyGraph (const GraphChange &change)
 notify the generator of a change applied to the graph
void clearChanges () noexcept
 empty the set of possible change operators that can be applied
void notifyGetCompleted ()
 notifies the generator that we have parsed all its legal changes
void setMaxNbThreads (Size nb) noexcept
 sets the maximum number of threads used to compute the set of changes

Protected Member Functions

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

Protected Attributes

DiGraph graph_
 the graph on which we generate operators
STRUCT_CONSTRAINT * constraint_
 the structural constraint used to restrict the changes
Set< GraphChangelegal_changes_
 the current set of graph changes

Private Attributes

Size _max_threads_number_ {gum::getNumberOfThreads()}
 the max number of threads authorized

Detailed Description

template<typename STRUCT_CONSTRAINT>
class gum::learning::GraphChangesGenerator4DiGraph< 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 GraphChangesGenerator4DiGraph provides a simple way to compute those that we wish to perform. For instance, in the basic LocalSearch algorithm for learning directed graphs, one may expect that all possible arc additions, deletions and reversals can be applied and GraphChangesGenerator4DiGraph provides exactly this set of operations. However, there may be cases where we would like to apply these operators, say, only on a subgraph. In this case, we should use the derived class of GraphChangesGenerator4DiGraph named GraphChangesGeneratorOnSubDiGraph. Anyway, all the search generators should have the following minimal methods:

  • void setGraph ( const DiGraph& ) : assigns a new graph as a starting point to the generator of graph change operators
  • void modifyGraph ( const GraphChange& ) : indicate to the generator that the graph has been changed and that we need to compute the new operators that result from this change
  • void clearChanges () : empty the set of possible changes
  • methods begin () and end () that return iterators allowing to parse the available set of changes.

Basically, the idea is to use method setGraph at the beginning of the structure learning in order to initialize the possible set of changes. Then, parse this set using a for ( auto iter = generator.begin (); iter != generator.end (); ++iter ) loop and compute the scores induced by these changes. When this is done, flush the generator 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 135 of file graphChangesGenerator4DiGraph.h.

Member Typedef Documentation

◆ const_iterator

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

the const iterator for parsing the list of graph change operators

Definition at line 141 of file graphChangesGenerator4DiGraph.h.

◆ iterator

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

the iterator for parsing the list of possible graph change operators

Definition at line 138 of file graphChangesGenerator4DiGraph.h.

Constructor & Destructor Documentation

◆ GraphChangesGenerator4DiGraph() [1/3]

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

default constructor

References constraint().

Referenced by GraphChangesGenerator4DiGraph(), GraphChangesGenerator4DiGraph(), ~GraphChangesGenerator4DiGraph(), operator=(), and operator=().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GraphChangesGenerator4DiGraph() [2/3]

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

copy constructor

References GraphChangesGenerator4DiGraph().

Here is the call graph for this function:

◆ GraphChangesGenerator4DiGraph() [3/3]

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

move operator

References GraphChangesGenerator4DiGraph().

Here is the call graph for this function:

◆ ~GraphChangesGenerator4DiGraph()

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

destructor

References GraphChangesGenerator4DiGraph().

Here is the call graph for this function:

Member Function Documentation

◆ begin()

template<typename STRUCT_CONSTRAINT>
iterator gum::learning::GraphChangesGenerator4DiGraph< 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::GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT >::clearChanges ( )
virtualnoexcept

empty the set of possible change operators that can be applied

Implements gum::learning::IGraphChangesGenerator4DiGraph.

References clearChanges().

Referenced by clearChanges().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ constraint()

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

returns the constraint that is used by the generator

Referenced by GraphChangesGenerator4DiGraph().

Here is the caller graph for this function:

◆ createChanges_()

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

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

References createChanges_().

Referenced by createChanges_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

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

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

Implements gum::learning::IGraphChangesGenerator4DiGraph.

◆ modifyGraph() [1/4]

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

notify the generator of a change applied to the graph

Implements gum::learning::IGraphChangesGenerator4DiGraph.

References modifyGraph().

Referenced by modifyGraph(), modifyGraph(), modifyGraph(), and modifyGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ modifyGraph() [2/4]

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

notify the generator of a change applied to the graph

Implements gum::learning::IGraphChangesGenerator4DiGraph.

References modifyGraph().

Here is the call graph for this function:

◆ modifyGraph() [3/4]

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

notify the generator of a change applied to the graph

Implements gum::learning::IGraphChangesGenerator4DiGraph.

References modifyGraph().

Here is the call graph for this function:

◆ modifyGraph() [4/4]

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

notify the generator of a change applied to the graph

Implements gum::learning::IGraphChangesGenerator4DiGraph.

References modifyGraph().

Here is the call graph for this function:

◆ notifyGetCompleted()

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

notifies the generator that we have parsed all its legal changes

Implements gum::learning::IGraphChangesGenerator4DiGraph.

References notifyGetCompleted().

Referenced by notifyGetCompleted().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator=() [1/2]

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

copy operator

References GraphChangesGenerator4DiGraph().

Here is the call graph for this function:

◆ operator=() [2/2]

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

move operator

References GraphChangesGenerator4DiGraph().

Here is the call graph for this function:

◆ setGraph()

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

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

Implements gum::learning::IGraphChangesGenerator4DiGraph.

References setGraph().

Referenced by setGraph().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ setMaxNbThreads()

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

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

References setMaxNbThreads().

Referenced by setMaxNbThreads().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _max_threads_number_

template<typename STRUCT_CONSTRAINT>
Size gum::learning::GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT >::_max_threads_number_ {gum::getNumberOfThreads()}
private

the max number of threads authorized

Definition at line 240 of file graphChangesGenerator4DiGraph.h.

unsigned int getNumberOfThreads()
returns the max number of threads used by default when entering the next parallel region

◆ constraint_

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

the structural constraint used to restrict the changes

Definition at line 230 of file graphChangesGenerator4DiGraph.h.

◆ graph_

template<typename STRUCT_CONSTRAINT>
DiGraph gum::learning::GraphChangesGenerator4DiGraph< STRUCT_CONSTRAINT >::graph_
protected

the graph on which we generate operators

Definition at line 227 of file graphChangesGenerator4DiGraph.h.

◆ legal_changes_

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

the current set of graph changes

Definition at line 233 of file graphChangesGenerator4DiGraph.h.


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