Presentation is loading. Please wait.

Presentation is loading. Please wait.

Online Algorithms Motivation and Definitions Paging Problem Competitive Analysis Online Load Balancing.

Similar presentations


Presentation on theme: "Online Algorithms Motivation and Definitions Paging Problem Competitive Analysis Online Load Balancing."— 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  –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 c A is the infimum of {c | A is c- competitive}. The optimal competitive ratio for a problem is –infimum A c A

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(σ) ≥ max i σ 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.


Download ppt "Online Algorithms Motivation and Definitions Paging Problem Competitive Analysis Online Load Balancing."

Similar presentations


Ads by Google