Ski rental problem

(Learn how and when to remove this message)

In computer science, the ski rental problem is a name given to a class of problems in which there is a choice between continuing to pay a repeating cost or paying a one-time cost which eliminates or reduces the repeating cost.[1]

The problem

Many online problems have a sub-problem called the rent-or-buy problem. Given an expensive up front cost, or a less expensive repeating cost, with no knowledge of how the future will play out, at what point is it better to pay the up front cost to avoid a continued repeating cost?

Consider a person who decides to go skiing, but for an undecided number of days. Renting skis costs $1 per day, whereas buying a pair of skis costs $10. If the person knows in advance how many days they want to ski, then the breakeven point is 10 days. Fewer than 10 days, renting is preferable, whereas with more than 10 days, buying is preferable. However, with no advance knowledge of how long one will be skiing, the breakeven point is unclear. A good algorithm will minimize the ratio of the cost when the number of days is known in advance to the cost when the number of days is not known in advance.[2] Ski rental[3][4] is one example of this class of problem.

The break-even algorithm

The break-even algorithm instructs one to rent for 9 days and buy skis on the morning of day 10 if one is still up for skiing.[5] If one has to stop skiing during the first 9 days, it costs the same as what one would pay if one had known the number of days one would go skiing. If one has to stop skiing after day 10, one's cost is $19 which is 90% more than what one would pay if one had known the number of days one would go skiing in advance. This is the worst case for the break-even algorithm.

The break-even algorithm is known to be the best deterministic algorithm for this problem.

The randomized algorithm

A person can flip a coin. If it comes up heads, she buys skis on day eight; otherwise, she buys skis on day 10. This is an instance of a randomized algorithm. The expected cost is at most 80% more than what the person would pay if she had known the number of days she would go skiing, regardless of how many days she skis. In particular, if the person skis for 10 days, her expected cost is 1/2 [7 +10] + 1/2 [9+10] = 18 dollars, only 80% excess instead of 90%.

A randomized algorithm can be understood as a composition of different algorithms, each one which occurs with a given probability. We define the expected competitive ratio on a given instance i as:

E i = j P ( A L G j ) A L G j ( i ) {\displaystyle E_{i}=\sum _{j}P(ALG_{j})\cdot ALG_{j}(i)} , where A L G j ( i ) {\displaystyle ALG_{j}(i)} is the competitive ratio for instance i, given A L G j {\displaystyle ALG_{j}} .

Consequently, the competitive ratio of a randomized algorithm is given by the worst value of E i {\displaystyle E_{i}} over all given instances. In the case of the coin flipping ski-rental, we note that the randomized algorithm has 2 possible branches: If the coin comes up heads, we buy on day 8, otherwise we buy on day 10. We may call the branches A L G h e a d s {\displaystyle ALG_{heads}} and A L G t a i l s {\displaystyle ALG_{tails}} , respectively. E i = P ( A L G h e a d s ) A L G h e a d s ( i ) + P ( A L G t a i l s ) A L G t a i l s ( i ) = 1 2 1 + 1 2 1 = 1 {\displaystyle E_{i}=P(ALG_{heads})\cdot ALG_{heads}(i)+P(ALG_{tails})\cdot ALG_{tails}(i)={\frac {1}{2}}\cdot 1+{\frac {1}{2}}\cdot 1=1} , for i < 8 {\displaystyle i<8} .

E 8 = P ( A L G h e a d s ) A L G h e a d s ( 8 ) + P ( A L G t a i l s ) A L G t a i l s ( 8 ) = 1 2 17 8 + 1 2 1 = 1.5625 {\displaystyle E_{8}=P(ALG_{heads})\cdot ALG_{heads}(8)+P(ALG_{tails})\cdot ALG_{tails}(8)={\frac {1}{2}}\cdot {\frac {17}{8}}+{\frac {1}{2}}\cdot 1=1.5625} ,

