Operations Research

Assigning Work Fairly and Cheaply: Technicians, Nurses and Drivers

Who goes to which job decides the day's driving, overtime and morale. This guide assigns technicians, drivers and nurses exactly, from dispatch rules to the Hungarian algorithm, and prices skills, fairness and preferences along the way.

19 Min Read Updated: September 2026 Beginner to Intermediate
Mohammed Islam Hadjoudj
Mohammed Islam Hadjoudj
Expert Operations Research Engineer

1. Small decisions made every morning

Every morning, somewhere, a dispatcher decides which technician goes to which job, a nurse manager decides who covers which shift, and a transport planner decides which driver takes which route. Each decision looks small, and each is usually made by hand, from a whiteboard or a spreadsheet, by someone who knows the people involved. Repeated every day across a whole workforce, those decisions set a large share of travel costs, overtime, service quality and staff satisfaction.

The mathematics behind them is one of the oldest and most elegant in operations research. Dénes Kőnig and Jenő Egerváry proved the key theorems in 1931, Philip Hall characterised when a complete assignment exists in 1935, and Harold Kuhn turned their work into the Hungarian algorithm in 1955, naming it after the two Hungarian mathematicians. David Gale and Lloyd Shapley added the theory of stable matching in 1962, work that later earned Shapley and Alvin Roth the 2012 Nobel Memorial Prize in Economic Sciences.

This article follows three real kinds of assignment: field technicians with different skills, delivery drivers who all want a short drive, and nurses with preferences for shifts. Each example is small enough to check every possible plan, so every number below is exact, not estimated.

2. What a poor assignment costs

These figures are illustrative rather than taken from any particular company. The structure is what matters: travel costs add up across a plan, skills restrict who can do what, and fairness and preferences are part of what makes a plan work.

3. The service day used throughout

A heating and utilities service company has nine technicians and eight jobs booked for tomorrow. Jobs need one of three skills: electrical (Jobs 1, 4 and 7), gas (Jobs 2, 5 and 8) and heating and cooling (Jobs 3 and 6). Each technician holds one or two of those qualifications. The table shows the driving time in minutes from each technician's home to each job they are qualified for; a dash means they are not qualified.

TechnicianSkillsJob 1Job 2Job 3Job 4Job 5Job 6Job 7Job 8
AnaElectrical, heating941195510675
BenGas, electrical3593757689123
CarlaElectrical824144
DevHeating45120
EmilGas, heating91119944065
FarahElectrical, heating762287127128
GusGas, electrical43517574846
HanaElectrical, heating37103592356
IvoHeating, electrical531780105115

Every job needs exactly one technician, each technician takes at most one job, and one technician will stay free as cover. The goal is the least total driving.

4. Step one: the day as a bipartite graph

Draw technicians on one side and jobs on the other, with an edge for every qualified pair weighted by its driving time. Edges only ever join a technician to a job, never two technicians or two jobs, so the graph is bipartite. A plan is a set of edges in which no technician and no job appears twice, which graph theory calls a matching, and a plan that covers every job is a matching of size eight. The cheapest such matching is the answer to the assignment problem.

Nine technicians could fill eight jobs in 362,880 ways if everyone could do everything. Skills cut that down: only 1,584 plans give every job a qualified technician. That is still far too many to compare on a whiteboard, and a realistic day with 40 technicians has more plans than there are atoms in the Earth.

5. How the dispatch board does it

Two maps of the same region with nine technicians shown as circles and eight jobs shown as squares coloured by skill: amber for electrical, red for gas and teal for heating and cooling. Left, the dispatcher's plan with lines from technicians to jobs labelled with driving minutes, including long drives of 106 and 128 minutes, totalling 521 minutes. Right, the proven optimum totalling 389 minutes, with Dev left free. Below, bars compare the dispatcher at 521 minutes, 33.9% above the optimum, cheapest pair first at 445 minutes, 14.4% above, and the proven optimum at 389 minutes.
Both rules are sensible, and both send someone on a long drive late in the process, when the good options have already gone.

