Απευθείας Υπολογισµός (Online Computation)

Similar documents
Algorithmen II. Peter Sanders, Christian Schulz, Simon Gog. Übungen: Michael Axtmann. Institut für Theoretische Informatik, Algorithmik II.

Online Algorithms. - Lecture 4 -

Removing Belady s Anomaly from Caches with Prefetch Data

Lecture 8 Sept 25, 2014

On the Max Coloring Problem

Lecture Overview. 2 Online Algorithms. 2.1 Ski rental problem (rent-or-buy) COMPSCI 532: Design and Analysis of Algorithms November 4, 2015

Applied Algorithm Design Lecture 3

Advanced Algorithms. On-line Algorithms

ECE7995 Caching and Prefetching Techniques in Computer Systems. Lecture 8: Buffer Cache in Main Memory (I)

Primality Testing. Public-Key Cryptography needs large prime numbers How can you tell if p is prime? Try dividing p by all smaller integers

Report on Cache-Oblivious Priority Queue and Graph Algorithm Applications[1]

Wednesday, November 22, 2017

Real-time integrated prefetching and caching

Approximation Algorithms

Virtual Memory. Chapter 8

Operating System - Virtual Memory

Comp Online Algorithms

More on weighted servers

Online file caching with rejection penalties

Approximation Algorithms

Models of distributed computing: port numbering and local algorithms

Operating Systems. Memory: replacement policies

On the Cell Probe Complexity of Dynamic Membership or

CALIFORNIA STATE UNIVERSITY, NORTHRIDGE

Lecture 2. 1 Introduction. 2 The Set Cover Problem. COMPSCI 632: Approximation Algorithms August 30, 2017

Memory Management. Virtual Memory. By : Kaushik Vaghani. Prepared By : Kaushik Vaghani

Online Algorithms with Advice

A Combined BIT and TIMESTAMP Algorithm for. the List Update Problem. Susanne Albers, Bernhard von Stengel, Ralph Werchner

!! What is virtual memory and when is it useful? !! What is demand paging? !! When should pages in memory be replaced?

Course Outline. Processes CPU Scheduling Synchronization & Deadlock Memory Management File Systems & I/O Distributed Systems

Locality of Reference

CS 580: Algorithm Design and Analysis. Jeremiah Blocki Purdue University Spring 2018

A Guide to Deterministic and Randomized Online Algorithms for the List Access Problem

a process may be swapped in and out of main memory such that it occupies different regions

CHAPTER 6 Memory. CMPS375 Class Notes (Chap06) Page 1 / 20 Dr. Kuo-pao Yang

Lecture 8 13 March, 2012

CSE 521: Design and Analysis of Algorithms I

Online Facility Location

Introduction to Algorithms April 21, 2004 Massachusetts Institute of Technology. Quiz 2 Solutions

The Probabilistic Method

Addresses in the source program are generally symbolic. A compiler will typically bind these symbolic addresses to re-locatable addresses.

Approximation Algorithms

CHAPTER 6 Memory. CMPS375 Class Notes Page 1/ 16 by Kuo-pao Yang

Calculating lower bounds for caching problems

Nim-Regularity of Graphs

Chapter 5 Hashing. Introduction. Hashing. Hashing Functions. hashing performs basic operations, such as insertion,

Chapter 6 Memory 11/3/2015. Chapter 6 Objectives. 6.2 Types of Memory. 6.1 Introduction

11. APPROXIMATION ALGORITHMS

Figure 1: An example of a hypercube 1: Given that the source and destination addresses are n-bit vectors, consider the following simple choice of rout

Memory. Objectives. Introduction. 6.2 Types of Memory

3 Fractional Ramsey Numbers

MEMORY MANAGEMENT/1 CS 409, FALL 2013

Network monitoring: detecting node failures

Introduction. hashing performs basic operations, such as insertion, better than other ADTs we ve seen so far

Online paging and caching

Data Stream Processing

Operating Systems Virtual Memory. Lecture 11 Michael O Boyle

CACHE-OBLIVIOUS SEARCHING AND SORTING IN MULTISETS

6 Distributed data management I Hashing

Lecture#16: VM, thrashing, Replacement, Cache state

Randomized Algorithms for Online Matching with Two Sources

On the Complexity of the Policy Improvement Algorithm. for Markov Decision Processes

11. APPROXIMATION ALGORITHMS

Online Algorithms. Lecture 11

The Encoding Complexity of Network Coding

Chapter 8 & Chapter 9 Main Memory & Virtual Memory

Distributed Algorithms 6.046J, Spring, Nancy Lynch

4.1 Paging suffers from and Segmentation suffers from. Ans

Lecture 1: An Introduction to Online Algorithms

Online Coloring Known Graphs

Hashing Based Dictionaries in Different Memory Models. Zhewei Wei

Online Algorithms. Lecture Notes for CSCI 570 by David Kempe December 1, 2006

Compact Sets. James K. Peterson. September 15, Department of Biological Sciences and Department of Mathematical Sciences Clemson University

