26 #ifndef DOXYGEN_SHOULD_SKIP_THIS 33 template <
typename STRUCT_CONSTRAINT >
35 STRUCT_CONSTRAINT& constraint) :
36 _constraint(&constraint) {
41 template <
typename STRUCT_CONSTRAINT >
52 template <
typename STRUCT_CONSTRAINT >
63 template <
typename STRUCT_CONSTRAINT >
69 template <
typename STRUCT_CONSTRAINT >
70 GraphChangesGenerator4K2< STRUCT_CONSTRAINT >&
72 operator=(
const GraphChangesGenerator4K2< STRUCT_CONSTRAINT >& from) {
84 template <
typename STRUCT_CONSTRAINT >
85 GraphChangesGenerator4K2< STRUCT_CONSTRAINT >&
87 operator=(GraphChangesGenerator4K2< STRUCT_CONSTRAINT >&& from) {
89 _graph = std::move(from._graph);
91 _order = std::move(from._order);
99 template <
typename STRUCT_CONSTRAINT >
104 std::vector< Set< GraphChange > > legal_changes;
105 # pragma omp parallel num_threads(int(__max_threads_number)) 113 legal_changes.resize(num_threads);
118 for (
Idx i = 0, j = 0; j <
_order.
size(); i = (i + 1) % num_threads, ++j) {
119 if (i == this_thread) {
124 legal_changes[this_thread].insert(std::move(arc_add));
133 for (
const auto& changes : legal_changes) {
134 for (
const auto& change : changes) {
141 template <
typename STRUCT_CONSTRAINT >
143 const DiGraph& graph) {
153 for (
const auto node : graph) {
162 template <
typename STRUCT_CONSTRAINT >
169 template <
typename STRUCT_CONSTRAINT >
171 const std::vector< NodeId >& order) {
173 for (
const auto node : order) {
179 template <
typename STRUCT_CONSTRAINT >
186 template <
typename STRUCT_CONSTRAINT >
193 template <
typename STRUCT_CONSTRAINT >
200 template <
typename STRUCT_CONSTRAINT >
202 const ArcAddition& change) {}
205 template <
typename STRUCT_CONSTRAINT >
207 const ArcDeletion& change) {}
210 template <
typename STRUCT_CONSTRAINT >
212 const ArcReversal& change) {}
215 template <
typename STRUCT_CONSTRAINT >
217 const GraphChange& change) {}
220 template <
typename STRUCT_CONSTRAINT >
227 template <
typename STRUCT_CONSTRAINT >
230 # if defined(_OPENMP) && !defined(GUM_DEBUG_MODE) 239 template <
typename STRUCT_CONSTRAINT >
240 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.
gum is the global namespace for all aGrUM entities
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.