Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add asserts for Configuration vs EventSet
authorMaxwell Pirtle <maxwellpirtle@gmail.com>
Tue, 7 Mar 2023 13:05:01 +0000 (14:05 +0100)
committerMaxwell Pirtle <maxwellpirtle@gmail.com>
Tue, 7 Mar 2023 13:05:01 +0000 (14:05 +0100)
This commit adds two asserts to ensure that
traversing a configuration is equivalent to
traversing the events of that configuration.
That is, the assertions check that a configuration
can effectively be treated as a set of events
when it comes to traversal of maximal sets and
computing a topological ordering

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

index aadcbd1..af975fc 100644 (file)
@@ -386,6 +386,13 @@ TEST_CASE("simgrid::mc::udpor::Configuration: Topological Sort Order Very Compli
       REQUIRE(events_seen == ordered_event_set);
     }
   }
+
+  SECTION("Test that the topological ordering is equivalent to that of the configuration's events")
+  {
+    REQUIRE(C.get_topologically_sorted_events() == C.get_events().get_topological_ordering());
+    REQUIRE(C.get_topologically_sorted_events_of_reverse_graph() ==
+            C.get_events().get_topological_ordering_of_reverse_graph());
+  }
 }
 
 TEST_CASE("simgrid::mc::udpor::maximal_subsets_iterator: Basic Testing of Maximal Subsets")
@@ -564,4 +571,30 @@ TEST_CASE("simgrid::mc::udpor::maximal_subsets_iterator: Stress Test for Maximal
       REQUIRE((*first).is_maximal());
     }
   }
+
+  SECTION("Test that the maximal set ordering is equivalent to that of the configuration's events")
+  {
+    maximal_subsets_iterator first_config(C);
+    maximal_subsets_iterator first_events(C.get_events());
+    maximal_subsets_iterator last;
+
+    // Make sure we actually have something to iterate over
+    REQUIRE(first_config != last);
+    REQUIRE(first_config == first_events);
+    REQUIRE(first_events != last);
+
+    for (; first_config != last; ++first_config, ++first_events) {
+      // first_events and first_config should always be at the same location
+      REQUIRE(first_events != last);
+      const auto& first_config_set = *first_config;
+      const auto& first_events_set = *first_events;
+
+      REQUIRE(first_config_set.size() <= C.get_events().size());
+      REQUIRE(first_config_set.is_maximal());
+      REQUIRE(first_events_set == first_config_set);
+    }
+
+    // Iteration with events directly should now also be finished
+    REQUIRE(first_events == last);
+  }
 }
\ No newline at end of file
index 08cd907..2be3497 100644 (file)
@@ -39,10 +39,9 @@ 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) : 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)
   {