46
Friedhelm Meyer auf der Heide 1 HEINZ NIXDORF INSTITUTE University of Paderborn Algorithms and Complexity Introduction to online algorithms Friedhelm Meyer auf der Heide

Introduction to online 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

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Introduction to online 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

Friedhelm Meyer auf der Heide 1

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Introduction to

online algorithms

Friedhelm

Meyer auf der Heide

Page 2: Introduction to online 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

Friedhelm Meyer auf der Heide 2

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 3: Introduction to online 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

Friedhelm Meyer auf der Heide 3

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 4: Introduction to online 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

Friedhelm Meyer auf der Heide 4

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and ComplexityToy Example: Ski rental problem

I go skiing one year after the other, until I am no longer

interested in skiing. I do not know in advance, when I loose

interest.

Bying skis costs D € (and I can use them for ever), renting

them costs 1€.

Question: When should I buy skis?

Answer: Immediately, if I am interested for at least D years,

never otherwise.

This can only be done offline!

Page 5: Introduction to online 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

Friedhelm Meyer auf der Heide 5

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and ComplexityToy Example: Ski rental problem

What to do online?

I buy when I go skiing for a D„th year.

Cost offline : D

Cost online : 2D

This strategy is 2-competitive

Page 6: Introduction to online 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

Friedhelm Meyer auf der Heide 6

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Paging

Page 7: Introduction to online 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

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: 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) as possible

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: Introduction to online 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

Friedhelm Meyer auf der Heide 8

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and ComplexityPaging

Optimal offline:

Page 9: Introduction to online 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

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.

Theorem: This competitive ratio is best possible.

Page 10: Introduction to online 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

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: Introduction to online 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

Friedhelm Meyer auf der Heide 11

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Page Migration

Page 12: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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

Remark: This ratio is optimal against adaptive-online

Adversary (may see the outcomes of the coinflips)

In each step after serving a request issued at ,

move page to with probability .

Page 17: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

Friedhelm Meyer auf der Heide 21

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and ComplexityCompetitiveness of CF – part 2

OPT moves to

Page 22: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

Friedhelm Meyer auf der Heide 24

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Data management in networks

Page 25: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

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: Introduction to online 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

Friedhelm Meyer auf der Heide 37

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Other networks

Idea: Simulate suitable tree in target-network M.

tree embedding:

Goals: - small dilation

(in order to reduce overall load)

- randomized embedding

(in order to reduce congestion)

Goals contradict?!?

Page 38: Introduction to online 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

Friedhelm Meyer auf der Heide 38

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Tree embedding

Example: nxn-mesh1 2 30

M„

v

• leaves: nodes of the mesh

• link-capacity: # links leaving the submesh

Randomized, locality preserving embedding!

Page 39: Introduction to online 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

Friedhelm Meyer auf der Heide 39

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Result for meshes

The static and dynamic strategies are

O (log(n))-competitive in nxn-meshes, w.h.p.

Finding an optimal static placement for several variables is

NP-hard already on 3x3-meshes.

Page 40: Introduction to online 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

Friedhelm Meyer auf der Heide 40

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Some Results

competitive ratio w.h.p.

d-dimensional meshes O(d log n)

Fat Trees O(log n)

Hypercubes O(log n)

SE Networks

De Bruijn Networks

Direct Butterflies

Indirect Butterflies

Arbitrary Networks

O(log n)

O(log n)

O(log n)

O(1)

polylog n (Räcke 2002)

Page 41: Introduction to online 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

Friedhelm Meyer auf der Heide 41

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Conclusions

Provably efficient protocols for data

management in networks

Different models for different

application scenarios

Open problem:

- randomized, locality preserving

embedding and routing in dynamic

networks

Page 42: Introduction to online 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

Friedhelm Meyer auf der Heide 42

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Robot Navigation

Page 43: Introduction to online 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

Friedhelm Meyer auf der Heide 43

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and ComplexityRobot navigation

Theorem: This competitive ratio can be achieved.

Page 44: Introduction to online 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

Friedhelm Meyer auf der Heide 44

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and ComplexityA simple navigation problem

The playground is a line, no obstacles.

The robot has to find the treaure, but does not know

in advance where it is. It only finds it when it

touches it.

Page 45: Introduction to online 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

Friedhelm Meyer auf der Heide 45

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and ComplexityA simple navigation problem

Offline : n

Online : Go left, right, left, right,..

In i„th step, go distance .

This gives total cost

This algorithm is 9-competitive.

This is best possible!!

Distance n

i2

Page 46: Introduction to online 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

Friedhelm Meyer auf der Heide 46

HEINZ NIXDORF INSTITUTE

University of Paderborn

Algorithms and Complexity

Heinz Nixdorf Institute

& Computer Science Institute

University of Paderborn

Fürstenallee 11

33102 Paderborn, Germany

Tel.: +49 (0) 52 51/60 64 66

Fax: +49 (0) 52 51/62 64 82

E-Mail: [email protected]

http://www.upb.de/cs/ag-madh

Thank you for

your attention!