Paging for Multicore Processors

/633 Introduction to Algorithms Lecturer: Michael Dinitz Topic: Approximation algorithms Date: 11/27/18

CPE300: Digital System Architecture and Design

CS 153 Design of Operating Systems Winter 2016

Approximation Algorithms

Lecture : Topological Space

Chapter 8 Virtual Memory

Cache Controller with Enhanced Features using Verilog HDL

Introduction to Randomized Algorithms

Outline. CS38 Introduction to Algorithms. Approximation Algorithms. Optimization Problems. Set Cover. Set cover 5/29/2014. coping with intractibility

Operating Systems. Designed and Presented by Dr. Ayman Elshenawy Elsefy

Time and Space Lower Bounds for Implementations Using k-cas

On the Performance of Greedy Algorithms in Packet Buffering

Trees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.

Final Exam. Introduction to Artificial Intelligence. CS 188 Spring 2010 INSTRUCTIONS. You have 3 hours.

Notes for Lecture 24

Randomized Algorithms Part Four

Randomized Algorithms Part Four

CS161 Design and Architecture of Computer Systems. Cache $$$$$

Outline. 1 Paging. 2 Eviction policies. 3 Thrashing 1 / 28

Chapter 3. Set Theory. 3.1 What is a Set?

Chapter 9: Virtual-Memory

Cache-Oblivious Traversals of an Array s Pairs

Semi-Passive Replication in the Presence of Byzantine Faults

Practice Exercises 449

On the Smoothness of Paging Algorithms

Proving Lower bounds using Information Theory

Transcription:

ΕΘΝΙΚΟ ΜΕΤΣΟΒΙΟ ΠΟΛΥΤΕΧΝΕΙΟ Σχολή Ηλεκτρολόγων Μηχανικών & Μηχανικών Υπολογιστών Απευθείας Υπολογισµός (Online Computation) Κ. Πατρούµπας 24 Μαΐου 2004 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 1

Online Algorithms: Why? Offline algorithms: Typical algorithms receive their entire inputs at one time. Unrealistic assumption in many practical situations. Online algorithms: Receive and process their input in partial amounts (incrementally). Receive a sequence of requests and service each one before receiving the next one. Generate output without knowledge of the entire input. For each request, make a choice of several alternative strategies. Each alternative has an associated cost. The alternative chosen at a step may influence the cost of future requests. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 2

Online Algorithms: Where? In many modern applications: @ Resource management in operating systems Paging in a two-level memory: keep actively referenced pages in fast memory without knowing which pages will be requested in the future. @ Data structures Dynamically maintain a tree or a linked list so that a sequence of future requests will be served at low cost. @ Scheduling & load balancing Schedule a series of jobs on a set of machines so as to optimize an objective function without knowledge of future jobs. @ Networks Dynamically maintain a set of active connections between nodes without knowing which connections will be needed in the future. @ Distributed computing, Web caching, Robot motion planning, Financial applications, Competitive auctions, 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 3

Online Algorithms: How? Quality of online algorithms: Evaluation using competitive analysis. Traditional worst-case analysis is meaningless for online algorithms. Compare the output (and total cost) generated by the online algorithm to that produced by an optimal offline algorithm, which services the same sequence of the requests. Optimal offline algorithm => an omniscient algorithm that knows the entire request sequence in advance and can compute an optimal output, tailoring its responses accordingly. The worst-case ratio over all possible request sequences between the two algorithms measures the quality of the online algorithm. The better the online algorithm approximates the optimal solution, the more competitive it is. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 4

Online Algorithms: How? Methods of Analysis: Worst Case Analysis For any input, the cost of the online algorithm is never worse than C times the cost of the optimal offline algorithm. Seen as a game between the online algorithm and an adversary. Adversary tries to devise each new piece of the input which will cause the algorithm to incur a high cost. Algorithm tries to minimize cost. =>A strong worst-case performance measure: a competitive algorithm must perform well on all inputs. (Often pessimistic!) Probabilistic Analysis Assume a distribution generating the input (determined in advance) Find an algorithm that minimizes expected cost of the algorithm. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 5

Online Algorithms Outline of the presentation The Online Paging Problem Adversary Models Paging against the Oblivious Adversary Relating the Adversaries The Adaptive Online Adversary The k-server Problem Recent Approaches 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 6

The Online Paging Problem Computer memory organized as a two-level store: a cache (fast memory) for k memory items (pages of virtual memory) a slower main memory that can hold infinite number of items (pages). Paging algorithm: Which k items to retain in cache at any point in time. A sequence of requests, specifying a memory item. Hit: the requested item is currently in cache. No cost at all. Miss: the item must be fetched from main memory at a unit cost => one of the k items currently in cache must be evicted, to free storage for the new item. Cost measure: the number of misses on a sequence of requests. Cost depends on the decision made at any point in time. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 7

