ReScheduler fills a residency year. Residents, rotations, blocks, and rules are all data, so the same app works for any program.
The schedule is a mixed-integer program. HiGHS 1.15 solves it with branch and cut, compiled to WebAssembly and run beside the page. If the clock runs out before a feasible grid exists, that is the answer.
For each resident
One means that person is on that rotation for that block. Every resident has exactly one rotation in every block:
A rotation that covers several blocks is a start, and the weeks it covers are tied to that start. Locked weeks, a locked resident, and approved leave are fixed before the search. A block where someone has no eligible rotation is reported up front, and the solver is not asked to drop the lock or the leave.
Staffing is the headcount on a rotation:
A training requirement
Rules at priority 0 stay in these inequalities. A rule can bend only when you marked it relaxable.
Feasible grids are not ranked by one blended score. The goals run in order. Each is a linear function of the
The balanced schedule uses this order.
Vacation. A pending request has a weight. The first choice is 1000, and each later choice steps down by how many requests that resident made. An alternate week is worth half the request. The solver maximizes
Approved leave is already fixed, so it does not add to
Fairness. Inside a class and track, ICU, nights, wards, and holiday blocks each get their own load. For a category, let
Career. A rotation that matches an interest or an elective preference scores up to 1000, with the same rank weights as vacation. The total of those points is maximized. A score entered on the rotation replaces the one inferred from its name.
Stability. Assignments that already match the grid are kept when that does not give back an earlier goal. Weeks that are already past weigh more.
Spacing. If two adjacent blocks are both high intensity, that pair counts. The number of such pairs is minimized last.
Generation also searches a few other schedules, each of which puts vacation, fairness, career, or stability ahead of the rest. Preview one, then apply it. Applying is what writes the grid.
If the hard model has no solution, rules you allowed to bend pick up slack. A staffing minimum becomes
and a requirement gets the same kind of slack on the credit still owed. Slack stops at the limit you set for that rule. The solver minimizes the higher-priority slack first, then the total slack, then how many residents a requirement slack touches. Vacation, fairness, and the other goals run after that, on the loosened model.
Locks, protected leave, eligibility, and priority 0 never take slack. If those contradict each other, there is no schedule to offer.
The grid is checked again, apart from the solver, against the same rules and whatever slack was used. A grid that fails that check stays off the calendar.