Assignment Problem
Assignment Problem
Assignment Problem
1 2
3 4
5 6
7
Trial and error works well enough for this problem, but 6
suppose you had ten salespeople flying to ten cities? How 5
many trials would this take? 4
3 n
There are n! ways of assigning n resources to n tasks.
2
That means that as n gets large, we have too many trials
1
to consider.
2 3 4 5 6 7
7 8
1000
40
800
30
600 en
20 400 n2
n2
10 n 200 n
1 2 3 4 5 6 7 1 2 3 4 5 6 7
9 10
5000
4000 n
Theorem: If a number is added to or subtracted from all
3000 en
of the entries of any one row or column of a cost matrix,
2000 n2 then on optimal assignment for the resulting cost matrix
1000 n is also an optimal assignment for the original cost matrix.
1 2 3 4 5 6 7
11 12
The Hungarian Method: The following algorithm applies the above Example 1: You work as a sales manager for a toy
theorem to a given n × n cost matrix to find an optimal assignment. manufacturer, and you currently have three salespeople on
the road meeting buyers. Your salespeople are in Austin, TX;
Step 1. Subtract the smallest entry in each row from all the entries of its
row. Boston, MA; and Chicago, IL. You want them to fly to three
Step 2. Subtract the smallest entry in each column from all the entries other cities: Denver, CO; Edmonton, Alberta; and Fargo,
of its column. ND. The table below shows the cost of airplane tickets in
Step 3. Draw lines through appropriate rows and columns so that all the dollars between these cities.
zero entries of the cost matrix are covered and the minimum number of
such lines is used. From \ To Denver Edmonton Fargo
Step 4. Test for Optimality: (i) If the minimum number of covering lines Austin 250 400 350
is n, an optimal assignment of zeros is possible and we are finished. (ii) If
the minimum number of covering lines is less than n, an optimal Boston 400 600 350
assignment of zeros is not yet possible. In that case, proceed to Step 5.
Chicago 200 400 250
Step 5. Determine the smallest entry not covered by any line. Subtract
this entry from each uncovered row, and then add it to each covered Where should you send each of your salespeople in order to
column. Return to Step 3.
minimize airfare?
13 14
15 16
Since the total cost for this assignment is 0, it must be Example 2: A construction company has four large
an optimal assignment. bulldozers located at four different garages. The bulldozers
⎡ ⎤ are to be moved to four different construction sites. The
0 0 100
⎢ ⎥ distances in miles between the bulldozers and the
⎢ ⎥
⎢ 50 100 0 ⎥ construction sites are given below.
⎣ ⎦
0 50 50
Bulldozer \ Site A B C D
Here is the same assignment made to the original cost 1 90 75 75 80
matrix. 2 35 85 55 65
⎡ ⎤ 3 125 95 90 105
250 400 350
⎢ ⎥ 4 45 110 95 115
⎢ ⎥
⎢ 400 600 350 ⎥
⎣ ⎦ How should the bulldozers be moved to the construction sites
200 400 250
in order to minimize the total distance traveled?
17 18
Step 1. Subtract 75 from Row 1, 35 from Row 2, 90
from Row 3, and 45 from Row 4. from Column 3, and 5 from Column 4.
⎡ ⎤ ⎡ ⎤ ⎡ ⎤ ⎡ ⎤
90 75 75 80 15 0 0 5 15 0 0 5 15 0 0 0
⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ ⎥
⎢ 35 85 55 65 ⎥ ⎢ 0 50 20 30⎥ ⎢0 50 20 30⎥ ⎢ ⎥
⎢ ⎥ ⎢ ⎥ ⎢ ⎥ ⎢ 0 50 20 25⎥
⎢ ⎥∼⎢ ⎥ ⎢ ⎥∼⎢ ⎥
⎢125 95 90 105⎥ ⎢35 5 0 15⎥ ⎢35 ⎥ ⎢
5 0 15⎦ ⎣35 5 0 10⎥
⎣ ⎦ ⎣ ⎦ ⎣ ⎦
45 110 95 115 0 65 50 70 0 65 50 70 0 65 50 65
19 20
21 22
23 24
Now return to Step 3. ⎡ ⎤
40 0 5 0
Step 3. Cover all the zeros of the matrix with the ⎢ ⎥
⎢0 0⎥
minimum number of horizontal or vertical lines. ⎢ 25 0 ⎥
⎢ ⎥
⎢ 55 0 0 5⎥
⎣ ⎦
0 40 30 40
Since the total cost for this assignment is 0, it must be
an optimal assignment.
Step 4. Since the minimal number of lines is 4, an
Here is the same assignment made to the original cost
optimal assignment of zeros is possible and we are
matrix.
finished.
25 26
⎡ ⎤
90 75 75 80
⎢ ⎥
⎢ 35 65 ⎥
⎢ 85 55 ⎥
⎢ ⎥
⎢ 125 95 90 105 ⎥
⎣ ⎦ Summary
45 110 95 115
27 28
29 30
The Hungarian Method: The Hungarian method (see
above) is an algorithm which finds an optimal assignment
for a given cost matrix.
31