The Assignment Problem
description
Transcript of The Assignment Problem
![Page 1: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/1.jpg)
The Assignment Problem
Math 20Linear Algebra and
Multivariable CalculusOctober 13, 2004
![Page 2: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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 37B 47 87 41C 60 92 36
![Page 3: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/3.jpg)
Naïve SolutionThere are only 6
possible assignments of companies to jobs
Check them and compare
![Page 4: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/4.jpg)
Naïve Solution—Guess #1
Bldg1
Bldg2
Bldg3
A 53 96 37B 47 87 41C 60 92 36
Total Cost = 53 + 87+ 36 = 176
![Page 5: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/5.jpg)
Naïve Solution—Guess #2
Bldg1
Bldg2
Bldg3
A 53 96 37B 47 87 41C 60 92 36
Total Cost = 53 + 92+ 41 = 186
![Page 6: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/6.jpg)
Naïve Solution—Guess #3
Bldg1
Bldg2
Bldg3
A 53 96 37B 47 87 41C 60 92 36
Total Cost = 47 + 96 + 36 = 179
![Page 7: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/7.jpg)
Naïve Solution—Guess #4
Bldg1
Bldg2
Bldg3
A 53 96 37B 47 87 41C 60 92 36
Total Cost = 47 + 92 + 37 = 176
![Page 8: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/8.jpg)
Naïve Solution—Guess #5
Bldg1
Bldg2
Bldg3
A 53 96 37B 47 87 41C 60 92 36
Total Cost = 47 + 96 + 41 = 197
![Page 9: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/9.jpg)
Naïve Solution—Guess #6
Bldg1
Bldg2
Bldg3
A 53 96 37B 47 87 41C 60 92 36
Total Cost = 60 + 87 + 37 = 184
![Page 10: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/10.jpg)
Naïve Solution—Completion
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
![Page 11: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/14.jpg)
An Ideal Cost MatrixAll nonnegative
entriesAn possible
assignment of zeroes, one in each row and column
In this case the minimal cost is apparently zero!
€
0 3 00 0 108 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 15: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/15.jpg)
The Hungarian AlgorithmFind 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: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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) decompressorare needed to see this picture.
![Page 17: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/17.jpg)
Critical ObservationSame is true of
columnsSo: we can
subtract minimum entry from each row and column to insure nonnegative entries
QuickTime™ and aTIFF (Uncompressed) decompressorare needed to see this picture.
![Page 18: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/18.jpg)
On our given matrix
€
53 96 3747 87 4160 92 36
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥a
16 59 06 46 0
24 56 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥a
10 13 00 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 19: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/19.jpg)
Still Not Done
€
10 13 00 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
![Page 20: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/20.jpg)
Still Not Done
€
10 13 00 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
![Page 21: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/21.jpg)
Still Not Done
€
10 13 00 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
![Page 22: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/22.jpg)
Still Not Done
€
10 13 00 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
![Page 23: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/23.jpg)
Still Not Done
€
10 13 00 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
No assignment of zeros in this matrix
?
![Page 24: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/24.jpg)
Still Not Done
€
0 3 −100 0 08 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: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/25.jpg)
Still Not Done
€
0 3 00 0 108 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: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/26.jpg)
Solutions
€
0 3 00 0 108 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
€
0 3 00 0 108 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 27: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/27.jpg)
Naïve Solution—Completion
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
1 2 3A 53 9
637
B 47 87
41
C 60 92
36
![Page 28: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/28.jpg)
The Hungarian Algorithm1. 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 column
Resulting matrix is nonnegative
QuickTime™ and aTIFF (Uncompressed) decompressor
are needed to see this picture.
![Page 29: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/29.jpg)
The Hungarian Algorithm3. 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 00 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 30: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/30.jpg)
The Hungarian Algorithm4. If you can only
do this with n lines, an assignment of zeroes is possible.
€
10 13 00 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 31: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/31.jpg)
€
0 3 00 0 108 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
€
10 13 00 0 0
18 10 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
The Hungarian Algorithm5. 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 −100 0 08 3 −10
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 32: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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 00 0 108 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 33: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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 00 0 108 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 34: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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 00 0 108 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 35: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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 00 0 108 3 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 36: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/36.jpg)
Solutions
€
0 3 00 0 108 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
€
0 3 00 0 108 0 0
⎡
⎣
⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥
![Page 37: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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?
Customer1 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: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/38.jpg)
Integerizing the Matrix
€
9 7.5 7.5 83.5 8.5 5.5 6.5
12.5 9.5 9 10.54.5 10 9.5 11.5
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥a
90 75 75 8035 85 55 65
125 95 90 10545 10 95 115
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
![Page 39: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/39.jpg)
Non-negativizing the Matrix
€
90 75 75 8035 85 55 65
125 95 90 10545 10 95 115
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥a
15 0 0 50 50 20 3035 5 0 150 65 50 70
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥a
15 0 0 00 50 20 25
25 5 0 100 65 50 65
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
![Page 40: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/40.jpg)
Covering the Zeroes
€
15 0 0 00 50 20 25
25 5 0 100 65 50 65
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
Can do it with three!
![Page 41: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/41.jpg)
Find Smallest Uncovered Entry
€
15 0 0 00 50 20 25
25 5 0 100 65 50 65
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
![Page 42: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/42.jpg)
Subtract and Add
€
30 0 0 00 30 0 5
55 5 0 100 45 30 45
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
![Page 43: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/43.jpg)
Cover Again
€
30 0 0 00 30 0 5
55 5 0 100 45 30 45
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
Still three!
![Page 44: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/44.jpg)
Find Smallest Uncovered
€
30 0 0 00 30 0 5
55 5 0 100 45 30 45
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
![Page 45: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/45.jpg)
Subtract and Add
€
40 0 5 00 25 0 0
55 0 0 50 40 30 40
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
![Page 46: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/46.jpg)
Cover Again
€
40 0 5 00 25 0 0
55 0 0 50 40 30 40
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
Done!
![Page 47: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/47.jpg)
Solutions
€
40 0 5 00 25 0 0
55 0 0 50 40 30 40
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
Done!€
40 0 5 00 25 0 0
55 0 0 50 40 30 40
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
![Page 48: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/html5/thumbnails/48.jpg)
€
9 7.5 7.5 83.5 8.5 5.5 6.5
12.5 9.5 9 10.54.5 10 9.5 11.5
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
€
9 7.5 7.5 83.5 8.5 5.5 6.5
12.5 9.5 9 10.54.5 10 9.5 11.5
⎡
⎣
⎢ ⎢ ⎢ ⎢
⎤
⎦
⎥ ⎥ ⎥ ⎥
Solutions
Total Cost = 27.5
![Page 49: The Assignment Problem](https://reader036.fdocuments.in/reader036/viewer/2022082213/56815a9f550346895dc8263b/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) decompressorare needed to see this picture.