Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Online algorithms 叶德仕 2 Online & offline Traditional theoretical analysis is concerned with off-line problems where the complete.

Similar presentations


Presentation on theme: "1 Online algorithms 叶德仕 2 Online & offline Traditional theoretical analysis is concerned with off-line problems where the complete."— Presentation transcript:

1 1 Online algorithms 叶德仕 yedeshi@zju.edu.cn

2 2 Online & offline Traditional theoretical analysis is concerned with off-line problems where the complete input is given and we look for a time-efficient algorithm. In on-line problems the input is not known in advance but instead it is revealed during the operation of the algorithm.

3 3 Simple Example (Ski-Rental Problem) Karp92 Rental: $100/tour Purchase: $1,000 (can be used forever) Question: Buy or Rental? Inputs: 11111….. (1: new ski tour) You do not know how many more 1’s are coming. You have to decide buy or rental at each input 1.

4 4 Three Online Algorithms 1.Always rental. 2.But at the first 1. 3.Buy at the 10 th 1 (rental before then) Your action must be decided at each 1 (tour) uniquely by the algorithm

5 5 CR (Competitive Ratio) Competitive Analysis Rental:$100 Buy: $1,000 1. Always rental:

6 6 CR (Competitive Ratio) Competitive Analysis Rental:$100 Buy: $1,000 2. Buy at the beginning

7 7 CR (Competitive Ratio) Competitive Analysis Rental:$100 Buy: $1,000 3. Buy before the 10 th tour

8 8 General lower bound Thm: There is no online algorithm can achieve competitive ratio less than 2 -1/B. Proof. The adversary decides the duration T. 1) If buy before B - 1 , stops T. 2) If never buy, increase T 3) Once buy B between B – 1 and 2B, stops T.

9 9 Ski rental problem A skier must decide every day she goes skiing whether to rent or buy skis, unless or until she decides to buy them. The cost to rent skis for a day is 1 unit, while the cost to buy skis is B units. The skiier doesn’t know how many days she will go on skiing before she gets tired of it (or breaks a leg). Call this (unknown) number of days T.

10 10 Analysis Claim: The competitive ratio 2 − 1/B.

11 11 Randomized Ski rental Suppose that the cost B of buying skis is 3 units. Suppose that our skier buys the skis on Day 1,2,3 with probabilities p 1, p 2, p 3 respectively, where p 1 + p 2 + p 3 = 1. If the adversary decides that the skier will give up skiing after T days The expected total cost will be:

12 12 Randomized Ski rental The expected competitive ratio is 27/19 = 1.42105 Proof. Let p 1 = 4/19, p 2 = 6/19, p 3 = 9/19


Download ppt "1 Online algorithms 叶德仕 2 Online & offline Traditional theoretical analysis is concerned with off-line problems where the complete."

Similar presentations


Ads by Google