![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
The basic class for computing the next graph changes possible in a structure learning algorithm. More...
#include <graphChangesGenerator4K2.h>
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 | |
| GraphChangesGenerator4K2 (STRUCT_CONSTRAINT &constraint) | |
| default constructor | |
| GraphChangesGenerator4K2 (const GraphChangesGenerator4K2< STRUCT_CONSTRAINT > &from) | |
| copy constructor | |
| GraphChangesGenerator4K2 (GraphChangesGenerator4K2< STRUCT_CONSTRAINT > &&from) | |
| move operator | |
| virtual | ~GraphChangesGenerator4K2 () |
| destructor | |
Operators | |
| GraphChangesGenerator4K2< STRUCT_CONSTRAINT > & | operator= (const GraphChangesGenerator4K2< STRUCT_CONSTRAINT > &from) |
| copy operator | |
| GraphChangesGenerator4K2< STRUCT_CONSTRAINT > & | operator= (GraphChangesGenerator4K2< STRUCT_CONSTRAINT > &&from) |
| move operator | |
Iterators | |
| iterator | begin () const |
| returns an (unsafe) iterator on the beginning of the list of operators | |
| const iterator & | end () 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 | |
| void | setOrder (const Sequence< NodeId > &order) |
| set a new order on the random variables | |
| void | setOrder (const std::vector< NodeId > &order) |
| set a new order on the random variables | |
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 | |
| Sequence< NodeId > | order_ |
| the order on the variables | |
| Set< GraphChange > | legal_changes_ |
| the current set of graph changes | |
Private Attributes | |
| Size | _max_threads_number_ {gum::getNumberOfThreads()} |
| the max number of threads authorized | |
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:
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 137 of file graphChangesGenerator4K2.h.
| using gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::const_iterator = iterator |
the const iterator for parsing the list of graph change operators
Definition at line 145 of file graphChangesGenerator4K2.h.
| 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 142 of file graphChangesGenerator4K2.h.
| gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::GraphChangesGenerator4K2 | ( | STRUCT_CONSTRAINT & | constraint | ) |
default constructor
References constraint().
Referenced by GraphChangesGenerator4K2(), GraphChangesGenerator4K2(), ~GraphChangesGenerator4K2(), operator=(), and operator=().
| gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::GraphChangesGenerator4K2 | ( | const GraphChangesGenerator4K2< STRUCT_CONSTRAINT > & | from | ) |
| gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::GraphChangesGenerator4K2 | ( | GraphChangesGenerator4K2< STRUCT_CONSTRAINT > && | from | ) |
|
virtual |
|
virtual |
returns an (unsafe) iterator on the beginning of the list of operators
Implements gum::learning::IGraphChangesGenerator4DiGraph.
|
virtualnoexcept |
empty the set of possible change operators that can be applied
Implements gum::learning::IGraphChangesGenerator4DiGraph.
References clearChanges().
Referenced by clearChanges().
|
noexcept |
returns the constraint that is used by the generator
Referenced by GraphChangesGenerator4K2().
|
protected |
create the set of legal and illegal changes from a given graph
References createChanges_().
Referenced by createChanges_().
|
virtual |
returns an (unsafe) iterator on the end of the list of operators
Implements gum::learning::IGraphChangesGenerator4DiGraph.
|
virtual |
notify the generator of a change applied to the graph
Implements gum::learning::IGraphChangesGenerator4DiGraph.
References modifyGraph().
Referenced by modifyGraph(), modifyGraph(), modifyGraph(), and modifyGraph().
|
virtual |
notify the generator of a change applied to the graph
Implements gum::learning::IGraphChangesGenerator4DiGraph.
References modifyGraph().
|
virtual |
notify the generator of a change applied to the graph
Implements gum::learning::IGraphChangesGenerator4DiGraph.
References modifyGraph().
|
virtual |
notify the generator of a change applied to the graph
Implements gum::learning::IGraphChangesGenerator4DiGraph.
References modifyGraph().
|
virtual |
notifies the generator that we have parsed all its legal changes
Implements gum::learning::IGraphChangesGenerator4DiGraph.
References notifyGetCompleted().
Referenced by notifyGetCompleted().
| GraphChangesGenerator4K2< STRUCT_CONSTRAINT > & gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::operator= | ( | const GraphChangesGenerator4K2< STRUCT_CONSTRAINT > & | from | ) |
| GraphChangesGenerator4K2< STRUCT_CONSTRAINT > & gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::operator= | ( | GraphChangesGenerator4K2< STRUCT_CONSTRAINT > && | from | ) |
|
virtual |
sets a new graph from which the generator will compute possible changes
Implements gum::learning::IGraphChangesGenerator4DiGraph.
References setGraph().
Referenced by setGraph().
|
noexcept |
sets the maximum number of threads used to compute the set of changes
References setMaxNbThreads().
Referenced by setMaxNbThreads().
| void gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::setOrder | ( | const Sequence< NodeId > & | order | ) |
set a new order on the random variables
References setOrder().
Referenced by setOrder(), and setOrder().
| void gum::learning::GraphChangesGenerator4K2< STRUCT_CONSTRAINT >::setOrder | ( | const std::vector< NodeId > & | order | ) |
set a new order on the random variables
References setOrder().
|
private |
the max number of threads authorized
Definition at line 253 of file graphChangesGenerator4K2.h.
|
protected |
the structural constraint used to restrict the changes
Definition at line 240 of file graphChangesGenerator4K2.h.
|
protected |
the graph on which we generate operators
Definition at line 237 of file graphChangesGenerator4K2.h.
|
protected |
the current set of graph changes
Definition at line 246 of file graphChangesGenerator4K2.h.
|
protected |
the order on the variables
Definition at line 243 of file graphChangesGenerator4K2.h.