Hungarian algorithm as a linear programmeEdexcel A-Level Further Maths: Revision notes
Section 1
Turning an allocation problem into an LP
An allocation problem can be written as a linear programme. For workers and tasks, define a binary variable for every pairing: The first subscript is the worker (row of the matrix) and the second is the task (column). A complete allocation is a choice of values of , and the cost is read from the cost matrix.
Swapping the subscripts. means worker 2 does task 3, not worker 3 does task 2.
Section 2
The objective function
Only chosen pairings () add their cost, so the total cost is To minimise cost, minimise this expression. For maximum profit, use profits and maximise (no conversion to a minimum is needed in an LP). Example: costs give minimise .
Section 3
The constraints
Each worker does exactly one task, and each task is done by exactly one worker:
- for each worker : ( constraints);
- for each task : ( constraints). Also . That is equality constraints and variables. Example, : worker 2 gives , and task 3 gives .
Check by counting: an problem has equalities and variables.
Section 4
Unequal numbers and impossible pairings
Unequal numbers. With more workers than tasks, every task is still done exactly once, but each worker does at most one task: . Equalities for every worker would be impossible. (This does the same job as adding a dummy task.) Impossible pairing. If worker cannot do task , leave out of the objective and constraints, or add . This does the same job as the large number in the algorithm. Maximising. Keep the profit matrix and write maximise .
Section 5
Worked example and what the algorithm cannot do
Three technicians and three tasks with profits (the dash means impossible): maximise subject to , , , , , . The best choice is with profit . The LP form is more flexible. A condition such as (the two pairings cannot both be used) is not a row or column condition, so the Hungarian algorithm cannot handle it, but it can be added to the LP. Here it rules out the best allocation, and the best remaining one is with profit .
Using equalities for the workers when there are more workers than tasks. Use at most one for the workers.
That's the notes covered.
Carry on to the next subtopic.
Exam questions on Hungarian algorithm as a linear programme
- A hospital assigns three nurses, 1, 2 and 3, to three wards, 1, 2 and 3, with one nurse on each ward. Let if nurse is assigned to ward , and otherwise. The cost, in £ hundred, of nurse on ward is the entry in row , column of . The hospital wants the total cost to be as small as possible and formulates the problem as a linear programme.Write down the constraint that ensures nurse 2 is assigned to exactly one ward, and state the values each may take.2 marks
- A company has four representatives and four regions. Let be the profit, in £ hundred, when representative works in region , and let if representative is sent to region and otherwise. Each representative goes to exactly one region and each region receives exactly one representative. The company wants to maximise the total profit and formulates the problem as a linear programme.The allocation , with all other variables , has , , and . Show that this allocation satisfies the constraints for representative 1 and for region 1, and find its total profit.2 marks
- A firm has four workers and three tasks. Each task must be done by exactly one worker and each worker does at most one task. The time, in hours, for worker to do task is the entry in row , column of . The firm wants the total time to be as small as possible and formulates the problem as a linear programme.Define suitable variables and write down the objective function.3 marks
Written by the Exaim team, led by Shaun Daswani (Head of Upper Secondary, Improve ME Institute; MSc Financial Mathematics, Imperial College London; BSc, UCL) and Jason Daswani (operational lead, Improve ME Institute; LSE).