Convex Hull for Dynamic Data Convex Hull and

  • Slides: 64
Download presentation
Convex Hull for Dynamic Data Convex Hull and Parallel Tree Contraction Jorge L. Vittes

Convex Hull for Dynamic Data Convex Hull and Parallel Tree Contraction Jorge L. Vittes June 12, 2003 (joint work with Umut Acar, and Guy Blelloch) Convex Hull for Dynamic Data

Motivation n Application data is dynamic n n word processors: slowly changing text graphics:

Motivation n Application data is dynamic n n word processors: slowly changing text graphics: render similar images mobile phone networks: continuously moving hosts Important to handle dynamic data efficiently 12/7/2020 Convex Hull for Dynamic Data 2

Dynamic Algorithms: Changing Data a a b b c c d d a e

Dynamic Algorithms: Changing Data a a b b c c d d a e b c d 12/7/2020 e Convex Hull for Dynamic Data 3

Kinetic Algorithms: Moving Data a a b b c c d d Time =

Kinetic Algorithms: Moving Data a a b b c c d d Time = 0 Time = 1 b a c 12/7/2020 d Time = 1+e. . . 1 Convex Hull for Dynamic Data 4

How to invent Dynamic/Kinetic Algorithms n n Just like any other algorithm. Think, ponder,

How to invent Dynamic/Kinetic Algorithms n n Just like any other algorithm. Think, ponder, divide, conquer. . . Or, use adaptivity. . . 12/7/2020 Convex Hull for Dynamic Data 5

Adaptivity n n Makes a standard algorithm dynamic or kinetic Requires little change to

Adaptivity n n Makes a standard algorithm dynamic or kinetic Requires little change to the standard algorithm Can be done semi-automatically Not all algorithms yield efficient adaptive algorithms n 12/7/2020 Will talk about this more Convex Hull for Dynamic Data 6

How does Adaptivity Work? n Represent a computation with a dynamic dependency graph nodes

How does Adaptivity Work? n Represent a computation with a dynamic dependency graph nodes = data, edges = dependencies Sources = input, sinks = output, n The user can n n change the input, update the output Update: n n n 12/7/2020 Take a changed node, Update all its children (the children are now changed) Repeat until no more changed nodes Convex Hull for Dynamic Data 7

Adaptivity Example fun f (a, b, c) = let u = a+b in if

Adaptivity Example fun f (a, b, c) = let u = a+b in if (u > 0) then g(u) else g(b+c) end 1 2 3 a b c a+b 1+b 3 u if u>0 then g(u) else g(b+c) 0. 33 12/7/2020 Convex Hull for Dynamic Data g(u) r 8

Adaptivity Example: Change fun f (a, b, c) = let u = a+b in

Adaptivity Example: Change fun f (a, b, c) = let u = a+b in if (u > 0) then g(u) else g(b+c) end -2 2 3 a b c a+b 1+b 3 u if u>0 then g(u) else g(b+c) 0. 33 12/7/2020 Convex Hull for Dynamic Data g(u) r 9

Update -2 fun f (a, b, c) = let u = a+b in if

Update -2 fun f (a, b, c) = let u = a+b in if (u > 0) then g(u) else g(b+c) end 2 b a a+b c -2+b 0 u v 5 if u>0 then g(u) else g(b+c) 0. 5 12/7/2020 3 Convex Hull for Dynamic Data g(u) g(v) r 10

