Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Add new entry in Release_Notes.
[simgrid.git] / src / mc / transition / TransitionRandom.cpp
1 /* Copyright (c) 2015-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 #include "src/mc/transition/TransitionRandom.hpp"
7 #include "xbt/asserts.h"
8 #include "xbt/string.hpp"
9
10 #include <sstream>
11
12 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_trans_rand, mc_transition, "Logging specific to MC Random transitions");
13
14 namespace simgrid::mc {
15 std::string RandomTransition::to_string(bool verbose) const
16 {
17   return xbt::string_printf("Random([%d;%d] ~> %d)", min_, max_, times_considered_);
18 }
19
20 RandomTransition::RandomTransition(aid_t issuer, int times_considered, std::stringstream& stream)
21     : Transition(Type::RANDOM, issuer, times_considered)
22 {
23   xbt_assert(stream >> min_ >> max_);
24 }
25
26 bool RandomTransition::reversible_race(const Transition* other) const
27 {
28   xbt_assert(type_ == Type::RANDOM, "Unexpected transition type %s", to_c_str(type_));
29
30   return true; // Random is always enabled
31 }
32
33 } // namespace simgrid::mc