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 #include "xbt/asserts.h"
8 #ifndef SIMGRID_MC_STRATEGY_HPP
9 #define SIMGRID_MC_STRATEGY_HPP
11 namespace simgrid::mc {
15 /** State's exploration status by actor. Not all the actors are there, only the ones that are ready-to-run in this
17 std::map<aid_t, ActorState> actors_to_run_;
20 virtual ~Strategy() = default;
21 void operator=(const Strategy&)
22 { /* nothing to copy over while cloning */
26 virtual std::pair<aid_t, double> next_transition() const = 0;
27 virtual void execute_next(aid_t aid, RemoteApp& app) = 0;
28 virtual void consider_best() = 0;
30 // Mark the first enabled and not yet done transition as todo
31 // If there's already a transition marked as todo, does nothing
32 void consider_one(aid_t aid)
34 xbt_assert(actors_to_run_.at(aid).is_enabled() and not actors_to_run_.at(aid).is_done(),
35 "Tried to mark as TODO actor %ld but it is either not enabled or already done", aid);
36 actors_to_run_.at(aid).mark_todo();
38 // Matk as todo all actors enabled that are not done yet
39 unsigned long consider_all()
41 unsigned long count = 0;
42 for (auto& [_, actor] : actors_to_run_)
43 if (actor.is_enabled() and not actor.is_done()) {
53 } // namespace simgrid::mc