1 / 52

Atama ve eşleme (eşleştirme) problemleri (Matching and Assignment problems)

Atama ve eşleme (eşleştirme) problemleri (Matching and Assignment problems). Hall Teoremi : Sözel olarak: Eğer her bir erkek grubu için onların hoşlandıkları kızlar grubu daha genişse, her bir erkek isteğine göre kız bulabilir. a. x. b. y. c. z. d. w. e.

kyung
Download Presentation

Atama ve eşleme (eşleştirme) problemleri (Matching and Assignment problems)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Atama ve eşleme (eşleştirme) problemleri(Matching and Assignment problems)

  2. Hall Teoremi: Sözel olarak: • Eğer her bir erkek grubu için onların hoşlandıkları kızlar grubu daha genişse, • her bir erkek isteğine göre kız bulabilir

  3. a x b y c z d w e

  4. Sözel olarak: Eğer her bir erkek yeterince istekli ise (k´dan fazla kızla ilgileniyorsa) ve • hiç bir kız özel ilgi görmüyorsa (k´dan fazla ilgi görmüyorsa), • her bir erkek isteğine göre kız bulabilir.

  5. Ör.: 50 öğrenciden oluşan bir sınıfta 25 erkek ve 25 kız vardır. Her erkek =5 kızdan hoşlanıyor. Her kız için ondan hoşlanan =5 erkek vardır. Bir okul partisine her erkek hoşlandığı bir kız ile katılabilir mi?

  6. Ör.: 45 öğrenciden oluşan bir sınıfta 20 erkek ve 25 kız vardır. Her erkek =5 kızdan hoşlanıyor. Her kız için ondan hoşlanan =4 erkek vardır. Bir okul partisine her erkek hoşlandığı bir kız ile katılabilir mi?

  7. Unweighted Bipartite Matching

  8. Definitions Matching Free Vertex

  9. Definitions • Maximum Matching: matching with the largest number of edges

  10. Definition • Note that maximum matching is not unique.

  11. Intuition • Let the top set of vertices be men • Let the bottom set of vertices be women • Suppose each edge represents a pair of man and woman who like each other • Maximum matching tries to maximize the number of couples!

  12. Applications • Matching has many applications. • This lecture lets you know how to find maximum matching.

  13. Alternating Path • Alternating between matching and non-matching edges. a c d e b f h i j g d-h-e: alternating path a-f-b-h-d-i: alternating path starts and ends with free vertices f-b-h-e: not alternating path e-j: alternating path starts and ends with free vertices

  14. Idea • “Flip” augmenting path to get better matching • Note: After flipping, the number of matched edges will increase by 1! 

  15. Idea of Algorithm • Start with an arbitrary matching • While we still can find an augmenting path • Find the augmenting path P • Flip the edges in P

  16. Breadth-First Search Algorithm for Augmented Path • Use Breadth-First Search: • LEVEL(0) = some unmatched vertex r • for odd L > 0, • LEVEL(L) = {u|{v,u}  E – M • when v  LEVEL(L -1) • and when u in no lower level} • For even L > 0, • LEVEL(L) = {u|{v,u}  M • when v  LEVEL(L -1) • and u in no lower level} • Assume G is bipartite graph with matching M.

  17. Labelling Algorithm • Start with arbitrary matching

  18. Labelling Algorithm • Pick a free vertex in the bottom

  19. Labelling Algorithm • Run BFS

  20. Labelling Algorithm • Alternate unmatched/matched edges

  21. Labelling Algorithm • Until a augmenting path is found

  22. Augmenting Tree

  23. Flip!

  24. Repeat • Pick another free vertex in the bottom

  25. Repeat • Run BFS

  26. Repeat • Flip

  27. Answer • Since we cannot find any augmenting path, stop!

  28. Overall algorithm • Start with an arbitrary matching (e.g., empty matching) • Repeat forever • For all free vertices in the bottom, • do bfs to find augmenting paths • If found, then flip the edges • If fail to find, stop and report the maximum matching.

  29. Time analysis • We can find at most |V| augmenting paths (why?) • To find an augmenting path, we use bfs! Time required = O( |V| + |E| ) • Total time: O(|V|2 + |V| |E|)

  30. Improvement • We can try to find augmenting paths in parallel for all free nodes in every iteration. • Using such approach, the time complexity is improved to O(|V|0.5 |E|)

  31. Stable Marriage Problem

  32. Stable Marriage Problem • Given N men and N women, each person list in order of preference all the people of the opposite sex who would like to marry. • Problem: • Engage all the women to all the men in such a way as to respect all their preferences as much as possible.

  33. A B C D E 1 2 3 4 5 2 1 2 1 5 E D A C D 5 2 3 3 3 A E D B B 1 3 5 2 2 D B B D C 3 4 4 4 1 B A C A E 4 5 1 5 4 C C E E A Stable? • A set of marriages is unstable if • two people who are not married both prefer each other than their spouses • E.g. Suppose we have A1 B3 C2 D4 E5. This is unstable since • A prefer 2 more than 1 • 2 prefer A more than C

  34. Naïve solution • Starting from a feasible solution. • Check if it is stable. • If yes, done! • If not, remove an unstable couple. • Is this work?

  35. A B C D E 1 2 3 4 5 2 1 2 1 5 E D A C D 5 2 3 3 3 A E D B B 1 3 5 2 2 D B B D C 3 4 4 4 1 B A C A E 4 5 1 5 4 C C E E A Naïve solution (2) • Does not work! • E.g. • A1 B3 C2 D4 E5 • A2B3 C1 D4 E5 • A3 B2 C1 D4 E5 • A3 B1 C2 D4 E5

  36. Solution • Let X be the first man. • X proposes to the best woman in the remaining on his list. (Initially, the first woman on his list!) • If α is not engaged • Pair up (X, α). Then, set X=next man and goto 1. • If α prefers X more than her fiancee Y, • Pair up (X, α). Then, set X=Y and goto 1. • Goto 1

More Related