Design and Analysis of Algorithms
CS345
Lecture 6
Stable Matching Algorithm and Applications
1
Recap from the last Lecture
2
Interpolation
There is a polynomial
with ’s unknown.
Given: the following (point, value) representation of :
{}
Aim: To compute ’s .
3
Interpolation
Polynomial Interpolation = Polynomial evaluation
Can you guess the polynomial whose evaluation
will help solve polynomial interpolation ?
Make an obvious guess.
4
Interpolation
Solution:
Define a polynomial
, where .
Evaluate on .
Can youWhat is ?is relation
guess what
Homework: between and ?
5
• It was very disheartening to see that only a handful of students attempted
the homework.
• Please attempt each homework sincerely. It is for your own benefit.
• If you are not able to do the homework, you may send email to the
instructor 1 day in advance for a short meeting (avoid holidays and week-
ends).
6
Real challenge
of multiple merit lists
7
Fairness
Choice list of Mohan
p q p
Mohan
q
Ram
Merit list of programme q
Ram Mohan
8
How to tackle Multiple Merit Lists using
“Single Merit list algorithm”
9
A common man’s algorithm
Allocation_IIT();
Allocation_NIT();
; Round
While ( ) and Round )
{ For each do
{ is asked to choose between the two choices;
The preference list of is trimmed accordingly;
}
Allocation_IIT();
Allocation_NIT(); Round Round +
;
}
Homework (not for exam): Prove that the algorithm outputs a fair seat allocation.
10
Multiple merit lists
IIT C B A A IIT ARCH NIT
NIT A C B B NIT IIT ARCH
ARCH B A C C ARCH NIT IIT
Merit Lists Choice Lists
A B C
Allocation Allocation Allocation
IIT C IIT A IIT B
NIT A NIT B NIT C
ARCH B ARCH C ARCH A
Candidate Pessimal Candidate Optimal
11
The Stable Marriage Problem
12
Stable Marriage Problem
Meaning of unstability
• prefers to
(, ) : an unstable pair
• prefers to
𝑤𝑙 divorce 𝑚𝑘
𝑤𝑖 divorce 𝑚𝑗
Definition:
A marriage is said to be stable if there is no unstable pair in the society.
13
Stable Marriage Problem
• : set of men
• : set of women
For each man ,
: a preference list of all women
For each woman ,
: a preference list of all men
Aim: To compute a stable marriage.
14
Algorithm for Stable Marriage
1962, David Gale and Lloyd Shapley
Nobel Prize in Economic Sciences, 2012
Man proposes, Woman
God disposes
15
We designed an iterative algorithm in the last class
based on these rules.
Rule for Men
• A man proposes in the decreasing order of preference.
• Once rejected by a woman, the man never proposes to her again.
Rule for Women
• A woman, if single, accepts a proposal.
• A woman, if engaged, accepts a proposal from a man if she prefers him to
her current partner.
16
GaleShapley(, )
(Proof of stability)
Consider
Lemma : There the pair (,pair
is no unstable ) in the marriage. How to restate it so that
If prefers to to ,
If prefers nothing to be done we can prove it easily ?
prefers to .
𝑤𝑙 𝑚𝑘
𝑤𝑖 𝑚𝑗
The key observation :
Each new engagement gives a woman a better partner (mate).
17
GaleShapley(, )
(Proof of stability)
Lemma :
If prefers to
prefers to .
𝑤𝑙 𝑚𝑘
The following slide gives
the steps of the analysis.
𝑤𝑖 𝑚𝑗
Proof: (a sketch (the details emerged from the interaction in the class))
must have proposed to .
At the moment of the proposal, was either engaged or single.
If was single, would have accepted the offer at that time but rejected later.
But a woman rejects her present mate only when she gets a better mate.
So would have surely got a better mate than .
Since the mate of a woman only improves in future rounds, would indeed be preferred to .
If was engaged, …fill in the details along similar lines as stated above…
18
𝑚𝑡
𝑤𝑙 𝑚𝑘
𝑤𝑖 𝑚𝑗
𝑚𝑝
19
GaleShapley(, )
(Proof of stability)
Lemma : If prefers to
prefers to .
𝑤𝑙 𝑚𝑘
𝑤𝑖 𝑚𝑗
20
GaleShapley(, )
Theorem:
GaleShapley(, ) indeed computes a stable marriage.
Question : Does there exist a unique stable marriage ?
Answer: No.
Homework:
Give an example graph with multiple stable matchings.
Gale Shapley Algorithm
Theorem:
There cannot exist any other stable matching that matches a man to a better woman.
Man
proposing
Woman pessimal Man Optimal
22
Gale Shapley Algorithm
Woman
proposing
Woman Optimal Man Pessimal
23
Gale Shapley Algorithm
Can you think of using this algorithm to solve the
problem of joint seat allocation ?
Women Men
𝑤1 𝑚1
𝑤2 𝑚2
𝑤3 𝑚3
𝑤𝑖 𝑚𝑗
𝑤𝑛 𝑚𝑛
24
Gale Shapley Algorithm
Programs Men
𝑃1 𝑚1
𝑃2 𝑚2
𝑃3 𝑚3
𝑃𝑖 𝑚𝑗
𝑃𝑛 𝑚𝑛
25
Gale Shapley
Deferred Algorithm
Acceptance Algorithm
Programs Candidates
𝑃1 𝑐1
𝑃2 𝑐2
Preference
Unstability
lists
𝑃3 𝑐3
Unfairness
Merit lists
𝑃𝑖 𝑐𝑗
𝑃𝑛 𝑐𝑚
26
Deferred Acceptance Algorithm
Programs Candidates
𝑃1 𝑐1
𝑃2 𝑐2
𝑃3 𝑐3
𝑃𝑖 𝑐𝑗
𝑃𝑛 𝑐𝑚
27
Algorithms
Gale Shapley
algorithm
Limited rounds
Programme proposing Programme proposing Candidate proposing
Common man’s algorithm Software Industry’s algorithm Deferred Acceptance algorithm
Candidate Pessimal Candidate Pessimal Candidate Optimal
28
Merits of
Deferred Acceptance Algorithm
• Any number of merit lists
• Candidate optimality guaranteed
• Efficient Algorithm
Deferred Acceptance
Joint Seat Allocation Algorithm
29
Many complex Business rules
of admissions
• Affirmative action rules
• Freeze/Float/Slide/withdraw
• Supernumerary Seats for Female Candidates [’18 - ]
– No increase in male seats
– No adverse affect on chances for the male candidates
– Create supernumerary seats (not reservation at all !)
Impact of Joint Seat Allocation
Vacancies in IITs
No. of Seats Vacancies
𝟓𝟖𝟕
𝟑𝟎𝟖
𝟏𝟗𝟎
𝟏𝟗𝟖
Impact of Joint Seat Allocation
• A single vacancy removed
many candidates getting better program (due to cascading effect)
No. of Candidates getting better Seats
𝟏𝟖𝟗𝟎
𝟏𝟕𝟔𝟕
𝟑𝟔𝟕𝟐 𝟏 ↔𝟑𝟎𝟎
Algorithms do have great impact in real world …
33
Impact of Joint Seat Allocation
• INFORMS J. Appl. Anal., 49(5) 338-354 (2019)
Centralized Admissions for Engineering Colleges in India
S. Baswana, P. P. Chakrabarti, S. Chandran, Y. Kanoria, U. Patange
The above research paper is available on the homepage of the
instructor.
Read it to see the role of algorithms in your journey to IITK
Not meant for exam or quizzes
Gayle Shapley Algorithm
Man-Proposing version
Proof of Man optimality
35
Gale Shapley Algorithm
Women Men
𝑤1 𝑚1
𝑤2 𝑚2
𝑤3 𝑚3
𝑤𝑖 𝑚𝑗
𝑤𝑛 𝑚𝑛
36
Let be the matching produced by GS algorithm.
Let be any other stable matching.
Theorem (Man Optimality):
There does not exist any man such that
precedes in the preference list of .
37
Theorem (Man Optimality):
There does not exist any man such that
precedes in the preference list of .
At the end of the th iteration,
the set of men matched by GS algorithm.
Theorem (Man Optimality): At the end of the th iteration,
There does not exist any man such that
precedes in the preference list of .
38
Theorem (Man Optimality): At the end of the th iteration,
There does not exist any man such that
precedes in the preference list of .
𝒇𝒊
𝒈 39
Theorem (Man Optimality): At the end of the th iteration,
There does not exist any man such that
precedes in the preference list of .
1st Iteration
𝒇𝟏
𝒈 40
Theorem (Man Optimality): At the end of the th iteration,
There does not exist any man such that
precedes in the preference list of .
Execution
th iteration:of th iteration:
𝒇 𝒊 −𝟏
𝑚𝑗
𝒈 41
Theorem (Man Optimality): At the end of the th iteration,
There does not exist any man such that
precedes in the preference list of .
Execution of th iteration:
𝑤𝑗 𝑚𝑗
𝒇𝒊 𝑤 𝑗′ 𝑚𝑗
Homework:
Prove that if prefers to , must be unstable. 𝒈 42