#define SIMGRID_MC_BASICSTRATEGY_HPP
#include "src/mc/transition/Transition.hpp"
+#include "src/mc/transition/TransitionAny.hpp"
+#include "src/mc/transition/TransitionComm.hpp"
namespace simgrid::mc {
return std::make_pair(aid, 0.0);
double dist;
+
+ TestAnyTransition* transition =
+ static_cast<TestAnyTransition*>(actor.get_transition(actor.get_times_considered()));
+
auto iterator = penalties_.find(aid);
if (iterator != penalties_.end())
dist = (*iterator).second;
else
dist = 0;
+
+ if (not transition->result())
+ dist += 5000;
+
if (dist < min.second)
min = std::make_pair(aid, dist);
}
+
if (min.first == -1)
return std::make_pair(-1, -1000);
return min;
void execute_next(aid_t aid, RemoteApp& app) override
{
auto actor = actors_to_run_.at(aid);
- if (actor.get_transition(actor.get_times_considered())->type_ == Transition::Type::TESTANY)
- penalties_[aid] = penalties_[aid] + 1.0;
- return;
+ if (actor.get_transition(actor.get_times_considered())->type_ == Transition::Type::TESTANY) {
+ TestAnyTransition* transition =
+ static_cast<TestAnyTransition*>(actor.get_transition(actor.get_times_considered()));
+ if (not transition->result()) {
+ penalties_[aid] = penalties_[aid] + 1.0;
+ return;
+ }
+ }
+ penalties_[aid] = 0;
}
void consider_best() override
// If there are processes to interleave and the maximum depth has not been
// reached then perform one step of the exploration algorithm.
- XBT_VERB("Execute %ld: %.60s (stack depth: %zu, state: %ld, %zu interleaves out of %zu enabled)",
+ XBT_VERB("Execute %ld: %.60s (stack depth: %zu, state: %ld, %zu interleaves out of %zu enabled, %zu alternatives "
+ "to explore after)",
state->get_transition()->aid_, state->get_transition()->to_string().c_str(), stack_.size(),
- state->get_num(), state->count_todo(), state->get_actor_count());
+ state->get_num(), state->count_todo(), state->get_actor_count(), opened_states_.size());
/* Create the new expanded state (copy the state of MCed into our MCer data) */
std::shared_ptr<State> next_state = std::make_shared<State>(get_remote_app(), state);
if (prev_state->is_actor_enabled(issuer_id)) {
if (not prev_state->is_actor_done(issuer_id)) {
prev_state->consider_one(issuer_id);
- opened_states_.push(std::shared_ptr<State>(tmp_stack.back()));
+ if (not tmp_stack.back()->is_opened) {
+ opened_states_.push(std::shared_ptr<State>(tmp_stack.back()));
+ tmp_stack.back()->is_opened = true;
+ }
} else
XBT_DEBUG("Actor %ld is already in done set: no need to explore it again", issuer_id);
} else {
"transition as todo",
issuer_id);
// If we ended up marking at least a transition, explore it at some point
- if (prev_state->consider_all() > 0)
+ if (prev_state->consider_all() > 0 and not tmp_stack.back()->is_opened) {
opened_states_.push(std::shared_ptr<State>(tmp_stack.back()));
+ tmp_stack.back()->is_opened = true;
+ }
}
break;
} else {
// Before leaving that state, if the transition we just took can be taken multiple times, we
// need to give it to the opened states
- if (stack_.back()->count_todo_multiples() > 0)
+ if (stack_.back()->count_todo_multiples() > 0 and not stack_.back()->is_opened) {
opened_states_.push(std::shared_ptr<State>(stack_.back()));
+ stack_.back()->is_opened = true;
+ }
if (_sg_mc_termination)
this->check_non_termination(next_state.get());
get_remote_app().restore_initial_state();
on_restore_initial_state_signal(get_remote_app());
/* Traverse the stack from the state at position start and re-execute the transitions */
- for (auto& state : backtracking_point->get_recipe()) {
- state->replay(get_remote_app());
- on_transition_replay_signal(state, get_remote_app());
+ long i = 1;
+ for (auto& transition : backtracking_point->get_recipe()) {
+ transition->replay(get_remote_app());
+ on_transition_replay_signal(transition, get_remote_app());
+ XBT_DEBUG("[Backtracking in progress] executing state #%ld/#%ld", i, backtracking_point->get_num());
visited_states_count_++;
+ i++;
}
this->restore_stack(backtracking_point);
}