Operational
Research
Hungarian Algorithm
Hungarian method
 This method is a “Combinatorial Optimization
Algorithm” that solves assignment problems
 Developed and published by Harold Kuhn in
1955
 Basically, this method is for assigning jobs by
one-for-one matching to identify the lowest
cost solution
 This method is actually a special case of
Primal-Dual algorithm
2
Example
A building firm possesses four cranes each of which
has a distance(km) from four different construction
sites as shown in the table
Construction site #
1 2 3 4
Crane #
1 90 75 75 80
2 35 85 55 65
3 125 95 90 105
4 45 110 95 115
3
The objective is to place the cranes in such a way
that the overall distance required for the transfer is as
small as possible
Instructions
1. Subtract the smallest number in each row from every number in the row. This is
called a row reduction. Enter the results in a new table.
2. Subtract the smallest number in each column of the new table from every
number in the column. This is called a column reduction. Enter the results in
another table.
3. Test whether an optimum assignment can be made. You do this by
determining the minimum number of lines needed to cover all zeros. If the
number of lines equals the number of rows, an optimum assignment is possible. In
that case, go to step 6. Otherwise go on to step 4.
4. If the number of lines is less than the number of rows, modify the table in this
way:
a. Subtract the smallest uncovered number from every uncovered
number in the table.
b. Add the smallest uncovered number to the numbers at intersections
of covering lines.
c. Numbers crossed out but not at intersections of cross-out lines carry
over unchanged to the next table.
5. Repeat steps 3 and 4 until an optimal table is obtained.
6. Make the assignments. Begin with rows or columns with only one zero. Match
items that have zeros, using only one match for each row and each column.
Cross out both the row and the column after the match.
4
Solution
 The COST matrix is:
5
90 75 75 80
35 85 55 65
125 95 90 105
45 110 95 115
Step 01
Find the Row minimum for each row and subtract it
from all entries on that row
 Resultant matrix is:
15 0 0 5
0 50 20 30
35 5 0 15
0 65 50 70
90 75 75 80
35 85 55 65
125 95 90 105
45 110 95 115
Solution Cont….
6
 Resultant matrix is:
15 0 0 0
0 50 20 25
35 5 0 10
0 65 50 65
Step 02
From each row, find the Row minimum and subtract
it from all entries in that row
Step 03
Draw a minimum number of lines across rows and
columns so that all the “zeros” are covered.
Solution Cont.
7
Step 04 – Test for optimality
Number of lines = 3
Number of rows in the Cost matrix = 4
3 ≠ 4  An optimum assignment is not possible
Step 05
Find the Smallest entry which is not covered by the
lines  20
and subtract it from each entry not covered by the
lines.
We add the smallest entry to the crossed entries
15 0 0 0
0 50 20 25
35 5 0 10
0 65 50 65
Solution Cont.
8
Repeat Step 03
35 0 0 0
0 30 0 5
55 5 0 10
0 45 30 45
 Resultant matrix is:
Number of lines = 3
Number of rows in the Cost matrix = 4
3 ≠ 4  An optimum assignment is not possible
35 0 0 0
0 30 0 5
55 5 0 10
0 45 30 45
Solution Cont.
9
40 0 5 0
0 25 0 0
55 0 0 5
0 40 30 40
If the number of lines = 4
Number of rows in the Cost matrix = 4
4 = 4  An optimum assignment is possible.
‘0’ positions determine the possible combinations
Repeat Step 03
Solution Cont.
10
1 2 3 4
1 40 0 5 0
2 0 25 0 0
3 55 0 0 5
4 0 40 30 40
Option 01
Crane 1  Site 2
Crane 2  Site 4
Crane 3  Site 3
Crane 4  Site 1
Distance = 275
Construction Site #
Crane#
Select a matching by choosing a set of zeros so that each row
or column has only one selected
Option 02
Crane 1  Site 4
Crane 2  Site 3
Crane 3  Site 2
Crane 4  Site 1
Distance = 275
 Hungarian Method is for assigning jobs by
a one-for-one matching to identify the
lowest-cost solution where each job must
be assigned to only one machine.
11
Conclusion
12
C. S. Suriyakula
AS/07/08/077

