1

This is a bit of a logic puzzle that I've been working on and I'm curious to see what kind of solutions the SO community comes up with. I have 24 randomly generated demand values, one for each hour of the day. I have a staff of 15, who each must work in 8 hours shifts, but may start at any hour of the day. I'm looking for the formula that will minimize the total difference in supply and demand for the 24 hour period. The result may look similar to the table below, given that the formula assigns a "1" for every hour in the staff's optimal eight hour shift.

    Hour   Demand     Staff 1     Staff 2   ...  Staff 15    Total Staff   Difference
    0      4          1           1              0           4             0 
    1      3          1           1              0           4             0
    ...       
    23     6          0           0              1           5             1
  • Probably is better to ask this question in programmers.stackexchange.com because this is not a a specific programming problem (http://stackoverflow.com/faq#questions). – Walery Strauch Apr 09 '13 at 22:33

1 Answers1

0

You could try a genetic algorithm:

  1. Set random starting times for each staff member.
  2. Create new mutations by randomly selecting staff members and moving they starting time by 1 hour
  3. Rate each mutation by the difference score and choose the best one.

This could lead to local minima, so it is a good idea to start it multiple times with other random choices.

You would also need to define the difference score. This could be the sum/average of difference, but possible also the max difference.

Matt
  • 1,148
  • 10
  • 15