Update fun f (a, b, c) = let u = a+b in if (u

Update fun f (a, b, c) = let u = a+b in if (u > 0) then g(u) else g(b+c) end -2 2 3 a b c a+b -2+b 0 u 2+c v 5 g'(v) if u>0 then g(u) else g(b+c) 0. 5 12/7/2020 b+c Convex Hull for Dynamic Data g(v) r 11

Adaptivity and Stability n n Adaptivity updates the result by rerunning the parts of

Adaptivity and Stability n n Adaptivity updates the result by rerunning the parts of the computation affected by the input change It is efficient when the computation is “stable”, I. e. , computations on “similar” inputs are “similar” We apply the adaptivity technique to convex hulls Result: Efficient Dynamic and Kinetic convex hulls 12/7/2020 Convex Hull for Dynamic Data 12

1 -D Convex Hull: Max and Min n Just consider upper hull: Finding the

1 -D Convex Hull: Max and Min n Just consider upper hull: Finding the maximum n Consider two algorithms: n n The March: March through the list The Tournament: pair up the elements and take the max of each pair 12/7/2020 Convex Hull for Dynamic Data 13

Kinetic Maximum n Numbers increase/decrease continuously in time ni(t) = ni + ci t

Kinetic Maximum n Numbers increase/decrease continuously in time ni(t) = ni + ci t ni n 1(t) = 2+t n 2(t) = 5 n 3(t) = 6 -t tred = 0 12/7/2020 tgreen = 1 tblue = 3 Convex Hull for Dynamic Data time 14

Sampling n 1(t) = 2+t ni n 2(t) = 5 n 3(t) = 6

Sampling n 1(t) = 2+t ni n 2(t) = 5 n 3(t) = 6 -t tred = 0 12/7/2020 tgreen = 1 tblue = 3 Convex Hull for Dynamic Data time 15

Internal and External Events External event: Final result changes Internal event: Final result does

Internal and External Events External event: Final result changes Internal event: Final result does not change but a test fails 12/7/2020 Convex Hull for Dynamic Data 16

Proof Simulation via Certificates n n A set of comparisons that prove the current

Proof Simulation via Certificates n n A set of comparisons that prove the current maximum Associate a certificate with each comparison n n certificate = comparison result + failure time Consider the times that a certificate fails We need an algorithm that updates the result as well as the certificates Use adaptivity to obtain to do the update efficiently 12/7/2020 Convex Hull for Dynamic Data 17

Kinetic March 0. 5 Time=0 4+t 0. 66 4 5 -t 1 7+1. 5

Kinetic March 0. 5 Time=0 4+t 0. 66 4 5 -t 1 7+1. 5 t 6 3 8 4 0. 66 Time=0. 5+e 4+t 5 -t 1 7+1. 5 t 6 3 8 4 Time=0. 66+e 4+t 5 -t 1 7+1. 5 t 6 3 8 4 12/7/2020 Convex Hull for Dynamic Data 18

Kinetic March Performance n n O(n): Because an item in the beginning of the

Kinetic March Performance n n O(n): Because an item in the beginning of the list could become the maximum and it will be compared to the rest of the list Not acceptable because computing from scratch takes O(n) 12/7/2020 Convex Hull for Dynamic Data 19

The Kinetic Tournament Time = 0 8 7 5 -t f = 2 7

The Kinetic Tournament Time = 0 8 7 5 -t f = 2 7 7 12/7/2020 8 4 1+t 5 -t 6 6 8 3 Convex Hull for Dynamic Data 8 4 20

The Kinetic Tournament 8 Time=2+e 7 f=6 7 7 12/7/2020 8 1+t 4 1+t

The Kinetic Tournament 8 Time=2+e 7 f=6 7 7 12/7/2020 8 1+t 4 1+t 5 -t 6 6 8 3 Convex Hull for Dynamic Data 8 4 21

The Kinetic Tournament 8 Time=6+e f=7 1+t 7 7 12/7/2020 8 1+t 4 1+t

The Kinetic Tournament 8 Time=6+e f=7 1+t 7 7 12/7/2020 8 1+t 4 1+t 5 -t 6 6 8 3 Convex Hull for Dynamic Data 8 4 22

The Kinetic Tournament 1+t Time=7+e f=7 1+t 7 7 12/7/2020 8 1+t 4 1+t

The Kinetic Tournament 1+t Time=7+e f=7 1+t 7 7 12/7/2020 8 1+t 4 1+t 5 -t 6 6 8 3 Convex Hull for Dynamic Data 8 4 23

Performance of Kinetic Tournament n n Worst case log n time per event This

Performance of Kinetic Tournament n n Worst case log n time per event This kinetic algorithm is an adaptive version of the standard tournament algorithm for finding maximum 12/7/2020 Convex Hull for Dynamic Data 24

2 -D Convex Hull n n n Many algorithms: Quick Hull, Graham Scan, Incremental,

2 -D Convex Hull n n n Many algorithms: Quick Hull, Graham Scan, Incremental, Merge Hull, Ultimate, Improved Ultimate. . . We will focus on the Quick Hull algorithm Input: A list of points P Output: The boundary points on the hull of P Example: Input = [a, b, c, d] Output = [a, b, d] a b c d 12/7/2020 Convex Hull for Dynamic Data 25

Quick Hull Example J O B F H D K G A I C

Quick Hull Example J O B F H D K G A I C M P L E N [A B C D E F G H I J K L M N O P] 12/7/2020 Convex Hull for Dynamic Data 26

Quick Hull Example - Filter J O B F H D K G A

Quick Hull Example - Filter J O B F H D K G A I C M P L E N [ A B D F G H J K M O P] 12/7/2020 Convex Hull for Dynamic Data 27

Quick Hull Example - Maximum J O B F H D K G A

Quick Hull Example - Maximum J O B F H D K G A I C M P L E N [A B D F G H J K M O P] 12/7/2020 Convex Hull for Dynamic Data 28

Quick Hull Example - Filter J O B F M H D K G

Quick Hull Example - Filter J O B F M H D K G A I C P L E N [ [A B F J ] [J O P] ] 12/7/2020 Convex Hull for Dynamic Data 29

Quick Hull Example - Maximum J O B F M H D K G

Quick Hull Example - Maximum J O B F M H D K G A I C P L E N [[A B F J] [J O P] ] 12/7/2020 Convex Hull for Dynamic Data 30

Quick Hull Example - Base Case J O B F M H D K

Quick Hull Example - Base Case J O B F M H D K G A I C P L E N [ [A B] [B J] [J O P] ] 12/7/2020 Convex Hull for Dynamic Data 31

Quick Hull Example - Done J O B F H D K G A

Quick Hull Example - Done J O B F H D K G A I C M P L E N [ [A B] [B J] [J O] [O P] ] 12/7/2020 Convex Hull for Dynamic Data 32

Kinetic Quick Hull n Two kinds of tests: Line-side and distance comparisons Filtering =>

Kinetic Quick Hull n Two kinds of tests: Line-side and distance comparisons Filtering => Line Side Finding the furthest point => Distance comparisons n Have certificates for these two events that is all n n 12/7/2020 Convex Hull for Dynamic Data 33

Line Side Test Fails J O B F M H D K G A

Line Side Test Fails J O B F M H D K G A P L C E I N [ A B D F G H J K M O P] 12/7/2020 Convex Hull for Dynamic Data 34

“I” is inserted in the middle of the list J O B F M

“I” is inserted in the middle of the list J O B F M H D G I A K P L C E N [A B D F G I H J K M O P] 12/7/2020 Convex Hull for Dynamic Data 35

Recompute Maximum J O B F M H D G I A K P

Recompute Maximum J O B F M H D G I A K P L C E N [A B D F G I H J K M O P] 12/7/2020 Convex Hull for Dynamic Data 36

Dynamic Tournament - Random Trees 8 7 7 12/7/2020 1 8 5 6 6

Dynamic Tournament - Random Trees 8 7 7 12/7/2020 1 8 5 6 6 8 3 8 4 4 Convex Hull for Dynamic Data 37

Dynamic Tournament - Random Trees 8 7 7 12/7/2020 4 8 5 1 6

Dynamic Tournament - Random Trees 8 7 7 12/7/2020 4 8 5 1 6 6 6 8 3 8 4 9 Convex Hull for Dynamic Data 38

Dynamic Tournament - Random Trees 9 7 7 12/7/2020 4 9 5 1 9

Dynamic Tournament - Random Trees 9 7 7 12/7/2020 4 9 5 1 9 3 9 6 8 8 4 9 Convex Hull for Dynamic Data 39

Distance Comparison Fails - Case 1 J O B F H D K G

Distance Comparison Fails - Case 1 J O B F H D K G A I C M P L E N [A B D F G H J K M O P] 12/7/2020 Convex Hull for Dynamic Data 40

Distance Comparison Fails - Case 2 J O B F H D K G

Distance Comparison Fails - Case 2 J O B F H D K G A I C M P L E N [A B D F G H J K M O P] 12/7/2020 Convex Hull for Dynamic Data 41

“B” is the new maximum B J O F H D K G A

“B” is the new maximum B J O F H D K G A I C M P L E N [A B D F G H J K M O P] 12/7/2020 Convex Hull for Dynamic Data 42

New recursive calls B J O F M H D K G A I

New recursive calls B J O F M H D K G A I C P L E N [[A B] [J M O]] 12/7/2020 Convex Hull for Dynamic Data 43

Experiments 12/7/2020 Convex Hull for Dynamic Data 44

Experiments 12/7/2020 Convex Hull for Dynamic Data 44

Summary of Convex. Hull Work n n n Kinetic Algorithms for convex hulls using

Summary of Convex. Hull Work n n n Kinetic Algorithms for convex hulls using adaptivity n Timothy Chan’s O(h log n) algorithm: Improved “Ultimate Convex Hull”: Have a working version n Quick. Hull Bounce events: Can maintain convex hull of points in a box the points bounce off of the walls of the box Streamlined library for kinetic convex hulls in the SML language n 12/7/2020 A standard algorithm can be made kinetic in a few hours of work Convex Hull for Dynamic Data 45

Parallel Tree Contraction � � Fundamental technique [Miller & Reif ‘ 85] Contraction proceeeds

Parallel Tree Contraction � � Fundamental technique [Miller & Reif ‘ 85] Contraction proceeeds in rounds � � � Each round shrinks the tree by a constant factor Expected O(logn) rounds Innovative Idea: Shrink the tree by local operations 12/7/2020 Convex Hull for Dynamic Data 46

Parallel Tree Contraction n n Start with a tree In each round: n n

Parallel Tree Contraction n n Start with a tree In each round: n n Each node flips a coin If leaf node then rake If degree=2 and flip = H, and neighbors = T then contract Expected O(logn) rounds. 12/7/2020 Convex Hull for Dynamic Data 47

Example H H T T H T 12/7/2020 Convex Hull for Dynamic Data 48

Example H H T T H T 12/7/2020 Convex Hull for Dynamic Data 48

Contracting and Raking H H T T H T 12/7/2020 Convex Hull for Dynamic

Contracting and Raking H H T T H T 12/7/2020 Convex Hull for Dynamic Data 49

Contracting and Raking H 12/7/2020 T Convex Hull for Dynamic Data T 50

Contracting and Raking H 12/7/2020 T Convex Hull for Dynamic Data T 50

Contracting and Raking (cont. ) H 12/7/2020 T Convex Hull for Dynamic Data T

Contracting and Raking (cont. ) H 12/7/2020 T Convex Hull for Dynamic Data T 51

Done H 12/7/2020 Convex Hull for Dynamic Data 52

Done H 12/7/2020 Convex Hull for Dynamic Data 52

Dynamic Trees Problem §Given a forest of weighted trees §Operations § Link: edge insertion

Dynamic Trees Problem §Given a forest of weighted trees §Operations § Link: edge insertion § cut: edge deletion § Queries § Heaviest edge in a subtree? § Heaviest edge on a path? 12/7/2020 Convex Hull for Dynamic Data 53

Data Structures for Dynamic Trees § Sleator Tarjan ‘ 85 § Amortized O(logn) and

Data Structures for Dynamic Trees § Sleator Tarjan ‘ 85 § Amortized O(logn) and worst-case O(logn) § Topology Trees [Frederickson ‘ 93] § Ternary (degree-tree) trees § Worst case O(logn) § Top Trees [Alstrup. Ho. Li. Th ‘ 97] § Generalize Topology Trees for arbitrary degree § Idea: Trees as paths 12/7/2020 Convex Hull for Dynamic Data 54

Dynamic Parallel Tree Contraction n n Keep a copy of each round of the

Dynamic Parallel Tree Contraction n n Keep a copy of each round of the initial run. Each round affects next round. The nodes that “live” to the next round copy their neighbors scars, and pointers to them. Dependencies are based on what the node reads to do its work. 12/7/2020 Convex Hull for Dynamic Data 55

Dynamic Parallel Tree Contraction H T x T H Tx 12/7/2020 T T H

Dynamic Parallel Tree Contraction H T x T H Tx 12/7/2020 T T H H T T x T H x Tx H T x T x Convex Hull for Dynamic Data 56

Propagation n n If any data changes nodes whose action depend on that data

Propagation n n If any data changes nodes whose action depend on that data are woken up. Wake-up only those nodes that get affected by a change. Run same code as in original run. Expected constant amount of nodes woken up per round. 12/7/2020 Convex Hull for Dynamic Data 57

Change an edge H T x T H Tx 12/7/2020 T T H H

Change an edge H T x T H Tx 12/7/2020 T T H H T T x T H x Tx H T x T x Convex Hull for Dynamic Data 58

Three nodes woken up H T x T H Tx 12/7/2020 T T H

Three nodes woken up H T x T H Tx 12/7/2020 T T H H T T x T H x Tx H T x T x Convex Hull for Dynamic Data 59

Nodes rerun code, more nodes woken up H T x T H Tx 12/7/2020

Nodes rerun code, more nodes woken up H T x T H Tx 12/7/2020 T T H H T T x T H x Tx H T x T x Convex Hull for Dynamic Data 60

Propagation continued H T x T H Tx 12/7/2020 T T H H T

Propagation continued H T x T H Tx 12/7/2020 T T H H T T x T H x Tx H T x T x Convex Hull for Dynamic Data 61

Experimental Results 12/7/2020 Convex Hull for Dynamic Data 62

Experimental Results 12/7/2020 Convex Hull for Dynamic Data 62

Work In Progress n n n Analyzing Power of the data structure (what it

Work In Progress n n n Analyzing Power of the data structure (what it can and cannot do) Different Applications Analyzing Running times for: n Different changes. n Unbalanced Trees. 12/7/2020 Convex Hull for Dynamic Data 63

Conclusion and Future Work n Convex. Hull n n n Used adaptivity to solve

Conclusion and Future Work n Convex. Hull n n n Used adaptivity to solve the kinetic convex hull problem. Encouraging results. Adaptivity makes writing dynamic/kinetic algorithms a simple edition on the standard algorithm The quickhull algorithm updates based on events efficiently in the expected case. Parrallel Tree Contraction n Efficient times O(log(n)) expected time for an update. n 12/7/2020 Future Work: n More Applications Convex Hull for Dynamic Data 64