Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add first implementation of maximal_subsets_iterator
[simgrid.git] / src / mc / explo / udpor / UnfoldingEvent.hpp
1 /* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved.          */
2
3 /* This program is free software; you can redistribute it and/or modify it
4  * under the terms of the license (GNU LGPL) which comes with this package. */
5
6 #ifndef SIMGRID_MC_UDPOR_UNFOLDING_EVENT_HPP
7 #define SIMGRID_MC_UDPOR_UNFOLDING_EVENT_HPP
8
9 #include "src/mc/explo/udpor/EventSet.hpp"
10 #include "src/mc/explo/udpor/udpor_forward.hpp"
11 #include "src/mc/transition/Transition.hpp"
12
13 #include <initializer_list>
14 #include <memory>
15 #include <string>
16
17 namespace simgrid::mc::udpor {
18
19 class UnfoldingEvent {
20 public:
21   explicit UnfoldingEvent(std::initializer_list<UnfoldingEvent*> init_list);
22   UnfoldingEvent(EventSet immediate_causes              = EventSet(),
23                  std::shared_ptr<Transition> transition = std::make_unique<Transition>());
24
25   UnfoldingEvent(const UnfoldingEvent&)            = default;
26   UnfoldingEvent& operator=(UnfoldingEvent const&) = default;
27   UnfoldingEvent(UnfoldingEvent&&)                 = default;
28
29   EventSet get_history();
30   bool in_history_of(const UnfoldingEvent* otherEvent) const;
31
32   bool conflicts_with(const UnfoldingEvent* otherEvent) const;
33   bool conflicts_with(const Configuration& config) const;
34   bool immediately_conflicts_with(const UnfoldingEvent* otherEvt) const;
35
36   const EventSet& get_immediate_causes() const { return this->immediate_causes; }
37   Transition* get_transition() const { return this->associated_transition.get(); }
38
39   bool operator==(const UnfoldingEvent&) const;
40
41   /**
42    * @brief The transition that UDPOR "attaches" to this
43    * specific event for later use while computing e.g. extension
44    * sets
45    *
46    * The transition points to that of a particular actor
47    * in the state reached by the configuration C (recall
48    * this is denoted `state(C)`) that excludes this event.
49    * In other words, this transition was the "next" event
50    * of the actor that executes it in `state(C)`.
51    */
52   std::shared_ptr<Transition> associated_transition;
53
54   /**
55    * @brief The "immediate" causes of this event.
56    *
57    * An event `e` is an immediate cause of an event `e'` if
58    *
59    * 1. e < e'
60    * 2. There is no event `e''` in E such that
61    * `e < e''` and `e'' < e'`
62    *
63    * Intuitively, an immediate cause "happened right before"
64    * this event was executed. It is sufficient to store
65    * only the immediate causes of any event `e`, as any indirect
66    * causes of that event would either be an indirect cause
67    * or an immediate cause of the immediate causes of `e`, and
68    * so on.
69    */
70   EventSet immediate_causes;
71 };
72
73 } // namespace simgrid::mc::udpor
74 #endif