Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Merge branch 'master' of https://framagit.org/simgrid/simgrid
[simgrid.git] / src / mc / api / strategy / BasicStrategy.hpp
index 9c1a482810186a2196cf02d46b750c9e431851cf..67c1ac86731156724a4069c934d59d7114d06a54 100644 (file)
@@ -6,14 +6,27 @@
 #ifndef SIMGRID_MC_BASICSTRATEGY_HPP
 #define SIMGRID_MC_BASICSTRATEGY_HPP
 
+#include "Strategy.hpp"
+
 namespace simgrid::mc {
 
-/** Basic MC guiding class which corresponds to no guide at all (random choice) */
+/** Basic MC guiding class which corresponds to no guide. When asked for different states
+ *  it will follow a depth first search politics to minize the number of opened states. */
 class BasicStrategy : public Strategy {
+    int depth_ = 100000; // Arbitrary starting point. next_transition must return a positiv value to work with threshold in DFSExplorer
+
 public:
-  void operator=(const BasicStrategy&) { return; }
+  void copy_from(const Strategy* strategy) override
+  {
+    const BasicStrategy* cast_strategy = static_cast<BasicStrategy const*>(strategy);
+    xbt_assert(cast_strategy != nullptr);
+    depth_ = cast_strategy->depth_ - 1;
+    xbt_assert(depth_ > 0, "The exploration reached a depth greater than 100000. We will stop here to prevent weird interaction with DFSExplorer.");
+  }
+  BasicStrategy()                     = default;
+  ~BasicStrategy() override           = default;
 
-  std::pair<aid_t, double> next_transition() const override
+  std::pair<aid_t, int> next_transition() const override
   {
     for (auto const& [aid, actor] : actors_to_run_) {
       /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */
@@ -21,9 +34,9 @@ public:
         continue;
       }
 
-      return std::make_pair(aid, 1.0);
+      return std::make_pair(aid, depth_);
     }
-    return std::make_pair(-1, 0.0);
+    return std::make_pair(-1, depth_);
   }
   void execute_next(aid_t aid, RemoteApp& app) override { return; }