Presentation is loading. Please wait.

Presentation is loading. Please wait.

JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys LauriDeli EdCheckout Matching the elements of 2 different sets occurs when for.

Similar presentations


Presentation on theme: "JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys LauriDeli EdCheckout Matching the elements of 2 different sets occurs when for."— Presentation transcript:

1 JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys LauriDeli EdCheckout Matching the elements of 2 different sets occurs when for example one tries to match up jobs with the people available. Certain people may be only able to do certain jobs. Matching Algorithm

2 We wish to find the matching which minimises the cost of the deliveries. Four supermarkets W, X, Y and Z are supplied by four warehouses A, B, C and D. The cost of supplying the supermarkets ( fuel, labour etc) is shown in the table below. Warehouse Supermarket

3 Consider how best to allocate the swimmers for a medley relay team given their times below We need to minimise the total time.

4 Matchings Example Freya buys some chocolates to share with her friends. There are six chocolates – raspberry rage (R), truffle tickle (T), nut nibble (N), strawberry supreme (S), walnut whirl (W) and marshmallow melt (M). Of her friends, Ann likes raspberry rage and marshmallow melt; Baz likes strawberry supreme; Carl likes nut nibble and marshmallow melt; Dee likes truffle tickle, nut nibble and walnut whirl; and Ellie likes strawberry supreme and marshmallow melt. Freya herself likes raspberry rage, truffle tickle and strawberry supreme. Can they each have a chocolate they like?

5 Matchings Bipartite graphs We can represent this situation using a bipartite graph. This is a graph with two distinct sets; the friends and the chocolates. The edges only go from a vertex in one set to a vertex in the other; in this case where the person likes that particular chocolate. Ana Baz Carl Dee Ellie Freya R. raspberry rage T. truffle tickle N. nut nibble S. strawberry supreme W. walnut whirl M. marshmallow melt Anna likes raspberry rage and marshmallow melt Baz likes strawberry supreme Carl likes nut nibble and marshmallow melt Dee likes truffle tickle, nut nibble and walnut whirl Ellie likes strawberry supreme and marshmallow melt Freya likes raspberry rage, truffle tickle and strawberry supreme

6 Initial Matching If we now pair people with particular chocolates they like in a one-to-one way (no two people to the same chocolate, no two chocolates to one person) then we have a matching. If a matching includes the same number of edges as vertices in each set (6 in this case) then it is called a complete matching. The diagram shows the matching A-R, B-S, C-N, D-T, E-M THIS MATCHING IS NOT COMPLETE If a matching includes the same number of edges as vertices in each set (6 in this case) then it is called a complete matching. The diagram shows the matching A-R, B-S, C-N, D-T, E-M THIS MATCHING IS NOT COMPLETE A B C D E F R. T. N. S. W. M.

7 Matchings Alternating paths If we have a matching and want to improve it we can do so by finding an alternating path. This is a path which (a) Starts on an unmatched vertex on the right hand side [W] (b) Consists of edges alternately not in and in the matching (c) Finishes on an unmatched vertex in the second set If we have a matching and want to improve it we can do so by finding an alternating path. This is a path which (a) Starts on an unmatched vertex on the right hand side [W] (b) Consists of edges alternately not in and in the matching (c) Finishes on an unmatched vertex in the second set Start with W join to W to D Now remove D-T T now has no match so include T-F F was previously unmatched, so we have now have breakthrough. The alternating path is W-D-T-F Every vertex is now matched so we have a complete matching Start with W join to W to D Now remove D-T T now has no match so include T-F F was previously unmatched, so we have now have breakthrough. The alternating path is W-D-T-F Every vertex is now matched so we have a complete matching A B C D E F R. T. N. S. W. M.

