Lesson 33: The Assignment Problem

9,860 views

Published on

The assignment problem is a kind of linear programming problem, but the hungarian method is a quicker algorithm for solving it.

Published in: Technology, Education
3 Comments
0 Likes
Statistics
Notes
  • Be the first to like this

No Downloads
Views
Total views
9,860
On SlideShare
0
From Embeds
0
Number of Embeds
48
Actions
Shares
0
Downloads
466
Comments
3
Likes
0
Embeds 0
No embeds

No notes for slide

Lesson 33: The Assignment Problem

  1. 1. Lesson 31 The Assignment Problem Math 20 Algebra and Multivariable Mathematics for Social Sciences December 10, 2007
  2. 2. The Problem <ul><li>Three air conditioners need to be installed in the same week by three different companies </li></ul><ul><li>Bids for each job are solicited from each company </li></ul><ul><li>To which company should each job be assigned? </li></ul>36 92 60 C 41 87 47 B 37 96 53 A Bldg3 Bldg2 Bldg1
  3. 3. Na ïve Solution <ul><li>There are only 6 possible assignments of companies to jobs </li></ul><ul><li>Check them and compare </li></ul>
  4. 4. Na ïve Solution—Guess #1 Total Cost = 53 + 87+ 36 = 176 36 92 60 C 41 87 47 B 37 96 53 A Bldg3 Bldg2 Bldg1
  5. 5. Na ïve Solution—Guess #2 Total Cost = 53 + 92+ 41 = 186 36 92 60 C 41 87 47 B 37 96 53 A Bldg3 Bldg2 Bldg1
  6. 6. Na ïve Solution—Guess #3 Total Cost = 47 + 96 + 36 = 179 36 92 60 C 41 87 47 B 37 96 53 A Bldg3 Bldg2 Bldg1
  7. 7. Na ïve Solution—Guess #4 Total Cost = 47 + 92 + 37 = 176 36 92 60 C 41 87 47 B 37 96 53 A Bldg3 Bldg2 Bldg1
  8. 8. Na ïve Solution—Guess #5 Total Cost = 47 + 96 + 41 = 197 36 92 60 C 41 87 47 B 37 96 53 A Bldg3 Bldg2 Bldg1
  9. 9. Na ïve Solution—Guess #6 Total Cost = 60 + 87 + 37 = 184 36 92 60 C 41 87 47 B 37 96 53 A Bldg3 Bldg2 Bldg1
  10. 10. Na ïve Solution—Completion 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1
  11. 11. Disadvantages of Na ïve Solution <ul><li>How does the time-to-solution vary with problem size? </li></ul><ul><li>Answer: O(n!) </li></ul>
  12. 12. Rates of Growth
  13. 13. Mathematical Modeling of the Problem <ul><li>Given a Cost Matrix C which lists for each “company” i the “cost” of doing “job” j . </li></ul><ul><li>Solution is a permutation matrix X : all zeros except for one 1 in each row and column </li></ul><ul><li>Objective is to minimize the total cost </li></ul>
  14. 14. An Ideal Cost Matrix <ul><li>All nonnegative entries </li></ul><ul><li>An possible assignment of zeroes, one in each row and column </li></ul><ul><li>In this case the minimal cost is apparently zero! </li></ul>
  15. 15. The Hungarian Algorithm <ul><li>Find an “ideal” cost matrix that has the same optimal assignment as the given cost matrix </li></ul><ul><li>From there the solution is easy! </li></ul>
  16. 16. Critical Observation <ul><li>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 </li></ul><ul><li>For each assignment, the new total cost differs by that constant </li></ul><ul><li>The optimal assignment is the same as before </li></ul>
  17. 17. Critical Observation <ul><li>Same is true of columns </li></ul><ul><li>So: we can subtract minimum entry from each row and column to insure nonnegative entries </li></ul>
  18. 18. On our given matrix
  19. 19. Still Not Done <ul><li>No assignment of zeros in this matrix </li></ul>
  20. 20. Still Not Done <ul><li>No assignment of zeros in this matrix </li></ul>
  21. 21. Still Not Done <ul><li>No assignment of zeros in this matrix </li></ul>
  22. 22. Still Not Done <ul><li>No assignment of zeros in this matrix </li></ul>
  23. 23. Still Not Done <ul><li>No assignment of zeros in this matrix </li></ul>?
  24. 24. Still Not Done <ul><li>No assignment of zeros in this matrix </li></ul><ul><li>Still, we can create new zeroes by subtracting the smallest entry from some rows </li></ul>
  25. 25. Still Not Done <ul><li>No assignment of zeros in this matrix </li></ul><ul><li>Still, we can create new zeroes by subtracting the smallest entry from some rows </li></ul><ul><li>Now we can preserve nonnegativity by adding that entry to columns which have negative entries </li></ul>
  26. 26. Solutions
  27. 27. Na ïve Solution—Completion 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1 36 92 60 C 41 87 47 B 37 96 53 A 3 2 1
  28. 28. The Hungarian Algorithm <ul><li>Find the minimum entry in each row and subtract it from each row </li></ul><ul><li>Find the minimum entry in each column and subtract it from each column </li></ul><ul><li>Resulting matrix is nonnegative </li></ul>
  29. 29. The Hungarian Algorithm <ul><li>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 </li></ul><ul><li>Find a way to do this with a minimum number of lines (≤n) </li></ul>
  30. 30. The Hungarian Algorithm <ul><li>4. If you can only do this with n lines, an assignment of zeroes is possible. </li></ul>
  31. 31. The Hungarian Algorithm <ul><li>Otherwise, determine the smallest entry not covered by any line. </li></ul><ul><li>Subtract this entry from all uncovered entries </li></ul><ul><li>Add it to all double-covered entries </li></ul><ul><li>Return to Step 3. </li></ul>
  32. 32. The Hungarian Algorithm <ul><li>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 </li></ul>
  33. 33. The Hungarian Algorithm <ul><li>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 </li></ul>
  34. 34. The Hungarian Algorithm <ul><li>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 </li></ul>
  35. 35. The Hungarian Algorithm <ul><li>4. If you can only do this with n lines, an assignment of zeroes is possible. </li></ul>
  36. 36. Solutions
  37. 37. Example 2 <ul><li>A cab company gets four calls from four customers simultaneously </li></ul><ul><li>Four cabs are out in the field at varying distance from each customer </li></ul><ul><li>Which cab should be sent where to minimize total (or average) waiting time? </li></ul>11.5 9.5 11.0 4.5 D 10.5 9.0 9.5 12.5 C 6.5 5.5 8.5 3.5 B 8 7.5 7.5 9 A Cab 4 3 2 1 Customer
  38. 38. Integerizing the Matrix
  39. 39. Non-negativizing the Matrix
  40. 40. Covering the Zeroes Can do it with three!
  41. 41. Find Smallest Uncovered Entry
  42. 42. Subtract and Add
  43. 43. Cover Again Still three!
  44. 44. Find Smallest Uncovered
  45. 45. Subtract and Add
  46. 46. Cover Again Done!
  47. 47. Solutions Done!
  48. 48. Solutions Total Cost = 27.5
  49. 49. Other Applications of AP <ul><li>Assigning teaching fellows to time slots </li></ul><ul><li>Assigning airplanes to flights </li></ul><ul><li>Assigning project members to tasks </li></ul><ul><li>Determining positions on a team </li></ul><ul><li>Assigning brides to grooms (once called the marriage problem ) </li></ul>

×