CS 401: Computer Algorithms I
Stable Matching
Xiaorui Sun
1
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,
Xiaorui Sun
1
2
https://www.gradescope.com/courses/169509
Calm down, just test GradeScope
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
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
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
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 }
7
How many iterations it takes?
It find a perfect matching that is stable.
8
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 }
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.
11
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
women only trade up
13
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 }
O(n2) time O(n) time
preference, denoted as pref[m/w, i] Overall: O(n4) time O(n) time