The Online Paging Problem Eviction rule: Try not to evict items that will be requested again in the near future. Online paging algorithm: Make the decision without knowledge of future requests. Offline paging algorithm: Make the decision with complete knowledge about future requests. Typical deterministic online algorithms: Least Recently Used (LRU) First-in, First-out (FIFO) Least Frequently Used (LFU) Non-trivial computational cost: e.g., LRU must maintain a priority queue of timestamps for k items 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 8

The Online Paging Problem Request sequence: ρ = ρ 1, ρ 2,..., ρ Ν If the online algorithm A is deterministic, we know its responses. So, it may be computed: the number of times f A (ρ 1, ρ 2,..., ρ Ν ) it misses on this sequence. the minimum possible number of misses f O (ρ 1, ρ 2,..., ρ Ν ) on the same sequence (for an optimal offline algorithm). A deterministic online paging algorithm A is called C-competitive if constant b s.t. sequence ρ 1, ρ 2,..., ρ Ν : f A (ρ 1, ρ 2,..., ρ Ν ) C ⅹ f O (ρ 1, ρ 2,..., ρ Ν ) b Constant b is independent of N, but may depend on k. Competitiveness coefficient C A : infimum of C, s.t. A is C-competitive. => Performance measures based on the worst-case ratio between an online and an optimal offline running on the same sequence. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 9

The Online Paging Problem MIN: Optimal offline paging algorithm request sequence ρ 1, ρ 2,..., ρ Ν, on a miss, evict the item whose next request occurs furthest in the future. No deterministic online paging algorithm A has competitiveness coefficient C A k => LRU and FIFO are optimal (k-competitive). Paging algorithm: automaton with a finite set S of states. function F specifies the response of the automaton to each request response depends on current state, the k items in cache, and the newly requested item. response provides a new state and a new set of items in cache. constraint: the new items must include the item requested. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 10

The Online Paging Problem Theorem 13.1: Let A be a deterministic online paging algorithm. Then C A k. PROOF: Assumption: for request sequence ρ 1, ρ 2,..., ρ Ν, both offline algorithm and A manage separate caches, initially with the same set of k items. Request sequence determined by A: 1 st request is to an item not in either cache => MISS. S: set of k + 1 items (k initial items in offline s cache + new request). Every request is to the unique item not in A s cache. Partition the request sequence into rounds: Round = maximal sequence of requests in which at most k distinct items are requested (each of them any number of times, in any order). 1 st round begins with the 1 st request (MISS). End of round: k items have been requested and ρ is the 1 st request of the next round (the one on which offline fails). Algorithm A misses on at least k requests during the round. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 11

The Online Paging Problem PROOF (continued): Offline algorithm misses only ONCE: There is only ONE (ρ) of the k+1 items of S that will NOT be requested until the end of the round. When missing on the first request, ρ is evicted =>NO further misses. A is deterministic, so the offline algorithm may guess the entire request sequence => the initial requests ρ of each round are known. Therefore: At the end of each round: both algorithms have the same items in their caches. Arbitrarily long sequences of requests may be created by repeatedly invoking this construction. Always A will have k times as many misses as the offline algorithm. The bottom line: No assumptions on computational resources of space and time: The lower bound applies to any deterministic online algorithm. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 12

Online Algorithms Outline of the presentation The Online Paging Problem Adversary Models Paging against the Oblivious Adversary Relating the Adversaries The Adaptive Online Adversary The k-server Problem Recent Approaches 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 13

Adversary models Offline algorithm as adversary: Managing the cache Generating the request sequence. Adversary s role (and goal): increase the cost of the online algorithm, while keeping it down for the reference algorithm. Randomization A randomized online algorithm R and a request sequence ρ 1, ρ 2,..., ρ Ν On a miss, R makes a random choice of which of the k items to evict. The number f R (ρ 1, ρ 2,..., ρ Ν ) of misses is a random variable. Study the behavior of R when the sequence of requests is generated by an adversary. Adversaries (what do they know when generating a request?) Oblivious Adaptive Offline Adaptive Online 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 14

Adversary models Oblivious adversary No knowledge of the random choices made by R Maintain the entire sequence in advance Worst-case sequence for R, optimally serviced by adversary with MIN Not influenced by actual execution of R (random choices) Randomized algorithm R is called C-competitive against the oblivious adversary if constant b independent of N s.t. sequence ρ 1, ρ 2,..., ρ Ν : E [ f R (ρ 1, ρ 2,..., ρ Ν ) ] C ⅹ f O (ρ 1, ρ 2,..., ρ Ν ) b obl C R Oblivious competitiveness coefficient : infimum of C, s.t. R is C-competitive. ------------------------------------------------------------------------------------------------ What if the adversary is allowed to adapt the request sequence to actual choices made by the randomized algorithm? => Adaptive adversaries Choose ρ i+1 after having observed previous responses ρ 1, ρ 2,..., ρ i No information about future choices of R Adaptive adversary and optimal algorithm working in collusion. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 15

