// Start only Activities with dependencies solved
for (auto const& activity: dag) {
- if (dynamic_cast<Exec*>(activity.get()) != nullptr and activity->dependencies_solved())
+ if (dynamic_cast<Exec*>(activity.get()) != nullptr && activity->dependencies_solved())
activity->start();
}
return dag;
{
std::unordered_set<aid_t> actors;
for (const auto& [aid, state] : get_actors_list()) {
- if (state.is_todo() or state.is_done()) {
+ if (state.is_todo() || state.is_done()) {
actors.insert(aid);
}
}
// works with ODPOR in the way we intend it to work. There is not a
// good way to perform transition equality in SimGrid; instead, we
// effectively simply check for the presence of an actor in the sleep set.
- if (!get_actors_list().at(out_transition->aid_).has_more_to_consider())
+ if (not get_actors_list().at(out_transition->aid_).has_more_to_consider())
add_sleep_set(std::move(out_transition));
}
}
std::pair<aid_t, int> best_transition(bool must_be_todo) const override
{
- std::pair<aid_t, int> min_found = std::make_pair(-1, value_of_state_+2);
+ std::pair<aid_t, int> min_found = std::make_pair(-1, value_of_state_ + 2);
for (auto const& [aid, actor] : actors_to_run_) {
if ((not actor.is_todo() && must_be_todo) || not actor.is_enabled() || actor.is_done())
continue;
const Transition* transition = actor.get_transition(actor.get_times_considered()).get();
if (auto const* cast_recv = dynamic_cast<CommRecvTransition const*>(transition)) {
- if (mailbox_.count(cast_recv->get_mailbox()) > 0 and
- mailbox_.at(cast_recv->get_mailbox()) > 0) {
- aid_value--; // This means we have waiting recv corresponding to this recv
- } else {
- aid_value++;
- }
+ if (mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) > 0) {
+ aid_value--; // This means we have waiting recv corresponding to this recv
+ } else {
+ aid_value++;
+ }
}
if (auto const* cast_send = dynamic_cast<CommSendTransition const*>(transition)) {
- if (mailbox_.count(cast_send->get_mailbox()) > 0 and
- mailbox_.at(cast_send->get_mailbox()) < 0) {
- aid_value--; // This means we have waiting recv corresponding to this send
- }else {
- aid_value++;
- }
+ if (mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) < 0) {
+ aid_value--; // This means we have waiting recv corresponding to this send
+ } else {
+ aid_value++;
+ }
}
if (aid_value < min_found.second)
std::pair<aid_t, int> best_transition(bool must_be_todo) const override
{
- std::pair<aid_t, int> min_found = std::make_pair(-1, value_of_state_+2);
+ std::pair<aid_t, int> min_found = std::make_pair(-1, value_of_state_ + 2);
for (auto const& [aid, actor] : actors_to_run_) {
if ((not actor.is_todo() && must_be_todo) || not actor.is_enabled() || actor.is_done())
continue;
const Transition* transition = actor.get_transition(actor.get_times_considered()).get();
if (auto const* cast_recv = dynamic_cast<CommRecvTransition const*>(transition)) {
- if ((mailbox_.count(cast_recv->get_mailbox()) > 0 and
- mailbox_.at(cast_recv->get_mailbox()) <= 0) or mailbox_.count(cast_recv->get_mailbox()) == 0)
- aid_value--; // This means we don't have waiting recv corresponding to this recv
- else
- aid_value++;
+ if ((mailbox_.count(cast_recv->get_mailbox()) > 0 && mailbox_.at(cast_recv->get_mailbox()) <= 0) ||
+ mailbox_.count(cast_recv->get_mailbox()) == 0)
+ aid_value--; // This means we don't have waiting recv corresponding to this recv
+ else
+ aid_value++;
}
if (auto const* cast_send = dynamic_cast<CommSendTransition const*>(transition)) {
- if ((mailbox_.count(cast_send->get_mailbox()) > 0 and
- mailbox_.at(cast_send->get_mailbox()) >= 0) or mailbox_.count(cast_send->get_mailbox()) == 0)
- aid_value--;
- else
- aid_value++;
+ if ((mailbox_.count(cast_send->get_mailbox()) > 0 && mailbox_.at(cast_send->get_mailbox()) >= 0) ||
+ mailbox_.count(cast_send->get_mailbox()) == 0)
+ aid_value--;
+ else
+ aid_value++;
}
if (aid_value < min_found.second)
// else raise an error
void consider_one(aid_t aid)
{
- xbt_assert(actors_to_run_.at(aid).is_enabled() and not actors_to_run_.at(aid).is_done(),
+ xbt_assert(actors_to_run_.at(aid).is_enabled() && not actors_to_run_.at(aid).is_done(),
"Tried to mark as TODO actor %ld but it is either not enabled or already done", aid);
actors_to_run_.at(aid).mark_todo();
}
{
unsigned long count = 0;
for (auto& [_, actor] : actors_to_run_)
- if (actor.is_enabled() and not actor.is_done()) {
+ if (actor.is_enabled() && not actor.is_done()) {
actor.mark_todo();
count++;
}
// Consider only valid actors
for (auto const& [aid, actor] : actors_to_run_) {
- if ((actor.is_todo() or not must_be_todo) and (not actor.is_done()) and actor.is_enabled())
+ if ((actor.is_todo() || not must_be_todo) && (not actor.is_done()) && actor.is_enabled())
possibilities++;
}
chosen = xbt::random::uniform_int(0, possibilities-1);
for (auto const& [aid, actor] : actors_to_run_) {
- if (((not actor.is_todo()) and must_be_todo) or actor.is_done() or (not actor.is_enabled()))
+ if (((not actor.is_todo()) && must_be_todo) || actor.is_done() || (not actor.is_enabled()))
continue;
if (chosen == 0) {
return std::make_pair(aid, valuation.at(aid));
for (const auto e_race : execution_seq_.get_reversible_races_of(next_E_p)) {
State* prev_state = stack_[e_race].get();
const auto choices = execution_seq_.get_missing_source_set_actors_from(e_race, prev_state->get_backtrack_set());
- if (!choices.empty()) {
+ if (not choices.empty()) {
// NOTE: To incorporate the idea of attempting to select the "best"
// backtrack point into SDPOR, instead of selecting the `first` initial,
// we should instead compute all choices and decide which is best
XBT_DEBUG("\tPerformed ODPOR 'clean-up'. Sleep set has:");
for (const auto& [aid, transition] : state->get_sleep_set())
XBT_DEBUG("\t <%ld,%s>", aid, transition->to_string().c_str());
- if (!state->has_empty_tree()) {
+ if (not state->has_empty_tree()) {
return state;
}
}
// 2. disqualified_events.count(e_j) > 0
// then e_i --->_E target indirectly (either through
// e_j directly, or transitively through e_j)
- if (disqualified_events.count(e_j) > 0 and happens_before(e_i, e_j)) {
+ if (disqualified_events.count(e_j) > 0 && happens_before(e_i, e_j)) {
disqualified_events.insert(e_i);
break;
}
// happen after `e` is a member of `v`. In addition to marking
// the event in `v`, we also "simulate" running the action `v`
// from E'
- if (not happens_before(e, e_prime) or e_prime == next_E_p) {
+ if (not happens_before(e, e_prime) || e_prime == next_E_p) {
// First, push the transition onto the hypothetical execution
E_prime_v.push_transition(get_event_with_handle(e_prime).get_transition());
const EventHandle e_prime_in_E_prime_v = E_prime_v.get_latest_event_handle().value();
}
}
}
- xbt_assert(!I_E_prime_v.empty(),
+ xbt_assert(not I_E_prime_v.empty(),
"For any non-empty execution, we know that "
"at minimum one actor is an initial since "
"some execution is possible with respect to a "
const bool e_j_before_e_k = execution.happens_before(e_j, e_k);
const bool e_i_before_e_k = execution.happens_before(e_i, e_k);
// Logical equivalent of `e_i_before_e_j ^ e_j_before_e_k --> e_i_before_e_k`
- REQUIRE((!(e_i_before_e_j and e_j_before_e_k) or e_i_before_e_k));
+ REQUIRE((not(e_i_before_e_j && e_j_before_e_k) || e_i_before_e_k));
}
}
}
// If the other event is a communication event, then we
// are not reversible; otherwise we are reversible.
const auto e1_action = E.get_transition_for_handle(e1)->type_;
- return e1_action != Transition::Type::COMM_ASYNC_SEND and e1_action != Transition::Type::COMM_ASYNC_RECV;
+ return e1_action != Transition::Type::COMM_ASYNC_SEND && e1_action != Transition::Type::COMM_ASYNC_RECV;
}
bool ReversibleRaceCalculator::is_race_reversible_CommTest(const Execution&, Execution::EventHandle e1,
{
// TODO: Get the semantics correct here
const auto e1_action = E.get_transition_for_handle(e1)->type_;
- return e1_action != Transition::Type::MUTEX_ASYNC_LOCK and e1_action != Transition::Type::MUTEX_UNLOCK;
+ return e1_action != Transition::Type::MUTEX_ASYNC_LOCK && e1_action != Transition::Type::MUTEX_UNLOCK;
}
bool ReversibleRaceCalculator::is_race_reversible_SemAsyncLock(const Execution&, Execution::EventHandle e1,
// and instead track this with the iterator
PartialExecution seq_;
const WakeupTreeNode* cur_node = this;
- while (cur_node != nullptr and !cur_node->is_root()) {
+ while (cur_node != nullptr && not cur_node->is_root()) {
seq_.push_front(cur_node->action_);
cur_node = cur_node->parent_;
}
shortest_sequence.has_value()) {
// Insert the sequence as a child of `node`, but only
// if the node is not already a leaf
- if (not node->is_leaf() or node == this->root_) {
+ if (not node->is_leaf() || node == this->root_) {
// NOTE: It's entirely possible that the shortest
// sequence we are inserting is empty. Consider the
// following two cases:
Configuration::Configuration(const EventSet& events) : events_(events)
{
- if (!events_.is_valid_configuration()) {
+ if (not events_.is_valid_configuration()) {
throw std::invalid_argument("The events do not form a valid configuration");
}
this->latest_event_mapping[e->get_actor()] = e;
// Preserves the property that the configuration is causally closed
- if (auto history = History(e); !this->events_.contains(history)) {
+ if (auto history = History(e); not this->events_.contains(history)) {
throw std::invalid_argument("The newly added event has dependencies "
"which are missing from this configuration");
}
// 2. `e` itself must not conflict with any events of
// the configuration; otherwise adding the event would
// violate the invariant that a configuration is conflict-free
- return contains(e->get_history()) and (not e->conflicts_with_any(this->events_));
+ return contains(e->get_history()) && (not e->conflicts_with_any(this->events_));
}
bool Configuration::is_compatible_with(const History& history) const
// The first alternative that is found is the one that is chosen. Since
// traversal over the elements of an unordered_set<> are not guaranteed,
// both {e0, e4} and {e0, e7} are valid alternatives
- REQUIRE((alternative.value().get_events() == EventSet({e0_handle, e4_handle}) or
+ REQUIRE((alternative.value().get_events() == EventSet({e0_handle, e4_handle}) ||
alternative.value().get_events() == EventSet({e0_handle, e7_handle})));
}
const auto alternative = C.compute_alternative_to(D_plus_e, U);
REQUIRE(alternative.has_value());
- REQUIRE((alternative.value().get_events() == EventSet({e0_handle, e7_handle}) or
- alternative.value().get_events() == EventSet({e0_handle, e4_handle, e7_handle}) or
+ REQUIRE((alternative.value().get_events() == EventSet({e0_handle, e7_handle}) ||
+ alternative.value().get_events() == EventSet({e0_handle, e4_handle, e7_handle}) ||
alternative.value().get_events() == EventSet({e0_handle, e4_handle, e7_handle, e8_handle})));
}
temporarily_marked_events.insert(evt);
EventSet immediate_causes = evt->get_immediate_causes();
- if (!immediate_causes.empty() && immediate_causes.is_subset_of(temporarily_marked_events)) {
+ if (not immediate_causes.empty() && immediate_causes.is_subset_of(temporarily_marked_events)) {
throw std::invalid_argument("Attempted to perform a topological sort on a configuration "
"whose contents contain a cycle. The configuration (and the graph "
"connecting all of the events) is an invalid event structure");
return contents;
}
-} // namespace simgrid::mc::udpor
\ No newline at end of file
+} // namespace simgrid::mc::udpor
bool UnfoldingEvent::related_to(const UnfoldingEvent* other) const
{
- return this->in_history_of(other) or other->in_history_of(this);
+ return this->in_history_of(other) || other->in_history_of(this);
}
bool UnfoldingEvent::in_history_of(const UnfoldingEvent* other) const
[&](const UnfoldingEvent* e) { return e->is_dependent_with(other); });
const bool conflicts_with_other = std::any_of(unique_to_other.begin(), unique_to_other.end(),
[&](const UnfoldingEvent* e) { return e->is_dependent_with(this); });
- return conflicts_with_me or conflicts_with_other;
+ return conflicts_with_me || conflicts_with_other;
}
bool UnfoldingEvent::conflicts_with_any(const EventSet& events) const
}
const auto next_event_ref = [&]() {
- if (!has_started_searching) {
+ if (not has_started_searching) {
has_started_searching = true;
return bookkeeper.find_next_candidate_event(topological_ordering.begin(), topological_ordering.end());
} else {
simgrid::kernel::actor::simcall_answered([this] {
double now = simgrid::s4u::Engine::get_clock();
double time_delta_real = now - last_updated_;
- if (time_delta_real <= 0 or not is_active())
+ if (time_delta_real <= 0 || not is_active())
return;
double time_delta_until_event = next_event_ - last_updated_;
bool event = next_event_ != -1 and time_delta_until_event <= time_delta_real;
if (now <= last_updated_)
return;
double power_w = conversion_efficiency_ * area_m2_ * solar_irradiance_w_per_m2_;
- if (min_power_w_ > 0 and power_w_ < min_power_w_)
+ if (min_power_w_ > 0 && power_w_ < min_power_w_)
power_w = 0;
- if (max_power_w_ > 0 and power_w_ > max_power_w_)
+ if (max_power_w_ > 0 && power_w_ > max_power_w_)
power_w = max_power_w_;
power_w_ = power_w;
if (eval_cost_) {
{
ensure_plugin_inited();
return host->extension<Photovoltaic>()->get_power();
-}
\ No newline at end of file
+}
template <typename Iterator> void powerset_iterator<Iterator>::increment()
{
- if (!current_subset_iter.has_value() || !current_subset_iter_end.has_value() || !current_subset_iter.has_value() ||
- !iterator_end.has_value()) {
+ if (not current_subset_iter.has_value() || not current_subset_iter_end.has_value() ||
+ not current_subset_iter.has_value() || not iterator_end.has_value()) {
return; // We've traversed all subsets at this point, or we're the "last" iterator
}
template <typename Iterator> bool subsets_iterator<Iterator>::equal(const subsets_iterator<Iterator>& other) const
{
- if (this->end == std::nullopt and other.end == std::nullopt) {
+ if (this->end == std::nullopt && other.end == std::nullopt) {
return true;
}
if (this->k != other.k) {
if (this->k == 0) { // this->k == other.k == 0
return true;
}
- return this->end != std::nullopt and other.end != std::nullopt and this->P[0] == other.P[0];
+ return this->end != std::nullopt && other.end != std::nullopt && this->P[0] == other.P[0];
}
template <typename Iterator> const std::vector<Iterator>& subsets_iterator<Iterator>::dereference() const
const auto has_effect =
std::none_of(collections.begin(), collections.end(), [](const auto& c) { return c.get().empty(); });
- if (has_effect and (not collections.empty())) {
+ if (has_effect && (not collections.empty())) {
std::transform(collections.begin(), collections.end(), std::back_inserter(current_subset),
[](const auto& c) { return c.get().cbegin(); });
underlying_collections = std::move(collections);
{
// Termination occurs when `current_subset := the empty set`
// or if we have nothing to iterate over
- if (current_subset.empty() or underlying_collections.empty()) {
+ if (current_subset.empty() || underlying_collections.empty()) {
return;
}