Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
An integer seems good enough to handle priorities, and is not subject to rounding...
[simgrid.git] / src / mc / api / strategy / BasicStrategy.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_BASICSTRATEGY_HPP
7 #define SIMGRID_MC_BASICSTRATEGY_HPP
8
9 namespace simgrid::mc {
10
11 /** Basic MC guiding class which corresponds to no guide at all (random choice) */
12 class BasicStrategy : public Strategy {
13 public:
14   void operator=(const BasicStrategy&)
15   { /* nothing to copy over while cloning */
16     return;
17   }
18
19   std::pair<aid_t, int> next_transition() const override
20   {
21     for (auto const& [aid, actor] : actors_to_run_) {
22       /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */
23       if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) {
24         continue;
25       }
26
27       return std::make_pair(aid, 1);
28     }
29     return std::make_pair(-1, 0);
30   }
31   void execute_next(aid_t aid, RemoteApp& app) override { return; }
32
33   void consider_best() override
34   {
35     for (auto& [_, actor] : actors_to_run_) {
36       if (actor.is_todo())
37         return;
38       if (actor.is_enabled() and not actor.is_done()) {
39         actor.mark_todo();
40         return;
41       }
42     }
43   }
44 };
45
46 } // namespace simgrid::mc
47
48 #endif