Adversary models Adaptive Offline adversary Adversary generates the sequence adaptively Request sequence depends on previous random choices made by R Adversary exhibits optimal strategy (using MIN) Both f O (ρ 1, ρ 2,..., ρ Ν ) and f R (ρ 1, ρ 2,..., ρ Ν ) are random variables. Randomized algorithm R is called C-competitive against the adaptive offline adversary if constant b s.t. sequence ρ 1, ρ 2,..., ρ Ν : E [ f R (ρ 1, ρ 2,..., ρ Ν ) ] C ⅹ E [ f O (ρ 1, ρ 2,..., ρ Ν ) ] b aof C R Adaptive offline competitiveness coefficient : infimum of C, s.t. R is C-competitive. Adaptive Online adversary Adversary generates the sequence adaptively as in the Offline case BUT ALSO, concurrently manage a cache online Chooses ρ i+1 after having observed previous responses ρ 1, ρ 2,..., ρ i of R, but immediately gives its own response to ρ i+1 Again f O (ρ 1, ρ 2,..., ρ Ν ) and f R (ρ 1, ρ 2,..., ρ Ν ) are random variables. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 16

Adversary models Randomized algorithm R is called C-competitive against the adaptive online adversary if constant b s.t. sequence ρ 1, ρ 2,..., ρ Ν : C det E [ f R (ρ 1, ρ 2,..., ρ Ν ) ] C ⅹ E [ f O (ρ 1, ρ 2,..., ρ Ν ) ] b Adaptive online competitiveness coefficient : infimum of C, s.t. R is C-competitive. ------------------------------------------------------------------- Adaptive offline adversary at least as powerful as the adaptive online adversary, and this in turn at least as powerful as the oblivious adversary: obl C R randomized algorithm R, aon C R aof C R Let be the lowest competitiveness coefficient of any deterministic paging algorithm, and define similarly the lowest coefficients for any randomized ones. Then: C obl C aon C aof aon C R 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 17

Online Algorithms Outline of the presentation The Online Paging Problem Adversary Models Paging against the Oblivious Adversary Relating the Adversaries The Adaptive Online Adversary The k-server Problem Recent Approaches 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 18

Paging against the Oblivious Adversary Oblivious adversary cannot predict responses of randomized algorithm. Request sequence specified in advance and does not change. Oblivious adversary does not know the contents of the cache of the online algorithm. Let P the probability distribution by which each ρ i is chosen (allowed to depend on previous choices ρ 1, ρ 2,..., ρ i-1 ). P For a deterministic online algorithm A, its competitiveness C A under P, is defined as the infimum of C, s.t. : E [ f A (ρ 1, ρ 2,..., ρ Ν ) ] C ⅹ E [ f O (ρ 1, ρ 2,..., ρ Ν ) ] b Yao s Minimax Principle: inf R obl C R = sup P P C A i.e. the competitiveness of the best randomized online algorithm equals the competitiveness of the best possible deterministic algorithm A on inputs generated according to a worst-case distribution of requests. Can the randomized paging algorithm achieve superior performance? 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 19 inf A

Paging against the Oblivious Adversary Theorem 13.2: Let R be a randomized online paging algorithm. Then H k, k where H k = 1 j is the k th Harmonic number. Intuition: Establish a lower bound on by giving a probability P distribution P and a lower bound on for any deterministic algorithm A. PROOF: / j = 1 Let a set of k+1 memory items I = { I 1, I 2,..., I k+1 }. A sequence ρ is composed of N k such requests. At any given time, k of them are in cache, one outside the cache. Paging algorithm: on a miss, specify which one to evict from cache. How is the request sequence chosen? first request ρ 1 uniformly from all items in set I. for i >1, choose request ρ i uniformly from k items in set I { ρ i-1 }. Offline algorithm divides sequence ρ into rounds, s.t. it misses on the final request of each round. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 20 C A obl C R

Paging against the Oblivious Adversary PROOF (continued): Proceed in rounds: Let a set of k+1 memory items I = { I 1, I 2,..., I k+1 }. 1 st round: starts with the 1 st request, ends when every item in I has been requested at least once. Each successive round ends when the (k +1) th distinct item is requested since the beginning of the round. Offline algorithm: use MIN algorithm during each round for paging: leave out of cache the item requested last (the final request) in a round. Each item requested exactly ONCE, so only ONE miss in each round. What about the online algorithm? every request goes to an item chosen uniformly at random from k items (apart from the one requested) = > Probability the item requested is the one left out of cache is 1 / k. Expected number of misses = H k. => Expected number of times the online algorithm misses = = H k ⅹ number of misses of the offline algorithm on the same sequence. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 21

Paging against the Oblivious Adversary MARKER: randomized online paging algorithm Proceed in rounds: A marker bit associated to each of the k cache locations. Reset all k marker bits to 0, at the beginning of each round. Hit: the item requested is in cache => set marker bit of its location to 1. Miss: the item requested is not in cache => evict one of k items. Eviction rule: choose an unmarked cache location uniformly at random, evict the item it contains, and set its marker bit to 1. End of round: when a miss occurs but all bits are marked. Theorem 13.3: The MARKER algorithm is (2H k ) competitive. PROOF: Again, an optimal offline algorithm is assumed for sequence ρ 1, ρ 2,..., ρ Ν. Assumption: Both algorithms start with the same k items in cache, and ρ 1 is not in cache. MARKER divides the sequence into a series of rounds, the first beginning with ρ 1. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 22

