Assignment Problem

The problem of assigning nn agents to nn tasks one-to-one, minimizing total cost, given a cost cijc_{ij} for assigning agent ii to task jj. A special case of the transportation problem.

minimize z=∑i=1n∑j=1ncijxij\text{minimize } z = \sum_{i=1}^{n} \sum_{j=1}^{n} c_{ij} x_{ij}

Subject to ∑jxij=1\sum_j x_{ij} = 1 for every agent, ∑ixij=1\sum_i x_{ij} = 1 for every task, and xij∈{0,1}x_{ij} \in \{0, 1\}.

Every supply and demand equals 1, so every basic feasible solution is inherently degenerate (nn occupied cells needed for a non-degenerate BFS, but only nn assignments exist against 2n−12n - 1 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 MM, driving it out of the optimal assignment.

Big MM 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 nn, 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 nn lines are needed, select nn 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:

1 /

0 entry covering line assigned updated this step

Balanced, since 3 agents equal 3 tasks.

Subtract each row’s minimum (22, 33, 11) from every entry in that row.

Subtract each column’s minimum (33, 00, 00) from every entry in that column. Covering all 0s needs 3 lines (row Agent 2, column Task 2, column Task 3), equal to n=3n = 3: an optimal assignment exists among the 0s.

z=2+6+1=9z = 2 + 6 + 1 = 9

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.

1 /

0 entry covering line assigned updated this step

Balanced, since 3 agents equal 3 tasks.

Subtract each row’s minimum (22, 33, 11) from every entry in that row.

Subtract each column’s minimum (11, 00, 44) from every entry in that column. Covering all 0s needs only 2 lines (row Agent 2, column Task 2), fewer than n=3n = 3, so no optimal assignment exists yet. The smallest uncovered entry is 11.

Subtract 11 from every uncovered entry (Agents 1 and 3, Tasks 1 and 3). Add 11 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 n=3n = 3. An optimal assignment exists among the 0s.

z=4+7+1=12z = 4 + 7 + 1 = 12

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 z=12z = 12, so the optimum is not unique.

Wolfram Mathematica notebooks

A companion notebook for this note. Open it in Mathematica and evaluate the cells to reproduce the worked example.

The summary notebook defines every function used in this module, with documentation and no examples, as a starting point for your own problems.

Written by October 25, 2026 4 min read
Was this helpful?