1 / 112

Online Algorithms

Rahul Singhal , Nimantha Baranasuriya, Karthik Yadati , Girisha De Silva, Zhou Ziling. Online Algorithms. Today’s Outline. 1. 3. 2. Introduction. k -Server Problem. Hiring Problem. 1. Introduction to Online Algorithms. Online Algorithms.

piper
Download Presentation

Online Algorithms

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. Rahul Singhal, Nimantha Baranasuriya, KarthikYadati, Girisha De Silva, Zhou Ziling Online Algorithms

  2. Today’s Outline 1 3 2 Introduction k-Server Problem Hiring Problem

  3. 1 Introduction to Online Algorithms

  4. Online Algorithms • Work without full knowledge of the future • Deal with a sequence of events • Future events are unknown to the algorithm • The algorithm has to deal with one event at each time. • The next event happens only after the algorithm is done dealing with the previous event A Service Goal : Minimize total cost incurred in serving

  5. The Paging/Caching Problem Page Fault: Requested page is not in fast memory A A Fast Memory Service Access to a page in the memory system Slow Memory = 1, 6, 4, 1, 4, 7, 6, 1, 3, … Request sequence of pages Goal: Minimize the total cost incurred in serving Goal: Minimize the number of page faults

  6. Online vs. Offline • We compare the behavior of the online algorithm to an optimal offline algorithm,OPT, which is familiar with the sequence • The offline algorithm knows the exact properties of all the events in the sequence

  7. Absolute Competitive Ratio • We measure the performance of an online algorithm by the competitive ratio • This is the ratio between what the online algorithms pays to what the optimal offline algorithm pays

  8. Absolute Competitive Ratio • Formally: let be the cost of the online algorithm on the sequence . Let be the optimal offline cost on Then the competitive ratio is:

  9. Types of Online Algorithms • Deterministic • Generating same output for same input • Examples • LIFO, FIFO paging … etc. • Randomization • In addition to the input, the algorithm takes a source of random numbers and makes random choices during execution • Behavior can vary even on a fixed input • Example • Randomized paging algorithm ALGORITHM ALGORITHM OUTPUT INPUT OUTPUT INPUT RANDOM NUMBERS

  10. Adversaries (Bad Guy) • Competitiveness is defined with respect to an adversary • Role of an adversary • It constructs • It also serves • Adversary knows the description of the deterministic online algorithm • What does the adversary know about the random choices made by the randomized online algorithm?

  11. Oblivious Adversary • One who must construct the request sequence in advance (based only on the description of the online algorithm but before any moves are made) A Service ADV

  12. Adaptive Online Adversary • One who makes the next request based on the algorithm's answers to previous events A Service ADV

  13. The Ski Rental Problem • Buying costs $D (never pay again) • Renting costs $1 per day Problem: • Days of skiing(d) is not known in advance • Adversary breaks his knee  no more skiing Goal: Minimize the total cost

  14. Optimal Offline Ski Rental Algorithm OPT : if d < D, then rent if d >= D, then buy on day 1 • Analysis • COPT= min(d, D)

  15. Deterministic Ski Rental online Algorithm Rent until day K Buy skis on day K • Analysis • Adversary breaks legs at day K (d = K) to maximize the cost • Optimize value of K (to minimize the cost) • CALG = K – 1 + D • COPT = min(d, D) = min(K, D) • CR = min ((K -1 + D )/K , (K -1 + D )/D ) • We get K = D ( Buy on day D)

  16. Randomized Ski Rental Algorithm Flip a coin (on day 0) heads: buy on D/2 (p = ½) tails: buy on D (p = ½) Adversary breaks legs on day d • Analysis: • Case 1: d < D/2 • COPT = d (Rent d days) • CALG= d (Rent d days) • CR = d/d = 1

  17. Randomized Ski Rental Algorithm Flip a coin (on day 0) heads: buy on D/2 (p = ½) tails: buy on D (p = ½) Adversary breaks legs on day d • Analysis: • Case 2: d = D/2 • COPT= d (= D/2) • CALG = ½(D/2) + ½(D + D/2) = D • CR = D/(D/2) = 2 Buy on D Buy on D/2

  18. Randomized Ski Rental Algorithm Flip a coin (on day 0) heads: buy on D/2 (p = ½) tails: buy on D (p = ½) Adversary breaks legs on day d • Analysis: • Case 3: D/2 < d < D • COPT = d • CALG = ½(d) + ½(D + D/2) = d/2 + 3D/4 • CR = (d/2 + 3D/4)/d Buy on D Buy on D/2

  19. Randomized Ski Rental Algorithm Flip a coin (on day 0) heads: buy on D/2 (p = ½) tails: buy on D (p = ½) Adversary breaks legs on day d • Analysis: • Case 4: d >= D • COPT= D • CALG = ½(D + D) + ½(D/2 + D) = (1.75)D • CR = (1.75)D/D = 1.75 Buy on D Buy on D/2

  20. Randomized Ski Rental Algorithm (Generalized) Flip a biased coin (on day 0) heads: buy on D/2 (p) tails: buy on D(1 - p) Adversary breaks legs on day d • Analysis: • Case 1: d < D/2 • COPT = d (Rent d days) • CALG = d (Rent d days) • CR = d/d = 1

  21. Randomized Ski Rental Algorithm (Generalized) Flip a biased coin (on day 0) heads: buy on D/2 (p) tails: buy on D(1 - p) Adversary breaks legs on day d • Analysis: • Case 2: d = D/2 • COPT = d = D/2 • CALG = p(D + D/2) + (1 – p)D/2 • CR = 2p + 1 Buy on D Buy on D/2

  22. Randomized Ski Rental Algorithm (Generalized) Flip a biased coin (on day 0) heads: buy on D/2 (p) tails: buy on D(1 - p) Adversary breaks legs on day d • Analysis: • Case 3: d = D • COPT = d = D • CALG= p(D + D/2) + (1 – p)2D • CR = 2 – p/2 Buy on D Buy on D/2

  23. Randomized Ski Rental Algorithm (Generalized) Flip a biased coin (on day 0) heads: buy on D/2 (p) tails: buy on D(1 - p) Adversary breaks legs on day d • Optimize: • 2p + 1 = 2 – p/2 • p = 2/5 = 0.4 • CR = 1.8

  24. 2 Hiring Problem

  25. Hiring Problem Decision making under Uncertainty

  26. The Problem • Hire an employee • Process: • Interview one at a time • Select or reject • Goal: Hire the best candidate

  27. The Offline Solution • Has knowledge of all candidates • Just hire the best candidate • Pr(Success) = 1

  28. The Online Algorithm • Interview first t candidates • g = best candidate seen so far • Interview remaining n-t candidates • Hire first candidate better than g

  29. Adversary Effect t 4 3 1 2

  30. Adversary Effect t 4 3 1 2

  31. The Online Algorithm • Order candidates by random permutation • Interview first t candidates • g = best candidate seen so far • Interview remaining n-t candidates • Hire first candidate better than g

  32. Algorithm Instances t 4 3 1 2

  33. Algorithm Instances t 4 3 1 2

  34. Algorithm Instances t 4 3 1 2

  35. Algorithm Instances t 4 3 1 2

  36. Analysis • Analyze two things • Pr(Success) • t that increases Pr(Success) … … … 1 t n j 4 3 1 2

  37. Analysis … … … 1 t n j 4 3 1 2

  38. Analysis … … … 1 t n j 4 3 1 2

  39. Analysis … … … 1 k n j 4 3 1 2

  40. Analysis … … … 1 k n j 4 3 1 2

  41. Analysis

  42. Analysis

  43. Competitive Ratio • Cost = Number of runs needed to succeed • COPT = 1 • CALG = • = =

  44. 3 k-Server Problem

  45. k-Server Problem Outline • Introduction to the k-Server problem • Preliminaries • Optimal offline algorithm • Balanced algorithm (BAL) • Lower bound for CR • State-of-the-art k-Server algorithm

  46. The Problem • Let be an n-vertex graph with positive edge lengths obeying the triangle inequality, and let mobile servers occupy vertices of • Then, • Planning the motion of mobile servers on the vertices of a graph under a sequence of requests for service is the k-server problem • Goal • Minimize the cost that incurs because of the movement of the server(s)

  47. The Problem S1 B D A C E S2 Request-Sequence ()= { A, B, E, …….. }

  48. The Problem • k-server algorithms are defined on metric spaces! • The graph • Should consist of positive edge lengths • Must obey the triangle inequality • Initial location of the servers are specified • Each Request • Specifies a vertex • Satisfying a request requires a server to be placed in the specified vertex

  49. The Problem • The request sequence • Should be satisfied in-order • The cost of satisfying is the total distance moved by the servers • The k-server problem is • symmetric if for all vertices and , the distance from to is equal to the distance from to • asymmetric otherwise

  50. The Online k-Server Problem • An Online k-server problem • Operates under an additional constraint • Mustdecide which server to move to satisfy a given request without knowing the future requests

More Related