Allocation Problems: The Hungarian Algorithm and LP Formulations | Edexcel A Level Further Maths notes
Free preview: Allocation Problems: The Hungarian Algorithm and LP Formulations
Allocation Problems and Reducing the Matrix
Year 2 (A level): this is on Edexcel's A level Decision Mathematics 2 paper (9FM0/4D). Check your own specification if you are unsure when it is taught.
Four workers A, B, C and D must each do exactly one of four jobs 1, 2, 3 and 4. The table gives the time (minutes) each worker takes on each job. How should we pair them up to keep the total time as small as possible?
| 1 | 2 | 3 | 4 | |
|---|---|---|---|---|
| A | 14 | 5 | 8 | 7 |
| B | 2 | 12 | 6 | 5 |
| C | 7 | 8 | 3 | 9 |
| D | 2 | 4 | 6 | 10 |
- This is an allocation (assignment) problem: each worker gets one job and each job gets one worker.
- A greedy plan fails. B and D are both fastest on job 1 (2 minutes), but only one of them can have it.
- With 4 workers there are possible pairings. Checking them all is slow; for 6 workers it would be 720.
- The Hungarian algorithm finds the best pairing using an n by n cost matrix.
Step 1: reduce rows, then columns
- Subtract the smallest number in each row from every number in that row. Why: every worker has to do some job, so their fastest time is a cost they pay anyway.
- Then subtract the smallest number in each column from that column. Why: same idea for the jobs.
- Now every row and every column has at least one zero.
๐ Watch me do it: reduce the workers' matrix
| What I write | Why I do it |
|---|---|
| Row minima: 5, 2, 3, 2. | A's smallest is 5, B's 2, C's 3, D's 2. |
| A: 9, 0, 3, 2. B: 0, 10, 4, 3. C: 4, 5, 0, 6. D: 0, 2, 4, 8. | Subtract each row's minimum. |
| Column minima now: 0, 0, 0, 2. | Only column 4 has no zero yet. |
| Column 4 becomes 0, 1, 4, 6. | Subtract 2 down column 4. |
| 1 | 2 | 3 | 4 | |
|---|---|---|---|---|
| A | 9 | 0 | 3 | 0 |
| B | 0 | 10 | 4 | 1 |
| C | 4 | 5 | 0 | 4 |
| D | 0 | 2 | 4 | 6 |
- Taking a fixed amount off a whole row or column changes every pairing's total by the same amount, so the best pairing does not change.
- A zero marks a pairing that is as cheap as possible for that row or column.
โ๏ธ YOUR TURN 1
Try this first:
Reduce this matrix (rows, then columns) and, if possible, allocate using zeros. Give the minimum total from the original costs.
| 1 | 2 | 3 | |
|---|---|---|---|
| A | 9 | 4 | 7 |
| B | 6 | 8 | 5 |
| C | 3 | 7 | 6 |
Answer:
- Row minima 4, 5, 3: rows become (5, 0, 3), (1, 3, 0), (0, 4, 3).
- Each column already has a zero, so the columns don't change.
- Zeros at A2, B3, C1: one in each row and column. Allocate A to 2, B to 3, C to 1.
- Total .
Covering the Zeros
In the reduced matrix, can we pick one zero in every row and every column? The test is to cover the zeros with lines.
Step 2: the recipe
- Cover all the zeros with the fewest horizontal and vertical lines.
- Try rows or columns with several zeros first. Why: one line then covers more zeros.
- If the number of lines equals n, an optimal allocation can be made from the zeros. Allocate.
- If it is less than n, go to step 3 (adjust).
๐ Watch me do it: cover the reduced workers' matrix
| What I write | Why I do it |
|---|---|
| Zeros: A2, A4, B1, C3, D1. | List them. |
| Row A covers A2 and A4. | Row A has two zeros. |
| Column 1 covers B1 and D1. | Column 1 has two zeros. |
| Column 3 covers C3. | The last zero. |
| 3 lines, but n = 4. | Not enough: B and D both need job 1, so we can't allocate yet. |
๐ก Why the line count matters
- The fewest lines that cover all the zeros equals the largest number of zeros you can choose with no two in the same row or column.
- So n lines means a full allocation exists among the zeros. Fewer than n means it doesn't (yet).
Allocating from the zeros
- Start with a row or column that has only one zero. That pairing is forced.
- Cross out that row and column.
- Repeat until everyone is allocated.
- Total from the original matrix, not the reduced one.
โ๏ธ YOUR TURN 2
Try this first:
A reduced 3 by 3 matrix has zeros at A1, A3, B2 and C2 only. What is the fewest number of lines, and can you allocate?
Answer:
- Column 2 covers B2 and C2; row A covers A1 and A3. So 2 lines.
- 2 < 3, so you cannot allocate yet: B and C both have their only zero in column 2.
Adjusting the Matrix
Step 3: the recipe
- Find the smallest uncovered number, call it e.
- Subtract e from every uncovered number. Why: this makes at least one new zero.
- Add e to every number covered twice (where two lines cross).
- Numbers covered once stay the same. Go back to step 2.
๐ Watch me do it: adjust the workers' matrix
| What I write | Why I do it |
|---|---|
| Uncovered cells: rows B, C, D in columns 2 and 4: 10, 1, 5, 4, 2, 6. | Everything not under a line. |
| Smallest is e = 1 (at B4). | |
| Uncovered: subtract 1. B4 becomes 0. | A new zero. |
| Crossings A1 and A3: add 1, giving 10 and 4. | Row A crosses columns 1 and 3 there. |
| Others covered once: unchanged. |
Unlock the full note: start 7 days free.
Log in or subscribe to read the rest of this note. Members also get the AI tutor, practice quizzes, mock exams and flashcards for this topic.
Log in ยท Subscribe ยท Start free trial
All notes in Transportation and Allocation Problems
- Transportation Problems: Balancing, North-West Corner and Degeneracy
- Transportation Problems: Shadow Costs, Improvement Indices and Stepping Stones
- Allocation Problems: The Hungarian Algorithm and LP Formulations
What's inside for this topic
3 teacher notes, 94 practice questions, 49 flashcards, 2 quizzes.
Get the full notes, every practice question, flashcards, quizzes and mock papers.
Previous note: Transportation Problems: Shadow Costs, Improvement Indices and Stepping Stones
All Edexcel A Level Further Maths topics ยท A Level Further Maths