The Assignment Problem is a special case of the transportation problem in which \(n\) tasks (jobs) must be assigned to \(n\) agents (workers / machines), one-to-one, so as to minimise total cost (or maximise profit). Each agent does exactly one job and each job is done by exactly one agent.
Examples:
Let \(c_{ij}\) = cost of assigning agent \(i\) to job \(j\) (\(i, j = 1, \ldots, n\)) and \(x_{ij} \in \{0, 1\}\) the assignment variable. Then:
Subject to:
\[ \sum_{j=1}^{n} x_{ij} = 1, \quad i = 1, 2, \ldots, n \quad \text{(each agent does exactly one job)}, \] \[ \sum_{i=1}^{n} x_{ij} = 1, \quad j = 1, 2, \ldots, n \quad \text{(each job done by exactly one agent)}, \] \[ x_{ij} \in \{0, 1\}. \]It can be viewed as a balanced TP with all supplies and demands equal to 1.
Solving an AP through TP/Simplex works but is slow because every BFS has only \(n\) non-zero values (one per row/column) but the TP framework expects \(2n − 1\) — so each AP is heavily degenerate. The Hungarian method (König 1916, Egerváry 1931, Kuhn 1955) exploits the assignment structure to solve the problem in \(O(n^3)\) time using only integer arithmetic.
Adding a constant to a row or column does not change the optimum assignment (only shifts the total cost by that constant). Step 4 transforms the matrix while preserving the optimal solution, until the matrix has enough zeros to make a valid assignment.
Assign jobs J₁..J₄ to workers W₁..W₄ to minimise total time:
| J₁ | J₂ | J₃ | J₄ | |
|---|---|---|---|---|
| W₁ | 10 | 12 | 19 | 11 |
| W₂ | 5 | 10 | 7 | 8 |
| W₃ | 12 | 14 | 13 | 11 |
| W₄ | 8 | 15 | 11 | 9 |
Row reduction — subtract row mins (10, 5, 11, 8):
| J₁ | J₂ | J₃ | J₄ | |
|---|---|---|---|---|
| W₁ | 0 | 2 | 9 | 1 |
| W₂ | 0 | 5 | 2 | 3 |
| W₃ | 1 | 3 | 2 | 0 |
| W₄ | 0 | 7 | 3 | 1 |
Column reduction — subtract column mins (0, 2, 2, 0):
| J₁ | J₂ | J₃ | J₄ | |
|---|---|---|---|---|
| W₁ | 0 | 0 | 7 | 1 |
| W₂ | 0 | 3 | 0 | 3 |
| W₃ | 1 | 1 | 0 | 0 |
| W₄ | 0 | 5 | 1 | 1 |
Make assignments: Row 1: only zero at J₂ (J₁ is shared) → assign W₁→J₂. Row 4: zero at J₁ → assign W₄→J₁. Row 2: zero at J₃ → assign W₂→J₃. Row 3: zero at J₄ → assign W₃→J₄.
All 4 rows assigned ⇒ optimum found.
Total cost (read from the original matrix): W₁→J₂ = 12, W₂→J₃ = 7, W₃→J₄ = 11, W₄→J₁ = 8. Sum = 12 + 7 + 11 + 8 = 38.
Consider:
| J₁ | J₂ | J₃ | |
|---|---|---|---|
| W₁ | 3 | 5 | 4 |
| W₂ | 5 | 3 | 2 |
| W₃ | 4 | 4 | 5 |
Row mins: 3, 2, 4. After row reduction:
| J₁ | J₂ | J₃ | |
|---|---|---|---|
| W₁ | 0 | 2 | 1 |
| W₂ | 3 | 1 | 0 |
| W₃ | 0 | 0 | 1 |
Column mins: 0, 0, 0 — no further reduction needed. Assignments: W₁→J₁ (only zero in row 1), W₂→J₃ (only zero in row 2), W₃→J₂. All distinct columns ⇒ optimum.
Cost = 3 + 2 + 4 = 9.
If the number of agents ≠ number of jobs, add dummy rows or columns with zero costs to make the matrix square. Then apply the Hungarian method as usual.
Dummy assignments mean the corresponding agent (or job) is not used.
4 workers and 3 jobs. Add a dummy job J₄ with cost 0 for all workers:
| J₁ | J₂ | J₃ | J₄ (dummy) | |
|---|---|---|---|---|
| W₁ | 9 | 14 | 19 | 0 |
| W₂ | 7 | 17 | 20 | 0 |
| W₃ | 9 | 18 | 21 | 0 |
| W₄ | 10 | 12 | 18 | 0 |
One worker will be assigned to the dummy job — that worker remains idle.
3 workers and 4 jobs. Add a dummy worker W₄ with cost 0 for all jobs. One job will go to the dummy and stay unfinished.
If \(c_{ij}\) represents profit and we want to maximise:
Profit matrix:
| R₁ | R₂ | R₃ | |
|---|---|---|---|
| S₁ | 40 | 52 | 49 |
| S₂ | 32 | 46 | 58 |
| S₃ | 56 | 54 | 47 |
M = 58. Transformed (loss) matrix:
| R₁ | R₂ | R₃ | |
|---|---|---|---|
| S₁ | 18 | 6 | 9 |
| S₂ | 26 | 12 | 0 |
| S₃ | 2 | 4 | 11 |
Apply Hungarian to this matrix.
Sometimes certain assignments are forbidden (a worker cannot do a specific job, an item cannot be shipped via a certain route).
Assign a very large cost \(M\) (often denoted ∞ or 10⁹) to the forbidden cells before running the Hungarian method. The optimum solution will avoid these cells.
4 workers × 4 jobs but W₃ cannot do J₂ and W₁ cannot do J₄. Set those cells to M:
| J₁ | J₂ | J₃ | J₄ | |
|---|---|---|---|---|
| W₁ | 4 | 2 | 7 | M |
| W₂ | 3 | 5 | 6 | 4 |
| W₃ | 5 | M | 4 | 3 |
| W₄ | 6 | 4 | 8 | 5 |
Apply Hungarian; the algorithm naturally avoids cells with M.
The classical Travelling Salesman Problem (TSP) asks for the shortest cyclic route visiting each city exactly once and returning to the origin. It can be formulated as an assignment problem with the extra constraint that the solution must form a single cycle (no sub-tours).
Pure Hungarian may yield sub-tours; specialised branch-and-bound is required for true TSP solutions. (Outside the scope of this course but worth knowing.)