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:

 19 98 58 54 84 81 83 26 61 54 43 1 63 80 31 9

Subtract row minima

We subtract the row minimum from each row:

 0 79 39 35 (-19) 58 55 57 0 (-26) 60 53 42 0 (-1) 54 71 22 0 (-9)

Subtract column minima

We subtract the column minimum from each column:

 0 26 17 35 58 2 35 0 60 0 20 0 54 18 0 0 (-53) (-22)

Cover all zeros with a minimum number of lines

There are 4 lines required to cover all zeros:

 0 26 17 35 x 58 2 35 0 x 60 0 20 0 x 54 18 0 0 x

The optimal assignment

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

 0 26 17 35 58 2 35 0 60 0 20 0 54 18 0 0

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

 19 98 58 54 84 81 83 26 61 54 43 1 63 80 31 9

The optimal value equals 130.