1 / 12

Online Algorithms

Online Algorithms. Motivation and Definitions Paging Problem Competitive Analysis Online Load Balancing. Motivation. In many settings, an algorithm needs to make a decision “online” without complete knowledge of the input.

medea
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. Online Algorithms • Motivation and Definitions • Paging Problem • Competitive Analysis • Online Load Balancing

  2. Motivation • In many settings, an algorithm needs to make a decision “online” without complete knowledge of the input. • For example, when a page fault occurs, the virtual memory system must decide on a page to evict without knowing what future requests will be • We model this lack of knowledge of the future by defining the concept of online problems

  3. Definition • Optimization problem P • Goal is to minimize or maximize some cost/value • Input is given as a sequence of requests σ • σ1, σ2, … • An algorithm A must service request σi without knowledge of future requests (including whether or not there are more requests) • A(σ) represents the cost of using algorithm A to service sequence σ

  4. Example: Paging Problem • Setting • We have k fast memory pages and an infinite number of slow memory pages • Input: A sequence of requests for slow memory pages • If the page currently also resides in fast memory (hit), we can service this page with 0 cost • If the page only resides in slow memory (fault), we must bring the page into fast memory and evict a page currently in fast memory for cost 1 • Goal: Process the requests with minimum cost.

  5. The offline version of the problem • Suppose we knew the entire request sequence in advance. What is the optimal way to handle any page fault? • 2 fast memory pages • σ =1, 3, 1, 2, 1, 3, 2, 3, 1, 3, 1, 2, 2, 1, 3, 2

  6. Worst-case Analysis of Online Algorithms • What are some natural online algorithms we can define for this problem? • Show that for every online algorithm A, there exists a request sequence σA such that A performs poorly on σA • What does this imply about using this form of worst-case analysis for online algorithms? What is a good online algorithm for the paging problem given this performance metric?

  7. Competitive Analysis • Let A(σ) denote algorithm A’s cost on input sequence σ • Let Opt(σ) denote the optimal algorithm’s cost on input sequence σ • We say that algorithm A is c-competitive if for any sequence σ and some constant b, A(σ) ≤ c Opt(σ) + b • Essentially that A(s)/Opt(s) ≤ c • The competitive ratio cA is the infimum of {c | A is c-competitive}. • The optimal competitive ratio for a problem is • infimumA cA

  8. 2 example online algorithms • Consider the following two algorithms • MRU (evict the most recently used page) • LRU (evict the least recently used page) • Consider a scenario with 2 fast memory pages and the following request sequences • σ1 = 1, 2, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, … • σ2 = 1, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, … • What is LRU(σ1)/OPT(σ1) ? MRU(σ1)/OPT(σ1) ? • What is LRU(σ2)/OPT(σ2) ? MRU(σ2)/OPT(σ2) ?

  9. General questions • Show that for any online algorithm A, there exists a request sequence σA such that A faults on every request of σA while OPT faults on at most /k requests of σA where there are k fast memory pages and there are k+1 slow memory pages • What does this result imply about the best possible competitive ratio of any online algorithm for the paging problem. • How can we try to show that LRU achieves this competitive ratio?

  10. Example: Online Load Balancing • Setting • We have m identical machines • Input: A sequence of jobs with loads σi • We must assign each job to a machine before the next job arrives • Goal: Assign jobs to machines so that the maximum load on any machine is minimized

  11. The offline version of the problem • Suppose we knew the entire request sequence in advance. • Consider the following problem instance: • 2 machines • σ =1, 7, 9, 12, 15, 7, 9 • What is optimal solution for this instance? • What can you say about the hardness of this offline problem?

  12. Online Algorithms and Questions • What is an obvious greedy strategy for this problem? • Consider the following two lower bounds on OPT(σ) • OPT(σ) ≥ maxi σi (largest job is on some machine) • OPT(σ) ≥ Σi σi/m (at best total load is divided evenly) • Prove that the greedy strategy has a competitive ratio of 2 – 1/m • Consider the last job j placed on the max loaded machine for greedy • Greedy(σ) = h, the load of the machine before job j, + σj • Using the lower bound above, argue that Greedy(σ) ≤ (2-1/m) OPT(σ) • Find specific input instances σ where Greedy(σ) = (2-1/m) OPT(σ) for m=2 and 3. • For these input instances, could any online algorithm do better? Argue why not.

More Related