From e44579c859ff7502f40f4d4ed79d5ea1fa5455be Mon Sep 17 00:00:00 2001 From: Corentin Le Molgat Date: Fri, 21 May 2021 18:01:16 +0200 Subject: [PATCH] Reapply fixes lost in shift_scheduling_sat.py related to #2396 --- examples/python/shift_scheduling_sat.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/python/shift_scheduling_sat.py b/examples/python/shift_scheduling_sat.py index 2631adbed2..6ba8f16cde 100644 --- a/examples/python/shift_scheduling_sat.py +++ b/examples/python/shift_scheduling_sat.py @@ -90,13 +90,13 @@ def add_soft_sequence_constraint(model, works, hard_min, soft_min, min_cost, # Forbid sequences that are too short. for length in range(1, hard_min): - for start in range(len(works) - length - 1): + for start in range(len(works) - length + 1): model.AddBoolOr(negated_bounded_span(works, start, length)) # Penalize sequences that are below the soft limit. if min_cost > 0: for length in range(hard_min, soft_min): - for start in range(len(works) - length - 1): + for start in range(len(works) - length + 1): span = negated_bounded_span(works, start, length) name = ': under_span(start=%i, length=%i)' % (start, length) lit = model.NewBoolVar(prefix + name) @@ -110,7 +110,7 @@ def add_soft_sequence_constraint(model, works, hard_min, soft_min, min_cost, # Penalize sequences that are above the soft limit. if max_cost > 0: for length in range(soft_max + 1, hard_max + 1): - for start in range(len(works) - length - 1): + for start in range(len(works) - length + 1): span = negated_bounded_span(works, start, length) name = ': over_span(start=%i, length=%i)' % (start, length) lit = model.NewBoolVar(prefix + name) @@ -219,7 +219,7 @@ def solve_shift_scheduling(params, output_proto): (3, 0, 5, -2), # Employee 5 wants a night shift on the second Thursday. (5, 3, 10, -2), - # Employee 2 does not want a night shift on the third Friday. + # Employee 2 does not want a night shift on the first Friday. (2, 3, 4, 4) ]