![Page 1: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/1.jpg)
Self-Adjusting Computation
Umut Acar
Carnegie Mellon University
Joint work with Guy Blelloch, Robert Harper, Srinath Sridhar, Jorge Vittes, Maverick Woo
![Page 2: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/2.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
2
Dynamic Algorithms
Maintain their input-output relationship as the input changes
Example: A dynamic MST algorithm maintains the MST of a graph as user to insert/delete edges
Useful in many applications involvinginteractive systems, motion, ...
![Page 3: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/3.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
3
Developing Dynamic Algorithms: Approach I
Dynamic by designMany papersAgarwal, Atallah, Bash, Bentley, Chan, Cohen, Demaine, Eppstein, Even, Frederickson, Galil, Guibas, Henzinger, Hershberger, King, Italiano, Mehlhorn, Overmars, Powell, Ramalingam, Roditty, Reif, Reps, Sleator, Tamassia, Tarjan, Thorup, Vitter, ...
Efficient algorithms but can be complex
![Page 4: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/4.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
4
Approach II: Re-execute the algorithm when the input changes
Very simpleGeneralPoor performance
![Page 5: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/5.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
5
Smart re-execution
Suppose we can identify the pieces of execution affected by the input changeRe-execute by re-building only the affected pieces
Execution (A,I)
Execution (A,I+)
![Page 6: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/6.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
6
Smart Re-execution
Time re-execute = O(distance between executions)
Execution (A,I)
Execution (A,I+)
![Page 7: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/7.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
7
Incremental Computation or Dynamization
General techniques for transforming algorithms dynamicMany papers: Alpern, Demers, Field, Hoover, Horwitz, Hudak, Liu, de Moor, Paige, Pugh, Reps, Ryder, Strom, Teitelbaum, Weiser, Yellin...Most effective techniques are
Static Dependence Graphs [Demers, Reps, Teitelbaum ‘81]Memoization [Pugh, Teitelbaum ‘89]
These techniques work well for certain problems
![Page 8: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/8.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
8
Bridging the two worlds
Dynamization simplifies development of dynamic algorithms
but generally yields inefficient algorithms
Algorithmic techniques yield good performance
Can we have the best of the both worlds?
![Page 9: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/9.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
9
Our Work
Dynamization techniques:Dynamic dependence graphs [Acar,Blelloch,Harper ‘02]Adaptive memoization [Acar, Blelloch,Harper ‘04]
Stability: Technique for analyzing performance [ABHVW ‘04]
Provides a reduction from dynamic to static problemsReduces solving a dynamic problem to finding a stable solution to the corresponding static problem
Example: Dynamizing parallel tree contraction algorithm [Miller, Reif 85] yields an efficient solution to the dynamic trees problem [Sleator, Tarjan ‘83], [ABHVW SODA 04]
![Page 10: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/10.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
10
Outline
Dynamic Dependence GraphsAdaptive Memoization
Applications toSortingKinetic Data Structures with experimental resultsRetroactive Data Structures
![Page 11: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/11.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
11
Control dependences arise from function calls
Dynamic Dependence Graphs
![Page 12: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/12.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
12
Control dependences arise from function callsData dependences arise from reading/writing the memory
Dynamic Dependence Graphs
aabb cc
![Page 13: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/13.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
13
Change
Propagation
Change propagation
aabb cc
aabb
cc
![Page 14: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/14.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
14
Change
Propagation
Change propagation
aabb cc
aabb
cc
![Page 15: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/15.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
15
Change
Propagation
Change propagation with Memoization
aabb cc
aabb
cc
![Page 16: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/16.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
16
Change
Propagation
aabb cc
aabb
cc
Change propagation with Memoization
![Page 17: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/17.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
17
Change
Propagation
Change propagation with Memoization
aabb cc
aabb
cc
![Page 18: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/18.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
18
Change
Propagation
Change Propagation with Adaptive Memoization
aabb cc
aabb
cc
![Page 19: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/19.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
19
The Internals
1. Order Maintenance Data Structure [Dietz, Sleator ‘87]Time stamp vertices of the DDG in sequential execution order
2. Priority queue for change propagationpriority = time stampRe-execute functions in sequential execution order
Ensures that a value is updated before being read
3. Hash tables for memoizationRemember results from the previous execution only
4. Constant-time equality tests
![Page 20: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/20.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
20
Standard Quicksortfun qsort (l) = let fun qs (l,rest) = case l of NIL => rest | CONS(h,t) => let (smaller, bigger) = split(h,t) sbigger = qs (bigger,rest) in qs (smaller, CONS(h,sbigger)) end in qs(l,NIL) end
![Page 21: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/21.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
21
Dynamic Quicksortfun qsort (l) = let fun qs (l,rest,d) = read(l, fn l' => case l' of NIL => write (d, rest) | CONS(h,t) => let (less,bigger) = split (h,t) sbigger = mod (fn d => qs(bigger,rest,d)) in qs(less,CONS(h,sbigger,d)) endin modmod (fn d => qs (l,NIL,d)) end
![Page 22: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/22.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
22
Performance of QuicksortDynamized Quicksort updates its output in expected
O(logn) time for insertions/deletions at the end of the inputO(n) time for insertions/deletions at the beginning of the inputO(logn) time for insertions/deletions at a random location
Other Results for insertions/deletions anywhere in the inputDynamized Mergesort: expected O(logn) Dynamized Insertion Sort: expected O(n) Dynamized minimum/maximum/sum/...: expected O(logn)
![Page 23: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/23.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
23
Function Call Tree for Quicksort
![Page 24: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/24.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
24
Function Call Tree for Quicksort
![Page 25: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/25.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
25
Function Call Tree for Quicksort
![Page 26: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/26.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
26
Insertion at the end of the input
![Page 27: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/27.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
27
Insertion in the middle
![Page 28: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/28.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
28
Insertion in the middle
![Page 29: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/29.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
29
Insertion at the start, in linear time
15
1 30
5
3
26 35
4616 279
Input: 15,30,26,1,5,16,27,9,3,35,46
![Page 30: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/30.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
30
Insertion at the start, in linear time
15
1
30
5
3
26 35
4627
9
20
16
15
1 30
5
3
26 35
4616 279
Input: 20,15,30,26,1,5,16,27,9,3,35,46
![Page 31: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/31.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
31
Kinetic Data Structures [Basch,Guibas,Herschberger ‘99]
Goal: Maintain properties of continuously moving objects
Example: A kinetic convex-hull data structure maintains the convex hull of a set of continuously moving objects
![Page 32: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/32.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
32
Kinetic Data StructuresRun a static algorithm to obtain a proof of the propertyCertificate = Comparison + Failure timeInsert the certificates into a priority queue
Priority = Failure time
A framework for handling motion [Guibas, Karavelas, Russel, ALENEX 04]
while queue empty do { certificate = remove (queue) flip (certificate) update the certificate set (proof) }
![Page 33: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/33.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
33
Kinetic Data Structures via Self-Adjusting Computation
Update the proof automatically with change propagation
A library for kinetic data structures [Acar, Blelloch, Vittes]Quicksort: expected O(1), Mergesort: expected O(1)Quick Hull, Chan’s algorithm, Merge Hull: expected O(logn)
while queue empty do { certificate = remove (queue) flip (certificate) propagate ()}
![Page 34: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/34.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
34
Quick Hull: Find Min and Max
A
C
B
D
F
G
H
I
E
J
M
K
L
N
O
P
[A B C D E F G H I J K L M N O P]
![Page 35: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/35.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
35
Quick Hull: Furthest Point
A
C
B
D
F
G
H
I
E
J
M
K
L
N
O
P
[A B D F G H J K M O P]
![Page 36: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/36.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
36
Quick Hull: Filter
A
C
B
D
F
G
H
I
E
J
M
K
L
N
O
P
[ [A B F J ] [J O P] ]
![Page 37: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/37.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
37
Quick Hull: Find left hull
A
C
B
D
F
G
H
I
E
J
M
K
L
N
O
P
[ [A B] [B J] [J O] [O P] ]
![Page 38: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/38.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
38
Quick Hull: Done
A
C
B
D
F
G
H
I
E
J
M
K
L
N
O
P
[ [A B] [B J] [J O] [O P] ]
![Page 39: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/39.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
39
Static Quick Hull fun findHull(line as (p1,p2),l,hull) = let pts = filter l (fn p => Geo.lineside(p,line)) in case pts of EMPTY => CONS(p1, hull) | _ => let pm = max (Geo.dist line) l left = findHull((pm,p2),l,hull,dest) full = findHull((p1,pm),l,left) in full end end fun quickHull l = let (mx,xx) = minmax (Geo.minX, Geo.maxX) l in findHull((mx,xx),points,CONS(xx,NIL) end
![Page 40: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/40.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
40
Kinetic Quick Hullfun findHull(line as (p1,p2),l,hull,dest) = let pts = filter l(fn p => Kin.lineside(p,line))in modr (fn dest => read l (fn l => case l of NIL => write(dest,CONS(p1, hull)) | _ => read (max (Kin.dist line) l) (fn pm => let gr = modr (fn d => findHull((pm,p2),l,hull,d)) in findHull((p1,pm),l,gr,dest)))) end end
fun quickHull l = let (mx,xx) = minmax (Kin.minX, Kin.maxX) lin modr(fn d => read (mx,xx)(fn (mx,xx) => split ((mx,xx),l, CONS(xx,NIL),d)))) end
![Page 41: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/41.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
41
Kinetic Quick Hull
Input size
Cert
ificate
s /
Even
t
![Page 42: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/42.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
42
Dynamic and Kinetic Changes
Often interested in dynamic as well as kinetic changesInsert and delete objectsChange the motion plan, e.g., direction, velocity
Easily programmed via self-adjusting computationExample: Kinetic Quick Hull code is both dynamic and kinetic
Batch changesReal time changes: Can maintain partially correct data structures (stop propagation when time expires)
![Page 43: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/43.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
43
Retroactive Data Structures[Demaine, Iacono, Langerman ‘04]
Can change the sequence of operations performed on the data structure
Example: A retroactive queue would allow the user to go back in time and insert/remove an item
![Page 44: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/44.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
44
Retroactive Data Structures via Self-Adjusting Computation
Dynamize the static algorithm that takes as input the list of operations performed
Example: retroactive queuesInput: list of insert/remove operationsOutput: list of items removed Retroactive change: change the input list and propagate
![Page 45: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/45.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
45
Rake and Compress Trees [Acar,Blelloch,Vittes]
Obtained by dynamizing tree contraction [ABHVW ‘04]
Experimental analysisImplemented and applied to a broad set of applications
Path queries, subtree queries, non-local queries etc.
For path queries, compared to Link-Cut Trees [Werneck]
Structural changes are relatively slow Data changes are faster
![Page 46: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/46.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
46
Conclusions
Automatic dynamization techniques can yield efficient dynamic and kinetic algorithms/data structuresGeneral-purpose techniques for
transforming static algorithms to dynamic and kineticanalyzing their performance
Applications to kinetic and retroactive data structuresReduce dynamic problems to static problems
Future work: Lots of interesting problemsDynamic/kinetic/retroactive data structures
![Page 47: Self-Adjusting Computation Umut Acar Carnegie Mellon University](https://reader036.vdocuments.us/reader036/viewer/2022062518/568146c1550346895db3f681/html5/thumbnails/47.jpg)
14 January 2004 Workshop on Dynamic Algorithms and Applications
47
Thank you!