# 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?

-
– GlenH7 Apr 22 '14 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." – MichaelT Apr 22 '14 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. – BobDalgleish Apr 22 '14 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. – David Conrad Apr 25 '14 at 19:24