0% found this document useful (0 votes)
324 views6 pages

Hungarian Method Calculator

This document describes how to solve an assignment problem using the Hungarian method. It provides an example with 6 jobs and 6 workers. The goal is to maximize the total value of assignments. It shows the step-by-step process of converting the problem to minimization, finding minimum values in rows and columns, and making assignments by crossing off values. The solution assigns each job to a single worker to maximize the total value.

Uploaded by

PRIDOLIN BATO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
324 views6 pages

Hungarian Method Calculator

This document describes how to solve an assignment problem using the Hungarian method. It provides an example with 6 jobs and 6 workers. The goal is to maximize the total value of assignments. It shows the step-by-step process of converting the problem to minimization, finding minimum values in rows and columns, and making assignments by crossing off values. The solution assigns each job to a single worker to maximize the total value.

Uploaded by

PRIDOLIN BATO
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

6/14/23, 11:12 PM Hungarian method calculator

We use cookies to improve your experience on our site and to show you relevant advertising. By browsing this website, you agree to our use of cookies. Learn more    Acce

Support us
I want to sell my website www.AtoZmath.com with complete code

Try our new - Enter problem or search problem


Home What's new College Algebra Games
Algebra Matrix & Vector Numerical Methods Statistical Methods Operation Research Word Problems

Home > Operation Research calculators > Assignment Problem calculator (Using Hungarian method-1)

Algorithm and examples


Method 1.1 Assignment problem using Hungarian method-1
Hungarian method
 
Type your data (either with heading or without heading),
for seperator you can use space or tab
for sample click random button
1 2 3 4 5 6
A 12 13 16 13 13 12
B 16 20 21 22 21 16
C 20 21 23 23 21 20
D 25 22 22 22 24 22
E 23 23 25 25 20 20
F 17 19 19 17 17 18
OR
 Minimize    Maximize
Rows : 6   Columns :  6   Generate

Job 1 2 3 4 5 6
Work
A 12 13 16 13 13 12
B 16 20 21 22 21 16
C 20 21 23 23 21 20
D 25 22 22 22 24 22
E 23 23 25 25 20 20
F 17 19 19 17 17 18

Find Random New


 
Solution Help

Solution will be displayed step by step (In 4 parts)


Solution
Ad

Find Solution of Assignment problem using Hungarian method-1 (MAX case)


Job 1 2 3 4 5 6
Work\

A 12 13 16 13 13 12
B 16 20 21 22 21 16
C 20 21 23 23 21 20
D 25 22 22 22 24 22
E 23 23 25 25 20 20
F 17 19 19 17 17 18

Solution:

https://cbom.atozmath.com/CBOM/Assignment.aspx?q=hm&q1=12%2c13%2c16%2c13%2c13%2c12%3b16%2c20%2c21%2c22%2c21%2c16%… 1/7
6/14/23, 11:12 PM Hungarian method calculator
The number of rows = 6 and columns = 6
    1   2   3   4   5   6     

 A  12 13 16 13 13 12
 B  16 20 21 22 21 16

 C  20 21 23 23 21 20
 D  25 22 22 22 24 22

 E  23 23 25 25 20 20

 F  17 19 19 17 17 18
   

Here the problem is of Maximazition type and convert it into minimization by substracting it from maximum
    1   2   3   4   5   6     

 A  13 12 9 12 12 13

 B  9 5 4 3 4 9

 C  5 4 2 2 4 5

 D  0 3 3 3 1 3
 E  2 2 0 0 5 5

 F  8 6 6 8 8 7
   

Here given problem is balanced.

Step-1: Find out the each row minimum element and subtract it from that row
    1   2   3   4   5   6     

 A  4 3 0 3 3 4 (-9)

 B  6 2 1 0 1 6 (-3)
 C  3 2 0 0 2 3 (-2)
 D  0 3 3 3 1 3 (-0)

 E  2 2 0 0 5 5 (-0)

 F  2 0 0 2 2 1 (-6)
   

Step-2: Find out the each column minimum element and subtract it from that column.
    1   2   3   4   5   6     

 A  4 3 0 3 2 3
 B  6 2 1 0 0 5

 C  3 2 0 0 1 2

 D  0 3 3 3 0 2

 E  2 2 0 0 4 4

 F  2 0 0 2 1 0
    (-0) (-0) (-0) (-0) (-1) (-1)

Iteration-1 of steps 3 to 6
+ Step-3: Make assignment in the opporunity cost table
Step-3: Make assignment in the opporunity cost table
(1) Rowwise cell (A, 3) is assigned, so columnwise cell (C, 3),(E, 3),(F, 3) crossed off.

(2) Rowwise cell (C, 4) is assigned, so columnwise cell (B, 4),(E, 4) crossed off.

(3) Rowwise cell (B, 5) is assigned, so columnwise cell (D, 5) crossed off.

