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):

Size: 3x3 4x4 5x5 6x6 7x7 8x8 9x9 10x10

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

This is the original cost matrix:

1093964046
769944974
3955251027
2178102366
6426468833

Subtract row minima

We subtract the row minimum from each row:

083863036(-10)
729504570(-4)
294515017(-10)
116801356(-10)
38020627(-26)

Subtract column minima

We subtract the column minimum from each column:

083863029
729504563
294515010
116801349
38020620
(-7)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

083863029  x
729504563
294515010  x
116801349
38020620  x
x

Create additional zeros

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

083973029
618403452
294526010
0570238
38031620

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

083973029
618403452
294526010  x
0570238
38031620  x
xx

Create additional zeros

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

081972827
618203250
314528010
0550036
40033620

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

081972827
618203250
314528010
0550036
40033620  x
xxx

Create additional zeros

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

071972817
617203240
31352800
0450026
50043720

Cover all zeros with a minimum number of lines

There are 5 lines required to cover all zeros:

071972817  x
617203240  x
31352800  x
0450026  x
50043720  x

The optimal assignment

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

071972817
617203240
31352800
0450026
50043720

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

1093964046
769944974
3955251027
2178102366
6426468833

The optimal value equals 90.