The dispatcher. An experienced dispatcher works through the jobs in booking order and sends the nearest free technician who is qualified. A careful one also keeps enough gas technicians back so that later gas jobs can still be covered, and here that check stops the nearest choice twice. The early jobs get short drives, but by the time Job 7 comes up the only free electrician is Farah, 128 minutes away. The plan totals 521 minutes.

Cheapest pair first. A smarter rule looks at the whole board and repeatedly makes the shortest remaining qualified trip, again without leaving any job uncoverable. It totals 445 minutes, but its early grabs leave Emil a 91-minute drive to Job 2.

The optimum. Checking all 1,584 plans finds one that totals 389 minutes, and it is the only plan that low: the next best costs 406. It sends Ivo to Job 1, Gus to Job 2, Farah to Job 3, Ana to Job 4, Ben to Job 5, Hana to Job 6, Carla to Job 7 and Emil to Job 8, and keeps Dev free. Against the dispatcher it saves 132 minutes a day, about $33,000 a year over 250 working days, and against cheapest pair first it saves 56 minutes a day, about $14,000 a year, for one small team.

Greedy rules fail for the same reason in every assignment problem: a choice that is cheap now can force an expensive choice later, and a rule that never looks ahead cannot see it. The delivery route optimization guide shows the same effect when routes are built one stop at a time.

6. The Hungarian algorithm

Checking every plan works for eight jobs and fails completely for eighty. The Hungarian algorithm finds the optimum without enumeration, in time proportional to n3 for n people, as James Munkres showed in 1957. Its idea is to keep two sets of numbers, one for each side of the graph, and to adjust them until the cheapest plan becomes obvious.

  1. Reduce. Subtracting the same amount from every travel time in a row, or in a column, does not change which plan is cheapest, because every plan uses exactly one entry from each job's column. Subtract so that every row and column has a zero.
  2. Look for a complete plan among the zeros. If qualified pairs with reduced time zero form a complete matching, that plan costs nothing extra in the reduced problem, so it is optimal in the original. Finding the largest matching among zeros is a maximum flow question solved with augmenting paths.
  3. Adjust and repeat. If the zeros cannot cover every job, Kőnig's theorem says they can all be covered by fewer lines than there are jobs. Subtract the smallest uncovered value from the uncovered entries and add it where lines cross. This creates a new zero without making any entry negative, and the algorithm repeats.

Modern implementations, such as the shortest augmenting path method of Jonker and Volgenant (1987), follow the same logic with better bookkeeping, and solve problems with thousands of people in well under a second. Dimitri Bertsekas's auction algorithm (1988) reaches the same optimum by letting jobs raise their prices until every technician is happy with one, which parallelises well.

7. Prices that prove the plan is optimal

The numbers the Hungarian algorithm keeps are more than bookkeeping. At the end, they give every job a price and every technician a value, measured in minutes, with two properties: for every qualified pair, driving time is at least the job's price minus the technician's value, and for every pair in the plan the two are equal.

A grid of driving minutes with nine technician rows and eight job columns, coloured by skill, with unqualified pairs greyed out. The eight chosen pairs are highlighted in green: Ivo to Job 1 in 53 minutes, Gus to Job 2 in 51, Farah to Job 3 in 22, Ana to Job 4 in 55, Ben to Job 5 in 76, Hana to Job 6 in 23, Carla to Job 7 in 44 and Emil to Job 8 in 65. Each cell also shows its extra minutes over price minus value. A value column lists Ana 0, Ben 23, Carla 31, Dev 0, Emil 29, Farah 0, Gus 48, Hana 46 and Ivo 5. A price row lists Job 1 58, Job 2 99, Job 3 22, Job 4 55, Job 5 99, Job 6 69, Job 7 75 and Job 8 94. A note says the sum of prices, 571, minus the sum of values, 182, equals 389 minutes, the cost of the plan.
Anyone can check this certificate with a calculator. It proves that no plan beats 389 minutes without trying a single alternative.
JobJob 1Job 2Job 3Job 4Job 5Job 6Job 7Job 8
Price, minutes5899225599697594
TechnicianAnaBenCarlaDevEmilFarahGusHanaIvo
Value, minutes02331029048465

