Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add asserts for Configuration vs EventSet
[simgrid.git] / src / mc / explo / udpor / maximal_subsets_iterator.hpp
index 128e244..2be3497 100644 (file)
@@ -7,8 +7,10 @@
 #define SIMGRID_MC_UDPOR_MAXIMAL_SUBSETS_ITERATOR_HPP
 
 #include "src/mc/explo/udpor/Configuration.hpp"
+#include "src/xbt/utils/iter/iterator_wrapping.hpp"
 
 #include <boost/iterator/iterator_facade.hpp>
+#include <functional>
 #include <optional>
 #include <stack>
 #include <unordered_map>
@@ -17,10 +19,11 @@ namespace simgrid::mc::udpor {
 
 /**
  * @brief An iterator over the tree of sets of (non-empty) maximal events that
- * can be generated from a given configuration
+ * can be generated from a given set of events
  *
  * This iterator traverses all possible sets of maximal events that
- * can be formed from a configuration, each of which satisfy a predicate.
+ * can be formed from some subset of events of an unfolding,
+ * each of which satisfy a predicate.
  *
  * Iteration over the maximal events of a configuration is an important
  * step in computing the extension set of a configuration for an action
@@ -36,11 +39,16 @@ public:
   using topological_order_position = std::vector<const UnfoldingEvent*>::const_iterator;
 
   maximal_subsets_iterator() = default;
-  explicit maximal_subsets_iterator(const Configuration& config) : maximal_subsets_iterator(config, std::nullopt) {}
-  maximal_subsets_iterator(const Configuration& config, std::optional<node_filter_function> filter);
+  explicit maximal_subsets_iterator(const Configuration& config) : maximal_subsets_iterator(config.get_events()) {}
+  explicit maximal_subsets_iterator(const EventSet& events) : maximal_subsets_iterator(events, std::nullopt) {}
+
+  maximal_subsets_iterator(const Configuration& config, std::optional<node_filter_function> filter)
+      : maximal_subsets_iterator(config.get_events(), filter)
+  {
+  }
+  maximal_subsets_iterator(const EventSet& events, std::optional<node_filter_function> filter);
 
 private:
-  const std::optional<std::reference_wrapper<const Configuration>> config;
   std::vector<const UnfoldingEvent*> topological_ordering;
 
   // The boolean is a bit of an annoyance, but it works. Effectively,
@@ -77,7 +85,6 @@ private:
     /// bookkeeping that has been done thus far, can be added to the
     /// current candidate maximal set
     bool is_candidate_event(const UnfoldingEvent*) const;
-
   } bookkeeper;
 
   void add_element_to_current_maximal_set(const UnfoldingEvent*);
@@ -133,5 +140,8 @@ private:
   friend class boost::iterator_core_access;
 };
 
+using maximal_subsets_iterator_wrapper =
+    simgrid::xbt::iterator_wrapping<maximal_subsets_iterator, const Configuration&>;
+
 } // namespace simgrid::mc::udpor
 #endif