Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Allow iteration over maximal subsets of an EventSet
authorMaxwell Pirtle <maxwellpirtle@gmail.com>
Tue, 7 Mar 2023 12:48:29 +0000 (13:48 +0100)
committerMaxwell Pirtle <maxwellpirtle@gmail.com>
Tue, 7 Mar 2023 12:48:29 +0000 (13:48 +0100)
The maximal_subsets_iterator was updated to allow
traversal over the subsets of events of some set `E`
which are maximal (i.e. causally-free). It is a
simple addition which extends the power of the iterator
to EventSets more generally (as opposed to strictly
for Configurations)

src/mc/explo/udpor/maximal_subsets_iterator.cpp
src/mc/explo/udpor/maximal_subsets_iterator.hpp

index 1dd635a..a33d418 100644 (file)
@@ -6,11 +6,10 @@
 
 namespace simgrid::mc::udpor {
 
-maximal_subsets_iterator::maximal_subsets_iterator(const Configuration& config,
-                                                   std::optional<node_filter_function> filter)
-    : config({config}), current_maximal_set({EventSet()})
+maximal_subsets_iterator::maximal_subsets_iterator(const EventSet& events, std::optional<node_filter_function> filter)
+    : current_maximal_set({EventSet()})
 {
-  const auto candidate_ordering = config.get_topologically_sorted_events_of_reverse_graph();
+  const auto candidate_ordering = events.get_topological_ordering_of_reverse_graph();
   if (filter.has_value()) {
     // Only store the events in the ordering that "matter" to us
     std::copy_if(std::move_iterator(candidate_ordering.begin()), std::move_iterator(candidate_ordering.end()),
index 74682b8..08cd907 100644 (file)
@@ -19,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
@@ -38,11 +39,17 @@ 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(), 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::nullopt;
   std::vector<const UnfoldingEvent*> topological_ordering;
 
   // The boolean is a bit of an annoyance, but it works. Effectively,