The proof takes one line. Any plan gives each job one technician and uses each technician at most once, so its total driving is at least the sum of the eight prices, 571, minus the values of the technicians it uses, which is at most 182. So every plan costs at least 389 minutes, and the green plan costs exactly that. This is linear programming duality, which Egerváry's 1931 theorem anticipated for assignment problems.

The prices also answer practical questions. The extra minutes in each cell are a lower bound on what forcing that pair would cost: sending Dev to Job 3 would add at least 23 minutes to the day. The gas jobs carry the highest prices, 94 and 99, because gas skills are scarce, which is the first hint of the next section.

8. Skills, sick days and Hall's theorem

On Thursday, Emil calls in sick. Eight technicians remain for eight jobs, so on paper everyone can be covered. They cannot. Only Ben and Gus are still qualified for gas, and there are three gas jobs.

Hall's marriage theorem (1935) makes this precise: a complete assignment exists if and only if every group of jobs has at least as many qualified people as jobs. Checking every one of the 255 non-empty groups of jobs finds exactly the failing group here, Jobs 2, 5 and 8, with only two qualified technicians. When a matching algorithm stops short, the same argument hands the planner that group, which says exactly which skill is missing rather than just that the plan failed.

Left, a bipartite graph with technicians on the left and jobs on the right, with qualification edges. Emil is marked sick and greyed out. Red edges show that gas Jobs 2, 5 and 8 connect only to Ben and Gus: three jobs, two people. Right, bars of the day's cost with driving valued at 1 dollar a minute: normal day 389 dollars; normal day with Dev trained in gas 304 dollars; Emil sick with a contractor taking Job 2, 719 dollars including a 400 dollar fee; Emil sick with Dev trained in gas, 333 dollars.
Hall's theorem finds the exact bottleneck skill. Cross-training one person pays on sick days and on ordinary days.

The best response is to send one gas job to a contractor and optimise the rest. Trying each gas job in turn, contracting Job 2 is cheapest: 319 minutes of driving plus the $400 fee, $719 for the day.

Now suppose Dev, who is only qualified for heating, had also been trained in gas. On the sick day the plan would cover every job in-house for $333, saving $386. More surprisingly, the training pays on ordinary days too: with Dev qualified, the normal-day optimum falls from 389 to 304 minutes, because Dev lives 14 minutes from Job 2 and Gus can take Job 4, only 7 minutes away. That is 85 minutes a day, about $21,250 a year, before counting a single sick day. The assignment model turns "who should we cross-train?" into a question with a number attached.

9. Drivers: least total driving or the fairest plan?

A delivery company has nine drivers for seven routes tomorrow, so two drivers will be on standby. Each driver drives from home to the start of a route:

DriverRoute 1Route 2Route 3Route 4Route 5Route 6Route 7
Ali251264710712612786
Bo16024118521048069
Cy441213195849576
Dina391041080869159
Ed129108622816037
Flo16230121571108773
Gil40132401069410687
Hal108367032897330
Ines102605533332729

Handing out routes in order, each to the nearest free driver, totals 263 minutes. The assignment with the least total driving, found among all 181,440 plans, totals 222 minutes, but it asks Cy to drive 84 minutes to Route 5 while everyone else drives half an hour or less.

Paired horizontal bars for seven routes showing each driver's minutes under two plans. Least total driving, in red: Route 1 Ali 25, Route 2 Bo 24, Route 3 Dina 10, Route 4 Ed 22, Route 5 Cy 84, Route 6 Ines 27, Route 7 Hal 30, total 222 minutes, longest 84, Flo and Gil on standby. Fairest plan, in green: Route 1 Ali 25, Route 2 Bo 24, Route 3 Dina 10, Route 4 Flo 57, Route 5 Ines 33, Route 6 Ed 60, Route 7 Hal 30, total 239 minutes, longest 60, Cy and Gil on standby. Dashed lines mark 84 and 60 minutes.
The fairest plan moves three drivers to cut the longest drive by 24 minutes, at a cost of 17 minutes in total.