8 Matchings Alternating paths The solution consists of 1. Edges in the alternating path but not in the initial matching; D-W and F-T 2. Edges in the initial matching but not in the alternating path; A-R, B-S, C-N and E-M The solution consists of 1. Edges in the alternating path but not in the initial matching; D-W and F-T 2. Edges in the initial matching but not in the alternating path; A-R, B-S, C-N and E-M Interpretation: Ann has raspberry rage Baz has strawberry supreme Carl had nut nibble Dee has walnut whirl Ellie has marshmallow melt Freya has truffle tickle. Interpretation: Ann has raspberry rage Baz has strawberry supreme Carl had nut nibble Dee has walnut whirl Ellie has marshmallow melt Freya has truffle tickle. A B C D E F R. T. N. S. W. M.

9 The next problem is matching people with jobs. We are not concerned with minimising costs or times or maximising profits. All we need is to match people with jobs so that as many jobs as possible are completed

10 JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys LauriDeli EdCheckout Matching Algorithm Jobs that past students were capable of at a supermarket

11 JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys Lauri Deli EdCheckout Method of Solving:Draw a bipartite graph and start with any matching– shown in black lines. All the people/jobs won’t be included as it will not be a maximal matching. Label all the left vertices (people) which don’t belong to the matching M with a * * Lauri cannot do shelf stacking so they are not included in the matching. The blue lines indicate the jobs that can be done by each person

12 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly * labelled left vertex (Lauri) and label a right vertex joined by an arc not in the matching M to the * (Blue arcs). * Lauri to Checkout 1 Step

13 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly labelled right vertex and label a left vertex joined by an arc in the matching M. Black arcs * Checkout back to Ed 2 Step

14 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Now repeat steps 2 and 3 until no more labelling is possible i.e Blue arcs * Ed forward to Shelves 3 Step

15 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout As Shelves is not in the original matching Breakthrough has been achieved. * 4 Step The alternating path Shelves –EdCheckout–Lauri + the original matchings Charlotte–Manager Produce–Jessica Deli–Jason Trolleys–Robert Use the solid red + the black arcs

16 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly * labelled left vertex (Lauri) and label all the right vertices joined by an arc not in the matching M to the * (Blue arcs). * i.e Lauri to Produce 1 Step Alternative Matching 2

17 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly labelled right vertex and label a left vertex joined by an arc in the matching M. Black arcs * i.e Produce back to Jessica 2 Step

18 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Now repeat steps 2 and 3 until no more labelling is possible i.e Blue arcs * Jessica forward to Checkout 3 Step

19 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Black arcs * Checkout back to Ed 3 Step

20 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Blue arcs * Ed forward to Shelves 3 Step

21 As Shelves is not in the original matching Breakthrough has been achieved. 4 Step The alternating path Shelves–Ed Checkout–Jessica Produce–Laurie + the original matchings Charlotte–Manager Deli–Jason Trolleys–Robert JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Use the solid red + the black arcs

22 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly * labelled left vertex (Lauri) and label a right vertx joined by an arc not in the matching M to the * (Blue arcs). * i.e Lauri to Produce 1 Step Alternative Matching 3

23 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Choose a newly labelled right vertex and label a left vertex joined by an arc in the matching M. Black arcs * i.e Produce back to Jessica 2 Step

24 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout Now repeat steps 2 and 3 until no more labelling is possible i.e Blue arcs * Jessica forward to Checkout 3 Step

25 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Checkout back to Ed 4 Step Black arcs

26 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Ed forward to Trolleys 4 Step Blue arcs

27 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Trolleys back to Robert 4 Step Black arcs

28 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * Robert forward to Shelves 4 Step Blue arcs

29 JessicaManager JasonProduce RobertShelves CharlotteTrolleys LauriDeli EdCheckout * As Shelves is not in the original matching Breakthrough has been achieved. 4 Step The alternating path Shelves–Robert Trolleys–Ed Checkout–Jessica Produce–Laurie + the original matchings Charlotte–Manager Deli–Jason Use the solid red + the black arcs

30

31

32

33

34

35

36 Past Exam Qu.s June 2005

37 Past Exam Qu.s Jan 2004


Download ppt "JessicaManager JasonProduce section RobertShelf Stacking CharlotteTrolleys LauriDeli EdCheckout Matching the elements of 2 different sets occurs when for."

Similar presentations


Ads by Google