Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Class 15: Stable Matching

David Evans
October 18, 2016
4.3k

Class 15: Stable Matching

cs2102: Discrete Mathematics
University of Virginia, Fall 2016

See course site for notes:
https://uvacs2102.github.io

David Evans

October 18, 2016
Tweet

Transcript

  1. Class 15: Stable Matching cs2102: Discrete Mathematics | F16 uvacs2102.github.io

    David Evans | University of Virginia Storage fees on Exam 1 double after today! Can pick up after class today No class Thursday
  2. Formal Problem Definition Input: Output: Stable matching between and ,

    , ≺% , ≺& A matching, = { , , , , . , . , … , 0 , 0 } is a stable matching if there is no pair (3 , 4 ) where 3 ≺67 4 and 4 ≺89 3 .
  3. Stable Matches? Anna Elsa Hans Kristoff Kristoff ≺:;;<Hans Kristoff ≺=>?<Hans

    Elsa ≺@<;?Anna Elsa ≺ABC?DEFFAnna {(Anna, Hans), (Elsa, Kristoff)} {(Anna, Kristoff), (Elsa, Hans)}
  4. Stable Matches? Anna Elsa Olaf Kristoff Olfa ≺:;;<Kristoff Kristoff ≺=>?<Olaf

    Anna ≺G><F Elsa Elsa ≺ABC?DEFFAnna {(Anna, Olaf), (Elsa, Kristoff)} {(Anna, Kristoff), (Elsa, Olaf)}
  5. Olfa ≺:;;< Kristoff Kristoff ≺=>?< Olaf Anna ≺G><F Elsa Elsa

    ≺ABC?DEFF Anna Implementing Gale-Shapley
  6. Simplified Code (Non-Defensive) Do not write programs like this: assertions

    (especially) and comments are valuable (but don’t fit on slides)
  7. = { , | = { , ∈ , ∈

    , no duplicate occurences of or = , , . , … , 0 where 0 ≤ 3 ≤ }
  8. = { , | = { , ∈ , ∈

    , no duplicate occurences of or = , , . , … , 0 where 0 ≤ 3 ≤ } = , ⟶ g, g All cases:
  9. = { , | = { , ∈ , ∈

    , no duplicate occurences of or = , , . , … , 0 where 0 ≤ 3 ≤ } = , ⟶ g, g All cases: g = , , . , … , 3 + 1, … , 0 j is the 3 -ranked match for 3 Case 1:
  10. = { , | = { , ∈ , ∈

    , no duplicate occurences of or = , , . , … , 0 where 0 ≤ 3 ≤ } = , ⟶ g, g All cases: g = , , . , … , 3 + 1, … , 0 j is the 3 -ranked match for 3 Case 1: new pairing ∀l ∈ . l , j ∉ g = ∪ 3 , j Case 2: better pairing ∃l ∈ . l , j ∈ , j prefers 3 to j g = ∪ 3 , j Case 3: rejected proposal ∃l ∈ . l , j ∈ , j prefers j to 3 g =
  11. Proving Termination For all valid inputs, gale_shapley eventually terminates (returns

    a pairing). Each step, one of the proposals counts increases by 1 (and all others stay the same). After .steps, must be , , … , so no further transitions possible.
  12. Proving Correctness For all valid inputs, gale_shapley returns a stable

    matching of its inputs. A matching, = { , , , … , 0 , 0 } is a stable matching if there is no pair (3 , 4 ) where 3 ≺67 4 and 4 ≺89 3 .
  13. For all valid inputs, gale_shapley returns a stable matching of

    its inputs. A matching, = { , , , … , 0 , 0 } is a stable matching if there is no pair (3 , 4 ) where 3 ≺67 4 and 4 ≺89 3 . = , ⟶ g, g All cases: g = , , . , …, 3 + 1, …, 0 jis the 3-ranked match for 3 Case 1: new pairing ∀l ∈ . l , j ∉ g = ∪ 3 , j Case 2: better pairing ∃l ∈ . l , j ∈ , j prefers 3 to j g = ∪ 3 , j Case 3: rejected proposal ∃l ∈ . l , j ∈ , j prefers j to 3 g = Left as problem for PS7