1 / 47

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.

rtheriot
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. Ağırlıksız ikili eşleştirme

  8. Tanımlar Eşleştirme Serbest köşe

  9. Tanımlar • Maksimum eşleştirme: en fazla kiriş sayısına sahip eşleştirme

  10. Tanım • Maksimum eşleştirme tek türlü olmayabilir.

  11. Değişmeli Yol • Değişmeli yol eşleştirilmiş ve eşleştirilmemiş kirişlerin değişmeli yoludur. a c d e b f h i j g d-h-e: değişmeli yoldur a-f-b-h-d-i: serbest köşeden serbest köşeye değişmeli yoldur f-b-h-e: değişmeli yol değil e-j: serbest köşeden serbest köşeye değişmeli yoldur

  12. Ana fikir • “Çevir”işlemi:serbest köşeden serbest köşeye olan değişmeli yolda eşleştirilmiş kirişleri eşleştirilmemiş ve tersine yap • Not: Çevir işleminden sonra eşleştirilmiş kiriş sayısı 1 artar 

  13. Ana fikir • Herhangi bir eşleştirmeden başla • Serbest köşeden serbest köşeye değişmeli yol bulunduğu sürece • Bu tür bir P yolunu bul • P yolunda çevir yap

  14. 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.

  15. Labelling Algorithm • Start with arbitrary matching

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

  17. Labelling Algorithm • Run BFS

  18. Labelling Algorithm • Alternate unmatched/matched edges

  19. Labelling Algorithm • Until a augmenting path is found

  20. Augmenting Tree

  21. Flip!

  22. Repeat • Pick another free vertex in the bottom

  23. Repeat • Run BFS

  24. Repeat • Flip

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

  26. 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.

  27. 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|)

  28. 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|)

  29. Stable Marriage Problem

  30. 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.

  31. 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

  32. 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?

  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 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

  34. 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

  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 Example A B C D E 2 1 2 1 5 5 2 3 3 3 1 3 5 2 4

  36. Time analysis • If there are N men and N women, • O(N2) time

More Related