CSE 780 Algorithms Advanced Algorithms SSSP Dijkstra’s algorithm SSSP in DAGs.
Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online...
Transcript of Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online...
![Page 1: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/1.jpg)
Friedhelm Meyer auf der Heide 1
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Welcome to the course
Algorithm Design
Summer Term 2011
Friedhelm Meyer auf der Heide
Lecture 12, 8.7.2011
![Page 2: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/2.jpg)
Friedhelm Meyer auf der Heide 2
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Randomised Algorithms
![Page 3: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/3.jpg)
Friedhelm Meyer auf der Heide 3
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityTopics
- Divide & conquer
- Dynamic programming
- Greedy Algorithms
- Randomized Algorithms
- Approximation Algorithms
- Online Algorithms
![Page 4: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/4.jpg)
Friedhelm Meyer auf der Heide 4
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityOnline Algorithms
An online algorithm is one that can process its input piece-by-piece,
without having the entire input available from the start.
In contrast, an offline algorithm is given the whole problem data from the
beginning and is required to output an answer which solves the problem
at hand.
Input: a sequence of requests.
Task: process the requests as efficiently as possible
Online:
i„th request has to be processed before future requests are known
Offline:
All requests are known in advance
![Page 5: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/5.jpg)
Friedhelm Meyer auf der Heide 5
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityHow to measure quality of online algorithms?
1. Assume some a priori knowledge about request
sequence, e.g., „requests are chosen randomly“
2. Assume worst case measure, compare online cost to
offline cost
Online : standard competitive analysis – competitive ratio
Online randomized:
![Page 6: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/6.jpg)
Friedhelm Meyer auf der Heide 6
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Paging
![Page 7: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/7.jpg)
Friedhelm Meyer auf der Heide 7
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Paging:
A basic problem for an operating system
• Main memory
• Size k=6
• Disk
Paging: given a main memory that can
hold k pages.
Input: request sequence of pages to be
used by the processor
Goal: Need as few page faults ( requests
for pages that have to be moved from
disk to main memory)
The algorithm has to store the requested
page in main memory in case of a page
fault, and has to choose a page to be
removed from main memory.
![Page 8: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/8.jpg)
Friedhelm Meyer auf der Heide 8
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityPaging
Optimal offline:
![Page 9: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/9.jpg)
Friedhelm Meyer auf der Heide 9
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityPaging
Two online strategies:
Theorem: LRU and FIFO are k-competitive.
This competitive ratio is best possible.
![Page 10: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/10.jpg)
Friedhelm Meyer auf der Heide 10
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityPaging
In practise, both algorithms are much better, the observed competitive ratio decreases with increasing memory size k.
Furthermore, LRU turns out to be better than FIFO.
Reasons: In practise, request sequences exhibit locality, i.e., they tend to use the same pages more often, and have dependencies among pages.
(„If page A is accessed, then it is likely that page B will be accessed shortly afterwards“)
Way out: Model restrictions to the „adversary“, i.e. the bad guy that generates the worst case sequences.
This is done using access graphs.
![Page 11: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/11.jpg)
Friedhelm Meyer auf der Heide 11
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Page Migration
![Page 12: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/12.jpg)
Friedhelm Meyer auf der Heide 12
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Page migration – Classical online problem
• processors connected by a network
There are costs of communication associated with each
edge. Cost of communication between pair of nodes =
cost of the cheapest path between these nodes.
• Costs of communication fulfill the triangle inequality.
Page Migration Model (1)
v1
v2
v3
v4
v7
v6
v5
![Page 13: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/13.jpg)
Friedhelm Meyer auf der Heide 13
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Alternative view:
• processors in a metric space
Indivisible memory page of size in the local memory of
one processor (initially at )
Page Migration Model (2)
v1
v2
v3
v4
v7
v6
v5
![Page 14: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/14.jpg)
Friedhelm Meyer auf der Heide 14
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityPage Migration Model (3)
Input: sequence of processors,
dictated by a request adversary
- processor which wants to access (read or write)
one unit of data from the memory page.
After serving a request an algorithm may move the page
to a new processor.
v1
v2
v3
v4
v7
v6
v5
![Page 15: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/15.jpg)
Friedhelm Meyer auf der Heide 15
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityPage Migration (cost model)
Cost model:
The page is at node .
Serving a request issued at costs .
Moving the page to node costs .
![Page 16: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/16.jpg)
Friedhelm Meyer auf der Heide 16
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityA randomized algorithm
Memoryless coin-flipping algorithm CF [Westbrook 92]
Theorem: CF is 3-competitive against an adaptive-online
adversary (may see the outcomes of the coinflips).
Remark: This ratio is optimal against adaptive-online
adversary.
In each step, after serving a request issued at ,
move page to with probability .
![Page 17: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/17.jpg)
Friedhelm Meyer auf der Heide 17
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityProof of competitiveness of CF
We run CF and OPT „in parallel” on the input sequence
We define potential function
There are two events to consider in each step
– Request occurs at a node ,
– CF and OPT serve the requests, part 1
– CF optionally moves the page
– OPT optionally moves the page } part 2
– For each part separately, we prove that
![Page 18: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/18.jpg)
Friedhelm Meyer auf der Heide 18
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityProof of competitiveness of CF
Note:
This is a telescopic sum.
Thus the cancel out
and we get the competitive ratio 3.
![Page 19: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/19.jpg)
Friedhelm Meyer auf der Heide 19
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityCompetitiveness of CF, a step
Page in and resp.
Request occurs at
CF and OPT serve the requests
CF optionally moves the page to part 1
OPT optionally moves the page part 2
to
•
![Page 20: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/20.jpg)
Friedhelm Meyer auf der Heide 20
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityCompetitiveness of CF – part 1
Request occurs at
Cost of serving requests:
in CF : a, in OPT : b
Expected cost of moving the page:
Potential before:
Exp. potential after:
Exp. change of the potential:
![Page 21: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/21.jpg)
Friedhelm Meyer auf der Heide 21
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityCompetitiveness of CF – part 2
OPT moves to
![Page 22: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/22.jpg)
Friedhelm Meyer auf der Heide 22
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityDeterministic algorithm
Algorithm Move-To-Min (MTM) [Awerbuch, Bartal, Fiat 93]
Theorem: MTM is 7-competitive
Remark: The currently best deterministic algorithm achieves
competitive ratio of 4.086
After each steps, choose to be the node
which minimizes , and move to .
( is the best place for the page in the last steps)
![Page 23: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/23.jpg)
Friedhelm Meyer auf der Heide 23
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and ComplexityResults on page migration
The best known bounds:
Algorithm Lower bound
Deterministic
[Bartal, Charikar, Indyk
„96]
[Chrobak, Larmore,
Reingold, Westbrook „94]
Randomized:
Oblivious
adversary
[Westbrook „91] [Chrobak, Larmore,
Reingold, Westbrook „94]
Randomized:
Adaptive-online
adversary
[Westbrook „91] [Westbrook „91]
![Page 24: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/24.jpg)
Friedhelm Meyer auf der Heide 24
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Data management in networks
![Page 25: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/25.jpg)
Friedhelm Meyer auf der Heide 25
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Scenario
Networks have low bandwidth, global objects are small, access is
fine grained.
• typical for parallel processor networks, partially also for the internet.
• bottleneck: link-congestion
task: distribute global objects (maybe dynamically) among
processors such that
• an application (sequence of read/write access to global
variables) can be executed using small link-congestion
• storage overhead is small.
- Exploit Locality -
![Page 26: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/26.jpg)
Friedhelm Meyer auf der Heide 26
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Basic Strategy
Design strategy for trees
Produce strategy for target-network by tree embedding
![Page 27: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/27.jpg)
Friedhelm Meyer auf der Heide 27
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Dynamic Model
Application: Sequence of read / write requests from processors
to objects. Each processor decides solely based on
its local knowledge.
distributed online-strategy
Goal: Develop strategy that produces only by a factor c more
congestion than an optimal offline strategy.
c-competitive strategy
(and by a factor m more storage per processor
(m, c) – competitive strategy )
![Page 28: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/28.jpg)
Friedhelm Meyer auf der Heide 28
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Dynamic strategy for trees
v writes to x :
v creates (or updates) copy of x in v,
and invalidates all other copies (consistency!)
v reads x:
v reads the closest copy of x and creates copies in
every processor on the path back to v.
(Remark: Data Tracking in trees is easy!)
![Page 29: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/29.jpg)
Friedhelm Meyer auf der Heide 29
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Example and Analysis
Consider phase write (v0), read (v1), read (v2), ... , read (vk-1), write (vk)
v0
![Page 30: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/30.jpg)
Friedhelm Meyer auf der Heide 30
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Example and Analysis
Consider phase write (v0), read (v1), read (v2), ... , read (vk-1), write (vk)
v0
v1
![Page 31: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/31.jpg)
Friedhelm Meyer auf der Heide 31
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Example and Analysis
Consider phase write (v0), read (v1), read (v2), ... , read (vk-1), write (vk)
v0
v1
![Page 32: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/32.jpg)
Friedhelm Meyer auf der Heide 32
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Example and Analysis
Consider phase write (v0), read (v1), read (v2), ... , read (vk-1), write (vk)
v0
v1
v2
![Page 33: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/33.jpg)
Friedhelm Meyer auf der Heide 33
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Example and Analysis
Consider phase write (v0), read (v1), read (v2), ... , read (vk-1), write (vk)
v0
v1
v2
![Page 34: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/34.jpg)
Friedhelm Meyer auf der Heide 34
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Example and Analysis
Consider phase write (v0), read (v1), read (v2), ... , read (vk-1), write (vk)
v0
v1
v2
v3
![Page 35: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/35.jpg)
Friedhelm Meyer auf der Heide 35
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Example and Analysis
Consider phase write (v0), read (v1), read (v2), ... , read (vk-1), write (vk)
v0
v1
v2
v3
vk
![Page 36: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/36.jpg)
Friedhelm Meyer auf der Heide 36
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Example and Analysis
Consider phase write (v0), read (v1), read (v2), ... , read (vk-1), write (vk)
v0
v1
v2
v3
Each strategy has to use each link of the red subtree at least once.
Our strategy uses each of these links at most three times.
Strategy is 3-competitive for trees
vk
![Page 37: Algorithm Design - hni.uni-paderborn.de · Algorithms and Complexity Online Algorithms An online algorithm is one that can process its input piece-by-piece, without having the entire](https://reader033.fdocuments.net/reader033/viewer/2022052721/5f0af11e7e708231d42e18c0/html5/thumbnails/37.jpg)
Friedhelm Meyer auf der Heide 37
HEINZ NIXDORF INSTITUTE
University of Paderborn
Algorithms and Complexity
Friedhelm Meyer auf der Heide
Heinz Nixdorf Institute
& Computer Science Department
University of Paderborn
Fürstenallee 11
33102 Paderborn, Germany
Tel.: +49 (0) 52 51/60 64 80
Fax: +49 (0) 52 51/62 64 82
E-Mail: [email protected]
http://www.upb.de/cs/ag-madh
Thank you for
your attention!