🧩 Constraint Solving POTD:Nurse Rostering — Scheduling Under Real-World Constraints #28456
Replies: 2 comments
-
|
💥 WHOOSH! 🦸 The Smoke Test Agent swoops in! ⚡ POW! Claude engine RUN 24931278162 was here — and the systems are NOMINAL! 🌟 "With great agentic power comes great automated testing responsibility." 💫 ZAPP! All MCP tools checked ✅ — See you next run, brave developer! 🚀 Note 🔒 Integrity filter blocked 1 itemThe following item was blocked because it doesn't meet the GitHub integrity level.
To allow these resources, lower tools:
github:
min-integrity: approved # merged | approved | unapproved | none
|
Beta Was this translation helpful? Give feedback.
-
|
This discussion has been marked as outdated by Constraint Solving — Problem of the Day. A newer discussion is available at Discussion #28721. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Category: Scheduling | Difficulty: Intermediate–Advanced | Date: 2026-04-25
Problem Statement
Given a set of nurses, a planning horizon (e.g., one week), and a set of daily shifts, assign each nurse to at most one shift per day such that:
Small Concrete Instance
n1, n2, n3, n4(4 nurses)D(Day 08:00–16:00),E(Evening 16:00–00:00),N(Night 00:00–08:00),O(Off)D, E, Nrequires at least 1 nurse per day.Nshifts.Input: nurse list, shift types, horizon, coverage demands, hard/soft constraint rules.
Output: A feasible (ideally optimal) roster minimising soft-constraint penalty.
Why It Matters
Modeling Approaches
Approach 1 — Constraint Programming (CP)
Decision variables:
Key constraints:
Trade-offs: CP models express sequencing and combinatorial structure elegantly. Global constraints like
gcc(global cardinality constraint) handle coverage in one propagation step, pruning heavily. Best for tight feasibility checks and medium horizons (≤ 4 weeks, ≤ 50 nurses).Approach 2 — Mixed-Integer Programming (MIP)
Decision variables:
Key constraints:
Trade-offs: MIP benefits from strong LP relaxations and mature solvers (Gurobi, CPLEX, HiGHS). Scales to large instances with hundreds of nurses when constraints are mostly linear. However, complex sequencing rules (e.g., "no more than 3 consecutive evenings") create many binary clauses that bloat the model.
Example Model — MiniZinc (CP)
Key Techniques
1. Global Cardinality Constraint (GCC)
The
gccconstraint enforces that the number of variables taking each value falls within given bounds — perfect for coverage requirements. Hall's theorem underpins its arc-consistency algorithm (O(n log n)), delivering powerful pruning in a single propagator rather than many individualsumconstraints.2. Symmetry Breaking
Nurses are often interchangeable up to their preferences. Ordering nurses lexicographically on their roster vectors (
lex_less(roster[1], roster[2])) can reduce the search space by up toN!. Be careful: symmetry breaking may be incompatible with soft preferences that distinguish nurses — apply it only when nurses are truly symmetric.3. Large Neighbourhood Search (LNS)
For real-world instances (30+ nurses, 4-week horizon), exact methods are too slow. LNS fixes a random subset of the roster and re-optimises the free portion using CP or MIP. A typical destroy/repair cycle: randomly unfix 20–30% of assignments, solve the sub-problem with a time limit, accept if improved. This meta-heuristic reaches high-quality solutions quickly and is the backbone of industrial nurse-scheduling tools.
Challenge Corner
References
Beta Was this translation helpful? Give feedback.
All reactions