X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ed9565ed57e9c8ff4f244c0cd0a5af96c947f14f..6bc04475b4308e91e18d869a5fb665bc35b48508:/src/mc/explo/udpor/maximal_subsets_iterator.hpp diff --git a/src/mc/explo/udpor/maximal_subsets_iterator.hpp b/src/mc/explo/udpor/maximal_subsets_iterator.hpp index 74682b828f..9f6b473091 100644 --- a/src/mc/explo/udpor/maximal_subsets_iterator.hpp +++ b/src/mc/explo/udpor/maximal_subsets_iterator.hpp @@ -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 @@ -37,12 +38,18 @@ public: using node_filter_function = std::function; using topological_order_position = std::vector::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 filter); + maximal_subsets_iterator() = default; + maximal_subsets_iterator(maximal_subsets_iterator&&) noexcept = default; + explicit maximal_subsets_iterator(const Configuration& config, + std::optional filter = std::nullopt, + std::optional maximum_subset_size = std::nullopt) + : maximal_subsets_iterator(config.get_events(), filter, maximum_subset_size) + { + } + explicit maximal_subsets_iterator(const EventSet& events, std::optional filter = std::nullopt, + std::optional maximum_subset_size = std::nullopt); private: - const std::optional> config = std::nullopt; std::vector topological_ordering; // The boolean is a bit of an annoyance, but it works. Effectively, @@ -50,6 +57,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 maximum_subset_size = std::nullopt; std::optional current_maximal_set = std::nullopt; std::stack backtrack_points = std::stack(); @@ -67,6 +75,11 @@ private: public: using topological_order_position = maximal_subsets_iterator::topological_order_position; + bookkeeper() = default; + bookkeeper(bookkeeper&&) = default; + bookkeeper& operator=(bookkeeper&) = default; + bookkeeper& operator=(bookkeeper&&) = default; + void mark_included_in_maximal_set(const UnfoldingEvent*); void mark_removed_from_maximal_set(const UnfoldingEvent*); topological_order_position find_next_candidate_event(topological_order_position first, @@ -118,6 +131,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; } @@ -134,8 +154,8 @@ private: friend class boost::iterator_core_access; }; -using maximal_subsets_iterator_wrapper = - simgrid::xbt::iterator_wrapping; +template +using maximal_subsets_iterator_wrapper = simgrid::xbt::iterator_wrapping; } // namespace simgrid::mc::udpor #endif