CS252 Algorithms Monday, 1 April 2024 + Problem sets - What's on your mind? + Stable matching: the problem - the metaphor 1962, creepiness, power of our intuitions about "engaged", etc. - inputs & outputs An "instance" of this problem consists of: two sets M and W, same size N, finite preference lists each m in M has an ordering/ranking of the elements of W each w in W has an ordering/ranking of the elements of M output: a set of pairings S = {(m,w),...} m in M, w in W S is a subset of MxW each m and each w appears exactly once in S "stable" - what is "stability"? Instance 1 M = {Adam, Bob} W = {Zelda, Yvonne} Adam: Yvonne, Zelda {(A,Y), (B,Z)} <-- stable Bob: Yvonne, Zelda {(A,Z), (B,Y)} <-- not stable Yvonne: Adam, Bob A prefers Y to current partner Zelda: Bob, Adam Y prefers A to current partner so they would elope Instance 2 Adam: Zelda, Yvonne {(A,Y), (B,Z)} <-- stable w's don't want to switch Bob: Yvonne, Zelda {(A,Z), (B,Y)} <-- stable m's don't want to switch Yvonne: Adam, Bob Zelda: Bob, Adam - play with examples - can an instance have > 1 stable matchings? yes (see Instance 2 above) - > 2? yes ... - none? no ... see the theorem - applications, variations - The CS Match People could in special cases match people to 2 classes Don't have to rank every class Sizes of the sets are different Not everybody gets a match The classes have weird preference lists class year, must-have-to-graduate-on-time,... - NRMP (medical residents & hospitals) - Questbridge - College applications - Only one set, and assign class project partners "roommates problem" ... + The algorithm - Do one by hand (always do a few by hand!) X Adam: *Zelda, Yvonne X Bob: *Yvonne, Zelda X Yvonne: Adam, Bob X Zelda: Bob, Adam S = {} m = Bob, w = Yvonne w is free, engagement happens S = {(B,Y)} m = Adam, w = Zelda w is free, engagement happens S = {(B,Y), (A,Z)} Loop terminates Questions - If I have an instance with 3 stables matches, is it possible to get G-S to generate all of them (men proposing, women proposing,...?) - What kinds of preference lists cause the slowest runtimes? - ... Do a N=3 example by hand A: *X, Y, Z B: *X, Z, Y C: Y, X, Z X: B, C, A Y: A, C, B Z: A, C, B {(B,X)} ... ==== WE STOPPED HERE === + Correctness proof + Runtime complexity