]> AND Public Git Repository - simgrid.git/blobdiff - src/mc/explo/udpor/UnfoldingEvent.cpp
Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add operation to plugin doc
[simgrid.git] / src / mc / explo / udpor / UnfoldingEvent.cpp
index 0f62179b154e833445a268fa9794c6e773be85b7..c51023b4745849b9d27ef7ec2d11550be068a436 100644 (file)
@@ -20,22 +20,20 @@ UnfoldingEvent::UnfoldingEvent(EventSet immediate_causes, std::shared_ptr<Transi
 
 bool UnfoldingEvent::operator==(const UnfoldingEvent& other) const
 {
-  // Must be run by the same actor
-  if (associated_transition->aid_ != other.associated_transition->aid_)
-    return false;
-
-  // If run by the same actor, must be the same _step_ of that actor's
-  // execution
-
-  // TODO: Add in information to determine which step in the sequence this actor was executed
-
-  // All unfolding event objects are created in reference to
-  // an Unfolding object which owns them. Hence, the references
+  // Two events are equivalent iff:
+  // 1. they have the same action
+  // 2. they have the same history
+  //
+  // NOTE: All unfolding event objects are created in reference to
+  // an `Unfolding` object which owns them. Hence, the references
   // they contain to other events in the unfolding can
   // be used as intrinsic identities (i.e. we don't need to
   // recursively check if each of our causes has a `==` in
   // the other event's causes)
-  return this->immediate_causes == other.immediate_causes;
+  return associated_transition->aid_ == other.associated_transition->aid_ &&
+         associated_transition->type_ == other.associated_transition->type_ &&
+         associated_transition->times_considered_ == other.associated_transition->times_considered_ &&
+         this->immediate_causes == other.immediate_causes;
 }
 
 EventSet UnfoldingEvent::get_history() const
@@ -67,12 +65,10 @@ bool UnfoldingEvent::conflicts_with(const UnfoldingEvent* other) const
   const EventSet unique_to_me    = my_history.subtracting(other_history);
   const EventSet unique_to_other = other_history.subtracting(my_history);
 
-  const bool conflicts_with_me = std::any_of(unique_to_me.begin(), unique_to_me.end(), [&](const UnfoldingEvent* e) {
-    return e->has_dependent_transition_with(other);
-  });
-  const bool conflicts_with_other =
-      std::any_of(unique_to_other.begin(), unique_to_other.end(),
-                  [&](const UnfoldingEvent* e) { return e->has_dependent_transition_with(this); });
+  const bool conflicts_with_me    = std::any_of(unique_to_me.begin(), unique_to_me.end(),
+                                                [&](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;
 }
 
@@ -85,7 +81,7 @@ bool UnfoldingEvent::conflicts_with(const Configuration& config) const
   // if they are not related)
   const EventSet potential_conflicts = config.get_events().subtracting(get_history());
   return std::any_of(potential_conflicts.cbegin(), potential_conflicts.cend(),
-                     [&](const UnfoldingEvent* e) { return this->has_dependent_transition_with(e); });
+                     [&](const UnfoldingEvent* e) { return this->is_dependent_with(e); });
 }
 
 bool UnfoldingEvent::immediately_conflicts_with(const UnfoldingEvent* other) const
@@ -122,7 +118,7 @@ bool UnfoldingEvent::is_dependent_with(const Transition* t) const
   return associated_transition->depends(t);
 }
 
-bool UnfoldingEvent::has_dependent_transition_with(const UnfoldingEvent* other) const
+bool UnfoldingEvent::is_dependent_with(const UnfoldingEvent* other) const
 {
   return is_dependent_with(other->associated_transition.get());
 }