/
CMSC451: Algorithms Lecture 3 CMSC451: Algorithms Lecture 3

CMSC451: Algorithms Lecture 3 - PowerPoint Presentation

edolie
edolie . @edolie
Follow
69 views
Uploaded On 2023-06-23

CMSC451: Algorithms Lecture 3 - PPT Presentation

Reminders HW1 is out on ELMS Gradescope Check that you can upload No class Monday Labor Day No inperson lecture on Wednesday Lecture will be prerecorded available on ELMS Stable matching ID: 1002021

stable matching free bound matching stable bound free match prefers valid algorithm candidate employer offer paired characterizing scratched set

Share:

Link:

Embed:

Download Presentation from below link

Download Presentation The PPT/PDF document "CMSC451: Algorithms Lecture 3" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

1. CMSC451: AlgorithmsLecture 3

2. RemindersHW1 is out on ELMS + GradescopeCheck that you can uploadNo class Monday (Labor Day)No in-person lecture on WednesdayLecture will be pre-recorded; available on ELMS

3. Stable matching

4. Stable-matching problemInput: a preference list on C for each e  E and a preference list on E for each c  C|E|=|C|=n; input length (n2)Output: a perfect, stable matching (or say none exists)A perfect matching is stable if it has no instabilitiesFor every unpaired (e, c), either e prefers its current match to c, or vice versa

5. The Gale-Shapley algorithm (1962)Say employer e or candidate c is “free” if they are not currently matched At the beginning, everyone is freeAlgorithm: While some employer is free and hasn’t yet made an offer to every candidate:A free employer e “makes an offer” to their highest-ranked candidate c to whom they have not yet made an offerIf c is free, c becomes (tentatively) bound to eIf c is bound to e’ and prefers e’, do nothingIf c is bound to e’ but prefers e, switch to e (so e’ becomes free)When loop ends (so no one is free), bindings become final

6. Analysis: running timeEvery time through the loop, some candidate c gets “scratched off” some employer’s listThe total number of candidates that are not scratched off decreases by 1When all candidates scratched off, algorithm endsAt the beginning of the algorithm, there are n2 candidates who are not scratched off Number of loop iterations is at most n2(Will consider complexity of an iteration later, but clearly can be done in polynomial time)

7. Analysis: correctnessLemma: at any point, the bindings are a matchinge only becomes bound to some c when e is freeWhen c becomes bound to e, then c was either free or else undoes its binding to some other e’Corollary: GS returns a matchingObservation: once c gets an offer, c is never free againLemma: GS returns a perfect matchingIf no e is free, we are done. Say some e is free, but has made an offer to every candidateSince e has made an offer to every candidate, every candidate is bound to some employerSince |E|=|C|=n and the bindings are always a matching, every employer is bound to some candidate and vice versa

8. Analysis: correctnessObservation: once c is bound to e, then c can only be bound to an employer that c ranks at least as high as eCorollary: if e makes an offer to c, then c ends up bound to an employer that c ranks at least as high as eTheorem: GS returns a stable matchingAssume not. So the algorithm matches (e, c) and (e’, c’) where e prefers c’ to c, and c’ prefers e to e’The last offer e made was to ce must have made an offer to c’ at some point (since e prefers c’ to c)c’ must end up bound to an employer that c’ ranks at least as high as e  contradiction

9. SummaryWe have shown an algorithm that always returns a stable matchingIn particular, a stable matching always exists for any set of preferences!The algorithm is efficientO(n2) iterationsThis is tight: there are executions that use (n2) iterationsEach iteration can be implemented efficiently

10. A closer look…Several aspects of the algorithm are unspecifiedHow is the free e chosen in each iteration? Doesn’t matter for correctness, but maybe it affects the output?How do we keep track of the free employers, and the highest-ranked candidate to whom they have not yet made offers?I.e., what data structure(s) would we use to implement this?Affects the overall efficiency of the algorithm

11. Characterizing the outputThere might be many stable matchingsWe show the output of GS is the same regardless of the way in which free employers are chosenGiven a set of preferences:c is a valid match for e if there is a stable matching in which c and e are pairedc is the best match for e (i.e., c = best(e)) if c is a valid match for e, and there is no valid match for e that e prefers to c

12. Characterizing the outputGiven a set of preferences, let M* = { (e, best(e)) }, i.e., every e is paired with its best matchNot immediately clear that this is a matching, let alone a stable matchingTheorem: every execution of GS on a given set of preferences results in M*

13. Characterizing the outputTheorem: every execution of GS results in M*Assume an execution that does not result in M*Since every e makes offers in decreasing preference, there is some e who was rejected by best(e) at some pointConsider the first time some e is rejected by a valid match c(must be that c = best(e))Let e’ be the employer to which c is bound when that rejection occurs. So c prefers e’ to e.e’ was not previously rejected by any valid match at that point. So e’ prefers c to any other valid match.Since c is a valid match for e, there is a stable matching M where e and c are paired. Say e’ is paired with c’ ≠ c in that matching (so in particular c’ is a valid match for e’)By (3), e’ must prefer c to c’ (e’, c) is an instability in M  contradiction

14. Characterizing the outputTheorem: GS outputs the matching in which every c is paired with its worst valid matchAssume GS outputs a matching with a pair (e, c), and e is not the worst valid match for cNote: by the previous result, c is the best match for eSo there is a stable matching M in which c is paired with some e’ that c prefers less than e Say e is paired with c’ in that matchingBut e prefers c to c’, and c prefers e to e’ Instability in M  contradiction

15. SummaryGS produces a stable matching……but the employers have the advantageAdvantage in being the one to make offers!