6
$\begingroup$

I'm working on an employee scheduling program in python. Having never done this before, I've been researching different libraries that can be used to accomplish the task.

Unfortunately, none of the examples I have been able to find for scheduling problems (for any library) seem to address one of the most common scheduling requirements - optimally scheduling breaks and lunches.

My program is ultimately going to fit the "coffee shop scheduling" model found here: https://towardsdatascience.com/how-to-solve-a-staff-scheduling-problem-with-python-63ae50435ba4

I know how many employees I need to meet demand every hour, but it swings wildly. So I need the program to select the optimal shifts to staff, from a list of known shifts, to be able to meet all demand.

For reference, number of employees needed would look something like this:

enter image description here

etc.

I'd have a list of shifts to pull from, with pre-defined breaks. It's essentially a cartesian product of all acceptable shift/break/lunch combinations:

enter image description here

etc.,

I'm sure there are a number of ways to do this, but what would be one possible way to incorporate the break/lunch schedules into PuLP, Pyomo, or Google OR-Tools? I've researched PuLP, Pyomo, and Google OR-Tools and I'm willing to use whichever library can best solve for this problem, they all seem like they can do the rest of what I need.

$\endgroup$
1
  • 4
    $\begingroup$ Welcome to OR.SE! I'd suggest explaining the problem in the body of your question rather than linking to a blog post that is behind a paywall and the author can remove it any time (on Medium, one can only read max 3 articles that are behind the paywall). $\endgroup$
    – EhsanK
    Commented Nov 21, 2021 at 21:24

1 Answer 1

5
$\begingroup$

The model you linked in the question will do the job. You just set $a_{jt}=0$ if a worker on shift $j$ would be taking a break at time $t$.

$\endgroup$
4
  • $\begingroup$ Thanks! I guess the part I'm struggling with from a code perspective is how to fractionalize my t period. My number of workers required by time window is in hours (the best I can approximate is hourly demand), but breaks are no more than 10 minutes and lunches are 60 minutes - but may span two different time windows. Any thoughts on how to do that? $\endgroup$
    – t25
    Commented Nov 21, 2021 at 23:57
  • 1
    $\begingroup$ If your shifts always start at 05:00 am, that is your t = 0. You then count up in 10 minute increments. So you can have t = 0, 10, 20, 30, 40, ..., 70, 80, ... . Those would correspond to real times of 05:00, 05:10, 05:20, 05:30, 05:40, ...,6:10, 6:20. Two time windows should work the same as one time window. Just implement both! Don't overthink it ;). $\endgroup$
    – lvenhofen
    Commented Nov 22, 2021 at 7:36
  • $\begingroup$ I concur with @lvenhofen. You need to use short enough time intervals to capture the breaks, which sounds like 10 minute intervals in this case. So a staffing requirement specified for a one hour interval would just be specified for six consecutive 10 minute segments. $\endgroup$
    – prubin
    Commented Nov 22, 2021 at 17:08
  • $\begingroup$ From a practical standpoint, you might want to consider the following question. If you need 9 employees from 10 to 11 a.m., do you really need 9 the entire time, or would it be OK to have 9 most of the time but 8 for 10 minutes (while one of them takes a break), or even 8 for 20 of the 60 minutes (two employees taking 10 minute breaks at different times) and 9 the other 40 minutes? Dealing with this would complicate the model but increase flexibility. It comes down in part to how "conservative" or "liberal" your minimum staff values are. $\endgroup$
    – prubin
    Commented Nov 22, 2021 at 17:11

Not the answer you're looking for? Browse other questions tagged or ask your own question.