1 online algorithms 叶德仕 2 online offline traditional theoretical analysis is concerned with...
DESCRIPTION
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.TRANSCRIPT
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
Simple Example(Ski-Rental Problem) Karp92
Rental: $100/tourPurchase: $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
Three Online Algorithms
1. Always rental.2. But at the first 1.3. Buy at the 10th 1 (rental before
then)Your action must be decided at each1 (tour) uniquely by the algorithm
5
CR (Competitive Ratio)
1001000nr
Cost of algorithm Cost of optimal offline algorithm
AlgOpt
Alg r Opt c
r
Competitive Analysis
Rental:$100Buy: $1,000
1. Always rental:
6
CR (Competitive Ratio)
Cost of algorithm Cost of optimal offline algorithm
AlgOpt
Alg r Opt c
r
Competitive Analysis
Rental:$100Buy: $1,000
1000 10.0100
r 2. Buy at the beginning
7
CR (Competitive Ratio)
Cost of algorithm Cost of optimal offline algorithm
AlgOpt
rAlg Opt c
r
Competitive Analysis
Rental:$100Buy: $1,000
100 9 1000 1.91000
r 3. Buy before
the 10th tour
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 T3) Once buy B between B – 1 and 2B, stops T.
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
Analysis
Claim: The competitive ratio 2 − 1/B.
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 p1, p2, p3 respectively, where p1 + p2 + p3 = 1. If the adversary decides that the skier will give up skiing after T days The expected total cost will be:
12
Randomized Ski rental
The expected competitive ratio is 27/19 = 1.42105Proof. Let p1 = 4/19, p2 = 6/19, p3 = 9/19