(4) Rowwise cell (D, 1) is assigned

(5) Columnwise cell (F, 2) is assigned, so rowwise cell (F, 6) crossed off.

https://cbom.atozmath.com/CBOM/Assignment.aspx?q=hm&q1=12%2c13%2c16%2c13%2c13%2c12%3b16%2c20%2c21%2c22%2c21%2c16%… 2/7
6/14/23, 11:12 PM Hungarian method calculator

Rowwise & columnwise assignment shown in table


    1   2   3   4   5   6     
 A  4 3 [0] 3 2 3

 B  6 2 1 0 [0] 5

 C  3 2 0 [0] 1 2

 D  [0] 3 3 3 0 2

 E  2 2 0 0 4 4

 F  2 [0] 0 2 1 0
   

Step-4: Number of assignments = 5, number of rows = 6


Which is not equal, so solution is not optimal.

+ Step-5: Draw a set of horizontal and vertical lines to cover all the 0
Step-5: Cover the 0 with minimum number of lines
(1) Mark(✓) row E since it has no assignment

(2) Mark(✓) column 3 since row E has 0 in this column

(3) Mark(✓) column 4 since row E has 0 in this column

(4) Mark(✓) row A since column 3 has an assignment in this row A.

(5) Mark(✓) row C since column 4 has an assignment in this row C.

(6) Since no other rows or columns can be marked, therefore draw straight lines through the unmarked row
marked columns 3, 4

Tick mark not allocated rows and allocated columns


    1   2   3   4   5   6     

 A  4 3 [0] 3 2 3 ✓(4)


 B  6 2 1 0 [0] 5

 C  3 2 0 [0] 1 2 ✓(5)

 D  [0] 3 3 3 0 2

 E  2 2 0 0 4 4 ✓(1)

 F  2 [0] 0 2 1 0

✓ ✓
   
(2) (3)

+ Step-6: Develop the new revised opportunity cost table


Step-6: Develop the new revised table by selecting the smallest element, among the cells not covered by a
Subtract k = 1 from every element in the cell not covered by a line.
Add k = 1 to every elment in the intersection cell of two lines.

    1   2   3   4   5   6     

 A  3 2 0 3 1 2

 B  6 2 2 1 0 5

 C  2 1 0 0 0 1

 D  0 3 4 4 0 2
 E  1 1 0 0 3 3

 F  2 0 1 3 1 0
   

Repeat steps 3 to 6 until an optimal solution is obtained.

Iteration : 1

https://cbom.atozmath.com/CBOM/Assignment.aspx?q=hm&q1=12%2c13%2c16%2c13%2c13%2c12%3b16%2c20%2c21%2c22%2c21%2c16%… 3/7
6/14/23, 11:12 PM Hungarian method calculator
Iteration-2 of steps 3 to 6
Step-3: Make assignment in the opporunity cost table
(1) Rowwise cell (A, 3) is assigned, so columnwise cell (C, 3),(E, 3) crossed off.

(2) Rowwise cell (B, 5) is assigned, so columnwise cell (C, 5),(D, 5) crossed off.

(3) Rowwise cell (C, 4) is assigned, so columnwise cell (E, 4) crossed off.

(4) Rowwise cell (D, 1) is assigned

(5) Columnwise cell (F, 2) is assigned, so rowwise cell (F, 6) crossed off.

Rowwise & columnwise assignment shown in table


    1   2   3   4   5   6     
 A  3 2 [0] 3 1 2
 B  6 2 2 1 [0] 5

 C  2 1 0 [0] 0 1

 D  [0] 3 4 4 0 2

 E  1 1 0 0 3 3

 F  2 [0] 1 3 1 0
   

Step-4: Number of assignments = 5, number of rows = 6


Which is not equal, so solution is not optimal.

Step-5: Cover the 0 with minimum number of lines


(1) Mark(✓) row E since it has no assignment

(2) Mark(✓) column 3 since row E has 0 in this column

(3) Mark(✓) column 4 since row E has 0 in this column

(4) Mark(✓) row A since column 3 has an assignment in this row A.

(5) Mark(✓) row C since column 4 has an assignment in this row C.

(6) Mark(✓) column 5 since row C has 0 in this column

(7) Mark(✓) row B since column 5 has an assignment in this row B.

(8) Since no other rows or columns can be marked, therefore draw straight lines through the unmarked row
columns 3, 4, 5

Tick mark not allocated rows and allocated columns


    1   2   3   4   5   6     

 A  3 2 [0] 3 1 2 ✓(4)

 B  6 2 2 1 [0] 5 ✓(7)

 C  2 1 0 [0] 0 1 ✓(5)


 D  [0] 3 4 4 0 2

 E  1 1 0 0 3 3 ✓(1)
 F  2 [0] 1 3 1 0

    ✓ ✓ ✓
(2) (3) (6)

