1 / 36

Instructor: Shengyu Zhang

CSC3160: Design and Analysis of Algorithms. Week 13: Online Algorithms. Instructor: Shengyu Zhang. Offline algorithms. Almost all algorithms we encountered in this course assume that the entire input is given all at once. An exception: Secretary problem. The input is given gradually.

zytka
Download Presentation

Instructor: Shengyu Zhang

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSC3160: Design and Analysis of Algorithms Week 13: Online Algorithms Instructor: Shengyu Zhang

  2. Offline algorithms • Almost all algorithms we encountered in this course assume that the entire input is given all at once. • An exception: Secretary problem. • The input is given gradually. • We need to respond to each candidate in time. • We care about our performance compared to the best one in hindsight.

  3. Online algorithms • The input is revealed in parts. • An online algorithm needs to respond to each part (of the input) upon its arrival. • The responding actions cannot be canceled/revoked later. • We care about the competitive ratio, which compares the performance of an online algorithm to that of the best offline algorithm. • Offline: the entire input is given beforehand.

  4. Ski rental • A person goes to a ski resort for a long vacation. • Two choices everyday: • Rent a ski: $1 per day. • Buy a ski: $ once. • An unknown factor: the number of remaining days for ski in this season. • When snow melts, the ski resort closes.

  5. Offline algorithm • If we had known , then it’s easy. • If , then we should rent everyday. The total cost is . • If , then we should buy on day 1. The total cost is . • In any case, the cost is . • Question: Without knowing , how to make decision every day?

  6. Deterministic algorithm • There is a simple deterministic algorithm s.t. our cost is at most . • We then say that the algorithm has a competitive ratio of 2. • Algorithm:On each day , rent.On day , buy. • If , then our cost is , which is optimal. • If , then our cost is

  7. Randomized algorithm • It turns out to exist a randomized algorithm with a competitive ratio of • The algorithm uses integer programming and linear programming.

  8. Integer programming • There is an integer programming to solve the offline version of the ski-rental problem. • We introduce some variables .

  9. Solution • It’s not hard to see that the optimal solution to the IP iswhich is the same as the previous optimal solution for the offline problem. • So the IP does characterize the offline problem.

  10. Relaxation • Relax it to LP.

  11. The relaxation doesn’t lose anything • It is easily observed that the LP has the following optimal solution • This is the same as the optimal solution to the IP. • So the LP relaxation doesn’t lose anything.

  12. Dual LP Primal Dual

  13. Consider the following algorithm, which defines variables . • for each new if, where

  14. Property 1 • Theorem. The above algorithm produces a feasible solution to Primal LP and a feasible solution to Dual LP. • Feasible to Primal LP: • always holds. • always holds since we assign only if . • when , and when . So always holds.

  15. Property 1 • Theorem. The above algorithm produces a feasible solution to Primal LP and a feasible solution to Dual LP. • Feasible to Dual LP: • . • To show , we need to show that the algorithm stops after iterations.

  16. Consider the increment of in iteration . • , . • In general, it’s not hard to prove that • So after iterations, increases to . • So only the first dual variables , resulting in . Thus is dual feasible.

  17. Property 2 • Actually, we will show stronger: in every iteration, the increment of primal obj value is at most that of dual. • The increment of dual is always .

  18. The increment of primal is . • is the at the beginning of iteration • Recall update: . So . • Recall update: . So . • So the increment of primal obj value is at most that of dual.

  19. Turning into an online algorithm • The above algorithm just gives a . • Now we give an online algorithm based on it. • Pick uniformly at random. • Suppose is the first day that , then rent in all days before and buy on day . … rent buy

  20. Expected cost • Theorem. • There are two costs. One is buying cost, and the other is renting cost. • Obs.. • So, the first term of the obj function of Primal. • .

  21. So , the second term of the obj function of Primal. • , the objective function value. • So // above// Property 2. // dual feasible

  22. So the online algorithm achieves a competitive ratio of . • Recall that , which is close to for large . • Thus the competitive ratio is , as claimed.

  23. Optimality: Both deterministic and randomized algorithms are optimal. • No better competitive ratio is possible. • Reference: The design of competitive online algorithms via a primal dual approach, NivBuchbinder and Joseph Naor, Foundations and Trends in Theoretical Computer Science, Vol. 3, pp. 93-263, 2007. • Next: Another learning algorithm

  24. Stock market • Simplification: Only consider up or down.

  25. Which expert to follow? • Each day, stock market goes up or down. • Each morning, “experts” predict the market. • How should we do? Whom to listen to? Or combine their advice in some way?

  26. Which expert to follow? • Each day, stock market goes up or down. • At the end of the day, we’ll see whether the market actually goes up or down. • We lose 1 if our prediction was wrong.

  27. After a year, we’ll see with hindsight that one expert is the best. • But, of course, we don’t know who in advance. • We’ll think “If we had followed his advice…” • Theorem: We have a method to perform close to the best expert! • We don’t assume anything about the experts. • They may not know what they are talking about. • They may even collaborate in any bad manner.

  28. Method and intuition • Algorithm: Randomized Weighted Majority • Use random choice: following expert with probability • If an expert predicts wrongly: punish him by decreasingthe probability of choosing him/her in next round. • If someone gives you wrong info, then you tend to trust him less in future.

  29. Randomized Weighted Majority : weight of expert at time : probability of choosing expert at time • for each • for each , : • if expert was wrong at step else • Choose with prob. , and follow expert ’s advice. Decrease your weight! Probability is proportional to weight

  30. Example (n=5, T=6, ε = 1/4) • Numbers: weight • Arrows: predications. Red: wrong.

  31. : expected loss of our algorithm • : loss of the best expert • Theorem. For , the loss on any sequence of in time satisfies .

  32. Proof • Key: Consider the total weight at time . • Fact: Any time our algorithm has significant expected loss, the total weight drops substantially. • : if expert is wrong at step (and otherwise) • Let . Two meanings: • The fraction of the weight on wrong experts • The expected loss of our algorithm at step • Note:

  33. Last slide: • So • On the other hand, • So • Note: is the loss of the best expert.

  34. Note that since , • Take log: • is the loss of our algorithm. • Rearranging the inequality and using we get the inequality in the theorem. .

  35. Extensions • The case that is unknown. • The case that loss is in instead of • References: • The Multiplicative Weights Update Method: a Meta-Algorithm and Applications, Sanjeev Arora, EladHazan, and SatyenKale, Theory of Computing, Volume 8, Article 6 pp. 121-164, 2012. • Chapter 4 of Algorithmic Game Theory, available at http://www.cs.cmu.edu/~avrim/Papers/regret-chapter.pdf

  36. Summary • Online algorithms: • The input is revealed in parts. • We need to respond to each part upon its arrival. • The responding actions cannot be revokedlater. • competitive ratio: performance of an online algorithm vs. performance of the best offline algorithm. • Primal-dual method. • Multiplicative weight update method.

More Related