Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Avoid casting errors in printf on MacOSX
[simgrid.git] / src / mc / explo / udpor / UnfoldingEvent.cpp
index b1d7382..865b701 100644 (file)
@@ -20,6 +20,8 @@ UnfoldingEvent::UnfoldingEvent(std::initializer_list<const UnfoldingEvent*> init
 UnfoldingEvent::UnfoldingEvent(EventSet immediate_causes, std::shared_ptr<Transition> transition)
     : associated_transition(std::move(transition)), immediate_causes(std::move(immediate_causes))
 {
+  static uint64_t event_id = 0;
+  this->id                 = ++event_id;
 }
 
 bool UnfoldingEvent::operator==(const UnfoldingEvent& other) const
@@ -50,13 +52,15 @@ std::string UnfoldingEvent::to_string() const
 
   dependencies_string += "[";
   for (const auto* e : immediate_causes) {
+    dependencies_string += " ";
     dependencies_string += e->to_string();
+    dependencies_string += " and ";
   }
   dependencies_string += "]";
 
-  return xbt::string_printf("(%p) Actor %ld: %s (%zu dependencies: %s)", this, associated_transition->aid_,
-                            associated_transition->to_string().c_str(), immediate_causes.size(),
-                            dependencies_string.c_str());
+  return xbt::string_printf("Event %lu, Actor %ld: %s (%lu dependencies: %s)", this->id, associated_transition->aid_,
+                            associated_transition->to_string().c_str(),
+                            static_cast<long unsigned>(immediate_causes.size()), dependencies_string.c_str());
 }
 
 EventSet UnfoldingEvent::get_history() const
@@ -73,7 +77,7 @@ EventSet UnfoldingEvent::get_local_config() const
 
 bool UnfoldingEvent::related_to(const UnfoldingEvent* other) const
 {
-  return this->in_history_of(other) or other->in_history_of(this);
+  return this->in_history_of(other) || other->in_history_of(this);
 }
 
 bool UnfoldingEvent::in_history_of(const UnfoldingEvent* other) const
@@ -99,7 +103,7 @@ bool UnfoldingEvent::conflicts_with(const UnfoldingEvent* other) const
                                                 [&](const UnfoldingEvent* e) { return e->is_dependent_with(other); });
   const bool conflicts_with_other = std::any_of(unique_to_other.begin(), unique_to_other.end(),
                                                 [&](const UnfoldingEvent* e) { return e->is_dependent_with(this); });
-  return conflicts_with_me or conflicts_with_other;
+  return conflicts_with_me || conflicts_with_other;
 }
 
 bool UnfoldingEvent::conflicts_with_any(const EventSet& events) const
@@ -117,21 +121,15 @@ bool UnfoldingEvent::immediately_conflicts_with(const UnfoldingEvent* other) con
   auto combined_events = History(EventSet{this, other}).get_all_events();
 
   // See the definition of immediate conflicts in the original paper on UDPOR
-  {
-    combined_events.remove(this);
-    if (not combined_events.is_valid_configuration()) {
-      return false;
-    }
-    combined_events.insert(this);
-  }
+  combined_events.remove(this);
+  if (not combined_events.is_valid_configuration())
+    return false;
+  combined_events.insert(this);
 
-  {
-    combined_events.remove(other);
-    if (not combined_events.is_valid_configuration()) {
-      return false;
-    }
-    combined_events.insert(other);
-  }
+  combined_events.remove(other);
+  if (not combined_events.is_valid_configuration())
+    return false;
+  combined_events.insert(other);
 
   return true;
 }