1 / 46

A Toolbox for Online Algorithms Marcin Bieńkowski U niversity of Wroc ław phd open 2011

A Toolbox for Online Algorithms Marcin Bieńkowski U niversity of Wroc ław phd open 2011. A (short) story about an angry student who was (eventually) right. What you need are smart tools and not smart problems. This course: quite good tools for very simple problems. What’s in the box?.

wyman
Download Presentation

A Toolbox for Online Algorithms Marcin Bieńkowski U niversity of Wroc ław phd open 2011

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. A Toolbox for Online AlgorithmsMarcin BieńkowskiUniversity of Wrocławphd open 2011

  2. A (short) story • about an angry student • who was (eventually) right. A Toolbox for Online Algorithms

  3. What you need • are smart tools • and not smart problems • This course: • quite good tools • for very simple problems A Toolbox for Online Algorithms

  4. What’s in the box? • 10 minute crash course into online algorithms • Toolbox • Potential functions • Work functions • Linear programming • Classify and randomly select A Toolbox for Online Algorithms

  5. Online algorithms A Toolbox for Online Algorithms

  6. Online algorithms (1) Optimization problems e.g. set cover, independent set, facility location, TSP, … Approximate solutions for any instance we want Online problems = input is revealed gradually for any instance we want scarce computational resources scarce computational resources + we don’t know the future offline optimum A Toolbox for Online Algorithms

  7. Online algorithms (2) Deterministic algorithms for any instance we want Randomized algorithms for any instance we want We say that is -competitive A Toolbox for Online Algorithms

  8. Online algorithms example Ski Rental Problem (SRP) • Each day, in the morning, a skier may • either borrow skis for 1$ • or buy them for B$ • Input: in the evening a skier may break his/her leg • Objective: minimize the total cost A Toolbox for Online Algorithms

  9. Online algorithms example: SRP (1) 1-approximation algorithm is trivial: • is the day when skier breaks leg • If T · B, rent all the time • If T > B, buy at the first day For any instance , What about online solutions? A Toolbox for Online Algorithms

  10. Online algorithms example: SRP (2) Bad (but natural) strategies: • Skier always rents For the instance I where the leg is never broken and • Skier buys at the first day For the instance I where the leg is broken at the first day and A Toolbox for Online Algorithms

  11. Online algorithms example: SRP (3) Best online strategy:rent for B-1 days and buy at day B. Analysis: If T < B, then If T ¸ B, then and this strategy is -competitive This is the best deterministic online algorithm A Toolbox for Online Algorithms

  12. Online algorithms example: SRP (4) Best randomized online strategy: • Choose purchase day randomly: day k · B with probability proportional to • For large B the such strategy is -competitive But WHY this probability distribution?! • Make several observations and solve the system of equations… • … or wait till tomorrow till you see LP-based approach! A Toolbox for Online Algorithms

  13. World is online Many real life problems have online nature: • network protocols • routing • scheduling • exploration • cache organization • some data structures • financial decisions • and many more A Toolbox for Online Algorithms

  14. Toolbox Outline • Potential functions (PF) • Work functions • Linear programming • Classify and randomly select A Toolbox for Online Algorithms

  15. PF: a toy problem Problem: List reorganization (singly-linked) Input: sequence of the following operations insert(x): inserts x at the end of the list, cost L+1 search(x): finds x on the list, cost = position of x delete(x): deletes x from the list, cost as for search. Model: • After search or insert, ALG may move x towards the front of the list for free. • Afterwards, ALG may swap arbitrary adjacent elements paying 1. G H C F A D B J A Toolbox for Online Algorithms

  16. PF: a natural algorithm Algorithm Move To Front (MTF) After each insert(x) or search(x) operation, move x to the beginning of the list (for free). A Toolbox for Online Algorithms

  17. PF: costs (1) Typical online setting: the problem consists of many rounds. In round : • there is a request • the algorithm serves it and pays What is OPT doing? Casual approach: simulate both ALG and OPT (actually any other algorithm) on the same sequence and relate their costs. OPT? Do I look I care? Neither should you! Besides, computing OPT is NP-complete A Toolbox for Online Algorithms

  18. PF: costs (2) Typical online setting: the problem consists of many rounds. In round : • there is a request • the algorithm serves it and pays Casual approach: simulate both ALG and OPT (actually any other algorithm) on the same sequence and relate their costs. We want: Showing for all steps would be sufficient, but it is not the case! A Toolbox for Online Algorithms

  19. PF: introduction to potential We want: Solution: take a potential function , such that where Does it help? Also known as: How the heck can I guess the correct potential function? There is a rule of the thumb that USUALLY works. PROOF A Toolbox for Online Algorithms

  20. PF: states For many online problems, algorithms are in states and the cost depends on request and state only. State space: Rule of the thumb: Define as a constant times the cost of changing state from ALG to OPT. OPT ALG • Access(x) request • x is at the beginning of OPT • x is at the end of MTF Why does it help (in the bad case)? When is small and is large… … then ALG changes state towards OPT, decreasing the potential! MTF moves x to the beginning of the list A Toolbox for Online Algorithms

  21. PF: potential for MTF Algorithm Move To Front (MTF): After each insert(x) or search(x) operation, move x to the beginning of the list (for free). Potential function: Inversion: a pair (x,y) such that: • x is before y in MTF list • x is after y in OPT list Potential function = number of inversions Theorem: MTF is 2-competitive. PROOF A Toolbox for Online Algorithms

  22. Toolbox Outline • Potential functions • Work functions (WF) • Linear programming • Classify and randomly select A Toolbox for Online Algorithms

  23. WF: a toy problem (1) Problem: File migration • A graph, distances on the edges. • One indivisible file of size D (e.g., shared database) placed at one node. Note that d satisfies triangle inequality Input: sequence of requests (accesses to the database). In one step t: • ALG serve the request paying • ALG may move the file to any node paying A Toolbox for Online Algorithms

  24. WF: a toy problem (2) Let’s make it even simpler • Just two nodes connected by an edge of length 1 • File is initially at node a Elementary, dear Watson a b A Toolbox for Online Algorithms

  25. WF: randomization Our algorithm will be randomized! Behavioral definition: ``At the end of step t, move the file to some random node.’’ Distributional definition: ``At the end of step t, choose probability distribution over nodes, i.e., file is at v with probability .’’ Lemma: We may emulate distributional definition of ALG by behavioral one. The cost of changing from to is a b PROOF A Toolbox for Online Algorithms

  26. WF: work functions (1) After t requests, we may compute work function : The optimal cost of serving sequence up to step t and ending with file at node x. Computing the work function Can be computed efficiently by a simple dynamic programming • We assume that ALG may move the file before the input seq. • starting conditions: and A Toolbox for Online Algorithms

  27. WF: work functions (2) After t requests, we may compute work function : The optimal cost of serving sequence up to step t and ending with file at node x. Relation to OPT • It does not mean that OPT has the file at such minimizer! • However, we may assume that (the amortized) OPT cost in step t is A Toolbox for Online Algorithms

  28. WF: work function evolution Definegradient Observation: . Moreover, if g = D (or –D), then the algorithm should have the file at a (or at b) with probability 1. In this example, we assume D = 2 7 6 For such configuration, request at a does not change the work function (or OPT cost) 5 D 4 3 2 1 0 Good guidance! Let’s extrapolate it to intermediate values! A Toolbox for Online Algorithms

  29. WF: the algorithm Theorem Work function algorithm is -competitive. Gradient Recall: Work Function Algorithm At step t, choose distribution , such that 7 6 5 D 4 3 2 1 and 0 PROOF A Toolbox for Online Algorithms

  30. Thank you for your attention! • (and see you tomorrow) A Toolbox for Online Algorithms

  31. Toolbox Outline • Potential functions • Work functions • Linear programming (LP) • Classify and randomly select A Toolbox for Online Algorithms

  32. LP: a toy problem (1) Problem: set cover • n elements • family of m sets covering all elements is the cost of set In this example: 1 2 4 2 4 Input: sequence of elements to cover Output: at each step, output the subset of that covers allelements seen so far. Online factor: removing already chosen sets not possible! A Toolbox for Online Algorithms

  33. LP: a toy problem (2) Make the problem easier: FRACTIONAL set cover • n elements • family of m sets covering all elements is the cost of set 1 2 4 2 4 Input: sequence of elements to cover Output: at each step, output the function which covers each already seen element , i.e., Online factor: removing already chosen fractions of sets not possible! A Toolbox for Online Algorithms

  34. LP: offline solution (1) What about offline (fractional) solution after step k? • We have to cover elements Yes, you guessed right, use linear programming! minimize: subject to: (for all 1 · i · k) (for all ) 1 2 4 2 4 A Toolbox for Online Algorithms

  35. LP: offline solution (2) Do you recall? • For potential functions we did not care about OPT at all • For work functions, our construction relied heavily on OPT • Are we going to use it now? We may compute it! For the algorithm: NO. For the analysis: YES. A Toolbox for Online Algorithms

  36. LP: dual program ``If you have an LP, write a dual program and stare at it long enough’’ (quote from a random Stanford professor) • Primal program (Pk) • min.: • subject to: • (for all ) • (for all ) • Dual program (Dk) • max.: • subject to: • (for all ) • (for all ) Strong duality theorem: OPT(Pk) = OPT(Dk) A Toolbox for Online Algorithms

  37. LP: online solution (1) We generate our online feasible solutions to primal and dual programs. Online = monotonic for analysis only Feasible dual solution is sometimes hard to achieve… Observation: implies competitive ratio at most PROOF A Toolbox for Online Algorithms

  38. LP: online solution (2) We generate: • feasible solutions to primal program • solutions to dual program in which each constraint is violated at most by factor H. This one is feasible! Corollary: implies competitive ratio at most A Toolbox for Online Algorithms

  39. LP: the algorithm (1) • Primal program (Pk) • minimize: subject to: • (for all ) • (for all ) • Dual program (Dk) • maximize: subject to: • (for all ) • (for all ) Assume we have a solution for Pk-1 Pk contains one extra constraint Algorithm for step k: While : • For each containing let Observation 1:Generated primal solution is feasible Observation 2: Observation 3:Each constraint of the dual solution is violated at most by factor O(log m) PROOF TRIVIAL PROOF A Toolbox for Online Algorithms

  40. LP: the algorithm (2) Observation 1:Generated primal solution is feasible Observation 2: Observation 3:Each constraint of the dual solution is violated at most by factor O(log m) Corollary: ALG is O(2 log m) = O(log m)-competitive A Toolbox for Online Algorithms

  41. Toolbox Outline • Potential functions • Work functions • Linear programming • Classify and randomly select (CRS) A Toolbox for Online Algorithms

  42. CRS: a toy problem (1) Problem: Call admission • A graph, capacities of the edges. Way too complicated, dear Watson 3 1 2 2 2 3 2 3 2 1 Input: sequence of call requests: pairs (si, ti). For each call request: • decide whether to admit this call (INFINITE DURATION!) • if so choose a routing path for it not violating capacities Goal: maximize the number of accepted calls A Toolbox for Online Algorithms

  43. CRS: a toy problem (2) Problem: Call admission on line • A line graph of n nodes • all edges have capacity 1 Input: sequence of call requests: pairs (si, ti). For each call request: • decide whether to admit this call (INFINITE DURATION!) without violating capacities • if so choose a routing path Goal: maximize the number of accepted calls A Toolbox for Online Algorithms

  44. CRS: deterministic lower bound Lemma: Any deterministic algorithm on n-node line graph has the competitive ratio at least n-1. For a nontrivial competitive ratio, we need randomization! PROOF A Toolbox for Online Algorithms

  45. CRS: randomized solution (1) We assume that n = 2k. We divide all edges into k classes. 2-nd level call i-th level call = contains edges from , but not edges from Algorithm CRS: • Choose j randomly from • Accept greedily all calls from level j, and reject all other calls Theorem: CRS is (log n)-competitive. PROOF A Toolbox for Online Algorithms

  46. Thank you for your attention! A Toolbox for Online Algorithms

More Related