# Building a staff roster: greedy, local search or an exact solver

How should a team build a staff roster when coverage, overtime and fairness pull against each other, and when is a
simple method good enough? This study builds rosters for 8 instances of a public nurse-rostering benchmark three ways
(greedy, local search, an exact constraint solver), scores every roster with one checker, and sweeps the price of
fairness. The page is `index.html`.

## Data

Instances 1 to 8 of the shift scheduling benchmark at https://www.schedulingbenchmarks.org/nrp/ (Tim Curtois and
Rong Qu, "Computational results on new staff scheduling benchmark instances", technical report, ASAP Research Group,
School of Computer Science, University of Nottingham, 2014). The instance files are not copied here.
`tools/get_instances.py` downloads them from the source.

## Reproduce

Python 3.12 with OR-Tools 9.15 (`pip install ortools==9.15.*`) for the exact solver; greedy, local search, the checker
and the tests need only the standard library.

```
python3 -I -B tools/get_instances.py /path/to/new/dir
python3 -B tests/test_roster.py
python3 -B tools/run_study.py greedy /path/to/new/dir
python3 -B tools/run_study.py ls /path/to/new/dir
python3 -B tools/run_study.py effort /path/to/new/dir
python3 -B tools/run_study.py exact /path/to/new/dir --budget <your budget>
python3 -B tools/run_study.py check /path/to/new/dir --budget <your budget>
python3 -B tools/summarize.py /path/to/new/dir
python3 -I -B site/render.py
```

Greedy and local search are deterministic for a given seed, so their runs reproduce exactly. A proven
optimum does not depend on the exact solver's budget, but a smaller budget may prove fewer settings, and with several workers the best unproven roster can differ between machines.

## Files

- `tools/roster.py`: parser, the checker (every hard rule) and the measures; the one scorer for every roster.
- `tools/greedy.py`, `tools/local_search.py`, `tools/exact.py`: the three methods.
- `tools/run_study.py`: runs each part and writes one JSON per run under `results/runs/`.
- `tools/summarize.py`: re-scores every stored roster and writes `results/summary.json`, including the predictions
  scored as declared.
- `predictions-r1.json`: the nine predictions, verbatim as committed before any benchmark run.
- `assumptions.json`: the money and rollout assumptions behind the page's "What it is worth" section.
- `site/render.py`, `site/page.css`: the page. Every number on it comes from `results/` or `assumptions.json`, and
  the claims the text makes are asserted in `render.py`.
- `vendor/viz-design-system/`: the chart kit (version 2.3.0) with its licences.

## Licence of the data

The benchmark instances belong to their authors and are fetched from their site; results here are derived from them
and credited to Curtois and Qu (2014).

Some files are packed in shift-scheduling-optimization-data-1.zip; unzip it here to restore the full export, which the manifest lists file by file.
