29 #ifndef DOXYGEN_SHOULD_SKIP_THIS 36 template <
typename STRUCT_CONSTRAINT >
38 STRUCT_CONSTRAINT& constraint) :
39 _constraint(&constraint) {
44 template <
typename STRUCT_CONSTRAINT >
55 template <
typename STRUCT_CONSTRAINT >
66 template <
typename STRUCT_CONSTRAINT >
72 template <
typename STRUCT_CONSTRAINT >
73 GraphChangesGenerator4K2< STRUCT_CONSTRAINT >&
75 operator=(
const GraphChangesGenerator4K2< STRUCT_CONSTRAINT >& from) {
87 template <
typename STRUCT_CONSTRAINT >
88 GraphChangesGenerator4K2< STRUCT_CONSTRAINT >&
90 operator=(GraphChangesGenerator4K2< STRUCT_CONSTRAINT >&& from) {
92 _graph = std::move(from._graph);
94 _order = std::move(from._order);
102 template <
typename STRUCT_CONSTRAINT >
107 std::vector< Set< GraphChange > > legal_changes;
108 # pragma omp parallel num_threads(int(__max_threads_number)) 116 legal_changes.resize(num_threads);
121 for (
Idx i = 0, j = 0; j <
_order.
size(); i = (i + 1) % num_threads, ++j) {
122 if (i == this_thread) {
127 legal_changes[this_thread].insert(std::move(arc_add));
136 for (
const auto& changes : legal_changes) {
137 for (
const auto& change : changes) {
144 template <
typename STRUCT_CONSTRAINT >
146 const DiGraph& graph) {
156 for (
const auto node : graph) {
165 template <
typename STRUCT_CONSTRAINT >
172 template <
typename STRUCT_CONSTRAINT >
174 const std::vector< NodeId >& order) {
176 for (
const auto node : order) {
182 template <
typename STRUCT_CONSTRAINT >
189 template <
typename STRUCT_CONSTRAINT >
196 template <
typename STRUCT_CONSTRAINT >
203 template <
typename STRUCT_CONSTRAINT >
205 const ArcAddition& change) {}
208 template <
typename STRUCT_CONSTRAINT >
210 const ArcDeletion& change) {}
213 template <
typename STRUCT_CONSTRAINT >
215 const ArcReversal& change) {}
218 template <
typename STRUCT_CONSTRAINT >
220 const GraphChange& change) {}
223 template <
typename STRUCT_CONSTRAINT >
230 template <
typename STRUCT_CONSTRAINT >
233 # if defined(_OPENMP) && !defined(GUM_DEBUG_MODE) 242 template <
typename STRUCT_CONSTRAINT >
243 INLINE STRUCT_CONSTRAINT&
typename Set< GraphChange >::const_iterator iterator
the iterator for parsing the list of possible graph change operators
GraphChangesGenerator4K2(STRUCT_CONSTRAINT &constraint)
default constructor
void clear()
Clear the sequence.
const iterator_safe & endSafe() const noexcept
Returns the safe end iterator.
unsigned int getNumberOfRunningThreads()
Get the current number of running threads.
void notifyGetCompleted()
notifies the generator that we have parsed all its legal changes
unsigned int getThreadNumber()
Get the calling thread id.
Size size() const noexcept
Returns the size of the sequence.
const iterator & end() const
returns an (unsafe) iterator on the end of the list of operators
iterator begin() const
returns an (unsafe) iterator on the beginning of the list of operators
Set< GraphChange > _legal_changes
the current set of graph changes
void setGraph(const DiGraph &graph)
sets a new graph from which the generator will compute possible changes
unsigned int getMaxNumberOfThreads()
Returns the maximum number of threads at any time.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
void setOrder(const Sequence< NodeId > &order)
set a new order on the random variables
STRUCT_CONSTRAINT & constraint() const noexcept
returns the constraint that is used by the generator
iterator_safe beginSafe() const
Returns a safe begin iterator.
void setMaxNbThreads(Size nb) noexcept
sets the maximum number of threads used to compute the set of changes
DiGraph _graph
the graph on which we generate operators
GraphChangesGenerator4K2< STRUCT_CONSTRAINT > & operator=(const GraphChangesGenerator4K2< STRUCT_CONSTRAINT > &from)
copy operator
STRUCT_CONSTRAINT * _constraint
the structural constraint used to restrict the changes
void modifyGraph(const ArcAddition &change)
notify the generator of a change applied to the graph
bool exists(const Key &k) const
Check the existence of k in the sequence.
void _createChanges()
create the set of legal and illegal changes from a given graph
Size __max_threads_number
the max number of threads authorized
Sequence< NodeId > _order
the order on the variables
void erase(const Key &k)
Remove an element from the sequence.
virtual ~GraphChangesGenerator4K2()
destructor
void clearChanges() noexcept
empty the set of possible change operators that can be applied
std::size_t Size
In aGrUM, hashed values are unsigned long int.
void insert(const Key &k)
Insert an element at the end of the sequence.