1 /* Copyright (c) 2007-2023. The SimGrid Team. All rights reserved. */
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. */
6 #ifndef SIMGRID_MC_STRATEGY_HPP
7 #define SIMGRID_MC_STRATEGY_HPP
9 #include "simgrid/forward.h"
10 #include "src/mc/api/RemoteApp.hpp"
11 #include "xbt/asserts.h"
15 namespace simgrid::mc {
19 /** State's exploration status by actor. Not all the actors are there, only the ones that are ready-to-run in this
21 std::map<aid_t, ActorState> actors_to_run_;
25 virtual ~Strategy() = default;
26 Strategy(const Strategy&) = delete;
27 Strategy& operator=(const Strategy&)
28 { /* nothing to copy over while cloning */
32 virtual std::pair<aid_t, int> next_transition() const = 0;
33 virtual void execute_next(aid_t aid, RemoteApp& app) = 0;
34 virtual void consider_best() = 0;
36 // Mark the first enabled and not yet done transition as todo
37 // If there's already a transition marked as todo, does nothing
38 void consider_one(aid_t aid)
40 xbt_assert(actors_to_run_.at(aid).is_enabled() and not actors_to_run_.at(aid).is_done(),
41 "Tried to mark as TODO actor %ld but it is either not enabled or already done", aid);
42 actors_to_run_.at(aid).mark_todo();
44 // Matk as todo all actors enabled that are not done yet
45 unsigned long consider_all()
47 unsigned long count = 0;
48 for (auto& [_, actor] : actors_to_run_)
49 if (actor.is_enabled() and not actor.is_done()) {
59 } // namespace simgrid::mc