aGrUM  0.14.2
graphChangesGenerator4K2.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  ***************************************************************************/
58 #ifndef GUM_LEARNING_GRAPH_CHANGES_GENERATOR_4_K2_H
59 #define GUM_LEARNING_GRAPH_CHANGES_GENERATOR_4_K2_H
60 
61 #include <agrum/agrum.h>
62 #include <agrum/core/OMPThreads.h>
63 #include <agrum/core/sequence.h>
64 #include <agrum/core/set.h>
65 
66 #include <agrum/graphs/diGraph.h>
69 
70 namespace gum {
71 
72  namespace learning {
73 
74  // a dummy class used to check that the generator is adapted to K2
76 
117  template < typename STRUCT_CONSTRAINT >
121  public:
124 
127 
128  // ##########################################################################
130  // ##########################################################################
132 
134  GraphChangesGenerator4K2(STRUCT_CONSTRAINT& constraint);
135 
139 
143 
145  virtual ~GraphChangesGenerator4K2();
146 
148 
149  // ##########################################################################
151  // ##########################################################################
153 
156  operator=(const GraphChangesGenerator4K2< STRUCT_CONSTRAINT >& from);
157 
161 
163 
164  // ##########################################################################
166  // ##########################################################################
168 
170  iterator begin() const;
171 
173  const iterator& end() const;
174 
176 
177  // ##########################################################################
179  // ##########################################################################
181 
183  STRUCT_CONSTRAINT& constraint() const noexcept;
184 
187  void setGraph(const DiGraph& graph);
188 
190  void modifyGraph(const ArcAddition& change);
191 
193  void modifyGraph(const ArcDeletion& change);
194 
196  void modifyGraph(const ArcReversal& change);
197 
199  void modifyGraph(const GraphChange& change);
200 
202  void clearChanges() noexcept;
203 
205  void notifyGetCompleted();
206 
208  void setMaxNbThreads(Size nb) noexcept;
209 
211  void setOrder(const Sequence< NodeId >& order);
212 
214  void setOrder(const std::vector< NodeId >& order);
215 
217 
218  protected:
220  DiGraph _graph;
221 
223  STRUCT_CONSTRAINT* _constraint;
224 
226  Sequence< NodeId > _order;
227 
229  Set< GraphChange > _legal_changes;
230 
232  void _createChanges();
233 
234  private:
236 #if defined(_OPENMP) && !defined(GUM_DEBUG_MODE)
237  Size __max_threads_number{getMaxNumberOfThreads()};
238 #else
239  Size __max_threads_number{1};
240 #endif /* GUM_DEBUG_MODE */
241  };
242 
243  } /* namespace learning */
244 
245 } /* namespace gum */
246 
249 
250 #endif /* GUM_LEARNING_GRAPH_CHANGES_GENERATOR_4_K2_H */
typename Set< GraphChange >::const_iterator iterator
the iterator for parsing the list of possible graph change operators
The base class for all GraphChangesGenerators for directed structures.
Base classes for oriented graphs.
Header file of gum::Sequence, a class for storing (ordered) sequences of objects. ...
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
The generic class for storing (ordered) sequences of objects.
Definition: sequence.h:1019
The class for notifying learning algorithms of arc removalsThis class is convenient to know at compil...
Definition: graphChange.h:213
STL namespace.
unsigned int getMaxNumberOfThreads()
Returns the maximum number of threads at any time.
gum is the global namespace for all aGrUM entities
Definition: agrum.h:25
Representation of a setA Set is a structure that contains arbitrary elements.
Definition: set.h:162
Base class for all oriented graphs.
Definition: diGraph.h:108
iterator const_iterator
the const iterator for parsing the list of graph change operators
Wrappers for OpenMP.
Unsafe iterators for the Set class.
Definition: set.h:1022
The class for notifying learning algorithms of arc reversalsThis class is convenient to know at compi...
Definition: graphChange.h:279
The basic class for computing the next graph changes possible in a (directed) structure learning algo...
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45
The basic class for computing the next graph changes possible in a structure learning algorithm...
Size NodeId
Type for node ids.
Definition: graphElements.h:97