Advertisement
Guest User

Untitled

a guest
Jul 26th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.18 KB | None | 0 0
  1. Stable marriage problem (You CAN always find a stable perfect matching, when nodes aren’t unisex / must be heterosexual)
  2. Have some boys and girls (N boys & N girls)
  3. (constraint: boys can only be paired with girls, and vice versa)
  4. All the boys have ranked preference list of all the girls they like.
  5. Vice Versa. (All the girls have a ranked preference list of the boys)
  6. GOAL: Find perfect matching s.t. there are no rogue couples.
  7.  
  8. e.g.
  9.  
  10. Boys
  11. 1. CBEAD
  12. 2. ABECD
  13. 3. DCBAE
  14. 4. ACDBE
  15. 5. ABDEC
  16. Girls
  17. A. 35214
  18. B. 52143
  19. C. 43512
  20. D. 12345
  21. E. 23415
  22.  
  23. How solve? Greedy algo (always try 1st. it’ll work a/b 50% of time in life, 50% of time it won’t):
  24. 1->C
  25. 2->A
  26. 3->D
  27. 4->B (rogue couple. 4C.)
  28. 5->E
  29.  
  30. Trying to ‘patch’ things up, you create other rogue couples/the orders get all mixed up.
  31. Can NOT require first matching a boy and girl that ‘like eachother best’ and then recurse on that, b/c you don’t know if the base case will exist.
  32.  
  33. Balcony Serenading Algo. (aka the marriage algorithm, TMA)
  34. Init. cond: preference lists (as above)
  35. A ritual: takes place over several days. Each day split into 3 parts: morning, noon & night.
  36. Each morning, girl comes out to her balcony to check who’s there.
  37. Each boy, goes to balcony of his fav girl who’s still on his list, hasn’t been crossed off (initially, every girl is still on his list so he just goes to his 1st favorite) off and serenades her.
  38. If he has nobody left, he just stays home & does homework, no serenading.
  39. At noon, girls who have at least 1 suitor, picks her favorite, says “maybe I’ll marry you, come back tomorrow.” Banishes the other lower priority boys.
  40. At night, the boys who heard “No”, he crosses her off his list, goes to his next priority tomorrow.
  41. Recurse the algo.
  42.  
  43. If ever find a condition in which every girl has at most 1 suitor (i.e. no balconies have > 1 suitor), then the termination condition is met, the boys and girls marry whoever is there.
  44.  
  45. Girls Day1 Day2 Day3 Day4 (Who came to balcony? Girl picks from them one to tell “hang around / come back tmrw”)
  46. A 2,4,5 5 5 5
  47. B 2 2,1 2
  48. C 1 1,4 4 4
  49. D 3 3 3 3
  50. E 1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement