Lesson 33: The Assignment Problem
-
Upload
matthew-leingang -
Category
Technology
-
view
10.394 -
download
3
description
Transcript of Lesson 33: The Assignment Problem
![Page 1: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/1.jpg)
Lesson 31The Assignment Problem
Math 20Algebra and Multivariable Mathematics for Social
SciencesDecember 10, 2007
![Page 2: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/2.jpg)
The ProblemThree air conditioners need to be installed in the same week by three different companies
Bids for each job are solicited from each company
To which company should each job be assigned?
Bldg1
Bldg2
Bldg3
A 53 96 37
B 47 87 41
C 60 92 36
![Page 3: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/3.jpg)
Naïve Solution
There are only 6 possible assignments of companies to jobs
Check them and compare
![Page 4: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/4.jpg)
Naïve Solution—Guess #1
Bldg1
Bldg2
Bldg3
A 53 96 37
B 47 87 41
C 60 92 36
Total Cost = 53 + 87+ 36 = 176
![Page 5: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/5.jpg)
Naïve Solution—Guess #2
Bldg1
Bldg2
Bldg3
A 53 96 37
B 47 87 41
C 60 92 36
Total Cost = 53 + 92+ 41 = 186
![Page 6: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/6.jpg)
Naïve Solution—Guess #3
Bldg1
Bldg2
Bldg3
A 53 96 37
B 47 87 41
C 60 92 36
Total Cost = 47 + 96 + 36 = 179
![Page 7: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/7.jpg)
Naïve Solution—Guess #4
Bldg1
Bldg2
Bldg3
A 53 96 37
B 47 87 41
C 60 92 36
Total Cost = 47 + 92 + 37 = 176
![Page 8: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/8.jpg)
Naïve Solution—Guess #5
Bldg1
Bldg2
Bldg3
A 53 96 37
B 47 87 41
C 60 92 36
Total Cost = 47 + 96 + 41 = 197
![Page 9: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/9.jpg)
Naïve Solution—Guess #6
Bldg1
Bldg2
Bldg3
A 53 96 37
B 47 87 41
C 60 92 36
Total Cost = 60 + 87 + 37 = 184
![Page 10: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/10.jpg)
Naïve Solution—Completion
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
![Page 11: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/11.jpg)
Disadvantages of Naïve Solution
How does the time-to-solution vary with problem size?
Answer: O(n!)
0
1000
2000
3000
4000
5000
6000
0 5 10
nn2enn!
![Page 12: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/12.jpg)
Rates of Growthn log(n) n n2 en n!1 0.00000 1 1 2.7 12 0.30103 2 4 7.4 23 0.47712 3 9 20.1 64 0.60206 4 16 54.6 245 0.69897 5 25 148.4 1206 0.77815 6 36 403.4 7207 0.84510 7 49 1096.6 50408 0.90309 8 64 2981.0 403209 0.95424 9 81 8103.1 362880
10 1.00000 10 100 22026.5 362880011 1.04139 11 121 59874.1 3991680012 1.07918 12 144 162754.8 47900160013 1.11394 13 169 442413.4 622702080014 1.14613 14 196 1202604.3 8.7178E+1015 1.17609 15 225 3269017.4 1.3077E+12
![Page 13: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/13.jpg)
Mathematical Modeling of the Problem
Given a Cost Matrix C which lists for each “company” i the “cost” of doing “job” j.
Solution is a permutation matrix X : all zeros except for one 1 in each row and column
Objective is to minimize the total cost
€
c total = c ij x iji, j=1
n
∑
![Page 14: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/14.jpg)
An Ideal Cost Matrix
All nonnegative entries
An possible assignment of zeroes, one in each row and column
In this case the minimal cost is apparently zero!
€
0 3 0
0 0 10
8 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 15: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/15.jpg)
The Hungarian Algorithm
Find an “ideal” cost matrix that has the same optimal assignment as the given cost matrix
From there the solution is easy!
QuickTime™ and aTIFF (Uncompressed) decompressor
are needed to see this picture.
![Page 16: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/16.jpg)
Critical Observation Let C be a given cost matrix and consider a new cost matrix C’ that has the same number added to each entry of a single row of C
For each assignment, the new total cost differs by that constant
The optimal assignment is the same as before
QuickTime™ and aTIFF (Uncompressed) decompressor
are needed to see this picture.
![Page 17: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/17.jpg)
Critical Observation
Same is true of columns
So: we can subtract minimum entry from each row and column to insure nonnegative entries
QuickTime™ and aTIFF (Uncompressed) decompressor
are needed to see this picture.
![Page 18: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/18.jpg)
On our given matrix
53 96 37
47 87 41
60 92 36
⎡
⎣
⎢⎢⎢
⎤
⎦
⎥⎥⎥→
16 59 06 46 024 56 0
⎡
⎣
⎢⎢⎢
⎤
⎦
⎥⎥⎥→
10 13 00 0 018 10 0
⎡
⎣
⎢⎢⎢
⎤
⎦
⎥⎥⎥
![Page 19: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/19.jpg)
Still Not Done
€
10 13 0
0 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
![Page 20: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/20.jpg)
Still Not Done
€
10 13 0
0 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
![Page 21: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/21.jpg)
Still Not Done
€
10 13 0
0 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
![Page 22: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/22.jpg)
Still Not Done
€
10 13 0
0 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
![Page 23: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/23.jpg)
Still Not Done
€
10 13 0
0 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
?
![Page 24: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/24.jpg)
Still Not Done
€
0 3 −10
0 0 0
8 0 −10
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
Still, we can create new zeroes by subtracting the smallest entry from some rows
![Page 25: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/25.jpg)
Still Not Done
€
0 3 0
0 0 10
8 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
Still, we can create new zeroes by subtracting the smallest entry from some rows
Now we can preserve nonnegativity by adding that entry to columns which have negative entries
![Page 26: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/26.jpg)
Solutions
€
0 3 0
0 0 10
8 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
€
0 3 0
0 0 10
8 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 27: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/27.jpg)
Naïve Solution—Completion
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
1 2 3
A 53 96
37
B 47 87
41
C 60 92
36
![Page 28: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/28.jpg)
The Hungarian Algorithm
1. Find the minimum entry in each row and subtract it from each row
2. Find the minimum entry in each column and subtract it from each columnResulting matrix is nonnegative
QuickTime™ and aTIFF (Uncompressed) decompressor
are needed to see this picture.
![Page 29: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/29.jpg)
The Hungarian Algorithm
3. Using lines that go all the way across or all the way up-and-down, cross out all zeros in the new cost matrix
Find a way to do this with a minimum number of lines (≤n)
€
10 13 0
0 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 30: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/30.jpg)
The Hungarian Algorithm
4. If you can only do this with n lines, an assignment of zeroes is possible.
€
10 13 0
0 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 31: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/31.jpg)
€
0 3 0
0 0 10
8 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
€
10 13 0
0 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
The Hungarian Algorithm
5. Otherwise, determine the smallest entry not covered by any line.
Subtract this entry from all uncovered entries
Add it to all double-covered entries
Return to Step 3.
€
0 3 −10
0 0 0
8 3 −10
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 32: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/32.jpg)
The Hungarian Algorithm
3. Using lines that go all the way across or all the way up-and-down, cross out all zeros in the new cost matrix
€
0 3 0
0 0 10
8 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 33: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/33.jpg)
The Hungarian Algorithm
3. Using lines that go all the way across or all the way up-and-down, cross out all zeros in the new cost matrix
€
0 3 0
0 0 10
8 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 34: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/34.jpg)
The Hungarian Algorithm
3. Using lines that go all the way across or all the way up-and-down, cross out all zeros in the new cost matrix
€
0 3 0
0 0 10
8 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 35: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/35.jpg)
The Hungarian Algorithm
4. If you can only do this with n lines, an assignment of zeroes is possible.
€
0 3 0
0 0 10
8 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 36: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/36.jpg)
Solutions
€
0 3 0
0 0 10
8 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
€
0 3 0
0 0 10
8 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 37: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/37.jpg)
Example 2
A cab company gets four calls from four customers simultaneously
Four cabs are out in the field at varying distance from each customer
Which cab should be sent where to minimize total (or average) waiting time?
Customer
1 2 3 4
Cab
A 9 7.5 7.5 8
B 3.5 8.5 5.5 6.5
C 12.5
9.5 9.0 10.5
D 4.5 11.0
9.5 11.5
![Page 38: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/38.jpg)
Integerizing the Matrix
9 7.5 7.5 8
3.5 8.5 5.5 6.5
12.5 9.5 9 10.5
4.5 10 9.5 11.5
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
→
90 75 75 8035 85 55 65125 95 90 10545 100 95 115
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
![Page 39: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/39.jpg)
Non-negativizing the Matrix
90 75 75 80
35 85 55 65
125 95 90 105
45 100 95 115
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
→
15 0 0 50 50 20 3035 5 0 150 55 50 70
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
→
15 0 0 00 50 20 2525 5 0 100 55 50 65
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
![Page 40: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/40.jpg)
Covering the Zeroes
15 0 0 0
0 50 20 25
25 5 0 10
0 55 50 65
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
Can do it with three!
![Page 41: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/41.jpg)
Find Smallest Uncovered Entry
15 0 0 0
0 50 20 25
25 5 0 10
0 55 50 65
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
![Page 42: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/42.jpg)
Subtract and Add
35 0 0 0
0 30 0 5
45 5 0 10
0 35 30 45
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
![Page 43: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/43.jpg)
Cover Again
35 0 0 0
0 30 0 5
45 5 0 10
0 35 30 45
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
Still three!
![Page 44: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/44.jpg)
Find Smallest Uncovered
35 0 0 0
0 30 0 5
45 5 0 10
0 35 30 45
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
![Page 45: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/45.jpg)
Subtract and Add
40 0 5 0
0 25 0 0
45 0 0 5
0 30 30 40
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
![Page 46: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/46.jpg)
Cover Again
40 0 5 0
0 25 0 0
45 0 0 5
0 30 30 40
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
Done!
![Page 47: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/47.jpg)
Solutions
40 0 5 0
0 25 0 0
45 0 0 5
0 30 30 40
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
Done!
40 0 5 0
0 25 0 0
45 0 0 5
0 30 30 40
⎡
⎣
⎢⎢⎢⎢
⎤
⎦
⎥⎥⎥⎥
![Page 48: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/48.jpg)
€
9 7.5 7.5 8
3.5 8.5 5.5 6.5
12.5 9.5 9 10.5
4.5 10 9.5 11.5
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
€
9 7.5 7.5 8
3.5 8.5 5.5 6.5
12.5 9.5 9 10.5
4.5 10 9.5 11.5
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
Solutions
Total Cost = 27.5
![Page 49: Lesson 33: The Assignment Problem](https://reader033.fdocuments.us/reader033/viewer/2022061220/54baa42c4a7959fc648b4579/html5/thumbnails/49.jpg)
Other Applications of AP
Assigning teaching fellows to time slots
Assigning airplanes to flights
Assigning project members to tasks
Determining positions on a team
Assigning brides to grooms (once called the marriage problem)
QuickTime™ and aTIFF (Uncompressed) decompressor
are needed to see this picture.