cs 256 admin
play

CS 256 Admin Videos posted on website Assignment 0 delayed to - PowerPoint PPT Presentation

CS 256 Admin Videos posted on website Assignment 0 delayed to Saturday (Assignment 1 still released tomorrow, due Thursday) Zoom link on Glow and slack (no longer emailed) TA Office hours coming soon Ill stay after class for


  1. CS 256

  2. Admin • Videos posted on website • Assignment 0 delayed to Saturday (Assignment 1 still released tomorrow, due Thursday) • Zoom link on Glow and slack (no longer emailed) • TA Office hours coming soon • I’ll stay after class for questions

  3. Quick Latex Note • The final X is a chi (the Greek letter), not an X • So it’s pronounced lay-tech • (or lah-tech) • But not “latex”

  4. Matching Med-Students to Hospitals H n S n Input. A set of hospitals, a set of students and their preferences (each hospital ranks each student, each students ranks each hospital) 1st 2nd 3rd 1st 2nd 3rd MA Aamir Beth Chris Aamir NH MA OH NH Beth Aamir Chris Beth MA NH OH OH Aamir Beth Chris Chris MA NH OH

  5. Perfect Matchings M ( h , s ) Definition. A matching is a set of ordered pairs where h ∈ H s ∈ S and such that h M • Each hospital is in at most one pair in s M • Each student is in at most one pair in M A matching is perfect if each hospital is matched to exactly one | M | = | H | = | S | student and vice versa (i.e., ) 1st 2nd 3rd 1st 2nd 3rd MA Aamir Beth Chris Aamir NH MA OH NH Beth Aamir Chris Beth MA NH OH OH Aamir Beth Chris Chris MA NH OH

  6. Unstable Pairs M Definition. A perfect matching is unstable if there exists an ( h , s ) ∈ H × S unstable pair , that is, h s M prefers to its current match in • s h M prefers to its current match in • Can you point out an unstable pair in this matching? 1st 2nd 3rd 1st 2nd 3rd MA Aamir Beth Chris Aamir NH MA OH NH Beth Aamir Chris Beth MA NH OH OH Aamir Beth Chris Chris MA NH OH

  7. False Starts Proceed greedily in rounds until matched. In each round, • Each hospital makes offer to its top available candidate • Each student accepts its top offer (irrecoverable contract) and rejects others What goes wrong? 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  8. Take a Step Back • Imagine you are one of these students • Why is it a bad idea to accept the best offer you get in the first round? • You might get a better offer later! • Can we come up with an example where this happens, causing an unstable matching?

  9. False Starts Proceed greedily in rounds until matched. → → → • (Round 1) MA Aamir, NH Aamir, OH Chris 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  10. False Starts Proceed greedily in rounds until matched. → → → • (Round 1) MA Aamir, NH Aamir, OH Chris • (Round 1) Aamir rejects MA, accepts NH, Chris accepts OH 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  11. False Starts Proceed greedily in rounds until matched. → → → • (Round 1) MA Aamir, NH Aamir, OH Chris • (Round 1) Aamir rejects MA, accepts NH, Chris accepts OH • (Round 2) Only Beth and MA left, and must match 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  12. False Starts Proceed greedily in rounds until matched. → → → • (Round 1) MA Aamir, NH Aamir, OH Chris • (Round 1) Aamir rejects MA, accepts NH, Chris accepts OH • (Round 2) Only Beth and MA left, and must match Is this a stable matching? 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  13. False Starts Proceed greedily in rounds until matched. → → → • (Round 1) MA Aamir, NH Aamir, OH Chris • (Round 1) Aamir rejects MA, accepts NH, Chris accepts OH • (Round 2) Only Beth and MA left, and must match Is this a stable matching? • Unstable pair: (MA, Chris). What could have avoided it? 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  14. What Should Students Do? • Don’t accept immediately (of course) • What if they can have a preliminary accept? • “I’m interested, but I also want to wait to see if I get a better offer” • That seems to solve the problem we mentioned, but does it always give a stable matching?

  15. Gale-Shapely Deferred Acceptance Algorithm Proceed in rounds until all hospitals matched.* In each round, • Each free hospital offers to its top choice among candidates it hasn’t offered yet • Each free student retains but defers accepting top offer , rejects others • If a student receives a better offer than currently retained, they reject current and retain new offer (trade up) 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  16. Gale-Shapely Deferred Acceptance Algorithm Proceed in rounds until all hospitals matched.* In each round, • Each free hospital offers to its top choice among candidates it hasn’t offered yet • Each free student retains but defers accepting top offer , rejects others • If a student receives a better offer than currently retained, they reject current and retain new offer (trade up) 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  17. Gale-Shapely Deferred Acceptance Algorithm Proceed in rounds until all hospitals matched.* In each round, • Each free hospital offers to its top choice among candidates it hasn’t offered yet • Each free student retains but defers accepting top offer , rejects others • If a student receives a better offer than currently retained, they reject current and retain new offer (trade up) 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  18. Gale-Shapely Deferred Acceptance Algorithm Proceed in rounds until all hospitals matched.* In each round, • Each free hospital offers to its top choice among candidates it hasn’t offered yet • Each free student retains but defers accepting top offer , rejects others • If a student receives a better offer than currently retained, they reject current and retain new offer (trade up) 1st 2nd 3rd 1st 2nd 3rd MA Aamir Chris Beth Aamir OH NH MA NH Aamir Beth Chris Beth MA OH NH OH Chris Beth Aamir Chris MA NH OH

  19. Gale-Shapely Algorithm

  20. Analyzing Gale-Shapely Questions to ask Efficiency: 
 • How long does it take to produce a matching? • How can we efficiently implement each step? Correctness: • Does it match everyone? (produce a perfect matching) • Does it produce a stable matching?

  21. Analyzing the Algorithm: Performance Each hospital makes an offer to each student at most once, so the • O ( n 2 ) algorithm makes at most iterations What do we do in each iteration? • h Select a free hospital • s h Find top ranked not yet offered a post by • s Find 's ranking of a given hospital • Add to & delete from set of matched pairs • (possibly) Add a hospital back into the free list • • How long does it take? • Depends on how we implement each of these!

  22. Analyzing the Algorithm: Performance II 1,…, n • Input representation. Index students and hospitals Each student provides a sorted list of hospitals (most to least • preferred) and each hospital provides a sorted list of students h O (1) • Of students not yet offered a post by , find most preferred: s h h ′ • Does prefer to the current hospital ? s For each , create inverse of preference list of hospitals • (Identify efficient data structures for operations) student prefers hospital 4 to 6 since rank[4] < rank[6] Student preference list indexed by rank Inverse pref-list indexed by hospital # 1 st 2 nd 3 rd 4 th 5 th 6 th 7 th 8 th 1 2 3 4 5 6 7 8 pref[] rank[] 4 th 8 th 2 nd 5 th 6 th 7 th 3 rd 1 st 8 3 7 1 4 5 6 2 for i = 1 to n rank[pref[i]] = i

  23. Analyzing the Algorithm: Performance III Analyzing running time: O ( n 2 ) • Creating the inverse-list for each student (preprocessing): O (1) • Once created, time to accept/reject proposal by student O (1) • Maintain free hospitals: Queue: for get() and put() • Add to & delete from set of matched pairs: s • Array, Matched( s ) = h currently matched to (or ‘free’) : O ( n ) O (1) Creation time (preprocessing) ; update time O (1) Each iteration thus takes time O ( n 2 ) O ( n 2 ) O ( n 2 ) Overall, time preprocessing + time in iterations: O ( n 2 ) • Linear time? Yes! Here input size is size, linear in input size

  24. Analyzing the Algorithm: Correctness Does it match everyone? (Perfect matching) • Once a student receives an offer, she has at least a tentative match for the rest of time. • Equivalently, if any student is unmatched, then no hospital has offered them which implies that the hospitals have not exhausted their preference lists. • When the algorithm terminates, everyone is matched (i.e., it produces a perfect matching) . Does it produce a stable matching? • Key idea: students always ‘trade up’ s h h ′ h ′ h breaks match with in favor of only if s prefers to •

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend