Assignment Problem Lecture # 6
Assignment Problem Lecture # 6
Assignment Problem
The Hungarian algorithm consists of the four steps below. The first
two steps are executed once, while Steps 3 and 4 are repeated until an
optimal assignment is found. The input of the algorithm is an n by n
square matrix with only nonnegative elements.
For each row, find the lowest element and subtract it from each element in that
row.
Similarly, for each column, find the lowest element and subtract it from each
element in that column.
Cover all zeros in the resulting matrix using a minimum number of horizontal
and vertical lines. If number of lines are equal to n , an optimal assignment
exists among the zeros. then go to step 5.
Find the smallest element (call it k) that is not covered by a line in Step 3.
Subtract k from all uncovered elements, and add k to all elements that are
covered twice. Then Steps 3 and 4 are repeated until an optimal assignment is
found.
X Y Z
A 19 28 31
B 11 17 16
C 12 15 13
Solution
Step 1: Subtract row minima
We start with subtracting the row minimum from each row. The smallest
element in the first row is, for example, 19. Therefore, we subtract 19 from each
element in the first row. The resulting matrix is:
X Y Z
A 0 9 12
B 0 6 5
C 0 3 1
Similarly, we subtract the column minimum from each column, giving the
following matrix:
X Y Z
A 0 6 11
B 0 3 4
C 0 0 0
X Y Z
A 0 6 11
B 0 3 4
C 0 0 0
Because the number of lines required (2) is lower than the size of the matrix
(n=3), we continue with Step 4.
A 0 3 8
B 0 0 1
C 3 0 0
X Y Z
A 0 3 8
B 0 0 1
C 3 0 0
Because the number of lines required (3) is equal to the size of the matrix (n=3),
we continue with Step 5.
Select a matching by choosing a set of zeros so that each row or column has
only one selected. The following zeros cover an optimal assignment:
X Y Z
A 0 3 8
B 0 0 1
C 3 0 0
X Y Z
A 19 28 31
B 11 17 16
C 12 15 13
Example 2:
The pharmaceutical firm has five salespersons, whom the firm wants to assign
to five sales regions. Given their various contacts, the salespersons are able to
cover the regions in different amounts of time. The amount of time (days)
required by each salesperson to cover each city is shown in the following table.
Which salesperson should be assigned to each region to minimize total time?
Identify the optimal assignments and compute total minimum time.
Regions
A B C D E
1 17 10 15 16 20
2 12 9 16 9 14
3 11 16 14 15 12
4 14 10 10 18 17
5 13 12 9 15 11
Solution
Step 1: Subtract row minima
We start with subtracting the row minimum from each row. The smallest
element in the first row is, for example, 10. Therefore, we subtract 10 from each
element in the first row. The resulting matrix is:
A B C D E
1 7 0 5 6 10
2 3 0 7 0 5
3 0 5 3 4 1
4 4 0 0 8 7
5 4 3 0 6 2
Step 2: Subtract column minima
Similarly, we subtract the column minimum from each column, giving
the following matrix:
A B C D E
1 7 0 5 6 9
2 3 0 7 0 4
3 0 5 3 4 0
4 4 0 0 8 6
5 4 3 0 6 1
A B C D E
1 7 0 5 6 9
2 3 0 7 0 4
3 0 5 3 4 0
4 4 0 0 8 6
5 4 3 0 6 1
Because the number of lines required (4) is lower than the size of the matrix
(n=5), we continue with Step 4.
Step 4: Create additional zeros
First, we find that the smallest uncovered number is 1. We subtract this number
from all uncovered elements and add it to all elements that are covered twice.
This results in the following matrix:
A B C D E
1 6 0 5 5 8
2 3 1 8 0 4
3 0 6 4 4 0
4 3 0 0 7 5
5 3 3 0 5 0
A B C D E
1 6 0 5 5 8
2 3 1 8 0 4
3 0 6 4 4 0
4 3 0 0 7 5
5 3 3 0 5 0
Because the number of lines required (5) equals the size of the matrix (n=5), an
optimal assignment exists among the zeros in the matrix. Therefore, go to step
5.
Step 5: assign optimal cells
Select a matching by choosing a set of zeros so that each row or column has
only one selected. The following zeros cover an optimal assignment:
A B C D E
1 6 (0) 5 5 8
2 3 1 8 (0) 4
3 (0) 6 4 4 0
4 3 0 (0) 7 5
5 3 3 0 5 (0)
A B C D E
1 17 10 15 16 20
2 12 9 16 9 14
3 11 16 14 15 12
4 14 10 10 18 17
5 13 12 9 15 11
Thus, salesperson 1 is assigned to Region B, salesperson 2 is assigned to Region
D, salesperson 3 is assigned to Region A, salesperson 4 is assigned to Region C
and salesperson 5 is assigned to Region E. The total time of this optimal
assignment is to 10 + 9 + 11 + 10 + 11 = 51 days.