-1

I am trying to adapt the shift scheduling problem from this code to use shifts with different lengths, but I didn't succeed any of my attempts to do. What is the best approach to include this feature?

In the code, we input the type of shitfs in the following section (line 194):

    shifts = ['OFF', 'MORNING', 'AFTERNOON', 'NIGHT']

The code where the demands are informed is the following:

    weekly_cover_demands = [
        (2, 3, 1),  # Monday
        (2, 3, 1),  # Tuesday
        (2, 2, 2),  # Wednesday
        (2, 3, 1),  # Thursday
        (2, 2, 2),  # Friday
        (1, 2, 3),  # Saturday
        (1, 3, 1),  # Sunday
    ]

This snippet is only receiving if there are some need for an employee in that shift, but in my problem I have demands for shifts with different lengths (e.g. 7 and 8 hours).

I tried to approach in two ways (without any success until now):

  1. Creating separated demands for each length:
    weekly_cover_demands = [
        (2, 3, 1, 7),  # Monday
        (1, 0, 1, 8),  # Monday
        (2, 3, 1, 7),  # Tuesday
        (2, 0, 1, 8),  # Tuesday
        (2, 2, 2, 7),  # Wednesday
        (1, 1, 1, 8),  # Wednesday
        (3, 3, 3, 7),  # Thursday
        (2, 3, 1, 8),  # Thursday
    ]
  1. Using a list inside the tuple.
    weekly_cover_demands = [
        ([2, 1], [3, 0], [1, 1]),  # Monday
        ([2, 2], [3, 0], [1, 1]),  # Tuesday
        ([2, 1], [2, 1], [2, 1]),  # Wednesday
        ([3, 2], [3, 3], [3, 1]),  # Thursday
    ]

But none of them worked well at all.

How can I include this feature taking the advantages of the or-tools?

emt
  • 77
  • 8
j3r3mias
  • 365
  • 2
  • 12

1 Answers1

0

I believe you misunderstand the semantics of (2, 3, 1). It means 2 morning shifts, 3 afternoon, and 1 night.

Adding one number behind that will not help.

Laurent Perron
  • 8,594
  • 1
  • 8
  • 22
  • I understood that. I added a number behind but I also tried to change the logic in the Cover Constraints in the for loop in the [line 253](https://github.com/google/or-tools/blob/master/examples/python/shift_scheduling_sat.py) without any success. – j3r3mias Aug 03 '19 at 08:43