X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/e9b99cc75875aaffe31d627aceb45a3583770d55..cddc05516f6bb5cb50d472ac61079cdee0243d20:/src/mc/explo/udpor/UnfoldingEvent.cpp diff --git a/src/mc/explo/udpor/UnfoldingEvent.cpp b/src/mc/explo/udpor/UnfoldingEvent.cpp index 88f4b82dc7..83e1d7dba3 100644 --- a/src/mc/explo/udpor/UnfoldingEvent.cpp +++ b/src/mc/explo/udpor/UnfoldingEvent.cpp @@ -40,4 +40,55 @@ EventSet UnfoldingEvent::get_history() const return History(this).get_all_events(); } +bool UnfoldingEvent::related_to(const UnfoldingEvent* other) const +{ + return this->in_history_of(other) or other->in_history_of(this); +} + +bool UnfoldingEvent::in_history_of(const UnfoldingEvent* other) const +{ + return History(other).contains(this); +} + +bool UnfoldingEvent::conflicts_with(const UnfoldingEvent* other) const +{ + // Events that have a causal relation never are in conflict + // in an unfolding structure. Two events in conflict must + // not be contained in each other's histories + if (related_to(other)) { + return false; + } + + const EventSet my_history = get_history(); + const EventSet other_history = other->get_history(); + const EventSet unique_to_me = my_history.subtracting(other_history); + const EventSet unique_to_other = other_history.subtracting(my_history); + + for (const auto e_me : unique_to_me) { + for (const auto e_other : unique_to_other) { + if (e_me->has_conflicting_transition_with(e_other)) { + return true; + } + } + } + return false; +} + +bool UnfoldingEvent::conflicts_with(const Configuration& config) const +{ + // A configuration is itself already conflict-free. Thus, it is + // simply a matter of testing whether or not the transition associated + // with the event is dependent with any already in `config` that are + // OUTSIDE this event's history (in an unfolding, events only conflict + // 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_conflicting_transition_with(e); }); +} + +bool UnfoldingEvent::has_conflicting_transition_with(const UnfoldingEvent* other) const +{ + return associated_transition->depends(other->associated_transition.get()); +} + } // namespace simgrid::mc::udpor