aGrUM  0.14.1
gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT > Class Template Reference

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

#include <graphChangesGenerator4K2.h>

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

Public Member Functions

Constructors / Destructors
GraphChangesGenerator4K2 (STRUCT_CONSTRAINT &constraint)
default constructor More...

GraphChangesGenerator4K2 (const GraphChangesGenerator4K2< STRUCT_CONSTRAINT > &from)
copy constructor More...

GraphChangesGenerator4K2 (GraphChangesGenerator4K2< STRUCT_CONSTRAINT > &&from)
move operator More...

virtual ~GraphChangesGenerator4K2 ()
destructor More...

Operators
GraphChangesGenerator4K2< STRUCT_CONSTRAINT > & operator= (const GraphChangesGenerator4K2< STRUCT_CONSTRAINT > &from)
copy operator More...

GraphChangesGenerator4K2< STRUCT_CONSTRAINT > & operator= (GraphChangesGenerator4K2< 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 generator will compute possible changes More...

notify the generator of a change applied to the graph More...

void modifyGraph (const ArcDeletion &change)
notify the generator of a change applied to the graph More...

void modifyGraph (const ArcReversal &change)
notify the generator of a change applied to the graph More...

void modifyGraph (const GraphChange &change)
notify the generator 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...

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

void setOrder (const Sequence< NodeId > &order)
set a new order on the random variables More...

void setOrder (const std::vector< NodeId > &order)
set a new order on the random variables 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

DiGraph _graph
the graph on which we generate operators More...

STRUCT_CONSTRAINT * _constraint
the structural constraint used to restrict the changes More...

Sequence< NodeId_order
the order on the variables More...

Set< GraphChange_legal_changes
the current set of graph changes 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::GraphChangesGenerator4K2< 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 GraphChangesGenerator4K2 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 GraphChangesGenerator4K2 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 GraphChangesGenerator4K2 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 operators. 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 118 of file graphChangesGenerator4K2.h.

◆ const_iterator

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

the const iterator for parsing the list of graph change operators

Definition at line 126 of file graphChangesGenerator4K2.h.

◆ iterator

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

the iterator for parsing the list of possible graph change operators

Definition at line 123 of file graphChangesGenerator4K2.h.

◆ GraphChangesGenerator4K2() [1/3]

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

default constructor

◆ GraphChangesGenerator4K2() [2/3]

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

copy constructor

◆ GraphChangesGenerator4K2() [3/3]

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

move operator

◆ ~GraphChangesGenerator4K2()

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

destructor

◆ _createChanges()

template<typename STRUCT_CONSTRAINT>
 void gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::_createChanges ( )
protected

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

◆ begin()

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

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

◆ clearChanges()

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

empty the set of possible change operators that can be applied

◆ constraint()

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

returns the constraint that is used by the generator

◆ end()

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

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

◆ modifyGraph() [1/4]

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

notify the generator of a change applied to the graph

◆ modifyGraph() [2/4]

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

notify the generator of a change applied to the graph

◆ modifyGraph() [3/4]

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

notify the generator of a change applied to the graph

◆ modifyGraph() [4/4]

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

notify the generator of a change applied to the graph

◆ notifyGetCompleted()

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

notifies the generator that we have parsed all its legal changes

◆ operator=() [1/2]

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

copy operator

◆ operator=() [2/2]

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

move operator

◆ setGraph()

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

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

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

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

◆ setOrder() [1/2]

template<typename STRUCT_CONSTRAINT>
 void gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::setOrder ( const Sequence< NodeId > & order )

set a new order on the random variables

◆ setOrder() [2/2]

template<typename STRUCT_CONSTRAINT>
 void gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::setOrder ( const std::vector< NodeId > & order )

set a new order on the random variables

Member Data Documentation

template<typename STRUCT_CONSTRAINT>
private

the max number of threads authorized

Definition at line 239 of file graphChangesGenerator4K2.h.

◆ _constraint

template<typename STRUCT_CONSTRAINT>
 STRUCT_CONSTRAINT* gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::_constraint
protected

the structural constraint used to restrict the changes

Definition at line 223 of file graphChangesGenerator4K2.h.

◆ _graph

template<typename STRUCT_CONSTRAINT>
 DiGraph gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::_graph
protected

the graph on which we generate operators

Definition at line 220 of file graphChangesGenerator4K2.h.

◆ _legal_changes

template<typename STRUCT_CONSTRAINT>
 Set< GraphChange > gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::_legal_changes
protected

the current set of graph changes

Definition at line 229 of file graphChangesGenerator4K2.h.

◆ _order

template<typename STRUCT_CONSTRAINT>
 Sequence< NodeId > gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::_order
protected

the order on the variables

Definition at line 226 of file graphChangesGenerator4K2.h.

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