Step-6: Develop the new revised table by selecting the smallest element, among the cells not covered by a
Subtract k = 1 from every element in the cell not covered by a line.
Add k = 1 to every elment in the intersection cell of two lines.

    1   2   3   4   5   6     


 A  2 1 0 3 1 1

 B  5 1 2 1 0 4

 C  1 0 0 0 0 0

 D  0 3 5 5 1 2

https://cbom.atozmath.com/CBOM/Assignment.aspx?q=hm&q1=12%2c13%2c16%2c13%2c13%2c12%3b16%2c20%2c21%2c22%2c21%2c16%… 4/7
6/14/23, 11:12 PM Hungarian method calculator

 E  0 0 0 0 3 2

 F  2 0 2 4 2 0
   

Repeat steps 3 to 6 until an optimal solution is obtained.

Iteration : 2
Iteration-3 of steps 3 to 6
Step-3: Make assignment in the opporunity cost table
(1) Rowwise cell (A, 3) is assigned, so columnwise cell (C, 3),(E, 3) crossed off.

(2) Rowwise cell (B, 5) is assigned, so columnwise cell (C, 5) crossed off.

(3) Rowwise cell (D, 1) is assigned, so columnwise cell (E, 1) crossed off.

 (4) Rowwise cell (E, 2) is assigned, so columnwise cell (C, 2),(F, 2) crossed off., so rowwise cell (E, 4) cross

(5) Rowwise cell (F, 6) is assigned, so columnwise cell (C, 6) crossed off.

(6) Rowwise cell (C, 4) is assigned

Rowwise & columnwise assignment shown in table


    1   2   3   4   5   6     
 A  2 1 [0] 3 1 1
 B  5 1 2 1 [0] 4

 C  1 0 0 [0] 0 0

 D  [0] 3 5 5 1 2

 E  0 [0] 0 0 3 2
 F  2 0 2 4 2 [0]
   

Step-4: Number of assignments = 6, number of rows = 6


Which is equal, so solution is optimal

Optimal assignments are


    1   2   3   4   5   6     

 A  2 1 [0] 3 1 1

 B  5 1 2 1 [0] 4

 C  1 0 0 [0] 0 0

 D  [0] 3 5 5 1 2
 E  0 [0] 0 0 3 2
 F  2 0 2 4 2 [0]

   

Optimal solution is
Work Job Cost
A 3 16

B 5 21

C 4 23

D 1 25
E 2 23

F 6 18
Total 126

Alternate Solution-2

https://cbom.atozmath.com/CBOM/Assignment.aspx?q=hm&q1=12%2c13%2c16%2c13%2c13%2c12%3b16%2c20%2c21%2c22%2c21%2c16%… 5/7
6/14/23, 11:12 PM Hungarian method calculator
opporunity cost table
    1   2   3   4   5   6     
 A  2 1 0 3 1 1
 B  5 1 2 1 0 4

 C  1 0 0 0 0 0

 D  0 3 5 5 1 2

 E  0 0 0 0 3 2
 F  2 0 2 4 2 0
   

Step-3: Make assignment in the opporunity cost table


(1) Rowwise cell (A, 3) is assigned, so columnwise cell (C, 3),(E, 3) crossed off.

(2) Rowwise cell (B, 5) is assigned, so columnwise cell (C, 5) crossed off.

(3) Rowwise cell (D, 1) is assigned, so columnwise cell (E, 1) crossed off.

(4) Rowwise cell (E, 4) is assigned, so columnwise cell (C, 4) crossed off., so rowwise cell (E, 2) crossed off

(5) Rowwise cell (C, 2) is assigned, so columnwise cell (F, 2) crossed off., so rowwise cell (C, 6) crossed off

(6) Rowwise cell (F, 6) is assigned

Rowwise & columnwise assignment shown in table


    1   2   3   4   5   6     

 A  2 1 [0] 3 1 1

 B  5 1 2 1 [0] 4

 C  1 [0] 0 0 0 0

 D  [0] 3 5 5 1 2
 E  0 0 0 [0] 3 2

 F  2 0 2 4 2 [0]
   

Step-4: Number of assignments = 6, number of rows = 6


Which is equal, so solution is optimal

Optimal assignments are


    1   2   3   4   5   6     
 A  2 1 [0] 3 1 1

 B  5 1 2 1 [0] 4

 C  1 [0] 0 0 0 0

 D  [0] 3 5 5 1 2

 E  0 0 0 [0] 3 2

 F  2 0 2 4 2 [0]

   

Optimal solution is
Work Job Cost

A 3 16
B 5 21

C 2 21

D 1 25

E 4 25

F 6 18
Total 126

https://cbom.atozmath.com/CBOM/Assignment.aspx?q=hm&q1=12%2c13%2c16%2c13%2c13%2c12%3b16%2c20%2c21%2c22%2c21%2c16%… 6/7

You might also like