We will discuss the Matching problem, which you already thought about on . We re-cap:
Consider the Marriage Problem:
we'll introduce it with an example input:
Four men (Alistair, Bernie, Corky, Dweezil -- abbreviated A,B,C,D resp.),
and four women
(Winnie, Xena, Yolanda, Zelda -- abbreviated W,X,Y,Z resp.),
along with their preferences for hooking up marriage:
Alistair: W,X,Y,Z Bernie: W,X,Z,Y Corky: W,Y,Z,X Dweezil: X,W,Y,Z Winnie: A,B,C,D Xena: C,B,D,A Yolanda: D,B,A,C Zelda: C,B,A,DThe task is to come up with a pairing of each person with someone of the opposite gender.
For example,
one dating company, HappyGuys
came up with the following solution:
A+W,
B+X,
C+Y,
D+Z.
Another company, HappyGals
arrived at a different solution:
A+W,
C+X,
D+Y,
B+Z.
A: Y,Z B: Z,Y Y: A,B Z: B,AThere are only two possible solutions: {A+Y,B+Z} and {A+Z,B+Y}.
A: Z,Y B: Y,Z Y: A,B Z: B,AThere are still only two possible solutions: {A+Y,B+Z} and {A+Z,B+Y}.
In fact, with two men and two women, there are is only one other fundamentally different input:
A: Y,Z B: Y,Z Y: A,B Z: A,BAll other inputs merely involve swapping the names A,B and X,Y (or both).
In the HappyGals solution to the example given above, what happens, when Bernie+Zelda happen to go out dancing at the same club as Corky+Xena?
Corky realizes he'd prefer Zelda to Xena, and winks at her. Zelda realizes she'd prefer the dreamy Corky to Bernie, and she winks back. The two of them dump their dates and find true (well, increased) happiness.
(Note that this re-arrangment isn't all mutual, and wouldn't be instigated by others: Although Bernie winks at Xena, Xena ignores him since she prefers her current date.)
Finally, consider
The Suitor's Algorithm (phrased in medieval, rather sexist terms):
This repeats until there are no changes.
We will talk about this algorithm in lecture,
starting with the question of
whether the Suitor's Algorithm is even guaranteed to terminate.
How many possible solutions? What is a good solution?
Questions:
- does this algorithm terminate? (Argue why there won't be some loop that goes on forever.) Yes: [why?] At each step, a woman's preference will stay the same or go up (never down). It can only go up a maximum of n times. If Alternately: Each man will move no more than n times, and there aren't any Note how our proof gives a bound on the running time. - When this algorithm stops, does it give a solution? That is, does every woman's tower have exactly one man at it? Yes -- when algorithrm terminates, there won't be more than one man at a tower (otherwise we wouldn't have terminated). By counting: if n men are assigned to n towers and none of them have 2 or more, then each must have exactly one. - Is The Suitor's ALgorithm guaranteed to produce a stable solution? Yes: Proof by contradiction: Suppose not; suppose that after a solution is reached, some couple A,Z would prefer to break out of the solution. In that case, Z visited A's tower (before the person he ended up with). But then A must have spurned Z, meaning she had some better catch M dangling on the line. So her final catch A* must at least as good as M, who was better then Z. So she would not want to swap with Z, contradicting our premise that A+Z would both prefer each other to their solution.
Definition:
A matching M is optimal for a person k if:
pref(k,M(k)) = max_S { pref(k,S(k)) | S is a stable matching }
Lemma:
If a woman A is flirting with a man M (during the Suitor's Algorithm),
and she eventually ends up with some man N (perhaps M=N),
then pref(A,N) ≥ pref(A,M).
Th'm: The Suitor's algorithm yields a match which is optimal for every single man. [that is, their most-preferred match, out of any stable matching.] Proof: Proof by contradiction: suppose *some* man is not paired with his optimal mate. In particular, during the algorithm, consider the first man who passes up his optimal mate; call him 'M'. Call M's optimal match opt(m). Clearly, in the suitor's alg, M won't end up with anybody preferred higher than opt(M). Suppose at some point, he visits opt(M)'s tower. But some other man N is there, and opt(M) chooses N over M. (Note that if Y shows up at that tower, it's because he was spurned by all his higher choices, and Y can't be with any of those women higher choices in a stable solution.) Well then, by def'n of "opt", there is some (other) matching where M+opt(M), N+...we'll call her X opt(M): ...,N,...,M,... (since M got bumped) N: ...,X,... Where does opt(M) fit, in N's list-of-preferences? We can't put opt(M) *before* X, else S isn't stable. We can't put opt(M) *after* X; this is the *first* round where somebody is leaving their optimal mate. Lemma: If M is matched with with W in a male-optimal matching, then M is W's pessimal (least-preferred) choice out of all stable matches. Proof: Consider any (other) stable matching S, where M is matched with soembody else, X. But M prefers W to X (by opt). Since S is stable, W prefers her match in S to M.
Sets M and F (males and females), where they are the same size and disjoint (|M|=|F| and M∩F = φ).
Each person's preference is
a functions
p: M→
Actually, we can be more precise, since people can't be repeated in a preference list; each person has in mind a permutation of the other gender: p : M→π(F) and p : F→π(M)
A solution is a matching function: s : M→F, s : F→M.