Paging against the Oblivious Adversary PROOF (continued): Each round starts with ρ i and ends with ρ j s.t. there are (k +1) items in the subsequence ρ i, ρ i+1,..., ρ j, ρ j+1 ( ρ j+1 is the first of the next round). All k locations are marked at the end of the round. First request of a round is to an item not currently in cache. Distinguish items in any round: stale, if the item is unmarked, but was marked in the previous round clean, if item is neither stale nor marked. Notation: l : the number of requests to clean items in a round. S 0 : the set of items in the cache of the offline algorithm. S M : the set of items in the cache of the MARKER algorithm. d I : the value S 0 \ S M at the beginning of the round. d F : the value S 0 \ S M at the end of the round. M 0 : the number of misses of the offline algorithm during the round. At least l d I of the l clean items in a round are not in cache of the offline algorithm at the beginning of the round => M 0 l d I 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 23

Paging against the Oblivious Adversary PROOF (continued): At the end of the round, all k marked items in S M are those requested during the round. Since d F items in the offline cache are not in S M, the offline algorithm has incurred at least d F misses during the round. So: l d I + d F M 0 max{ l d I, d F} 2 On summing the lower bound over all rounds, each round is charged at least l / 2 number of misses ( amortized number of misses). Expected number of misses of the MARKER algorithm in each round: Each of the l requests to clean items costs a miss. There are k l requests to stale items. The cost of each one is the probability P that it s not in the cache. P is maximized when the l requests to clean items precede the requests to the k l stale ones. For the i th request to a stale item, P = l / (k i +1), where 1 i k l. On summing over i, the expected cost of the MARKER is bounded by: l+ l(h k H l ) l H k MARKER has a competitiveness ratio at least twice the best possible. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 24

Online Algorithms Outline of the presentation The Online Paging Problem Adversary Models Paging against the Oblivious Adversary Relating the Adversaries The Adaptive Online Adversary The k-server Problem Recent Approaches 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 25

Relating the Adversaries How do adversary models relate to each other? How powerful adversaries are? How competitive a randomized algorithm can be against adaptive adversaries? A more general setting than paging: request-answer games. A request set R and a finite answer set A. Cost functions f : n n n R A R { }, non-negative integer n. Let f the union of all these functions f n. Let ρ the sequence of requests, and α the sequence of answers. A deterministic online algorithm: i sequence of functions gi : R A, for positive integers i. n, and a sequence ρ=(ρ 1, ρ 2,..., ρ n ), Define A(ρ)=(α 1, α 2,..., α n ) A n where α i = g i (ρ 1, ρ 2,..., ρ i ), for i =1,,n. Cost of algorithm on ρ is c A (ρ)=f n (ρ,a(ρ)). Optimal cost for the same sequence: c(ρ)= min { f n (ρ,α) α A n }. Algorithm is a-competitive if ρ, c A (ρ) a[c(ρ)], a is linear function. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 26

Relating the Adversaries A randomized online algorithm R against oblivious adversaries: is a probability distribution over deterministic algorithms A x x represents coin tosses of R : a random string that selects a deterministic algorithm. for a request sequence ρ the answer sequence A(ρ) is random. Cost of algorithm on ρ is c R (ρ) -- a random variable. Algorithm is a-competitive against oblivious adversaries, if ρ, E x [c A x(ρ)] a[c(ρ)], where a is linear function. An adaptive offline adversary Q: sequence of functions q n :A n R {STOP}, n =0,1,,d 0 and q d0 = STOP. For a deterministic algorithm A and an adaptive adversary Q, ρ (A,Q) are the requests and α (A,Q) the answers of their interaction. Optimal Cost of algorithm on ρ is c Q (A) = c(ρ(a,q)). 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 27

Relating the Adversaries An adaptive online adversary S = (Q, P): an adaptive offline adversary Q, with a sequence P of functions that define its own responses b to the input request sequence. request sequence independent of P (depends on algorithm A only). sequence of functions p n :A n A, n =0,1,,d 0. For a deterministic algorithm A and an adaptive adversary S, ρ (A,Q) are the requests, α (A,S) the answers and b(a,s) the answer sequence of the adversary produced by their interaction. Cost of S on ρ is c S (A) = f n (ρ(a,s), b(a,s)). A randomized algorithm R: a probability distribution on deterministic algorithms A x Costs become random variables. Algorithm is a-competitive against adaptive offline adversaries, if ρ, E x [c A x(ρ)] E[a[c Q (A)]], where a is linear function. Algorithm is a-competitive against adaptive online adversaries, if ρ, E x [c A x(ρ)] E[a[c S (A)]], where a is linear function. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 28

