Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix most cosmetics and code warnings
authorMaxwell Pirtle <maxwellpirtle@gmail.com>
Fri, 24 Feb 2023 13:15:12 +0000 (14:15 +0100)
committerMaxwell Pirtle <maxwellpirtle@gmail.com>
Mon, 27 Feb 2023 08:24:17 +0000 (09:24 +0100)
src/mc/explo/UdporChecker.cpp
src/mc/explo/UdporChecker.hpp
src/mc/explo/udpor/Configuration.cpp
src/mc/explo/udpor/Configuration.hpp
src/mc/explo/udpor/EventSet.cpp
src/mc/explo/udpor/EventSet.hpp
src/mc/explo/udpor/EventSet_test.cpp
src/mc/explo/udpor/History.cpp
src/mc/explo/udpor/History.hpp
src/mc/explo/udpor/UnfoldingEvent.hpp

index c15c280..3d97acd 100644 (file)
@@ -33,12 +33,13 @@ void UdporChecker::run()
   unfolding.insert(std::move(root_event));
   C_root.add_event(root_event_handle);
 
-  explore(std::move(C_root), EventSet(), EventSet(), std::move(initial_state), EventSet());
+  explore(C_root, EventSet(), EventSet(), std::move(initial_state), EventSet());
 
   XBT_INFO("UDPOR exploration terminated -- model checking completed");
 }
 
