ensure a shift cannot have two simillar shifts either side - shift_scheduling_sat.py #2422
-
|
Following the example of shift_scheduling_sat.py, how could I create a constraint that ensures that a shift on the preceding day is present and/or a shift on the following day is present. e.g. I had initially thought I could use similar logic to the penalized transitions, and it took me a while to work out how the penalized transitions blocked a transition with two .Not(). Which I understand now, but applying this to more than two variables gets awkward.. # Penalized transitions
for previous_shift, next_shift, cost in penalized_transitions:
for e in range(num_employees):
for d in range(num_days - 1):
transition = [
work[e, previous_shift, d].Not(), work[e, next_shift,
d + 1].Not()
]
model.AddBoolOr(transition)I appreciate it's a logic puzzle, and it's a question of saying....say when work[2] is true I'm just struggling to turn that into code. Many thanks in advance :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
|
You can use implications: |
Beta Was this translation helpful? Give feedback.
You can use implications: