Improving nurse scheduling by example: part 1 “the problem”

My current work is here. It’s just a minimal amount of work, and incomplete because as you’ll see below because I need to add some UI to make things work as I’ve designed.

A while back, Karin approached me and asked if it’s possible to write a program to create the schedule for nurses on her unit. I responded, “of course” although in th back of my mind I was thinking this might be can of worms.


I did some googling^w research. One thing which immediately stood out is that not only are there a number of papers on staff scheduling, but there’s quite a bit of research and work invested specifically into nurse scheduling. Some of the papers date back more than 50 years, and new ones are still being written. My “of course” was quickly turning into an “of crap.” As I was intending to write a program, the concept of Constraint Programming or CSP for short stood out to me. On my path to where I am now, I found a constaint programming framework (with solver) called Choco. There are a number of open source and/or free solving frameworks apparently, but Choco was definitely the most well documented. In the end, I’ve not been able to easily adopt any of the frameworks, and my solution abandons CSP for what I’ll term ICSP (interactive CSP) whereby the person using the software must actively modify the constraints if the problem has no immediate solution.

Enough abstract nonsense, below are the  constraints. Actually they are really just notes I took. Some are not exactly constraints, but there to demonstrate differences in the classical problem if you’ve done any googling^w research on your own.

  • Scheduling occurs weekly.
  • All nurses work only nights (the classic problem has every nurse capable of working day, evening, or night shift).
  • Nurses may work 2 or 3 shifts in a week..
  • Nurses choose nights they prefer to work equal to the number of shifts they work (ie. 2 or 3).
  • Nurses who didn’t receive their preference in a previous week should have higher preference in the following week.
  • Creating work chains of 4 is bad. Ie. if a nurse worked the previous sunday, scheduling them for Monday, Tuesday, Wednesday is bad.
  • Creating work chains longer than 4 is  REALLY bad. Ie. if a nurse worked the previous Saturday, and Sunday, scheduling them for monday, tuesday, wednesday is bad.
  • Nurses may choose nights that they prefer not to work. It’s not the inverse of the above, it’s more like: “I’m getting my vagina removed on Thursday” (quasi-quote from Louie).
  • Each night has a max, and min number of nurses that must work.
  • Generally nurses prefer to work consecutive days.
  • Charge nurses have priority in getting their requests.

The issue I found with the solver frameworks is that my math is really rusty, and figuring out how to describe some of the above constraints was very intellectually taxing. It was at this point I realized I was probably not going to be able to create a solver unless I wanted to go back to school and write one for my PhD thesis.

I think this post is long enough now. Stay tuned for the next post where I describe how I decided to tackle the problem further and make math people weep while engineers jump for joy (or something like that).



Download PDF

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.