What algorithm should I use to create an automatic staff scheduling feature?

Imagine a small local business (in my case a dog daycare) with a few dozen part-time employees . The goal is to automatically create weekly staff schedules. My question is about what algorithmic approaches to explore for this problem.

There are many constraints to keep in mind, chiefly (1) the availability of the staff and (2) the needs of each shift, not just how many staff for each shift but the skills needed for each shift (e.g. for a certain shift, you may need someone who knows how to drive to do pick-ups/drop-off of dogs, for another, someone who know how to give dogs baths, etc).

Other constraints include things like avoiding or requiring certain staff combos -- perhaps due to personality conflicts on one hand, or need for training by osmosis from a senior to junior staff on the other.

Also, there are preferences to take into account. Some staff prefer mornings, some two days in a row rather than say Monday and Thursday, etc. We know we can't always accommodate everyone's preferences. In fact we have a hierarchy of which employees get first dibs on their choices.

I have a hunch that there is a way to reduce or express this problem into an existing, already solved algorithm. But I don't know which algorithms to explore. Which existing, specific algorithms would be most promising?

• – user53019
Commented Apr 22, 2014 at 19:26
• And as an aside, I've never found an algorithm that works for this problem beyond the very simplest constraints in the past beyond "put everyone down on the schedule randomly ignoring any other constraint and let them swap or take shifts as desired."
– user40980
Commented Apr 22, 2014 at 19:32
• There is a complete solution available from the JBoss Drools site: optaplanner.org -- you need to codify the scheduling constraints, such as maximum hours per week, etc. Commented Apr 22, 2014 at 21:47
• I suspect this is equivalent to the SAT problem, which is known to be NP-complete, but there are no doubt good algorithms that get reasonable results. Commented Apr 25, 2014 at 19:24

1 Answer

Algorithms such as Local Search (Tabu Search, Simulated Annealing, Late Acceptance) work very well on such problems.

As Bob suggests, if you're working in Java, take a look at OptaPlanner (open source). See this video on employee rostering.

• Could you either explain the algorithms or add links to someplace that does? If you add links, please also add a little bit of information from the page that is relevant. Commented Apr 25, 2014 at 18:50
• Done. Note: many of these are explained on wikipedia too. Commented Apr 28, 2014 at 7:49