Minimising the longest drive instead is the bottleneck assignment problem, studied by Oliver Gross in 1959. It is solved by asking, for a threshold, whether every route can be covered using only drives no longer than it, which is a matching question, and lowering the threshold until the answer is no. Here the lowest achievable longest drive is 60 minutes, and 60 different plans achieve it. Choosing the one with the least total driving among them gives 239 minutes: 17 minutes, or 7.7%, more than the least total, to take 24 minutes off the worst drive and send Cy to standby.

The fair plan is not fairer by every measure. It has two drives over 45 minutes, 57 and 60, where the least-total plan had one. Fairness has several reasonable definitions: the longest drive, the number of long drives, or the spread between the longest and shortest. Each is a different objective, and the model makes the trade-off visible in minutes instead of leaving it to whoever complains loudest. Over several days, rotating long assignments is another option, and it turns the problem into the kind of roster model used for shift scheduling.

10. Nurses: preferences and stable matching

A hospital unit must fill six shifts with six nurses. Each nurse ranks the shifts, and each shift's manager ranks the nurses by experience and skills:

Nurse1st choice2nd3rd4th5th6th
NoraSurgical dayICU nightEmergency nightEmergency dayICU dayChildren's night
OmarICU nightSurgical dayEmergency nightChildren's nightICU dayEmergency day
PriyaEmergency nightEmergency dayICU dayICU nightSurgical dayChildren's night
QuinnEmergency nightICU dayChildren's nightSurgical dayICU nightEmergency day
RosaSurgical dayEmergency nightChildren's nightICU nightICU dayEmergency day
SamiSurgical dayChildren's nightICU nightICU dayEmergency nightEmergency day
ShiftManager's 1st choice2nd3rd4th5th6th
ICU dayOmarNoraRosaPriyaSamiQuinn
ICU nightNoraOmarRosaPriyaQuinnSami
Emergency dayOmarNoraPriyaRosaQuinnSami
Emergency nightOmarNoraPriyaRosaSamiQuinn
Surgical dayOmarNoraPriyaSamiRosaQuinn
Children's nightNoraOmarPriyaRosaSamiQuinn

Treating each nurse's rank as a cost, the assignment problem finds the plan with the lowest total rank: 10, with two nurses getting their first choice and the other four their second. It looks ideal. It has a flaw. Priya gets Emergency day, her second choice, while Rosa gets Emergency night. Priya would rather have Emergency night, and that shift's manager would rather have Priya than Rosa. A nurse and a shift who both prefer each other to what the plan gave them form a blocking pair, and plans with blocking pairs tend not to survive contact with reality: swaps get arranged informally, and trust in the process erodes.

Three columns of nurse-to-shift assignments with each nurse's rank shown in a coloured circle. Lowest total rank: Nora Surgical day 1, Omar ICU night 1, Priya Emergency day 2, Quinn ICU day 2, Rosa Emergency night 2, Sami Children's night 2, total rank 10, with Priya highlighted in red as unstable because Priya prefers Emergency night and its manager prefers Priya. Stable with nurses proposing: Nora Surgical day 1, Omar ICU night 1, Priya Emergency night 1, Quinn Emergency day 6, Rosa Children's night 3, Sami ICU day 4, total rank 16. Stable with managers proposing: Nora ICU night 2, Omar Surgical day 2, Priya Emergency night 1, Quinn Emergency day 6, Rosa Children's night 3, Sami ICU day 4, total rank 18.
The lowest total rank leaves one nurse and one shift who would both rather swap. Both stable plans cost more in total and give Quinn a last choice.

A stable matching has no blocking pairs, and Gale and Shapley proved in 1962 that one always exists. Their deferred acceptance algorithm finds it: each nurse proposes to their favourite shift not yet tried, each manager holds on to the best proposal so far and rejects the rest, and rejected nurses propose again. Here it takes 16 proposals. When nurses propose, the result is the best stable plan for every nurse; when managers propose, it is the best for every manager.

