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:

8739976182718131
79238978810787794
114495222821956798
775128493655906684
39476529415145189
719836927568458844
32408539658464719
70732542160864774
72162119294992926

Subtract row minima

We subtract the row minimum from each row:

8406945879687828(-3)
7216820813717087(-7)
03384111710845687(-11)
4923021827623856(-28)
35072489011104785(-4)
356205639329528(-36)
24327731570383911(-8)
66692101756824370(-4)
7014099092972724(-2)

Subtract column minima

We subtract the column minimum from each column:

8406945079595120
7216820733624379
0338411910752979
4923021027531148
3507248821112077
356205631320250
2432773149029123
6669210956731662
701409829288016
(-8)(-9)(-27)(-8)

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

8406945079595120
7216820733624379
0338411910752979  x
4923021027531148  x
3507248821112077
356205631320250  x
2432773149029123  x
6669210956731662
701409829288016  x
xx

Create additional zeros

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

8305944978585019
7116810722614278
0348412910752979
4924022027531148
3407148811001976
356305731320250
2433773249029123
6569200855721561
7015010829288016

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

8305944978585019  x
7116810722614278
0348412910752979  x
4924022027531148  x
3407148811001976  x
356305731320250  x
2433773249029123  x
6569200855721561
7015010829288016  x
x

Create additional zeros

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

8305964978585019
6914790700594076
0348414910752979
4924024027531148
3407150811001976
356305931320250
2433773449029123
6367180653701359
7015012829288016

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

8305964978585019  x
6914790700594076
0348414910752979  x
4924024027531148  x
3407150811001976  x
356305931320250  x
2433773449029123
6367180653701359
7015012829288016  x
xx

Create additional zeros

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

8305994981585019
6611760670563773
0348417913752979
4924027030531148
3407153811301976
356306231350250
213074344602690
6064150353671056
7015015829588016

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

8305994981585019  x
6611760670563773  x
0348417913752979  x
4924027030531148  x
3407153811301976  x
356306231350250  x
213074344602690  x
6064150353671056  x
7015015829588016  x

The optimal assignment

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

8305994981585019
6611760670563773
0348417913752979
4924027030531148
3407153811301976
356306231350250
213074344602690
6064150353671056
7015015829588016

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

8739976182718131
79238978810787794
114495222821956798
775128493655906684
39476529415145189
719836927568458844
32408539658464719
70732542160864774
72162119294992926

The optimal value equals 162.