Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Delete redundant blank lines at the start of a code blocks (CodeFactor).
[simgrid.git] / src / mc / api / guide / BasicGuide.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_BASICGUIDE_HPP
7 #define SIMGRID_MC_BASICGUIDE_HPP
8
9 namespace simgrid::mc {
10
11 /** Basic MC guiding class which corresponds to no guide at all (random choice) */
12 // Not Yet fully implemented
13 class BasicGuide : public GuidedState {
14 public:
15   std::pair<aid_t, double> next_transition() const override
16   {
17     for (auto const& [aid, actor] : actors_to_run_) {
18       /* Only consider actors (1) marked as interleaving by the checker and (2) currently enabled in the application */
19       if (not actor.is_todo() || not actor.is_enabled() || actor.is_done()) {
20         continue;
21       }
22
23       return std::make_pair(aid, 1.0);
24     }
25     return std::make_pair(-1, 0.0);
26   }
27   void execute_next(aid_t aid, RemoteApp& app) override { return; }
28
29   void consider_best() override
30   {
31     for (auto& [_, actor] : actors_to_run_) {
32       if (actor.is_todo())
33         return;
34       if (actor.is_enabled() and not actor.is_done()) {
35         actor.mark_todo();
36         return;
37       }
38     }
39   }
40 };
41
42 } // namespace simgrid::mc
43
44 #endif