Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add conflict detection to EventSet
[simgrid.git] / src / mc / explo / udpor / maximal_subsets_iterator.hpp
index 08cd907..7d0ab46 100644 (file)
@@ -39,15 +39,14 @@ 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.get_events(), std::nullopt)
+  explicit maximal_subsets_iterator(const Configuration& config,
+                                    std::optional<node_filter_function> filter = std::nullopt,
+                                    std::optional<size_t> maximum_subset_size  = std::nullopt)
+      : maximal_subsets_iterator(config.get_events(), filter, maximum_subset_size)
   {
   }
-  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);
+  explicit maximal_subsets_iterator(const EventSet& events, std::optional<node_filter_function> filter = std::nullopt,
+                                    std::optional<size_t> maximum_subset_size = std::nullopt);
 
 private:
   std::vector<const UnfoldingEvent*> topological_ordering;
@@ -57,6 +56,7 @@ private:
   // after the empty set" and "we've finished the search" since the resulting
   // maximal set and backtracking point stack will both be empty in both cases
   bool has_started_searching                              = false;
+  std::optional<size_t> maximum_subset_size               = std::nullopt;
   std::optional<EventSet> current_maximal_set             = std::nullopt;
   std::stack<topological_order_position> backtrack_points = std::stack<topological_order_position>();
 
@@ -125,6 +125,13 @@ private:
    */
   topological_order_position continue_traversal_of_maximal_events_tree();
 
+  /**
+   * @brief: Whether or not the current maximal set can
+   * grow based on the size limit imposed on the maximal
+   * sets that can be produced
+   */
+  bool can_grow_maximal_set() const;
+
   // boost::iterator_facade<...> interface to implement
   void increment();
   bool equal(const maximal_subsets_iterator& other) const { return current_maximal_set == other.current_maximal_set; }
@@ -141,8 +148,8 @@ private:
   friend class boost::iterator_core_access;
 };
 
-using maximal_subsets_iterator_wrapper =
-    simgrid::xbt::iterator_wrapping<maximal_subsets_iterator, const Configuration&>;
+template <typename T>
+using maximal_subsets_iterator_wrapper = simgrid::xbt::iterator_wrapping<maximal_subsets_iterator, const T&>;
 
 } // namespace simgrid::mc::udpor
 #endif