Assignment Overheads
Assignment Overheads
and Method
the Hungarian
1
Example 1: You work as a sales manager for a toy
manufacturer, and you currently have three salespeople on
the road meeting buyers. Your salespeople are in Austin, TX;
Boston, MA; and Chicago, IL. You want them to fly to three
other cities: Denver, CO; Edmonton, Alberta; and Fargo, ND.
The table below shows the cost of airplane tickets in dollars
between these cities.
From \ To Denver Edmonton Fargo
Austin 250 400 350
Boston 400 600 350
Chicago 200 400 250
3
Lets look at one possible assignment.
4
Heres another possible assignment.
5
After checking all six possible assignments we can
determine that the optimal one is the following.
6
Trial and error works well enough for this problem, but
suppose you had ten salespeople flying to ten cities?
How many trials would this take?
There are n! ways of assigning n resources to n tasks.
That means that as n gets large, we have too many
trials to consider.
7
7
6
5
4
3 n
2
1
2 3 4 5 6 7
8
40
30
20
2
n
10 n
1 2 3 4 5 6 7
9
1000
800
n
600 e
400 n2
200 n
12 3 4 5 6 7
1
0
5000
4000 n!
3000 en
2000 n2
1000 n
12 3 4 5 6 7
11
Theorem: If a number is added to or subtracted from all
of the entries of any one row or column of a cost matrix,
then on optimal assignment for the resulting cost matrix
is also an optimal assignment for the original cost matrix.
1
2
The Hungarian Method: The following algorithm applies the above
theorem to a given n n cost matrix to find an optimal assignment.
Step 1. Subtract the smallest entry in each row from all the entries of its row.
Step 2. Subtract the smallest entry in each column from all the entries of its
column.
Step 3. Draw lines through appropriate rows and columns so that all the zero
entries of the cost matrix are covered and the minimum number of such lines
is used.
Step 4. Test for Optimality: (i) If the minimum number of covering lines 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 assignment of
zeros is not yet possible. In that case, proceed to Step 5.
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 column.
Return to Step 3.
1
3
Example 1: You work as a sales manager for a toy
manufacturer, and you currently have three salespeople on
the road meeting buyers. Your salespeople are in Austin, TX;
Boston, MA; and Chicago, IL. You want them to fly to three
other cities: Denver, CO; Edmonton, Alberta; and Fargo, ND.
The table below shows the cost of airplane tickets in dollars
between these cities.
From \ To Denver Edmonton Fargo
Austin 250 400 350
Boston 400 600 350
Chicago 200 400 250
0 200 50 0 50 50
1
5
Step 3. Cover all the zeros of the matrix with the
minimum number of horizontal or vertical lines.
1
6
Since the total cost for this assignment is 0, it must be
an optimal assignment.
0 0 100
50 100 0
0 50 50
Bulldozer \ Site A B C D
1 90 75 75 80
2 35 85 55 65
3 125 95 90 105
4 45 110 95 115
90 75 75 80 15 0 0 5
35 85 55 65 0 50 20 30
125 95 90 105 35 5 0 15
45 110 95 115 0 65 50 70
1
9
from Column 3, and 5 from Column 4.
15 0 0 5 15 0 0 0
0 50 20 30 0 50 20 25
35 5 0 15 35 5 0 10
0 65 50 70 0 65 50 65
2
0
Step 3. Cover all the zeros of the matrix with the
minimum number of horizontal or vertical lines.
2
1
Step 5. Note that 5 is the smallest entry not covered by
any line. Subtract 5 from each uncovered row.
15 0 0 0 15 0 0 0
0 50 20 25 5 45 15 20
35 5 0 10 30 0 5 5
0 65 50 65 5 60 45 60
15 0 0 0 20 0 5 0
5 45 15 20 0 45 20 20
30 0 5 5 35 0 0 5
5 60 45 60 0 60 50 60
2
2
Now return to Step 3.
20 0 5 0 20 0 5 0
0 45 20 20 20 25 0 0
35 0 0 5 35 0 0 5
0 60 50 60 20 40 30 40
Then add 20 to each covered column.
20 0 5 0 40 0 5 0
20 25 0 0 0 25 0 0
35 0 0 5 55 0 0 5
20 40 30 40 0 40 30 40
2
4
Now return to Step 3.
2
5
40 0 5 0
0 25 0 0
55 0 0 5
0 40 30 40
Since the total cost for this assignment is 0, it must be
an optimal assignment.
Here is the same assignment made to the original
cost matrix.
2
6
90 75 75 80
35 85 55 65
125 95 90 105
45 110 95 115
2
7
Summary
2
8
The Assignment Problem: Suppose we have n
resources to which we want to assign to n tasks on a
one-to-one basis. Suppose also that we know the
cost of assigning a given resource to a given task.
We wish to find an optimal assignmentone which
minimizes total cost.
2
9
The Mathematical Model: Let ci,j be the cost of
assigning the ith resource to the jth task. We define
the cost matrix to be the n n matrix
3
1