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:

3080965311169718
2337094247038634
32145823218548455
229837962156859
77469195833377783
69476851736476
199992118923559346
80435755868328568
199583374524833371

Subtract row minima

We subtract the row minimum from each row:

2979955200159617(-1)
0316892226818432(-2)
30125603016528253(-2)
027817741936657(-2)
70398488762607076(-7)
25436447332072(-4)
8888107812448235(-11)
72354947787520480(-8)
0766418265641452(-19)

Subtract column minima

We subtract the column minimum from each column:

2974525200159617
0262592226818432
3071303016528253
022387741936657
70344188762607076
2006447332072
8833807812448235
7230647787520480
0712118265641452
(-5)(-43)

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

2974525200159617  x
0262592226818432
3071303016528253
022387741936657
70344188762607076  x
2006447332072  x
8833807812448235
7230647787520480  x
0712118265641452
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:

3074525300159617
0252492216708331
3061202915518152
021377731826556
71344189762607076
3006547332072
8823707711438134
7330648787520480
0702018254631351

Cover all zeros with a minimum number of lines

There are 6 lines required to cover all zeros:

3074525300159617  x
0252492216708331
3061202915518152
021377731826556
71344189762607076
3006547332072  x
8823707711438134
7330648787520480  x
0702018254631351
xxx

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:

3374525600189617
0222192186408028
303902612517849
018347701526253
71313889732306773
6006847335072
879340748437831
7630651787523480
0671718221631048

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

3374525600189617  x
0222192186408028
303902612517849
018347701526253  x
71313889732306773
6006847335072  x
879340748437831
7630651787523480  x
0671718221631048
xxx

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:

3474525700199617
0212092176307927
302802511517748
118347801536253
71303789722206672
7006947336072
878330737437730
7730652787524480
066161821063947

Cover all zeros with a minimum number of lines

There are 7 lines required to cover all zeros:

3474525700199617
0212092176307927
302802511517748
118347801536253
71303789722206672
7006947336072  x
878330737437730
7730652787524480  x
066161821063947
xxxxx

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:

3472505700199415
0191892176307725
300602511517546
116327801536051
71283589722206470
9007149538072
876310737437528
7930654807726480
064141821063745

Cover all zeros with a minimum number of lines

There are 8 lines required to cover all zeros:

3472505700199415
0191892176307725
300602511517546  x
116327801536051
71283589722206470
9007149538072  x
876310737437528  x
7930654807726480  x
064141821063745
xxxx

Create additional zeros

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

346543500019878
0121185176307018
370603218587546
19257101535344
71212882722205763
160071561245072
15763108014507528
8630654878433480
05771121063038

Cover all zeros with a minimum number of lines

There are 9 lines required to cover all zeros:

346543500019878  x
0121185176307018  x
370603218587546  x
19257101535344  x
71212882722205763  x
160071561245072  x
15763108014507528  x
8630654878433480  x
05771121063038  x

The optimal assignment

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

346543500019878
0121185176307018
370603218587546
19257101535344
71212882722205763
160071561245072
15763108014507528
8630654878433480
05771121063038

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

3080965311169718
2337094247038634
32145823218548455
229837962156859
77469195833377783
69476851736476
199992118923559346
80435755868328568
199583374524833371

The optimal value equals 129.