π§© Constraint Solving POTD:Nurse Rostering β Scheduling Under Hard and Soft Constraints #28265
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 #28456. |
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 Statement
A hospital needs to assign nurses to shifts over a planning horizon (typically one to four weeks) while satisfying both hard constraints (that must never be violated) and soft constraints (preferences that should be satisfied as much as possible).
Concrete instance β 5 nurses, 3 shifts/day, 7 days:
N1, N2, N3, N4, N5Day (D),Evening (E),Night (N)Input: number of nurses, shift types, horizon length, coverage requirements, individual nurse constraints/preferences
Output: an assignment
shift[n][d] β {D, E, N, OFF}for each nursenand daydthat satisfies all hard constraints and minimises soft-constraint violationsWhy It Matters
Modeling Approaches
Approach 1 β Constraint Programming (CP)
Decision variables:
shift[n][d] β {Day, Evening, Night, Off}for nursen β 1..N, dayd β 1..HHard constraints:
Soft objective (penalty minimisation):
Trade-offs: CP handles the combinatorial structure naturally via global constraints (
GCCfor coverage,Regular/Sequencefor pattern rules). Propagation is strong but the search space is exponential.Approach 2 β Mixed-Integer Programming (MIP)
Introduce binary variables:
x[n][d][s] β {0,1}= 1 if nursenworks shiftson dayd.Key constraints:
Objective: minimise weighted sum of soft-constraint violations (add slack variables for preferences).
Trade-offs: MIP benefits from LP relaxation bounds and mature solvers (Gurobi, CPLEX, HiGHS). However, modelling complex consecutive-shift patterns requires auxiliary binary variables, making the formulation verbose.
Example Model (MiniZinc pseudo-code)
Key Techniques
Global constraint
Regular: Encodes allowed/forbidden shift-sequence patterns as a finite automaton. This is far more efficient than posting pairwise "forbidden successor" constraints, especially for complex work-pattern rules (e.g., "at most 3 consecutive nights, then at least 2 days off").Variable ordering heuristics: Use first-fail on the most constrained nurse-day pairs, combined with impact-based search to quickly detect infeasible partial assignments. In practice, ordering by day before nurse often yields better propagation.
Large Neighbourhood Search (LNS): Because the full problem is NP-hard and instances can involve hundreds of nurses, pure tree search rarely scales. LNS iteratively destroys a random subset of the assignment (e.g., all shifts for 2 randomly chosen nurses) and re-solves the subproblem, accepting improvements. This is the dominant approach in competition-winning rostering solvers.
Challenge Corner
References
Beta Was this translation helpful? Give feedback.
All reactions