-void UdporChecker::explore(Configuration C, EventSet D, EventSet A, std::unique_ptr<State> stateC, EventSet prev_exC)
+void UdporChecker::explore(const Configuration& C, EventSet D, EventSet A, std::unique_ptr<State> stateC,
+                           EventSet prev_exC)
 {
   // Perform the incremental computation of exC
   //
@@ -55,14 +56,9 @@ void UdporChecker::explore(Configuration C, EventSet D, EventSet A, std::unique_
   // "sleep-set blocked" trace.
   if (enC.is_subset_of(D)) {
 
-    if (C.get_events().size() > 0) {
+    if (not C.get_events().empty()) {
 
       // g_var::nb_traces++;
-
-      // TODO: Log here correctly
-      // XBT_DEBUG("\n Exploring executions: %d : \n", g_var::nb_traces);
-      // ...
-      // ...
     }
 
     // When `en(C)` is empty, intuitively this means that there
@@ -104,8 +100,7 @@ void UdporChecker::explore(Configuration C, EventSet D, EventSet A, std::unique_
 
   // TODO: Determine a value of K to use or don't use it at all
   constexpr unsigned K = 10;
-  auto J               = compute_partial_alternative(D, C, K);
-  if (!J.empty()) {
+  if (auto J = compute_partial_alternative(D, C, K); !J.empty()) {
     J.subtract(C.get_events());
 
     // Before searching the "right half", we need to make
index 471d8a2..f19c8c6 100644 (file)
@@ -110,7 +110,7 @@ private:
    * TODO: Add the optimization where we can check if e == e_prior
    * to prevent repeated work when computing ex(C)
    */
-  void explore(Configuration C, EventSet D, EventSet A, std::unique_ptr<State> stateC, EventSet prev_exC);
+  void explore(const Configuration& C, EventSet D, EventSet A, std::unique_ptr<State> stateC, EventSet prev_exC);
 
   /**
    * @brief Identifies the next event from the unfolding of the concurrent system
index 447b5f0..8cc96f2 100644 (file)
@@ -18,7 +18,7 @@ Configuration::Configuration(std::initializer_list<UnfoldingEvent*> events) : Co
 {
 }
 
-Configuration::Configuration(EventSet events) : events_(events)
+Configuration::Configuration(const EventSet& events) : events_(events)
 {
   if (!events_.is_valid_configuration()) {
     throw std::invalid_argument("The events do not form a valid configuration");
index 8449c76..ead739e 100644 (file)
@@ -23,8 +23,8 @@ public:
   Configuration& operator=(Configuration const&) = default;
   Configuration(Configuration&&)                 = default;
 
-  Configuration(EventSet events);
-  Configuration(std::initializer_list<UnfoldingEvent*> events);
+  explicit Configuration(const EventSet& events);
+  explicit Configuration(std::initializer_list<UnfoldingEvent*> events);
 
   auto begin() const { return this->events_.begin(); }
   auto end() const { return this->events_.end(); }
index 6f486b7..b03bef5 100644 (file)
@@ -11,7 +11,7 @@
 
 namespace simgrid::mc::udpor {
 
-EventSet::EventSet(Configuration&& config) : EventSet(std::move(config.get_events())) {}
+EventSet::EventSet(Configuration&& config) : EventSet(config.get_events()) {}
 
 void EventSet::remove(UnfoldingEvent* e)
 {
index e640f0c..db42ff2 100644 (file)
@@ -25,7 +25,7 @@ public:
   EventSet& operator=(EventSet&&)      = default;
   EventSet(EventSet&&)                 = default;
   explicit EventSet(Configuration&& config);
-  explicit EventSet(std::unordered_set<UnfoldingEvent*>&& raw_events) : events_(raw_events) {}
+  explicit EventSet(std::unordered_set<UnfoldingEvent*>&& raw_events) : events_(std::move(raw_events)) {}
   explicit EventSet(std::initializer_list<UnfoldingEvent*> event_list) : events_(std::move(event_list)) {}
 
   auto begin() const { return this->events_.begin(); }
index 77a555d..14fb162 100644 (file)
@@ -51,7 +51,6 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Initial conditions when creating sets")
 
     SECTION("List initialization")
     {
-      UnfoldingEvent e1, e2, e3;
       EventSet event_set{&e1, &e2, &e3};
       REQUIRE(event_set.size() == 3);
       REQUIRE(event_set.contains(&e1));
@@ -117,7 +116,7 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Deletions")
   {
     REQUIRE(event_set.contains(&e1));
 
-    // event_set = {e2, e3}
+    // Recall that event_set = {e2, e3}
     event_set.remove(&e1);
 
     // Check that
@@ -132,7 +131,7 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Deletions")
 
     SECTION("Remove a single element more than once")
     {
-      // event_set = {e2, e3}
+      // Recall that event_set = {e2, e3}
       event_set.remove(&e1);
       REQUIRE(event_set.size() == 2);
       REQUIRE_FALSE(event_set.contains(&e1));
@@ -143,7 +142,7 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Deletions")
 
     SECTION("Remove more than one element")
     {
-      // event_set = {e3}
+      // Recall that event_set = {e3}
       event_set.remove(&e2);
 
       REQUIRE(event_set.size() == 1);
@@ -152,7 +151,7 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Deletions")
       REQUIRE(event_set.contains(&e3));
       REQUIRE_FALSE(event_set.empty());
 
-      // event_set = {}
+      // Recall that event_set = {}
       event_set.remove(&e3);
 
       REQUIRE(event_set.size() == 0);
@@ -167,7 +166,7 @@ TEST_CASE("simgrid::mc::udpor::EventSet: Deletions")
   {
     REQUIRE_FALSE(event_set.contains(&e4));
 
-    // event_set = {e1, e2, e3}
+    // Recall that event_set = {e1, e2, e3}
     event_set.remove(&e4);
     REQUIRE(event_set.size() == 3);
     REQUIRE(event_set.contains(&e1));
index 544980a..bb24494 100644 (file)
@@ -45,7 +45,7 @@ History::Iterator& History::Iterator::operator++()
     maximal_events.subtract(candidates);
 
     candidates.subtract(current_history);
-    frontier.form_union(std::move(candidates));
+    frontier.form_union(candidates);
   }
   return *this;
 }
@@ -72,9 +72,9 @@ EventSet History::get_all_maximal_events() const
   return first.maximal_events;
 }
 
-bool History::contains(UnfoldingEvent* e) const
+bool History::contains(const UnfoldingEvent* e) const
 {
-  return std::any_of(this->begin(), this->end(), [=](UnfoldingEvent* e_hist) { return e == e_hist; });
+  return std::any_of(this->begin(), this->end(), [=](const UnfoldingEvent* e_hist) { return e == e_hist; });
 }
 
 EventSet History::get_event_diff_with(const Configuration& config) const
index e667424..7087927 100644 (file)
@@ -71,7 +71,7 @@ public:
    * @param e the event to check
    * @returns whether or not `e` is contained in the collection
    */
-  bool contains(UnfoldingEvent* e) const;
+  bool contains(const UnfoldingEvent* e) const;
 
   /**
    * @brief Computes all events in the history described by this instance
@@ -102,14 +102,14 @@ private:
   struct Iterator {
   public:
     Iterator& operator++();
-    auto operator->() { return frontier.begin().operator->(); }
+    auto operator->() const { return frontier.begin().operator->(); }
     auto operator*() const { return *frontier.begin(); }
 
     // If what the iterator sees next is the same, we consider them
     // to be the same iterator. This way, once the iterator has completed
     // its search, it will be "equal" to an iterator searching nothing
-    bool operator==(const Iterator& other) { return this->frontier == other.frontier; }
-    bool operator!=(const Iterator& other) { return not(this->operator==(other)); }
+    bool operator==(const Iterator& other) const { return this->frontier == other.frontier; }
+    bool operator!=(const Iterator& other) const { return not(this->operator==(other)); }
 
     using iterator_category      = std::forward_iterator_tag;
     using difference_type        = int; // # of steps between
index 2bd29e9..4468b21 100644 (file)
@@ -18,7 +18,7 @@ namespace simgrid::mc::udpor {
 
 class UnfoldingEvent {
 public:
-  UnfoldingEvent(std::initializer_list<UnfoldingEvent*> init_list);
+  explicit UnfoldingEvent(std::initializer_list<UnfoldingEvent*> init_list);
   UnfoldingEvent(EventSet immediate_causes              = EventSet(),
                  std::shared_ptr<Transition> transition = std::make_unique<Transition>());
 
@@ -38,7 +38,6 @@ public:
 
   bool operator==(const UnfoldingEvent&) const;
 
-private:
   /**
    * @brief The transition that UDPOR "attaches" to this
    * specific event for later use while computing e.g. extension