Relating the Adversaries Theorem 13.4: If there is a randomized algorithm that is a-competitive against every adaptive offline adversary, then there exists an a-competitive deterministic algorithm. PROOF: Model the request-answer game as a game between two persons: C gives a request in every step and D answers to this request. A position in the game is a pair (ρ,α). This position is an instant winner for C, if f n (ρ,α) > a[c(ρ)], Position (ρ,α) is winning for C, if according to some rule for selecting requests and a positive integer t, s.t. starting from this position an instant winner will be reached in t steps, regardless of how D plays. Suppositions: there is an a-competitive randomized algorithm R for any adaptive offline adversary. there is no deterministic a-competitive algorithm A. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 29

PROOF (continued): Relating the Adversaries => C has a winning strategy against any deterministic player in the game. => Initial position (both ρ and α are empty strings) is winning for C, iff: adaptive offline adversary Q, s.t. deterministic algorithm A, c A (Q) > a [ c Q (A) ] BUT, a randomized algorithm R is a probability distribution over A x. By taking expectations: E x [ c Ax (Q)] > E x [a [ c Q (A x ) ]] => E [ c R (Q)] > E [a [ c Q (R) ]] Contradiction: R is not a-competitive, as supposed => C has not a winning strategy. A position (ρ,α) is winning for C iff request ρ n+1 s.t. answer α n+1 the position (ρρ n+1,αα n+1 ) is again a winning position for C. Since the answer set A is finite, if position (ρ,α) is not winning for C then request ρ n+1 an answer α n+1 resulting in a non-winning position. If D counters with answer α n+1 at each step, it has a winning strategy => a deterministic a-competitive algorithm. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 30

Relating the Adversaries Theorem 13.5: If R is a-competitive randomized algorithm against any adaptive online adversary, and there is a b-competitive randomized algorithm against any oblivious adversary, then R is (ab)-competitive against any adaptive offline adversary. Intuition: Fix an adaptive offline adversary Q. View R as a probability distribution over deterministic algorithms A x. Then prove that PROOF: E x [c Ax (Q)] E x [a [b[ c Q (A x ) ]]] H: b-competitive randomized algorithm against any oblivious adversary H: probability distribution on deterministic algorithms H y Then, n and ρ R n, E y [c H y(q)] b [c(ρ)]. Adaptive online adversary uses offline Q to generate request sequence and the deterministic H y to answer requests (independently of A): fixed y, define adaptive online adversary S y =(Q,P y ) s.t. deterministic online A, b(a,s y ) = H y (ρ (A,Q)). 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 31

PROOF (continued): Relating the Adversaries Since R is a-competitive against adaptive online adversary S y : fixed y, E x [c Ax (S y )] E x [a[c S y(a x )]] Taking expectation over y, E y [E x [c Ax (S y )]] E y [E x [a[c S y(a x )]]]. The adaptive online borrows the request sequence from the adaptive offline adversary, so y, ρ (A x,s y ) = ρ (A x,q)=ρ x. Hence: E x [c Ax (Q)] = E y [E x [c Ax (S y )]] E y [a [E x [c Sy (ρ x )]]] = a [E x [E y [c Hy (ρ x )]]] a [E x [b [c(ρ x )]]] = E x [a [b[ c Q (A x ) ]]] ------------------------------------------------------------------------------------------------ aon obl From Theorems 13.4 and 13.5, the conclusion is: So, for the paging problem: 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 32 C aon C C det obl C = Ω( k / C H k )

Online Algorithms Outline of the presentation The Online Paging Problem Adversary Models Paging against the Oblivious Adversary Relating the Adversaries The Adaptive Online Adversary The k-server Problem Recent Approaches 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 33

The Adaptive Online Adversary Weighted Paging: generalization of the paging problem Each item x has an associated positive real weight w(x). Cost w(x) when item x is brought into cache from main memory. Total cost is the sum of the costs for each request. When w(x)=1 => the simple paging problem. LRU and FIFO may perform poorly for the weighted paging problem. No randomized online algorithm for the weighted paging problem can achieve a competitiveness coefficient k against adaptive online adversaries. So, RECIPROCAL algorithm is optimal in its performance. RECIPROCAL: online randomized algorithm for weighted paging. Depends only on the weights of the current contents of the cache. Independent of the past. Let x 1, x 2,..., x k the k items in cache, when a miss occurs. Probabilistic eviction rule: evict x i with probability p i with 1/ w( xi ) pi = k 1/ w( x ) j = 1 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 34 j

The Adaptive Online Adversary Theorem 13.6: The RECIPROCAL algorithm is k competitive against any adaptive online adversary. Intuition: Use a typical potential function, which measures the discrepancy between a configuration of the online algorithm and a configuration of the offline algorithm after each request. PROOF: R S i S i : set of items kept in the cache by RECIPROCAL after i th reference. ADV : set of items kept in cache by the adversary after i th reference. The potential function is: and Φ i = Φ i Φ i-1. f i f i R : cost incurred by RECIPROCAL when servicing i th request. ADV : cost incurred by the adversary when servicing i th request. Then: X i = f Φ R i i = kf x S R i ADV i w( x) k Φ x S i R i \ S w( x) ADV i 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 35

