aGrUM  0.14.2
graphChangesGeneratorOnSubDiGraph.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005 by Christophe GONZALES and Pierre-Henri WUILLEMIN *
3  * {prenom.nom}@lip6.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it wil be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
47 #ifndef GUM_LEARNING_GRAPH_CHANGES_GENERATOR_ON_SUBDIGRAPH_H
48 #define GUM_LEARNING_GRAPH_CHANGES_GENERATOR_ON_SUBDIGRAPH_H
49 
50 #include <agrum/agrum.h>
51 #include <agrum/core/OMPThreads.h>
52 #include <agrum/core/set.h>
53 #include <agrum/graphs/diGraph.h>
56 
57 namespace gum {
58 
59  namespace learning {
60 
91  template < typename STRUCT_CONSTRAINT >
94  public:
97 
100 
101  // ##########################################################################
103  // ##########################################################################
105 
107  GraphChangesGeneratorOnSubDiGraph(STRUCT_CONSTRAINT& constraint);
108 
112 
116 
119 
121 
122  // ##########################################################################
124  // ##########################################################################
126 
130 
134 
136 
137  // ##########################################################################
139  // ##########################################################################
141 
143  iterator begin() const;
144 
146  const iterator& end() const;
147 
149 
150  // ##########################################################################
152  // ##########################################################################
154 
156  STRUCT_CONSTRAINT& constraint() const noexcept;
157 
159  void setGraph(const DiGraph& graph);
160 
162  void setTargets(const NodeSet& nodes);
163 
165  void addTarget(NodeId node);
166 
168  void eraseTarget(NodeId node);
169 
171  void setTails(const NodeSet& nodes);
172 
174  void setTails(Size nb_nodes);
175 
177  void addTail(NodeId node);
178 
180  void eraseTail(NodeId node);
181 
183  void modifyGraph(const ArcAddition& change);
184 
186  void modifyGraph(const ArcDeletion& change);
187 
189  void modifyGraph(const ArcReversal& change);
190 
192  void modifyGraph(const GraphChange& change);
193 
195  void clearChanges() noexcept;
196 
198  void notifyGetCompleted();
199 
201  void setMaxNbThreads(Size nb) noexcept;
202 
204 
205  protected:
207  STRUCT_CONSTRAINT* _constraint;
208 
211 
214 
217 
219  void _createChanges();
220 
221  private:
223 #if defined(_OPENMP) && !defined(GUM_DEBUG_MODE)
225 #else
227 #endif /* GUM_DEBUG_MODE */
228  };
229 
230  } /* namespace learning */
231 
232 } /* namespace gum */
233 
236 
237 #endif /* GUM_LEARNING_GRAPH_CHANGES_GENERATOR_ON_SUBDIGRAPH_H */
GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > & operator=(const GraphChangesGeneratorOnSubDiGraph< STRUCT_CONSTRAINT > &from)
copy operator
The base class for all GraphChangesGenerators for directed structures.
Base classes for oriented graphs.
NodeSet _tail_nodes
the tail nodes (other extremities than the targets)
STRUCT_CONSTRAINT & constraint() const noexcept
returns the constraint that is used by the generator
The basic class for computing the next graph changes possible in a structure learning algorithm...
Sets of elements (i.e.
the classes to account for structure changes in a graph
The class for notifying learning algorithms of new arc additionsThis class is convenient to know at c...
Definition: graphChange.h:147
Set< GraphChange > _legal_changes
the current set of operators
The class for computing the set of graph changes (over a subgraph) transmitted to learning algorithms...
void eraseTarget(NodeId node)
removes a target
GraphChangesGeneratorOnSubDiGraph(STRUCT_CONSTRAINT &constraint)
default constructor
void eraseTail(NodeId node)
removes a tail node
The class for notifying learning algorithms of arc removalsThis class is convenient to know at compil...
Definition: graphChange.h:213
unsigned int getMaxNumberOfThreads()
Returns the maximum number of threads at any time.
const iterator & end() const
returns an (unsafe) iterator on the end of the list of operators
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
void setTails(const NodeSet &nodes)
assign a set of "tail" nodes
void modifyGraph(const ArcAddition &change)
notify the operator set of a change applied to the graph
void clearChanges() noexcept
empty the set of possible change operators that can be applied
Size __max_threads_number
the max number of threads authorized
void setGraph(const DiGraph &graph)
sets a new graph from which the operator will compute possible changes
iterator const_iterator
the const iterator for parsing the list of graph change operators
void _createChanges()
create the set of legal and illegal changes from a given graph
iterator begin() const
returns an (unsafe) iterator on the beginning of the list of operators
Base class for all oriented graphs.
Definition: diGraph.h:108
STRUCT_CONSTRAINT * _constraint
a reference on the structural constraint used to restrict the changes
Wrappers for OpenMP.
Unsafe iterators for the Set class.
Definition: set.h:1022
void setMaxNbThreads(Size nb) noexcept
sets the maximum number of threads used to compute the set of changes
The class for notifying learning algorithms of arc reversalsThis class is convenient to know at compi...
Definition: graphChange.h:279
void setTargets(const NodeSet &nodes)
assign a set of target nodes
void addTarget(NodeId node)
adds a new target node
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
void addTail(NodeId node)
adds a new "tail" node
Size NodeId
Type for node ids.
Definition: graphElements.h:97
typename Set< GraphChange >::const_iterator iterator
the iterator for parsing the list of possible graph change operators
void notifyGetCompleted()
notifies the generator that we have parsed all its legal changes