An exact solver, not a guess
The allocation is worked out by a constraint solver, not written by a language model. Every possible placement, each doctor in each block of the year in each term, becomes a yes-or-no decision. Every rule becomes arithmetic over those decisions: how many terms of a kind, a minimum or maximum number of days, a share of the year, enough different specialties, and the head count each term can take from each year group. The solver then searches for the set of decisions that breaks no rule and costs the least.
What “costs the least” means
- Fill every position first. Then give everyone their minimum leave, then meet each term’s staffing target, and only then weigh preferences. A preference never outranks an empty position.
- One bad result counts for more than two mild ones. The cost of a placement grows with the square of how far down the doctor’s list it is, so disappointment is spread across the cohort instead of landing on a few people.
- Nobody carries the worst of it. The build also keeps down the total cost carried by the single worst-off doctor.
- A doctor who ranks nothing is not a free square. They are treated as holding a middle preference for everything.
Leave, half terms and what is already fixed
Leave requests become blocks that the solver places in the same pass as the terms, with limits on how many people can be away in the same week. Terms that split a block of the year in two, terms a doctor already holds from an earlier allocation, and placements the team has fixed by hand are all taken into account.
When the rules cannot all be met
Sometimes they cannot. The solver then finds the smallest set of rules that cannot hold together, relaxes them in a set order, and builds again. Every rule it relaxed is reported to the team. Nothing is dropped silently.
Every answer is checked twice
Before any draft is written, a separate rule engine rechecks the solver’s answer against every rule. A build takes minutes.