Only two stable plans exist in this unit, with total nurse ranks of 16 and 18. The price of stability is therefore at least 6 rank points, and it falls almost entirely on Quinn, who drops from a second choice to a last choice in both. That is a real dilemma, and there is no formula that settles it. What the model provides is clarity: a manager can choose the lowest total rank and manage the one blocking pair, or choose a stable plan and give Quinn priority next roster. Alvin Roth's redesign of the US medical residency match, with Elliott Peranson in 1999, applied the same deferred acceptance idea to tens of thousands of doctors a year.

11. Beyond one person, one job

12. What is easy, what is hard

ProblemMethodDifficulty
Can every job be covered by a qualified person?Bipartite matching (Hopcroft and Karp, 1973)Polynomial
Cheapest one-to-one assignmentHungarian algorithm (Kuhn, 1955; Munkres, 1957)Polynomial, O(n3)
Assignment minimising the longest single costThreshold plus matching (Gross, 1959)Polynomial
A stable matching with two-sided preferencesDeferred acceptance (Gale and Shapley, 1962)Polynomial, O(n2)
Stable matching with the lowest total rankIrving, Leather and Gusfield (1987)Polynomial
Several jobs per person, additive costsTransportation or minimum-cost flowPolynomial
Jobs with person-specific sizes and capacitiesGeneralised assignment problemNP-hard
People, jobs and time slots togetherThree-dimensional matching (Karp, 1972)NP-hard

The assignment problem is special among combinatorial optimisation problems because its linear programming relaxation always has a whole-number optimum, a consequence of Birkhoff's 1946 theorem on doubly stochastic matrices. Rainer Burkard, Mauro Dell'Amico and Silvano Martello's book Assignment Problems covers the whole family, from these easy cases to the notoriously hard quadratic assignment problem.

13. What the model leaves out

14. From whiteboard to optimiser

Build the cost matrix from real data. Travel times come from a routing service or historical GPS data, qualifications from the HR or skills system, and preferences from a simple ranking form. Missing qualifications should be recorded as forbidden pairs, not as very large travel times entered by hand.

Price the current plans first. Take last month's dispatch decisions and compute their total travel against the optimum for the same days. In the example the gap was 132 minutes a day, and a baseline like that is the business case.

Use solid tools. SciPy's linear_sum_assignment and Google OR-Tools' linear sum assignment solver handle the assignment problem directly; minimum-cost flow solvers handle capacities; and mixed integer programming solvers handle side constraints. Stable matching takes a few dozen lines of code.

Agree the objective with the people affected. Least total cost, the longest single drive, preference ranks and stability are all reasonable goals, and they lead to different plans. Showing planners and staff the cost of each option, as sections 9 and 10 do, turns an argument about fairness into a decision.

15. Mistakes that quietly cost money

16. Frequently asked questions

What is the assignment problem?

+

It is the problem of assigning people to tasks, one task each, so that the total cost, such as travel time, is as small as possible. In graph terms it is finding a minimum-cost perfect matching in a bipartite graph with people on one side and tasks on the other. It can be solved exactly in polynomial time with the Hungarian algorithm, even for thousands of people.

How does the Hungarian algorithm work?

+

It subtracts amounts from rows and columns of the cost matrix, which does not change the best assignment, until a complete assignment can be made using only zero entries. When the zeros are not enough, it adjusts the numbers to create a new zero and repeats. The amounts subtracted become prices and values that prove the final assignment is optimal, and the algorithm runs in time proportional to the cube of the number of people.

Why not send the nearest available worker to each job?

+

Because a short trip now can force a long trip later, when the good options are gone. In the article's example, dispatching jobs in booking order to the nearest qualified technician cost 521 minutes of driving, against 389 for the optimal plan, and choosing the cheapest remaining pair each time still cost 445 minutes.

What does Hall's theorem say about skills?

+

Hall's marriage theorem says every job can be given a different qualified person exactly when every group of jobs has at least as many qualified people as jobs. When coverage fails, the theorem points to the group that is short. In the example, with one gas technician sick, three gas jobs had only two qualified people, so no plan could cover the day even though there were as many people as jobs.

How can work be assigned fairly?

+

