Solve an assignment problem online

Fill in the cost matrix of an assignment problem and click on 'Solve'. The optimal assignment will be determined and a step by step explanation of the hungarian algorithm will be given.

Fill in the cost matrix (random cost matrix):

Don't show the steps of the Hungarian algorithm
Maximize the total cost

This is the original cost matrix:

108125150
150135175
122148250

Subtract row minima

We subtract the row minimum from each row:

01742(-108)
15040(-135)
026128(-122)

Subtract column minima

We subtract the column minimum from each column:

0172
1500
02688
(-40)

Cover all zeros with a minimum number of lines

There are 2 lines required to cover all zeros:

0172
1500  x
02688
x

Create additional zeros

The number of lines is smaller than 3. The smallest uncovered number is 2. We subtract this number from all uncovered elements and add it to all elements that are covered twice:

0150
1700
02486

Cover all zeros with a minimum number of lines

There are 3 lines required to cover all zeros:

0150  x
1700  x
02486  x

The optimal assignment

Because there are 3 lines required, the zeros cover an optimal assignment:

0150
1700
02486

This corresponds to the following optimal assignment in the original cost matrix:

108125150
150135175
122148250

The optimal value equals 407.