Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Online algorithms Typically when we solve problems and design algorithms we assume that we know all the data a priori. However in many practical situations.

Similar presentations


Presentation on theme: "1 Online algorithms Typically when we solve problems and design algorithms we assume that we know all the data a priori. However in many practical situations."— Presentation transcript:

1

2 1 Online algorithms Typically when we solve problems and design algorithms we assume that we know all the data a priori. However in many practical situations this may not be true and rather than have the input in advance it may be presented to us as we proceed. Input is revealed to the algorithm incrementally Output is produced incrementally Some output must be produced before the entire input is known to the algorithm Decision making under partial information Unknown information: the future

3 2 Applications Resource Allocation Scheduling Memory Management Robot Motion Planning Exploring an unknown terrain Finding a destination Computational Finance

4 3 How to evaluate the performance of online algorithms One way to analyze such algorithms is to assume that the input is given according to a certain probability distribution and compute the expected behavior of the algorithm based on this distribution. However we wish to avoid making assumptions about input distributions. The analytic machinery we present will not demand that the inputs come from some known distribution but instead will compare the performance of the online algorithm with that of the best online algorithm.

5 4 Methods of Analysis Probabilistic Analysis Assume a distribution generating the input Find an algorithm which minimizes the expected cost of the algorithm. Need to accurately determine the true distribution generating the request sequence Probability distribution generating input sequence is “non-adaptive” (i.e. determined in advance and is independent of the choices made by the algorithm).

6 5 Methods of Analysis Worst Case Analysis For any input, the cost of our online algorithm is never worse than “R” times the cost of the optimal offline algorithm. Definition An online algorithm A is R-competitive if for all input sequences I, A(I) ≤ROPT(I), where A(I) is the cost of the online strategy A for I and OPT(I) is the cost of the optimal offline algorithm for I. In many cases the definition of competitiveness is slightly relaxed by imposing that A(I) ≤ROPT(I)+c for some constant c independent of I.

7 6 Seen as a game between the online algorithm and an “adversary”. Adversary tries to devise each new piece of the input which will cause the algorithm to incur a high cost. Algorithm tries to minimize cost. Often results are very pessimistic.

8 7 Ski Rental Problem you are a skier and each day need to either rent skis for $1 or buy a pair of skis for $T which will last for the rest of the season. Unfortunately you do not know when the ski season will end. If you knew a priori the length of the season (this is the online case) say L then it is obvious that you should rent if L<T and buy if L≥T. On the other hand, an online strategy for this problem would first fix an integer k and then rent for k days and buy on day k+1 if it has the opportunity.

9 8 One strategy is to buy on the first day. This strategy is T-competitive and the worst input sequence is obtained when L=1. Another online strategy is to rent for the first T-1 days and then buy. If L<T the cost of the online and optimal offline strategy is the same. If L≥T the cost of the online strategy is 2T-1 and the cost of the optimal offline strategy is T. Hence this algorithm is (2-1/T)- competitive and it is fairly easy to show that it is the optimal online algorithm.

10 9 The Online Transportation Problem 5 miles 2 miles 3 miles 4 miles 2 miles

11 10 The Online Transportation Problem Given: a set of hospitals, each with a different sized ambulance fleet emergency sites that arise in unpredictable locations over time, each in immediate need of an ambulance Return: an assignment of ambulances to emergencies that minimizes the total distance traveled by all the ambulances

12 11 Why Greedy can be Bad Consider A, a large hospital with a dozen available ambulances, and B, a small hospital with only 2 ambulances. Imagine an emergency breaks out between A and B, but a bit closer to B. A B 10 miles 9 miles

13 12 Why Greedy can be Bad Since B is closer, we dispatch an ambulance from B. But what if two emergencies then break out on the other side of B from A? This solution costs 31 miles! A B 9 miles A 20 miles 2 miles

14 13 Why Greedy can be Bad If instead we chose hospital A for the first emergency, then used the ambulances at hospital B for the second and third......the distance traveled is much less! A B 2 miles A 10 miles 2 miles

15 14 Challenges Faced Intuition: A good algorithm must find a balance between distance of an emergency from the hospitals and the resources remaining at each hospital. Negative Results: Such balancing is not possible. The competitive ratio of every deterministic online algorithm is bad (linear in the number of hospitals). Random online algorithm.

16 15 Homework Exercises:Page 157 1,2


Download ppt "1 Online algorithms Typically when we solve problems and design algorithms we assume that we know all the data a priori. However in many practical situations."

Similar presentations


Ads by Google