One common approach minimises the worst individual cost, such as the longest drive, which is the bottleneck assignment problem, and then minimises the total among plans with that worst case. In the example this cut the longest drive from 84 to 60 minutes for 17 extra minutes of total driving. Other fairness goals, such as limiting the number of long drives or rotating them across days, lead to different plans.

What is a stable matching in nurse scheduling?

+

It is an assignment of nurses to shifts with no nurse and shift that would both prefer each other to what they were given. The Gale-Shapley deferred acceptance algorithm always finds one. A plan with the best total preference rank can be unstable: in the example it had a total rank of 10 but one blocking pair, while the stable plans had total ranks of 16 and 18.

What software solves assignment problems?

+

SciPy's linear_sum_assignment and Google OR-Tools solve the classic assignment problem in a few lines of code. Minimum-cost flow solvers handle people who can take several jobs, and mixed integer programming solvers such as HiGHS or Gurobi handle side constraints like working-time rules. Field service and workforce management systems often include these solvers behind their dispatch screens.

17. References

The foundational papers, surveys and books behind the methods in this article, in chronological order.

  1. Egerváry, J. (1931). “Mátrixok kombinatorikus tulajdonságairól.” Matematikai és Fizikai Lapok, 38, 16–28.
  2. Kőnig, D. (1931). “Gráfok és mátrixok.” Matematikai és Fizikai Lapok, 38, 116–119.
  3. Hall, P. (1935). “On representatives of subsets.” Journal of the London Mathematical Society, 10(1), 26–30.
  4. Birkhoff, G. (1946). “Tres observaciones sobre el álgebra lineal.” Universidad Nacional de Tucumán, Revista Serie A, 5, 147–151.
  5. Kuhn, H. W. (1955). “The Hungarian method for the assignment problem.” Naval Research Logistics Quarterly, 2(1–2), 83–97.
  6. Munkres, J. (1957). “Algorithms for the assignment and transportation problems.” Journal of the Society for Industrial and Applied Mathematics, 5(1), 32–38.
  7. Gross, O. (1959). The Bottleneck Assignment Problem. Paper P-1630. Santa Monica: RAND Corporation.
  8. Gale, D. and Shapley, L. S. (1962). “College admissions and the stability of marriage.” American Mathematical Monthly, 69(1), 9–15.
  9. Karp, R. M. (1972). “Reducibility among combinatorial problems.” In R. E. Miller and J. W. Thatcher (eds.), Complexity of Computer Computations, 85–103. New York: Plenum.
  10. Hopcroft, J. E. and Karp, R. M. (1973). “An n5/2 algorithm for maximum matchings in bipartite graphs.” SIAM Journal on Computing, 2(4), 225–231.
  11. Ross, G. T. and Soland, R. M. (1975). “A branch and bound algorithm for the generalized assignment problem.” Mathematical Programming, 8(1), 91–103.
  12. Jonker, R. and Volgenant, A. (1987). “A shortest augmenting path algorithm for dense and sparse linear assignment problems.” Computing, 38(4), 325–340.
  13. Irving, R. W., Leather, P. and Gusfield, D. (1987). “An efficient algorithm for the ‘optimal’ stable marriage.” Journal of the ACM, 34(3), 532–543.
  14. Bertsekas, D. P. (1988). “The auction algorithm: a distributed relaxation method for the assignment problem.” Annals of Operations Research, 14(1), 105–123.
  15. Roth, A. E. and Peranson, E. (1999). “The redesign of the matching market for American physicians: some engineering aspects of economic design.” American Economic Review, 89(4), 748–780.
  16. Burke, E. K., De Causmaecker, P., Vanden Berghe, G. and Van Landeghem, H. (2004). “The state of the art of nurse rostering.” Journal of Scheduling, 7(6), 441–499.
  17. Burkard, R., Dell'Amico, M. and Martello, S. (2012). Assignment Problems, revised reprint. Philadelphia: SIAM.

See Matching as a Flow Problem

Connect a source to every worker and every job to a sink, and watch augmenting paths find the largest set of assignments. It is the engine inside the Hungarian algorithm.

Open the Max-Flow Visualizer