CS 401: Computer Algorithms I Stable Matching Xiaorui Sun 1 - - PowerPoint PPT Presentation

cs 401 computer algorithms i
SMART_READER_LITE
LIVE PREVIEW

CS 401: Computer Algorithms I Stable Matching Xiaorui Sun 1 - - PowerPoint PPT Presentation

CS 401: Computer Algorithms I Stable Matching Xiaorui Sun 1 Administrativia Stuffs Website: http://www.cs.uic.edu/~xiaorui/cs401 Lecture slides, homework Piazza: piazza.com/uic/fall2020/2020fallcs40141675 Announcements,


slide-1
SLIDE 1

CS 401: Computer Algorithms I

Stable Matching

Xiaorui Sun

1

slide-2
SLIDE 2

Administrativia Stuffs

2

  • Website: http://www.cs.uic.edu/~xiaorui/cs401
  • Lecture slides, homework
  • Piazza: piazza.com/uic/fall2020/2020fallcs40141675
  • Announcements, online discussion forum
  • TA will answer course related questions
  • Homework/Exam submission:

https://www.gradescope.com/courses/169509

  • Homework 0 posted (due September 9)

Calm down, just test GradeScope

  • Office hours on Blackboard Collaborate:
  • Myself: Fri 2pm-4pm
  • TA Wenyu Jin: Tue 10am-12pm
slide-3
SLIDE 3

Last Lecture (summary)

Stable matching problem: Given n men and n women, and their preferences, find a stable matching. Q: Is Yuri-Brenda an unstable pair? A: No, Yuri and Brenda get matched.

3

For a perfect matching M, a pair m-w is unstable if they prefer each other to their match in M.

Zoran Amy Claire Brenda Yuri Brenda Claire Amy Xavier Amy Claire Brenda 1st 2nd 3rd

Men’s Preference Profile

Claire Xavier Zoran Yuri Brenda Xavier Zoran Yuri Amy Yuri Zoran Xavier 1st 2nd 3rd

Women’s Preference Profile

favorite least favorite favorite least favorite

slide-4
SLIDE 4

Last Lecture (summary)

Stable matching problem: Given n men and n women, and their preferences, find a stable matching. Q: Is Yuri-Amy an unstable pair? A: No. Yuri prefer Brenda to Amy

4

For a perfect matching M, a pair m-w is unstable if they prefer each other to their match in M.

Zoran Amy Claire Brenda Yuri Brenda Claire Amy Xavier Amy Claire Brenda 1st 2nd 3rd

Men’s Preference Profile

Claire Xavier Zoran Yuri Brenda Xavier Zoran Yuri Amy Yuri Zoran Xavier 1st 2nd 3rd

Women’s Preference Profile

favorite least favorite favorite least favorite

slide-5
SLIDE 5

Last Lecture (summary)

Stable matching problem: Given n men and n women, and their preferences, find a stable matching. Q: Is Xavier-Amy an unstable pair? A: Yes.

5

For a perfect matching M, a pair m-w is unstable if they prefer each other to their match in M.

Zoran Amy Claire Brenda Yuri Brenda Claire Amy Xavier Amy Claire Brenda 1st 2nd 3rd

Men’s Preference Profile

Claire Xavier Zoran Yuri Brenda Xavier Zoran Yuri Amy Yuri Zoran Xavier 1st 2nd 3rd

Women’s Preference Profile

favorite least favorite favorite least favorite

slide-6
SLIDE 6

Propose-And-Reject Algorithm [Gale-Shapley’62]

6

Initialize each person to be free. while (some man is free and hasn't proposed to every woman) { Choose such a man m w = 1st woman on m's list to whom m has not yet proposed if (w is free) assign m and w to be engaged else if (w prefers m to her fiancé m') assign m and w to be engaged, and m' to be free else w rejects m }

slide-7
SLIDE 7

Questions

  • Q: Why GS algorithm solves Stable Matching problem?
  • Q: How to implement GS algorithm efficiently?
  • Q: If there are multiple stable matchings, which one does

GS find?

7

slide-8
SLIDE 8

What do we need to prove?

Goal: prove Propose-And-Reject Algorithm always finds a stable matching.

  • The algorithm ends.

How many iterations it takes?

  • The output is correct.

It find a perfect matching that is stable.

8

slide-9
SLIDE 9

Main Properties of the algorithm

Observation 1: Men propose to women in decreasing order of preference. Observation 2: Once a woman is matched, she never becomes unmatched; she only "trades up."

9

Initialize each person to be free. while (some man is free and hasn't proposed to every woman) { Choose such a man m w = 1st woman on m's list to whom m has not yet proposed if (w is free) assign m and w to be engaged else if (w prefers m to her fiancé m') assign m and w to be engaged, and m' to be free else w rejects m }

slide-10
SLIDE 10

Proof of Correctness: Termination

Each step, a man proposed to a new woman. There are !×! = !$ possible man-to-woman proposals. Therefore, it takes at most !$ iterations.

10

Walter Victor 1st A B 2nd C D 3rd C B A Zoran Yuri Xavier C D A B B A D C 4th E E 5th A D E E D C B E Brenda Amy 1st W X 2nd Y Z 3rd Y X V Erika Diane Claire Y Z V W W V Z X 4th V W 5th V Z X Y Y X W Z

n(n-1) + 1 proposals required

One strategy to bound # iterations is to find a measure of progress.

slide-11
SLIDE 11

Proof of Correctness: Perfection

  • Claim. All men and women get matched.
  • Proof. (by contradiction)

Suppose, for sake of contradiction, that Zoran is not matched upon termination of algorithm. Then some woman, say Amy, is not matched upon termination. (Observation 2: once women matched, they never becoming unmatched.) Amy was never proposed to. But, Zoran proposes to everyone, since he ends up unmatched.

11

slide-12
SLIDE 12

Proof of Correctness: Stability

  • Claim. No unstable pairs.
  • Proof. (by contradiction)

Suppose A-Z is an unstable pair: each prefers each other to the partner in Gale-Shapley matching. Case 1: Z never proposed to A. Þ Z prefers his GS partner to A. Þ A-Z is stable. Case 2: Z proposed to A. Þ A rejected Z (right away or later) Þ A prefers her GS partner to Z. Þ A-Z is stable. In either case A-Z is stable, a contradiction.

12

men propose in decreasing

  • rder of preference

women only trade up

slide-13
SLIDE 13

Questions

  • Q: Why GS algorithm solves Stable Matching problem?
  • Q: How to implement GS algorithm efficiently?
  • Q: If there are multiple stable matchings, which one does

GS find?

13

slide-14
SLIDE 14

Propose-And-Reject Algorithm [Gale-Shapley’62]

14

Initialize each person to be free. while (some man is free and hasn't proposed to every woman) { Choose such a man m w = 1st woman on m's list to whom m has not yet proposed if (w is free) assign m and w to be engaged else if (w prefers m to her fiancé m') assign m and w to be engaged, and m' to be free else w rejects m }

  • Maintain two arrays wife[m], and husband[w].
  • set entry to 0 if unmatched
  • if m matched to w then wife[m]=w and husband[w]=m
  • Maintain a matrix proposed[m, w].
  • Set entry to 1 if m has proposed to w, otherwise set to 0

O(n2) time O(n) time

  • Input: For each man (woman), a list of women (men) ordered by

preference, denoted as pref[m/w, i] Overall: O(n4) time O(n) time