CSE 101 Algorithm Design and Analysis Sanjoy Dasgupta, Russell Impagliazzo, and Ragesh Jaiswal (with input from Miles Jones) Lecture 15: Another Scheduling Problem EVENT SCHEDULING WITH MULTIPLE ROOMS Suppose you have a conference to plan with π events and you have an unlimited supply of rooms. How can you assign events to rooms in such a way as to minimize the number of rooms? Brute Force: Β‘ Certainly you wonβt need more than π rooms. Β‘ So how many ways can you assign π events to π rooms?
EVENT SCHEDULING WITH MULTIPLE ROOMS Suppose you have a conference to plan with π events and you have an unlimited supply of rooms. How can you assign events to rooms in such a way as to minimize the number of rooms? Ideas for a greedy algorithm? EVENT SCHEDULING 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
EVENT SCHEDULING WITH MULTIPLE ROOMS Suppose you have a conference to plan with π events and you have an unlimited supply of rooms. How can you assign events to rooms in such a way as to minimize the number of rooms? Β‘ Greedy choice: Β§ Number each room from 1 to π . Β§ Sort the events by earliest start time. Β§ Put the first event in room 1. Β§ For events 2β¦ π , put each event in the smallest numbered room that is available. TECHNIQUES TO PROVE OPTIMALITY Some general methods to prove optimality: Β§ Modify-the-solution, aka Exchange: most general Β§ Greedy-stays-ahead: often the most intuitive Β§ Greedy-achieves-the-bound: also used in approximation, LP, network flow Β§ Unique-local-optimum: dangerously close to a common fallacy Which one to use is up to you.
ACHIEVES-THE-BOUND 1. Logically determine a bound on the value of the solution that must be satisfied by any valid answer. 2. Then show that the greedy strategy achieves this bound and therefore is optimal. ACHIEVES-THE-BOUND Β‘ Let π’ be any time during the conference. Β‘ Let πΆ(π’) be the set of events taking place at time π’ . Bounding Lemma : Any valid schedule requires at least |πΆ π’ | rooms. Proof: There are |πΆ π’ | events taking place at time π’ . They all need to be in different rooms. So we need at least |πΆ π’ | rooms. Β‘ Let π = πππ¦ |πΆ π’ | over all t. Β‘ Then π is a lower bound on the number of rooms needed.
EVENT SCHEDULING 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 ACHIEVES-THE-BOUND Achieves-the-Bound Lemma : Let π be the number of rooms picked by the greedy algorithm. Then at some point π’ , πΆ π’ β₯ π . In other words there are at least π events happening at time π’ . Proof: Let π’ be the starting time of the first event to be scheduled in room π. Then by the greedy choice, room π was the least number room available at that time. This means at time π’ , there was an event happening in rooms room 1, room 2, β¦, room π β 1 . And plus an event happening in room π Therefore πΆ π’ β₯ π .
CONCLUSION: GREEDY IS OPTIMAL Β‘ Let π»π be the greedy solution. Β‘ Let ππ be any other schedule. Β‘ Let L = max |B(t)| over all t. Β‘ By the Bounding lemma, Cost( ππ ) β₯ L. Β‘ By the achieves-the-bound lemma, Cost( π»π ) = |B(t)| β€ L for some t. Β‘ Putting the two together, Cost( π»π ) β€ Cost( ππ ). ACHIEVES-THE-BOUND The way it works: Β‘ Argue that when the greedy solution reaches its peak cost , it reveals a bound . Β‘ Then show this bound is also a lower bound on the cost of any other solution. Β‘ So we are showing : Cost( π»π ) β€ Bound β€ Cost ( ππ ) This is a proof technique that does not work in all cases.
Recommend
More recommend