π§© Constraint Solving POTD:π©Ί Problem of the Day β Nurse Rostering (Scheduling) #30342
Closed
Replies: 1 comment
-
|
This discussion has been marked as outdated by Constraint Solving β Problem of the Day. A newer discussion is available at Discussion #30608. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
π©Ί Problem of the Day: Nurse Rostering
Assign nursing staff to shifts over a planning horizon such that all shifts are covered, labor regulations are respected, and nurse preferences are honored as much as possible.
Problem Statement
You manage a hospital ward with 5 nurses over a 7-day planning horizon. Each day has three shifts: Morning (M), Afternoon (A), and Night (N). Each shift requires at least one nurse, and each nurse works at most one shift per day.
Hard constraints:
Soft constraints (minimize violations):
Input/Output:
nnurses,ddays, shift requirements, fatigue rules, preferences.x[nurse, day, shift] β {0,1}β 1 if that nurse works that shift.A valid assignment for the small instance might look like:
Why It Matters
Modeling Approaches
Approach 1: Constraint Programming (CP)
Decision variables:
Key constraints:
Objective: minimize
sum_{i,d} penalty[i,d] * (1 - day_off[i,d])(preference violations).Trade-offs: CP handles the combinatorial structure naturally, and global constraints like
sumandalldifferentenable strong propagation. Branching on shift assignments prunes quickly once infeasibility is detected. However, large instances (100+ nurses, 28-day horizons) can be slow without good search heuristics.Approach 2: Mixed-Integer Programming (MIP)
Use the same binary variables, but encode everything as linear constraints in a MIP solver (CPLEX, Gurobi, HiGHS).
Key additions over CP model:
x[i,d,N] + x[i,d+1,M] β€ 1(already linear β no change needed).Trade-offs: MIP solvers excel at proving optimality via LP bounds and can handle large instances with a good formulation. However, complex temporal patterns (e.g., "no more than 3 consecutive night shifts") require auxiliary variables and may weaken the LP relaxation if modeled naively.
Approach 3: Local Search / Large Neighborhood Search (LNS)
Start from a feasible (possibly poor) assignment, then repeatedly:
Trade-offs: LNS scales to industrial instances (hundreds of nurses, months of horizon) where exact methods struggle. It sacrifices optimality guarantees but delivers high-quality solutions quickly. Widely used in commercial rostering products.
Example Model β MiniZinc (CP)
Key Techniques
1. Global Cardinality Constraint (GCC)
The coverage requirement β "shift
son daydneeds betweenlbandubnurses" β is a perfect fit for GCC. CP solvers propagate GCC in polynomial time using network-flow algorithms (RΓ©gin 1994), achieving arc consistency far more efficiently than decomposing into individual sum constraints.2. Pattern-Based Variable Modeling
Instead of individual shift variables, model each nurse's week as a work pattern (a sequence like
MβAβ_βNβ_βMβ_). Pre-generate all feasible patterns (respecting fatigue rules), then use a set variable or covering constraint to select one pattern per nurse. This dramatically shrinks the search space and integrates complex temporal rules directly into the variable domain.3. Column Generation (for large MIP)
Formulate as a set-covering MIP: each column is a feasible weekly schedule for one nurse, and you select schedules to cover all shifts. Since the number of columns is exponential, generate them on-the-fly by solving a pricing sub-problem (a shortest-path or DP over the week) during branch-and-price. This is the approach used in industrial rostering software.
Challenge Corner
Hint: think about which constraints are local to a single nurse's pattern versus global across the roster.
References
Beta Was this translation helpful? Give feedback.
All reactions