Assigment: Hungarian Method
Assigment: Hungarian Method
ASSIGMENT
Hungarian Method
Objective
- Understand the features of assignment problems and transportation problems.
- Formulate an assignment problem as a square matrix.
- Apply the Hungarian method to solve an assignment problem.
- Make appropriate changes in the Hungarian method to solve an unbalanced
assignment problem, profit maximization assignment problem, etc.
2. Identify the minimum element in each column and subtract it from every element of
that column.
3. Make the assignments for the reduced matrix obtained from steps 1 and 2 in the
following way:
i) For each row or column with a single zero value cell that has not be assigned
or eliminated, box that zero value as an assigned cell.
ii) For every zero that becomes assigned, cross out (X) all other zeros in the
same row and the same column.
iii) If for a row and a column, there are two or more zeros and one cannot be
chosen by inspection, then you are at liberty to choose the cell arbitrarily for
assignment.
iv) The above process may be continued until every zero cell is either assigned
or crossed (X).
4. An optimal assignment is found, if the number of assigned cells equals the number of
rows (and columns). In case you have chosen a zero cell arbitrarily, there may be
alternate optimal solutions. If no optimal solution is found, go to step 5.
5. Draw the minimum number of vertical and horizontal lines necessary to cover all the
zeros in the reduced matrix obtained from step 3 by adopting the following procedure:
ii) Mark all the columns (not already marked) which have zeros in the marked
rows.
iii) Mark all the rows (not already marked) that have assignments in marked
columns.
iv) Repeat steps 5 (i) to (iii) until no more rows or columns can be marked.
v) Draw straight lines through all unmarked rows and marked columns.
6. Select the smallest element from all the uncovered elements. Subtract this smallest
element from all the uncovered elements and add it to the elements, which lie at the
intersection of two lines. Thus, we obtain another reduced matrix for fresh assignment.
7. Go to step 3 and repeat the procedure until you arrive at an optimal assignment.
Example 1
Assign the five tasks to five operators. The assigning time is given in Table.
Operator Job
J1 J2 J3 J4 J5
O1 3 6 1 5 4
O2 9 8 5 6 3
O3 10 12 8 7 11
O4 6 9 12 10 15
O5 12 8 7 8 10
Solution
This is a minimization example of assignment problem. Using the Hungarian
Algorithm to solve this problem.
1. We’ll check whether the matrix is balanced or not. Since the number of rows are equal to
number of columns, the matrix is balanced.
2. Identify the minimum element in each row and subtract it from every element of
that row. The result is shown in the following table.
Operator Job
J1 J2 J3 J4 J5
O1 2 5 0 4 3
O2 6 5 2 3 0
O3 3 5 1 0 4
O4 0 3 6 4 9
O5 5 1 0 1 3
3. Identify the minimum element in each column and subtract it from every element
of that column
Operator Job
J1 J2 J3 J4 J5
O1 2 4 0 4 3
O2 6 4 2 3 0
O3 3 4 1 0 4
O4 0 2 6 4 9
O5 5 0 0 1 3
4. Assign the tasks to the operators. Select a row that has a single zero and assign
by squaring it. Strike off remaining zeros if any in that row or column. Repeat the
assignment for other tasks. The final assignment is shown in table below.
Operator Job
J1 J2 J3 J4 J5
O1 2 4 0 4 3
O2 6 4 2 3 0
O3 3 4 1 0 4
O4 0 2 6 4 9
O5 5 0 0 1 3
Salesman District
D1 D2 D3 D4 D5
S1 90 105 60 50 65
S2 80 90 110 40 60
S3 40 50 75 55 80
S4 80 85 65 45 50
S5 70 80 85 65 70
Solution
This is a maximization example of assignment problem. Using the Hungarian
Algorithm to solve this problem.
S1 20 5 50 60 45
S2 30 20 0 70 50
S3 70 60 35 55 30
S4 30 25 45 65 60
S5 40 30 25 45 40
2. Identify the minimum element in each row and subtract it from every element of
that row. The result is shown in the following table.
Salesman District
D1 D2 D3 D4 D5
S1 15 0 45 55 40
S2 30 20 0 70 50
S3 40 30 5 25 0
S4 5 0 20 40 35
S5 15 5 0 20 15
3. Identify the minimum element in each column and subtract it from every element
of that column.
Salesman District
D1 D2 D3 D4 D5
S1 10 0 45 35 40
S2 25 20 0 50 50
S3 35 30 5 5 0
S4 0 0 20 20 35
S5 10 5 0 0 15
4. Make the assignments for the reduced matrix obtained from steps 1 and 2 in the
following way:
a. For each row or column with a single zero value cell that has not be
assigned or eliminated, box that zero value as an assigned cell.
b. For every zero that becomes assigned, cross out (X) all other zeros in the
same row and the same column.
c. If for a row and a column, there are two or more zeros and one cannot be
chosen by inspection, choose the cell arbitrarily for assignment.
d. The above process may be continued until every zero cell is either
assigned or crossed (X).
Salesman District
D1 D2 D3 D4 D5
S1 10 0 45 35 40
S2 25 20 0 50 50
S3 35 30 5 5 0
S4 0 0 20 20 35
S5 10 5 0 0 15
Person Job
1 2 3 4
A 20 25 22 28
B 15 18 23 17
C 19 17 21 24
D 25 23 24 24
Solution
This is a minimization example of assignment problem. Using the Hungarian
Algorithm to solve this problem.
1. Identify the minimum element in each row and subtract it from every element of
that row. The result is shown in the following table.
Person Job
1 2 3 4
A 0 5 2 8
B 0 3 8 2
C 2 0 4 7
D 2 0 1 1
2. Identify the minimum element in each column and subtract it from every element
of that column.
Person Job
1 2 3 4
A 0 5 1 7
B 0 3 7 1
C 2 0 3 6
D 2 0 0 0
3. Make the assignments for the reduced matrix obtained from steps 1 and 2 in the
following way:
a. For each row or column with a single zero value cell that has not be
assigned or eliminated, box that zero value as an assigned cell.
b. For every zero that becomes assigned, cross out (X) all other zeros in the
same row and the same column.
c. If for a row and a column, there are two or more zeros and one cannot be
chosen by inspection, choose the cell arbitrarily for assignment.
d. The above process may be continued until every zero cell is either
assigned or crossed (X).
Person Job
1 2 3 4
A 0 5 1 7
B 0 3 7 1
C 2 0 3 6
D 2 0 0 0
5. Draw the minimum number of vertical and horizontal lines necessary to cover all
the zeros in the reduced matrix obtained from step 3 by adopting the following
procedure:
ii. Mark all the columns (not already marked) which have zeros in the marked
rows.
iii. Mark all the rows (not already marked) that have assignments in marked
columns.
iv. Repeat steps 5 (ii) and (iii) until no more rows or columns can be marked.
v. Draw straight lines through all unmarked rows and marked columns.
Person Job
1 2 3 4
A 0 5 1 7
B 0 3 7 1
C 2 0 3 6
D 2 0 0 0
6. Select the smallest element (i.e., 1) from all the uncovered elements. Subtract
this smallest element from all the uncovered elements and add it to the elements,
which lie at the intersection of two lines. Thus, we obtain another reduced matrix
for fresh assignment.
Person Job
1 2 3 4
A 0 4 0 6
B 0 2 6 0
C 3 0 3 6
D 3 0 0 0
Since the number of assignments is equal to the number of rows (& columns), this is
the optimal solution.
Counter Person
A B C D E
1 30 37 40 28 40
2 40 24 27 21 36
3 40 32 33 30 35
4 25 38 40 36 36
5 29 62 41 34 39
Solution
1. This is a maximization problem and has to be converted into a minimization problem by
subtracting all the elements from the largest element of the sales table. The highest
value is 62. So we subtract each value from 62. The conversion is shown in the
following table.
Counter Person
A B C D E
1 32 25 22 34 22
2 22 38 35 41 26
3 22 30 29 30 27
4 37 24 22 26 26
5 33 0 21 28 23
2. Identify the minimum element in each row and subtract it from every element of
that row. The result is shown in the following table.
Counter Person
A B C D E
1 10 3 0 12 0
2 0 16 13 19 4
3 0 8 7 8 5
4 15 2 0 4 4
5 33 0 21 28 23
3. Identify the minimum element in each column and subtract it from every element
of that column.
Counter Person
A B C D E
1 10 3 0 8 0
2 0 16 13 15 4
3 0 8 7 4 5
4 15 2 0 0 4
5 33 0 21 24 23
4. Make the assignments for the reduced matrix obtained from steps 2 and 3 in the
following way:
a. For each row or column with a single zero value cell that has not be
assigned or eliminated, box that zero value as an assigned cell.
b. For every zero that becomes assigned, cross out (X) all other zeros in the
same row and the same column.
c. If for a row and a column, there are two or more zeros and one cannot be
chosen by inspection, choose the cell arbitrarily for assignment.
d. The above process may be continued until every zero cell is either
assigned or crossed (X).
Counter Person
A B C D E
1 10 3 0 8 0
2 0 16 13 15 4
3 0 8 7 4 5
4 15 2 0 0 4
5 33 0 21 24 23
5. Draw the minimum number of vertical and horizontal lines necessary to cover all
the zeros in the reduced matrix.
Counter Person
A B C D E
1 10 3 0 8 0
2 0 16 13 15 4
3 0 8 7 4 5
4 15 2 0 0 4
5 33 0 21 24 23
6. Select the smallest element from all the uncovered elements, i.e., 4. Subtract this
element from all the uncovered elements and add it to the elements, which lie at
the intersection of two lines. Thus, we obtain another reduced matrix for fresh
assignment. Repeating step 4, we obtain a solution which is shown in the
following table.
Counter Person
A B C D E
1 14 3 0 8 0
2 0 12 9 11 0
3 0 4 3 2 1
4 19 2 0 0 4
5 37 0 21 24 23
Programmers Programs
1 2 3 4
A 120 100 80 90
B 80 90 110 70
D 90 90 80 90
Find the assignment pattern that minimises the time required to develop the application
programs.
Solution
This is a minimization example of assignment problem. Using the Hungarian
Algorithm to solve this problem.
1. We’ll check whether the matrix is balanced or not. Since the number of rows are equal to
number of columns, the matrix is balanced.
2. Identify the minimum element in each row and subtract it from every element of
that row. The result is shown in the following table.
Programmers Programs
1 2 3 4
A 40 20 0 10
B 10 20 40 0
C 10 40 20 0
D 10 10 0 10
3. Identify the minimum element in each column and subtract it from every element
of that column.
Programmers Programs
1 2 3 4
A 30 10 0 10
B 0 10 40 0
C 0 30 20 0
D 0 0 0 10