Skip to content

Commit 418aafa

Browse files
committed
fix #4546
1 parent 766be56 commit 418aafa

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ortools/sat/cumulative_energy.cc

+8-7
Original file line numberDiff line numberDiff line change
@@ -225,14 +225,15 @@ bool CumulativeEnergyConstraint::Propagate() {
225225

226226
const int task_with_new_energy_max =
227227
start_event_task_time_[event_with_new_energy_max].task_index;
228-
helper_->AddStartMinReason(task_with_new_energy_max, window_start);
229-
helper_->AddEndMaxReason(task_with_new_energy_max, window_end);
230-
if (!demands_->DecreaseEnergyMax(task_with_new_energy_max,
231-
new_energy_max)) {
232-
return false;
233-
}
234-
235228
if (helper_->IsPresent(task_with_new_energy_max)) {
229+
helper_->AddPresenceReason(task_with_new_energy_max);
230+
helper_->AddStartMinReason(task_with_new_energy_max, window_start);
231+
helper_->AddEndMaxReason(task_with_new_energy_max, window_end);
232+
if (!demands_->DecreaseEnergyMax(task_with_new_energy_max,
233+
new_energy_max)) {
234+
return false;
235+
}
236+
236237
theta_tree_.AddOrUpdateEvent(
237238
task_to_start_event_[task_with_new_energy_max],
238239
start_event_task_time_[event_with_new_energy_max].time *

0 commit comments

Comments
 (0)