Hungarian algorithm

  • 1.
  • 2.
    Hungarian method  Thismethod is a “Combinatorial Optimization Algorithm” that solves assignment problems  Developed and published by Harold Kuhn in 1955  Basically, this method is for assigning jobs by one-for-one matching to identify the lowest cost solution  This method is actually a special case of Primal-Dual algorithm 2
  • 3.
    Example A building firmpossesses four cranes each of which has a distance(km) from four different construction sites as shown in the table Construction site # 1 2 3 4 Crane # 1 90 75 75 80 2 35 85 55 65 3 125 95 90 105 4 45 110 95 115 3 The objective is to place the cranes in such a way that the overall distance required for the transfer is as small as possible
  • 4.
    Instructions 1. Subtract thesmallest number in each row from every number in the row. This is called a row reduction. Enter the results in a new table. 2. Subtract the smallest number in each column of the new table from every number in the column. This is called a column reduction. Enter the results in another table. 3. Test whether an optimum assignment can be made. You do this by determining the minimum number of lines needed to cover all zeros. If the number of lines equals the number of rows, an optimum assignment is possible. In that case, go to step 6. Otherwise go on to step 4. 4. If the number of lines is less than the number of rows, modify the table in this way: a. Subtract the smallest uncovered number from every uncovered number in the table. b. Add the smallest uncovered number to the numbers at intersections of covering lines. c. Numbers crossed out but not at intersections of cross-out lines carry over unchanged to the next table. 5. Repeat steps 3 and 4 until an optimal table is obtained. 6. Make the assignments. Begin with rows or columns with only one zero. Match items that have zeros, using only one match for each row and each column. Cross out both the row and the column after the match. 4
  • 5.
    Solution  The COSTmatrix is: 5 90 75 75 80 35 85 55 65 125 95 90 105 45 110 95 115 Step 01 Find the Row minimum for each row and subtract it from all entries on that row  Resultant matrix is: 15 0 0 5 0 50 20 30 35 5 0 15 0 65 50 70 90 75 75 80 35 85 55 65 125 95 90 105 45 110 95 115
  • 6.
    Solution Cont…. 6  Resultantmatrix is: 15 0 0 0 0 50 20 25 35 5 0 10 0 65 50 65 Step 02 From each row, find the Row minimum and subtract it from all entries in that row Step 03 Draw a minimum number of lines across rows and columns so that all the “zeros” are covered.
  • 7.
    Solution Cont. 7 Step 04– Test for optimality Number of lines = 3 Number of rows in the Cost matrix = 4 3 ≠ 4  An optimum assignment is not possible Step 05 Find the Smallest entry which is not covered by the lines  20 and subtract it from each entry not covered by the lines. We add the smallest entry to the crossed entries 15 0 0 0 0 50 20 25 35 5 0 10 0 65 50 65
  • 8.
    Solution Cont. 8 Repeat Step03 35 0 0 0 0 30 0 5 55 5 0 10 0 45 30 45  Resultant matrix is: Number of lines = 3 Number of rows in the Cost matrix = 4 3 ≠ 4  An optimum assignment is not possible 35 0 0 0 0 30 0 5 55 5 0 10 0 45 30 45
  • 9.
    Solution Cont. 9 40 05 0 0 25 0 0 55 0 0 5 0 40 30 40 If the number of lines = 4 Number of rows in the Cost matrix = 4 4 = 4  An optimum assignment is possible. ‘0’ positions determine the possible combinations Repeat Step 03
  • 10.
    Solution Cont. 10 1 23 4 1 40 0 5 0 2 0 25 0 0 3 55 0 0 5 4 0 40 30 40 Option 01 Crane 1  Site 2 Crane 2  Site 4 Crane 3  Site 3 Crane 4  Site 1 Distance = 275 Construction Site # Crane# Select a matching by choosing a set of zeros so that each row or column has only one selected Option 02 Crane 1  Site 4 Crane 2  Site 3 Crane 3  Site 2 Crane 4  Site 1 Distance = 275
  • 11.
     Hungarian Methodis for assigning jobs by a one-for-one matching to identify the lowest-cost solution where each job must be assigned to only one machine. 11 Conclusion
  • 12.