Build a fairer two-week nurse roster
- The problem
- A unit roster has to cover every shift with the right skills while respecting rest, contracts, time off, and staff preferences. Doing that by hand is slow and error-prone.
- What the demo shows
- Build a two-week roster for 14 simulated nurses, see every rule checked cell by cell, then let a simple heuristic search for fewer violations. Edit any cell yourself.
- Why it matters
- Makes the trade-offs in a roster visible, so managers can see which gaps come from staffing levels and which come from the schedule itself.
Select any cell to cycle it through off, day, and night. Coverage rows show staff assigned against staff required. On a narrow screen, scroll the grid sideways.
Rule check
Every issue in the current roster, with the penalty it adds.
Shifts per nurse
Bar length is shifts worked in the two weeks, against the most a contract allows in two weeks (4 shifts a week full time, 3 part time). A full bar is at the limit, not over it.
Search progress
Settings
Changing staffing re-checks the current roster; build or improve again to adapt it.
Set staffing from a published ratio
California is the one US state with minimum licensed nurse-to-patient ratios for every hospital unit type (California Code of Regulations, Title 22, section 70217(a)). Pick a unit and a patient census to set both sliders from the rule.
The ratio applies at all times, so weekend reduction is switched off. Charge nurses count only while giving direct care. The ratio is a floor, not a staffing recommendation.
Rules and penalties
| Rule | Penalty |
|---|---|
| Each nurse short on a shift | 100 |
| Working a requested day off | 100 |
| Day shift right after a night (no rest) | 80 |
| Above weekly shift limit (4 full time, 3 part time) | 60 each |
| Shift with no ICU-certified nurse | 50 |
| More than 4 days in a row | 40 each |
| Preference missed (no nights, or weekend off) | 10 |
| Each extra nurse above requirement | 5 |
How the heuristic works: the first pass fills each shift day by day, picking the eligible nurse who adds the least penalty. Local search then tries random single-cell changes and swaps, keeping any that do not raise the score. A production scheduler would usually use a mathematical optimization solver and real contract rules.
Interactive demo · simulated roster, teaching heuristic, not a staffing recommendation.
Ratio source: California Code of Regulations, Title 22, Division 5, section 70217(a) (licensed nurse-to-patient ratios), as published by the California Office of Administrative Law and reproduced at law.cornell.edu, retrieved 19 November 2026. Government edicts are not subject to copyright. No affiliation with the State of California.