: remains_(cost), start_time_(surf_get_clock()), cost_(cost), model_(model), variable_(var)
{
if (failed)
- state_set_ = get_model()->get_failed_action_set();
+ state_set_ = model_->get_failed_action_set();
else
- state_set_ = get_model()->get_started_action_set();
+ state_set_ = model_->get_started_action_set();
state_set_->push_back(*this);
}
if (state_set_hook_.is_linked())
simgrid::xbt::intrusive_erase(*state_set_, *this);
if (get_variable())
- get_model()->get_maxmin_system()->variable_free(get_variable());
+ model_->get_maxmin_system()->variable_free(get_variable());
/* remove from heap on need (ie, if selective update) */
- get_model()->get_action_heap().remove(this);
+ model_->get_action_heap().remove(this);
if (modified_set_hook_.is_linked())
- simgrid::xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
+ simgrid::xbt::intrusive_erase(*model_->get_modified_set(), *this);
}
void Action::finish(Action::State state)
{
XBT_IN("(%p,%g)", this, bound);
if (variable_)
- get_model()->get_maxmin_system()->update_variable_bound(variable_, bound);
+ model_->get_maxmin_system()->update_variable_bound(variable_, bound);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY && get_last_update() != surf_get_clock())
- get_model()->get_action_heap().remove(this);
+ if (model_->is_update_lazy() && get_last_update() != surf_get_clock())
+ model_->get_action_heap().remove(this);
XBT_OUT();
}
void Action::set_max_duration(double duration)
{
max_duration_ = duration;
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) // remove action from the heap
- get_model()->get_action_heap().remove(this);
+ if (model_->is_update_lazy()) // remove action from the heap
+ model_->get_action_heap().remove(this);
}
void Action::set_sharing_penalty(double sharing_penalty)
{
XBT_IN("(%p,%g)", this, sharing_penalty);
sharing_penalty_ = sharing_penalty;
- get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
+ model_->get_maxmin_system()->update_variable_penalty(get_variable(), sharing_penalty);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
- get_model()->get_action_heap().remove(this);
+ if (model_->is_update_lazy())
+ model_->get_action_heap().remove(this);
XBT_OUT();
}
void Action::cancel()
{
set_state(Action::State::FAILED);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
+ if (model_->is_update_lazy()) {
if (modified_set_hook_.is_linked())
- xbt::intrusive_erase(*get_model()->get_modified_set(), *this);
- get_model()->get_action_heap().remove(this);
+ xbt::intrusive_erase(*model_->get_modified_set(), *this);
+ model_->get_action_heap().remove(this);
}
}
{
XBT_IN("(%p)", this);
if (suspended_ != SuspendStates::SLEEPING) {
- get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), 0.0);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) {
- get_model()->get_action_heap().remove(this);
- if (state_set_ == get_model()->get_started_action_set() && sharing_penalty_ > 0) {
+ model_->get_maxmin_system()->update_variable_penalty(get_variable(), 0.0);
+ if (model_->is_update_lazy()) {
+ model_->get_action_heap().remove(this);
+ if (state_set_ == model_->get_started_action_set() && sharing_penalty_ > 0) {
// If we have a lazy model, we need to update the remaining value accordingly
update_remains_lazy(surf_get_clock());
}
{
XBT_IN("(%p)", this);
if (suspended_ != SuspendStates::SLEEPING) {
- get_model()->get_maxmin_system()->update_variable_penalty(get_variable(), get_sharing_penalty());
+ model_->get_maxmin_system()->update_variable_penalty(get_variable(), get_sharing_penalty());
suspended_ = SuspendStates::RUNNING;
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY)
- get_model()->get_action_heap().remove(this);
+ if (model_->is_update_lazy())
+ model_->get_action_heap().remove(this);
}
XBT_OUT();
}
{
XBT_IN("(%p)", this);
/* update remains before returning it */
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) /* update remains before return it */
+ if (model_->is_update_lazy()) /* update remains before return it */
update_remains_lazy(surf_get_clock());
XBT_OUT();
return remains_;
while (not maxmin_system_->modified_set_->empty()) {
Action* action = &(maxmin_system_->modified_set_->front());
maxmin_system_->modified_set_->pop_front();
- bool max_duration_flag = false;
+ ActionHeap::Type action_type = ActionHeap::Type::normal;
if (action->get_state_set() != &started_action_set_)
continue;
(min <= -1 || action->get_start_time() + action->get_max_duration() < min)) {
// when the task will complete anyway because of the deadline if any
min = action->get_start_time() + action->get_max_duration();
- max_duration_flag = true;
+ action_type = ActionHeap::Type::max_duration;
}
XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->get_variable()->rank_);
action->get_start_time(), min, share, action->get_max_duration());
if (min > -1) {
- action_heap_.update(action, min, max_duration_flag ? ActionHeap::Type::max_duration : ActionHeap::Type::normal);
+ action_heap_.update(action, min, action_type);
XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min, now);
} else
DIE_IMPOSSIBLE;
bool select = config::get_value<bool>("cpu/maxmin-selective-update");
- if (algo == Model::UpdateAlgo::LAZY) {
+ if (is_update_lazy()) {
xbt_assert(select || config::is_default("cpu/maxmin-selective-update"),
"You cannot disable cpu selective update when using the lazy update mechanism");
select = true;
action->set_state(Action::State::IGNORED);
get_model()->get_maxmin_system()->update_variable_penalty(action->get_variable(), 0.0);
- if (get_model()->get_update_algorithm() == Model::UpdateAlgo::LAZY) { // remove action from the heap
+ if (get_model()->is_update_lazy()) { // remove action from the heap
get_model()->get_action_heap().remove(action);
// this is necessary for a variable with weight 0 since such variables are ignored in lmm and we need to set its
// max_duration correctly at the next call to share_resources
model->get_maxmin_system()->variable_new(this, 1.0 / requested_core, requested_core * speed, 1))
, requested_core_(requested_core)
{
- if (model->get_update_algorithm() == Model::UpdateAlgo::LAZY)
+ if (model->is_update_lazy())
set_last_update();
model->get_maxmin_system()->expand(constraint, get_variable(), 1.0);
}