Reapply fixes lost in shift_scheduling_sat.py

related to #2396
This commit is contained in:
Corentin Le Molgat
2021-05-21 18:01:16 +02:00
parent 8b8b32c7e7
commit e44579c859

View File

@@ -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)
]