The problem of assigning agents to tasks one-to-one, minimizing total cost, given a cost for assigning agent to task . A special case of the transportation problem.
Subject to for every agent, for every task, and .
Every supply and demand equals 1, so every basic feasible solution is inherently degenerate ( occupied cells needed for a non-degenerate BFS, but only assignments exist against required).
Balanced
An assignment problem is balanced iff the number of agents equals the number of tasks.
Unbalanced
When the problem is not balanced. Dummy agents or tasks are added to rebalance.
- Minimisation problem
Use 0 as the dummy assignment cost. - Maximisation problem
First convert the profit matrix to a minimisation cost matrix. Then use 0 as the dummy assignment cost.
Maximization
A maximization assignment problem is one where the objective is to maximize total cost.
The problem is converted to minimization by subtracting every cost from the largest cost in the matrix, then solve as usual.
Restricted
An assignment problem is restricted iff there are prohibited agent-task pairs.
A prohibited agent-task pair is assigned a very large cost , driving it out of the optimal assignment.
Big is used for prohibited assignments. It is not required for an ordinary dummy assignment after a maximisation problem has been converted to a minimisation problem.
Hungarian Method
Solves a balanced assignment problem in polynomial time, avoiding the degeneracy the transportation methods would hit.
Steps
- Row reduction
Subtract the minimum entry of each row from every entry in that row. - Column reduction
Subtract the minimum entry of each column from every entry in that column. - Cover all 0s in the resulting matrix using the minimum number of horizontal and vertical lines.
- If the number of lines equals , an optimal assignment exists among the 0s. Stop.
- Otherwise, find the smallest uncovered entry. Subtract it from every uncovered entry, and add it to every entry covered twice (at a line intersection). Repeat the covering step.
Reading the Assignment
Once lines are needed, select independent 0s (1 per row and column) by assigning rows/columns with a unique 0 first, then resolving remaining choices, until every agent is assigned a task.
Worked Examples
Simple Example
3 agents and 3 tasks, with cost matrix:
0 entry covering line assigned updated this step
Balanced, since 3 agents equal 3 tasks.
Subtract each row’s minimum (, , ) from every entry in that row.
Subtract each column’s minimum (, , ) from every entry in that column. Covering all 0s needs 3 lines (row Agent 2, column Task 2, column Task 3), equal to : an optimal assignment exists among the 0s.
Independent 0s, 1 per row and column: Agent 1 has a single 0, at Task 2. Agent 3 has a single 0, at Task 3. Task 1 is then Agent 2’s only remaining column.
Adjusting the Matrix
Here the 0s need only 2 lines after reduction, so no assignment exists yet. The matrix is adjusted and covered again.
0 entry covering line assigned updated this step
Balanced, since 3 agents equal 3 tasks.
Subtract each row’s minimum (, , ) from every entry in that row.
Subtract each column’s minimum (, , ) from every entry in that column. Covering all 0s needs only 2 lines (row Agent 2, column Task 2), fewer than , so no optimal assignment exists yet. The smallest uncovered entry is .
Subtract from every uncovered entry (Agents 1 and 3, Tasks 1 and 3). Add to the entry covered twice (Agent 2, Task 2). Entries covered once stay unchanged.
Covering all 0s needs 3 lines (Task 1, Task 2, Task 3), equal to . An optimal assignment exists among the 0s.
No row or column has a single 0 here, so choose one. Agent 1 to Task 1 forces Agent 2 to Task 3 and Agent 3 to Task 2. Agent 1 to Task 2 also gives , so the optimum is not unique.