Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps...

64
Kinetic Heaps K, Tarjan, and Tsioutsiouliklis

description

(Lecture by Mike Franklinresearch papers) Users One server, many possible items to send (say, all the same length) One broadcast channel. Users submit requests for items. Goal: Satisfy users as well as possible, making decisions on-line. (say, minimize sum of waiting times) Server: many data items Broadcast channel (single-item) Broadcast Scheduling

Transcript of Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps...

Page 1: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Kinetic Heaps

K, Tarjan, and Tsioutsiouliklis

Page 2: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Broadcast Scheduling

Parametric and Kinetic Heaps

Broadcast Scheduling Using a Kinetic Heap

The Computational Geometry View

What is known

Four New Structures

Simple Heap Balanced Heap Fibonacci Heap Incremental Heap

Open problems

Outline

Page 3: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

(Lecture by Mike Franklin research papers)

Users

One server, many possible items to send (say, all the same length)

One broadcast channel.

Users submit requests for items.

Goal: Satisfy users as well as possible, making decisions on-line. (say, minimize sum of waiting times)

Server:many

data items Broadcastchannel

(single-item)

Broadcast Scheduling

Page 4: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Greedy = Longest Wait first (LWF):Send item with largest sum of waiting times.

R x W: send item with largest (# requests x longest waiting time)

Scheduling policies

(vs. number of requests or longest single waiting time)

Page 5: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Questions (for an algorithm guy or gal)

LWF does well compared to what?Try a competitive analysis

Can we improve the cost of LWF?

What data structure?

Open question 1

Will talk about this

Page 6: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

A collection of items, each with an associated key.

key (i) = ai x + bi ai,, bi reals, x a real-valued parameterai = slope, bi = constant

Operations:

make an empty heap.

insert item i with key ai x + bi into the heap: insert(i,ai,bi)

find an item i of minimum key for x = x0: find-min( x0)

delete item i : delete(i)

Parametic Heap

Page 7: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

A parametric heap such that successive x-values of find mins are non-decreasing.

(Think of x as time.)

xc = largest x in a find min so far (current time)

Additional operation:

decrease the key of an item i, replacing it by a key that is no larger for all x xc : decrease-key(i,a,b)

Kinetic Heap

Page 8: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Need a max-heap (replace find min by find max, decrease key by increase key, etc) Can implement LWF or R x W or any similar policy:

Broadcast decision is find max plus delete

Request is insert (if first) or increase key (if not)

Only find max need be real-time, other ops can proceed concurrently with broadcasting

Slopes are integers that count requests

Broadcast scheduling via kinetic heap

Page 9: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

LWF:

Suppose a request for item i arrives at time ts

If i is inactive then insert(i, t-ts)

If i is active with key at+b then increase-key(i, (a+1)t+(b-ts))

To broadcast an item at time ts we perform delete-max(ts)

and broadcast the item returned.

Broadcast scheduling via kinetic heap (Cont.)

Page 10: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

A key is a line computational geometry

Equivalent problems:

maintain the lower envelope of a collection of lines in 2D

projective duality

maintain the convex hull of a set of points in 2Dunder insertion and deletion

“kinetic” restriction = “sweep line” query constraint

What is known about parametric and kinetic heaps?

Page 11: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Overmars and Van Leeuwen (1981)

O( log n) time per query

O(log2n) time per update, worst-case

Chazelle (1985), Hershberger and Suri (1992)

(deletions only)

O( log n) time per query, worst-case

O(n log n) for n deletions

Results I

Page 12: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Results II

Chan (1999)

Dynamic hulls and envelopes

O( log n) time per query

O(log1+n) time per update, amortized

Brodal and Jacob (2000)

O( log n) time per query

O( log n log log log n) time per insert,

O( log n log log n) timer per delete, amortized

Page 13: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Results III

Basch, Guibas, and Hershberger (1997)

“Kinetic” data structure paradigm

Page 14: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

A balanced binary tree, with items in the leavesin left-right order by decreasing key slope.

The tree is a tournament on items by current key.

Simple heap (details)

Page 15: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c ea

a c

a

Page 16: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Simple kinetic heaps (Cont)

Add swap times at internal nodes

Page 17: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c ea

a c

a

3

6 6.8

4.4

Page 18: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Simple kinetic heaps (Cont)

Add minimum future swap time

Page 19: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c ea

a c

a

3

3 6.8

3

6

3

4.4

6.8

Page 20: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Simple kinetic heaps (Cont)

When we do a find-min if the current time moves forward, we act as follows:

Locate all nodes whose winner changes.

The paths from the root to those nodes form a subtree.

Update this subtree

Page 21: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c ea

a c

a

3

3 6.8

3

6

3

4.4

6.8

Page 22: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c ea

a c

a

3

3 6.8

3

6

3

4.4

6.8

Page 23: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c eb

a c

a

3 6.8

3

6

3

4.4

6.8

Page 24: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c eb

b

2020

3

c

a 34.4

6.8 6.8

Page 25: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c eb

b

2020

3

c

b 55

6.8 6.8

Page 26: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c eb

b c

b

20

5

20

3

5

6.86.8

Page 27: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c eb

b c

b

20

5

20

3

5

6.86.8

Page 28: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c eb

b e

e

2020

3

6.8

205

Page 29: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c eb

b e

e

2020

3

205

6.8

Page 30: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Simple kinetic heaps – insert & delete

Use the regular mechanism of (say) red-black trees

Page 31: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

d c eb

b e

ef

2020

3

5

6.8

20

Page 32: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b d

c eb

b e

e

20 20

3

5

6.8

20

f

f

f -20

Page 33: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b d

c eb

f e

e

-10

3

6.9

6.8

f

f

f -20

Page 34: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Simple kinetic heaps (analysis)

Find-min takes O(1) time if we do not advance the current time.

Advancing the current time can be expensive on the worst-case

Amortization:

Assign O(log n) potential to each node whose swap time is in the future. This potential pays for advancing the time.

So find-min takes O(1) amortized time.

Insert and delete take O(log2n) amortized time

Page 35: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

How do we make this a parametric heap ?(Overmars-Van Leeuwen)

Page 36: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

c e

d

Page 37: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Looks like we use non linear space ?

Each node keeps the chain of segments that are on its envelope but not on its parent envelope.

This makes the space linear.

Page 38: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

c e

d

Page 39: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Analysis

Using search trees to represent the envelopes sorted by slopes then:

Find-min takes O(log n) time

Insert and delete take O(log2 n) time: You split and concatenate O(log n) such envelopes.

Page 40: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Balanced kinetic heaps

Def: The level of a line is the depth of the highest node where it is stored.

Plan: first we’ll do only deletions faster and then we’ll add insertions.

Our starting point is the previous data structure.

Page 41: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Deletion-only data structure

The level of a line is the depth of the highest node where it is stored.

Page 42: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

c e

d

d

Page 43: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Deletion-only data structure

What happens when we delete a line ?

Page 44: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

c e

d

d

Page 45: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

e

d

d

Page 46: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

e

d

d

Page 47: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

a

be

d

c

a b

e

d

d

Page 48: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Balanced kinetic heaps When we delete a line, lines only decrease their level.

Page 49: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.
Page 50: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.
Page 51: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

AnalysisKey idea: Implement the envelopes using finger search trees

How much time it takes to delete an element ?

O(log n) + log (# lines get on the replacement piece)

+ log (# lines get off the replacement piece)

If in all nodes # lines get on/off the replacement piece < log2n we are ok --- the delete takes O(log n loglog n) time

However it could be that # lines get on/off the replacement piece > log2n

Page 52: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Analysis (Cont)If a line gets on the replacement piece it changes its level

Since the total number of level changes is nlog(n)

The number of chains of length > log2n is at most n/log(n)

So the total work in moving long chain is O(n) and can be charged to the initialization phase.

Page 53: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

A better deletions only data structure

O(n) init. time and then O(log n loglog n) per delete.O(1) find-min if we are kinetic.

Now we add insert.

Summary so far

Page 54: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Balanced kinetic heaps (finalle)Balanced heaps (step 2):

Use a well known reduction by Bently and Saxe to add insertions

. . . . . . . . . . . . . .

Maintain a binary counter of deletion only data structures

Page 55: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Balanced kinetic heaps Delete : O(log n loglog n)

. . . . . . . . . . . . . .

Insert : O(log n)Find-min : O(log n) (kinetic)

Page 56: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Based one Fibonacci heaps with lazy linking.

We link only when it is safe

Fibonacci heap (highlights)

We get

O(log2 n) for delete

O(log n) for find-min and insert

O(log n) for decrease-key

Page 57: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Fibonacci heaps (Fredman & Tarjan 84)

Want to do decrease-key(x,h,) faster than delete+insert.

( in O(1) time.)

Page 58: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

55

6

2

6

1

85

95

10

Heap ordered (Fibonacci) trees

Page 59: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Linking

Operations are defined via a basic operation, called linking, of Fibonacci trees:Produce a Fk from two Fk-1, keep heap order.

1

65

8

2

95

10

4

116

9

5

96

10

Page 60: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Basic idea: delay the linking until they are safe

S1S0

Sr

Regular heap

Page 61: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Linking

The basic operation is inserting a tree of rank r into Sr, making the appropriate linking if needed.

Insert(i) : Insert a new node containing i into S0

This may cascade, but we have one tree less every time we do the linking

Decrease-key(i, a’.b’) : Decrease the key of i in the tree containing it making cascading cuts, link the resulting trees back into the structure.

Page 62: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Analysis

Similar to the analysis of F-heaps

Multiply the potential by log n

Page 63: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Incremental heap (highlights)Assumptions

insertion of i: ai = 1, increase key of i: ai := ai + 1

Group items by key slope, each group is an ordinary Fibonacci heap

Move items among groups as key slopes change(“displaced” items because entire subtrees are moved)

We get

find-max, insert : O(1)The kth increase-key : O(log min{k,n})delete : O(log n)

Page 64: Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.

Open problems

Experiments: What is the best structure in practice?

Better bounds: kinetic heaps in ordinary F-heap bounds?

parametric heaps in O(log n) amortized time per operation?

Simple kinetic heaps via splay trees?