- if (((action.get_remains() <= 0) && (action.get_variable()->get_weight() > 0)) ||
- ((action.get_max_duration() > NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
- action.finish(kernel::resource::Action::State::FINISHED);
- } else {
- /* Need to check that none of the model has failed */
- int i = 0;
- kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
- while (cnst != nullptr) {
- i++;
- void* constraint_id = cnst->get_id();
- if (static_cast<simgrid::kernel::resource::Resource*>(constraint_id)->is_off()) {
- XBT_DEBUG("Action (%p) Failed!!", &action);
- action.finish(kernel::resource::Action::State::FAILED);
- break;
- }
- cnst = action.get_variable()->get_constraint(i);
+ if (((action.get_remains() <= 0) && (action.get_variable()->get_penalty() > 0)) ||
+ ((action.get_max_duration() != NO_MAX_DURATION) && (action.get_max_duration() <= 0))) {
+ action.finish(Action::State::FINISHED);
+ continue;
+ }
+
+ /* Need to check that none of the model has failed */
+ int i = 0;
+ const lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
+ while (cnst != nullptr) {
+ i++;
+ if (not cnst->get_id()->is_on()) {
+ XBT_DEBUG("Action (%p) Failed!!", &action);
+ action.finish(Action::State::FAILED);
+ break;