E 9 = P ( A L G h e a d s ) A L G h e a d s ( 9 ) + P ( A L G t a i l s ) A L G t a i l s ( 9 ) = 1 2 17 9 + 1 2 1 = 1.444444 {\displaystyle E_{9}=P(ALG_{heads})\cdot ALG_{heads}(9)+P(ALG_{tails})\cdot ALG_{tails}(9)={\frac {1}{2}}\cdot {\frac {17}{9}}+{\frac {1}{2}}\cdot 1=1.444444} , and

E i = P ( A L G h e a d s ) A L G h e a d s ( i ) + P ( A L G t a i l s ) A L G t a i l s ( i ) = 1 2 17 10 + 1 2 19 10 = 1.8 {\displaystyle E_{i}=P(ALG_{heads})\cdot ALG_{heads}(i)+P(ALG_{tails})\cdot ALG_{tails}(i)={\frac {1}{2}}\cdot {\frac {17}{10}}+{\frac {1}{2}}\cdot {\frac {19}{10}}=1.8} , for i 10 {\displaystyle i\geq 10} .

Therefore, the competitive ratio of the randomized ski-rental coin flipping algorithm is 1.8.

The best randomized algorithm against an oblivious adversary is to choose some day i at random according to the following distribution p, rent for i-1 days and buy skis on the morning of day i if one are still up for skiing. Karlin et al.[3] first presented this algorithm with distribution p i = { ( b 1 b ) b i 1 b ( 1 ( 1 ( 1 / b ) ) b ) i b 0 i > b , {\displaystyle p_{i}=\left\{{\begin{array}{ll}({\frac {b-1}{b}})^{b-i}{\frac {1}{b(1-(1-(1/b))^{b})}}&i\leq b\\0&i>b\end{array}}\right.,} where buying skis costs $ b {\displaystyle b} and renting costs $1. Its expected cost is at most e/(e-1) {\displaystyle \approx } 1.58 times what one would pay if one had known the number of days one would go skiing. No randomized algorithm can do better.

Applications

See also

References

  1. ^ Blum, Avrim. "cos 521: Advanced Algorithm Design Lecture 24: Online Algorithms" (PDF). Computer Science Princeton University. Princeton University. Retrieved 2022-07-16.
  2. ^ a b Steven S. Seiden. A guessing game and randomized online algorithms. Annual ACM Symposium on Theory of Computing, 2000. http://portal.acm.org/citation.cfm?id=335385
  3. ^ a b c A. R. Karlin, M. S. Manasse, L. A. McGeoch, and S. Owicki. Competitive randomized algorithms for non-uniform problems. In Proceedings of the First Annual ACM-SIAM Symposium on Discrete Algorithms, San Francisco, CA, 22–24 January 1990, pp. 301-309. Also in Algorithmica, 11(6): 542-571, 1994. http://courses.csail.mit.edu/6.895/fall03/handouts/papers/karlin.pdf
  4. ^ Claire Mathieu. Brown University. Lecture note: http://www.cs.brown.edu/~claire/Talks/skirental.pdf
  5. ^ A. R. Karlin, M. Manasse, L. Rudolph and D. Sleator. Competitive snoopy caching. Algorithmica, 3(1): 79-119, 1988
  6. ^ Dooly, Daniel R.; Goldman, Sally A.; Scott, Stephen D. (1998). "TCP Dynamic Acknowledgment Delay: Theory and Practice (Extended Abstract)". In Vitter, Jeffrey Scott (ed.). Proceedings of the Thirtieth Annual ACM Symposium on the Theory of Computing, Dallas, Texas, USA, May 23-26, 1998. {ACM}. pp. 389–398. doi:10.1145/276698.276792.
  7. ^ Anna R. Karlin and Claire Kenyon and Dana Randall. Dynamic TCP acknowledgement and other stories about e/(e-1). Thirty-Third Annual ACM Symposium on Theory of Computing (STOC), 2001. Algorithmica. http://www.cs.brown.edu/people/claire/Publis/ACKpaper.ps