An assignment problem: n workers, n jobs, a cost for each pairing. One job per worker, one worker per job. The Hungarian algorithm finds the matching with the smallest total cost by reducing the cost table until the answer shows up as zeros.
Adjustment: smallest uncovered number, subtract it from all uncovered, add it to any number covered twice.
3ร3 costs reduce to the table below; the zeros cover with 3 lines, so we assign.
| J1 | J2 | J3 | |
|---|---|---|---|
| W1 | 0 | 0 | 5 |
| W2 | 0 | 7 | 7 |
| W3 | 6 | 5 | 0 |
W1 โ J2, W2 โ J1, W3 โ J3. Cost from the original table: 11 + 6 + 6 = $23.
โข Read the final cost off the original table, the reducing was just to find the pairing.
โข You can only assign when the covering lines equal n.
โข Each assignment uses one zero per row and per column.
โข If lines < n, do the adjustment, don't force an assignment.
| J1 | J2 | J3 | |
|---|---|---|---|
| W1 | 9 | 11 | 14 |
| W2 | 6 | 15 | 13 |
| W3 | 12 | 13 | 6 |
| J1 | J2 | J3 | |
|---|---|---|---|
| W1 | 0 | 2 | 5 |
| W2 | 0 | 9 | 7 |
| W3 | 6 | 7 | 0 |
| J1 | J2 | J3 | |
|---|---|---|---|
| W1 | 0 | 0 | 5 |
| W2 | 0 | 7 | 7 |
| W3 | 6 | 5 | 0 |
Each reduction makes more zeros. Once the zeros need n lines to cover, you can read off one zero per row and column.
Gold zeros = the chosen pairings: W1 โ J2, W2 โ J1, W3 โ J3. One per row, one per column. Total from the original table = $23.
Don't read yet, just have a go in your head:
Row W1 is 9, 11, 14. Smallest is 9. Subtract: 0, 2, 5.
Row W3 is 12, 13, 6. Smallest is 6. Subtract 6: 6, 7, ? โ the new row is 6, 7, ?
After row reduction the column 2 entries are 2, 9, 7. Column reduce this column (subtract its smallest). What does it become? Check below.
In one sentence, out loud: when are you allowed to make the assignment?