The Adaptive Online Adversary PROOF (continued): Costs incurred by two actions: The adversary evicts an item. Item is brought to cache immediately before it is referenced. Charge the adversary for the items it evicts, rather than the item it brings into the cache. ADV Then, f = w x ), if x i is evicted on i th reference (0, otherwise). i ( i RECIPROCAL evicts an item on a miss and is charged for the weight of the item brought into cache. i = Effects of these actions to X j 1 j : The adversary brings x into cache and evicts x => f ADV i = w(x ) and Φi kw(x ). The contribution of the adversary s action to E [ X i X i-1,,x 1 ] is never positive. f R i = w(x) RECIPROCAL misses on a reference to item x, so that Just before this action, \ 1. By substituting probabilities, R ADV k S \ S Ε[ Φ] = w( x) + k w( x) 1/ w( y) 1/ w( y) y S R 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 36 y S R

The Adaptive adaptive Online Adversary PROOF (continued): The contribution of RECIPROCAL s action to E [ X i X i-1,,x 1 ]is 0. After a sequence of requests, Ε[ X i ] 0. Since, Φ 0 and Φ n are bounded, it follows that this is also bounded: R ADV ( Ε[ f ] kε[ f ]) i i ----------------------------------------------------------------------------------------------- Special case of the RECIPROCAL algorithm for (unweighted) paging: On any miss, evict an item chosen at random from the k items in cache. This RANDOM algorithm is k-competitive against any adaptive online adversary. It is also proven that RANDOM has a competitiveness coefficient of kh k against any adaptive offline adversary and There is a randomized algorithm for paging that is H k -competitive. RANDOM provides an instance where Theorem 13.5 holds. i 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 37

Online Algorithms Outline of the presentation The Online Paging Problem Adversary Models Paging against the Oblivious Adversary Relating the Adversaries The Adaptive Online Adversary The k-server Problem Recent Approaches 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 38

The k-server Problem Typical setting: a metric space. k mobile servers, each residing at one point of the space at any time. A sequence of requests ρ 1, ρ 2,..., ρ Ν is presented to the online algorithm. Each request is a point in space. In response to ρ i, the algorithm must move a server to ρ i, unless a server is already there. When a server is moved from point u to point v, there is a cost c uv = distance(u,v) in the metric space. M A (ρ 1, ρ 2,..., ρ Ν ) = total cost of the online algorithm A for servicing the sequence of requests. M O (ρ 1, ρ 2,..., ρ Ν ) = total cost of an optimal offline algorithm for the same sequence. Then, A is C-competitive if sequence ρ 1, ρ 2,..., ρ Ν : M A (ρ 1, ρ 2,..., ρ Ν ) C ⅹ M O (ρ 1, ρ 2,..., ρ Ν ) b for a constant b independent of N. Competitiveness coefficient C A : infimum of C, s.t. A is C-competitive. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 39

The k-server Problem Paging problem: a special case of the k-server problem. A point in metric space corresponds to an item that may be requested. Distance between any two points is 1. Each of the k mobile servers corresponds to one of k cache locations. Moving a server in response to a request = a MISS in paging. Point of origin for server = the memory item evicted to free space for the new item. k-server problem also used to model: planning the motion of two-headed disks. maintenance of data structures. Conjecture: For every metric space, there is a deterministic online algorithm that is k competitive. BUT [ Theorem 13.1 ], for the special case of paging, there is no deterministic online algorithm with a competitiveness coefficient k. Generalize this result for randomized algorithms against adaptive online adversaries. = > NEXT [ Theorem 13.7 ] 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 40

The k-server Problem Theorem 13.7: Let R be a randomized online algorithm that manages k servers in any aon metric space. Then k. Intuition: Exhibit an adaptive request sequence ρ 1, ρ 2,..., ρ Ν so that: R is forced to have cost M R (ρ 1, ρ 2,..., ρ Ν ) and an online algorithm with expected cost at most M R (ρ 1, ρ 2,..., ρ Ν ) / k on the same sequence. PROOF: C R Request sequence: Let H a subset of k +1 points in metric space. k points occupied by R s servers : no two servers on the same point. One point that is not occupied by any server = the next request. Starting position and subsequent moves produce a random sequence ρ 1, ρ 2,..., ρ Ν of requests. Total cost for entire sequence: N N R ( ρ, ρ2,..., ρ N ) = cρ = i+ i c 1ρ ρiρi i= 1 i= 1 1 + 1 by moving a server from ρ i+1 to ρ i so as to service request ρ i. M 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 41

The k-server Problem PROOF (continued): Intuition: A family of k online algorithms All together pay a cost of at most M R (ρ 1, ρ 2,..., ρ Ν ) for the sequence. A randomly chosen one of these k online algorithms has an expected cost no more than M R (ρ 1, ρ 2,..., ρ Ν ) / k on the same sequence. OnIine adversary s actions: Let ρ 1, u 1, u 2,..., u k the points in H (sequence starts with request for ρ 1 ). Online algorithm B j places servers at all points in H, expect u j,1 j k. B j processes request ρ i as follows: for i=1, use the server at u j and for i>1, if there is no server at ρ i, then it moves server from ρ i-1 to ρ i. It suffices to prove that: At any time in the sequence, the set of k points occupied by B j servers is not the same as the set of k points occupied by B m servers, j m. Then, exactly one of the algorithms B j moves a server at cost cρi 1 ρi Summing over all i and j, the total cost by all algorithms B j is: N 1 k cρ c ( 1, 2,..., ) 1 u M i ρ + i j ρ = R ρ ρ ρn i= 1 + j = 1 1 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 42

The k-server Problem PROOF (continued): Why do servers placed by algorithms B j and B m (j m) occupy different sets of points? Let S j and S m the sets of k points, before request ρ i is processed. If S j S m then the two sets remain different after ρ i is processed by B j and B m < = If ρ i is in both S j and S m, neither set is changed when ρ i is processed. If only one of them, say S j, has no server in ρ i, it adds ρ i and drops ρ i-1. But B m has a server at ρ i-1, so the two sets differ. Exactly one of the algorithms B j moves a server on request ρ i with cost. Therefore: k j = 1 M B j ( ρ 1, ρ2,..., ρn ) = M R( ρ1, ρ2,..., ρn ) M B j ( ρ1, ρ,..., ρ ) M ( ρ, ρ2,..., ρ ) / k So, there j s.t. 2 N R 1 N ------------------------------------------------------------------------------------------------ Theorem 13.7 applies to any metric space => also to weighted paging. => RECIPROCAL is optimal for the weighted paging problem. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 43

Online Algorithms Outline of the presentation The Online Paging Problem Adversary Models Paging against the Oblivious Adversary Relating the Adversaries The Adaptive Online Adversary The k-server Problem Recent approaches 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 44

Recent Approaches k-server Lazy adversaries: when one of the servers is located on a point not covered by the online algorithm s servers, the lazy adversary requests that point. Main Open issue: Develop randomized algorithms with a competitive ratio of c < k in an arbitrary metric space. Paging Standard competitive analysis ignores locality of reference: When a page is requested, the next request is usually to a page that comes from a very small set of associated pages. Approaches modeling locality of reference as an access graph, as a Markov chain or as a working set. LRU has the best possible competitiveness ratio on tree graphs. The access graph has to be known in advance for randomization. Open issue: Develop online algorithms for general directed access graphs. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 45

Recent Approaches Web caching Generalized caching is similar to the paging problem (fast memory = = local cache, slow memory = memory of the remaining network) Documents have varying sizes and incur varying costs for download. Several models (Bit, Fault, Cost, General) and algorithms. Open issue: Develop randomized algorithms for generalized caching. Maintaining TCP connections (Connection caching) Limited number of open connections for a node (each with a cache) Synchronize both parts of each connection. Problem usually modeled as a unidirected graph. Local caches are not independent of each other. LRU and FIFO are 2k-competitive (k the size of the largest cache). Randomized RECIPROCAL (Harmonic) algorithm is k-competitive against adaptive online adversaries. Open issues: Generalize objective functions for taking into account delays in establishing connections. Penalize long delays more heavily. Develop randomized algorithms for the objective functions. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 46

Recent Approaches Data Streams Finding frequency counts and association rules in massive, rapid, noisy streams in one pass over the data. Deterministic algorithms exceed memory resources. Randomization / approximation using hashing for frequency counts (Lossy Counting). Sampling can give sublinear time, but low-frequency values are underrepresented in the sample (underestimated) (Sticky sampling). Refinements to Competitive analysis Diffuse adversary model: Adversaries generate input according to a probability distribution D taken from a class of distributions known to the online algorithm. LRU is proven optimal against diffuse adversaries. Comparative analysis: Compare the performance of online algorithms taken from given classes of algorithms. Use of extra resource analyses, statistical adversaries, max/max ratio 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 47

Online Algorithms References [MR95] R. Motwani, and P. Raghavan. Randomized Algorithms. Cambridge University Press, 1995. [BY98] A. Borodin, and R. El-Yaniv. Online Computation and Competitive Analysis. Cambridge University Press, 1998. [HMS01] D. Hand, H. Mannila, P. Smyth. Principles of Data Mining (Adaptive Computation & Machine Learning). MIT Press, 2001. [Alb03] S. Albers. Online Algorithms: A Survey. Mathematical Programming, 97: 3-26, 2003. [MM02] G. Manku, and R. Motwani. Approximate frequency counts over Data Streams. In Proceedings of the 28 th International Conference on Very Large Data Bases, Hong Kong, 2002. 24/05/2004 Αλγόριθµοι Εξόρυξης εδοµένων 48