Wash U DARPA PCES PI Meeting Report

Stable Matching Examples
Ron K. Cytron
http://www.cs.wustl.edu/~cytron/
Examples drawn from Knuths’ lecture in French:
Marriages stables et leurs relations avec d’autres problemes
combinatoires
24 November 2008
Can’t we just guess?
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Can’t we just guess?
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Aa
Stable Matching Problem CSE 131
Can’t we just guess?
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Aa Bb
Stable Matching Problem CSE 131
Can’t we just guess?
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Aa Bb Cc
Stable Matching Problem CSE 131
Can’t we just guess?
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Aa Bb Cc Dd
Stable Matching Problem CSE 131
Can’t we just guess?
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Aa Bb Cc Dd is not stable
Do you see why?
Stable Matching Problem CSE 131
Can’t we just guess?
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Aa Bb Cc Dd is not stable
Ab elope
Stable Matching Problem CSE 131
Let infidelity derive a solution?
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Aa Bb Cc Dd is not stable
Ab elope
Stable Matching Problem CSE 131
Let infidelity derive a solution?
Let Ab elope and…..
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Ab Ba Cc Dd is not stable
Cb elope
Stable Matching Problem CSE 131
Let infidelity derive a solution?
Let Cb elope and…..
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Ac Ba Cb Dd is not stable
Dc elope
Stable Matching Problem CSE 131
Let infidelity derive a solution?
Let Cb elope and…..
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Ad Ba Cb Dc is stable!
How can we show this?
Stable Matching Problem CSE 131
Proof of no infidelity
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Ad Ba Cb Dc is stable!
Stable Matching Problem CSE 131
Proof of no infidelity
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Ad Ba Cb Dc is stable!
Stable Matching Problem CSE 131
Proof of no infidelity
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Ad Ba Cb Dc is stable!
Algorithm?
Stable Matching Problem CSE 131
Your ideas?
• Let infidelity rule and see what happens
• Put top choices together and see
• Compute average of X y y X and do something
with that score
• Favor one side with its preference, ignore the
other side
• Make smaller instances and try that
• Start with worst matches and try to improve
Stable Matching Problem CSE 131
Iterate until stable?
Stable Matching Problem CSE 131
Iterate until stable?
A
b
a
c
a
A
C
B
B
--
--
--
b
C
A
B
C
a
b
c
c
--
--
--
Ab elope
Stable Matching Problem CSE 131
Iterate until stable?
A
b
a
c
a
A
C
B
B
--
--
--
b
C
A
B
C
a
b
c
c
--
--
--
Ab elope Cb elope
Stable Matching Problem CSE 131
Iterate until stable?
A
b
a
c
a
A
C
B
B
--
--
--
b
C
A
B
C
a
b
c
c
--
--
--
Ab elope Cb elope Ca elope
Stable Matching Problem CSE 131
Iterate until stable?
A
b
a
c
a
A
C
B
B
--
--
--
b
C
A
B
C
a
b
c
c
--
--
--
Ab elope Cb elope Ca elope Aa elope – back to start
Stable Matching Problem CSE 131
Try everything?
• How many possibilities are there?
Stable Matching Problem CSE 131
How many possible stable matchings?
1
2
1
2
2
1
…
…
1
2
…
…
1
2
3
4
…
n-1
3
4
4
3
n-1
n
n
n-1
…
…
…
…
3
4
…
n-1
…
…
…
…
3
4
…
n-1
…
n
…
n
n
Stable Matching Problem CSE 131
How many possible stable matchings?
1
2
1
2
2
1
…
…
1
2
…
…
1
2
3
4
…
n-1
3
4
4
3
n-1
n
n
n-1
…
…
…
…
3
4
…
n-1
…
…
…
…
3
4
…
n-1
…
n
…
n
n
Left group can decide to approach
distinct people from the right group
Stable Matching Problem CSE 131
How many possible stable matchings?
1
2
1
2
2
1
…
…
1
2
…
…
1
2
3
4
…
n-1
3
4
4
3
n-1
n
n
n-1
…
…
…
…
3
4
…
n-1
…
…
…
…
3
4
…
n-1
…
n
…
n
n
Each adjacent pair will decide between
their first and second choices.
For example, 1 and 2 ….
Stable Matching Problem CSE 131
How many possible stable matchings?
1
2
1
2
2
1
…
…
1
2
…
…
1
2
3
4
…
n-1
3
4
4
3
n-1
n
n
n-1
…
…
…
…
3
4
…
n-1
…
…
…
…
3
4
…
n-1
…
n
…
n
n
Go with their first choices
1 and 2 are stable from the left
Or…….
Stable Matching Problem CSE 131
How many possible stable matchings?
1
2
1
2
2
1
…
…
1
2
…
…
1
2
3
4
…
n-1
3
4
4
3
n-1
n
n
n-1
…
…
…
…
3
4
…
n-1
…
…
…
…
3
4
…
n-1
…
n
…
n
n
Go with their second choices
1 and 2 are stable from the right
Stable Matching Problem CSE 131
How many possible stable matchings?
1
2
1
2
2
1
…
…
1
2
…
…
1
2
3
4
…
n-1
3
4
4
3
n-1
n
n
n-1
…
…
…
…
3
4
…
n-1
…
…
…
…
3
4
…
n-1
…
n
…
n
n
n/2 groups can go 1 of 2 ways here
Exponential number of possibilties:
2
n/2
Stable Matching Problem CSE 131
The algorithm
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
Stable Matching Problem CSE 131
Algorithm applied to first example
#1
#2
#3
#4
#1
#2
#3
#4
A
c
b
d
a
a
A
B
D
C
B
b
a
c
d
b
C
A
D
B
C
b
d
a
c
c
C
B
D
A
D
c
a
d
b
d
B
A
C
D
C and D are unbreakable
Little a could try for big A, but big A won’t go for it
Little d could try for big B, but big B won’t go for it
Stable!
Stable Matching Problem CSE 131
Desirable properties
• Termination
• Correctness
– Everybody paired up
– Stable arrangement
• Fairness
– Is it fair?
– If not, who suffers?
Stable Matching Problem CSE 131
Fairness
#1
#2
#3
#4
#1
#2
#3
#4
A
a
b
c
d
a
B
C
D
A
B
b
c
d
a
b
C
D
A
B
C
c
d
a
b
c
D
A
B
C
D
d
a
b
c
d
A
B
C
D
Stable Matching Problem CSE 131
Fairness
#1
#2
#3
#4
#1
#2
#3
#4
A
a
b
c
d
a
B
C
D
A
B
b
c
d
a
b
C
D
A
B
C
c
d
a
b
c
D
A
B
C
D
d
a
b
c
d
A
B
C
D
Big letters have the advantage.
Hospitals hosting residents.
Stable Matching Problem CSE 131
How about picking roommates?
• Like stable matching, but instead of two
populations
– ABC…
– abc…
• We have just one population:
– A, B, C, …
• Example:
– A, B, C, D
– Make any one pairing (such as AB) and the other
paring (CD) is determined
Stable Matching Problem CSE 131
Roommates
#1
#2
#3
A
C
B
D
B
A
C
D
C
B
A
D
D
A
B
C
We can cover all possibilities by trying
A with C, then B, then D
Let’s see what happens
Stable Matching Problem CSE 131
Roommates
#1
#2
#3
A
C
B
D
B
A
C
D
C
B
A
D
D
A
B
C
Try A with C
Stable Matching Problem CSE 131
Roommates
#1
#2
#3
A
C
B
D
B
A
C
D
C
B
A
D
D
A
B
C
Try A with C
BC bail
Stable Matching Problem CSE 131
Roommates
#1
#2
#3
A
C
B
D
B
A
C
D
C
B
A
D
D
A
B
C
Try A with B
Stable Matching Problem CSE 131
Roommates
#1
#2
#3
A
C
B
D
B
A
C
D
C
B
A
D
D
A
B
C
Try A with B
AC bail
Stable Matching Problem CSE 131
Roommates
#1
#2
#3
A
C
B
D
B
A
C
D
C
B
A
D
D
A
B
C
Try A with D
Stable Matching Problem CSE 131
Roommates
#1
#2
#3
A
C
B
D
B
A
C
D
C
B
A
D
D
A
B
C
No stable matching exists
Try A with D
AB bail
Stable Matching Problem CSE 131