job-schedulingor-toolsconstraint-programmingcp-sat

Nurse Scheduling With Varying Number of Shifts Per Day and Varying Nurse Availability


I am building a CP-SAT model using Google OR Tools in C# to solve a variation of the nurse scheduling problem in which there are a variable number of shifts per day and a variable number of nurses available on any given day to work those shifts.

Following this example from ShiftSchedulingSat.cs, I see there is a way to implement this easily if the number of shifts per day and number of employees per day is known. How can I modify this to work with my requirements?

var model = new CpModel();

IntVar[,,] work = new IntVar[numEmployees, numShifts, numDays];

foreach (int e in Range(numEmployees))
{
    foreach (int s in Range(numShifts))
    {
        foreach (int d in Range(numDays))
        {
            work[e, s, d] = model.NewBoolVar($"work{e}_{s}_{d}");
        }   
    }
}

Solution

  • Create the maximum of nurses, and force the number of off-shifts, or force some nurses to have an off-shift.