diff --git a/examples/python/single_machine_scheduling_with_setup_release_due_dates_sat.py b/examples/python/single_machine_scheduling_with_setup_release_due_dates_sat.py index 3c80436f53..2353717294 100644 --- a/examples/python/single_machine_scheduling_with_setup_release_due_dates_sat.py +++ b/examples/python/single_machine_scheduling_with_setup_release_due_dates_sat.py @@ -224,9 +224,14 @@ def main(args): lit = model.NewBoolVar('%i follows %i' % (j, i)) arcs.append([i + 1, j + 1, lit]) - # We add the reified transition to link the literals with the times - # of the tasks. - model.Add(starts[j] >= ends[i] + setup_times[i + 1][j]).OnlyEnforceIf(lit) + # We add the reified precedence to link the literal with the times of the + # two tasks. + # If release_dates[j] == 0, we can strenghten this precedence into an + # equality as we are minimizing the makespan. + if release_dates[j] == 0: + model.Add(starts[j] == ends[i] + setup_times[i + 1][j]).OnlyEnforceIf(lit) + else: + model.Add(starts[j] >= ends[i] + setup_times[i + 1][j]).OnlyEnforceIf(lit) model.AddCircuit(arcs)