teaching geometric algorithms to gracefully “walk” and “jump” kanat tangwongsan aladdin 2005...

28
Teaching Teaching Geometric Geometric Algorithms to Gracefully Algorithms to Gracefully “Walk” “Walk” and and “Jump” “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes. Guy Blelloch, and Jorge Vittes.

Post on 21-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

TeachingTeaching Geometric Algorithms Geometric Algorithms to Gracefully to Gracefully “Walk”“Walk” and and “Jump”“Jump”

Kanat TangwongsanALADDIN 2005

Joint work with Umut Acar, Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes.Guy Blelloch, and Jorge Vittes.

Page 2: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

A “Simple” Problem

• The Convex Hull Problem– Given: a set S µ R 3

– Maintain: smallest convex set containing S

Input:Input: S S

Output: Output: CHCH((S)S)

Page 3: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

A “Simple” Problem (cont.)

• The Kinetic Convex Hull Problem– points continuously moving

• Imagine making a movie!

Page 4: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Facts…

• Trivial solution: calculate the CH for every frame.

• Better solution? Unfortunately, no known efficient solution.

• To support only insertion/deletion is super complicated already.

• Implication: Kinetic algorithm for CH in 3D is rather HOPELESS!

Page 5: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

...To Conserve Our Brain Cells,

we chose a different approach…

Page 6: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

In this Talk…• Recap of the self-adjusting framework.• Our design/implementation of a kinetic

framework.– Generated the movie we see previously.

• Discuss a few applications of the framework.– Jumping ahead in time and its beneficial

consequences. – Analysis of two algorithms.

• New problems for future work.

Page 7: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Self-Adjusting Computation

main

f gh

k m

main

f g

h

k m

Memory

Some parts of the input changeSome parts of the input change

IdeaIdea: Record who reads what and when : Record who reads what and when

Note: Some part of the computation can be re-used by applying the memoization technique.

Page 8: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

The Kinetic Framework

• Static Geometric Algorithm:– Input: a set S µ Rd Output: A(S)

• Goal: enable straight-forward methodical transformation of a static geometric algorithm:– to handle continuous motioncontinuous motion.– to allow insertion/deletion of pointsinsertion/deletion of points.– to allow motion parameters updatemotion parameters update at any

time.– to support compositioncomposition of algorithms.

Page 9: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

The Kinetic Framework (cont.)

• Idea: insert a tracking code into an existing code.

• Builds on the self-adjusting computation framework.– immediate dynamization

• Introduce certificate– test/comparison– expires when the current value is

invalid.– Illustration (next slide).

Self-Adjusting Computation

Our Kinetic Library

Page 10: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

The Kinetic Framework (cont.) [An Example]

• Given: a list of moving points in R2.• Calculate: the right-most point (assuming

no tie at all time)• Trivial algorithm: maintain the max so far and

scan the list

p0 <L p1 p1 <L p2

Y

p0 <L p2

N

p2

p1

p2

p0

Y

Y

N

N

Page 11: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

The Kinetic Framework (cont.)

• In theory: – able to kinetize every algorithm

whose certificate’s expiration time can be computed.

• Efficiency? not always!

p0 <L p1 p1 <L p2

Y

p0 <L p2

N

p2

p1

p2

Y

Y

N

N

p0

certificate = comparsion result + expiration time

Page 12: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Our Kinetic Library• SML library (compatible with SML/NJ and

MLton) ~ 700 lines of SML code• Builds atop the self-adjusting library

– A Library for Self-Adjusting Computation (to appear in ML 2005)

• Priority queue of certificate failure times. Self-adjusting computation to reflect the changes.

• We were able to kinetize – 2d: Graham-scan, Merge Hull, QuickHull,

Randomized QuickHull– 3d: Incremental Hull

• Benchmark: Pending

Page 13: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Training QuickHull to “Walk”

fun split (p1,p2, pts, hull) = let val l = List.filter (fn p => lineSideTest((p1,p2),p)) pts in case l of nil => bp1::hull | h::t => let

fun selectMin (a,b) = if (distCmp(a, b, (p1,p2)) then a else b

val max = List.foldr selectMin h t val rest = split (max,bp2,l,hull) in split (bp1,max,l,rest) end end

fun splitM (p1, p2, pts, hull) = let val l = filter (fn p => K.mkCert(lineSideTest((p1,p2),p)) pts in l ==> (fn cl => case cl of

ML.NIL => ML.write (ML.CONS(p1,hull)) | ML.CONS(h,t) => hull ==> (fn chull =>

let fun select (a,b) = K.mkCert(distCmp(a,b,(vp1,vp2)))

val rmax = minimum select l val rest = C.modref (rmax ==> (fn max => splitM (max,p2,l,hull)))

in rmax ==> (fn max => splitM (p1,max,l,rest))

end)) end

Static

Kinetic

Page 14: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Jumping Time• An Open Problem [Guibas’98]: How can one

skip ahead in time?• Fact: The set of “certificates” is a correctness

proof wrt. running it from scratch.• Theorem: By advancing the time to t + and

updating the certificates corresponding to events in the queue up to the time t + , the resulting set of certificates after propagation agrees with running it from scratch.

• Efficiency: no worse than processing each event one by one.

Timet t +

Page 15: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Jumping Time (cont.)

• Benefits– Interested in events up to precision? ( can

be chosen to suit one’s need/machine)– Make video more efficiently– Dealing with less floating-point round-off

error

• New Problems– Suppose float precision up to , what should

be to avoid round-off error?– Jumping so far ahead in time? When is it

faster to simply re-run it form scratch?

Page 16: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Introducing the Communist Model

• Coined by Mulmuley’91• Dynamic setting

– Operations: insert/delete– Finite set U, and active set S.– Each element has an equal probability of

being inserted or deleted from the active set.

insert

delete

Page 17: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Stable Randomized QuickHull

• QuickHull (for computing 2d convex hull) – Very Fast in practice– Worst-case: O(n2) – Unstable (in self-adjusting framework)

• Randomize it to stabilize.

Page 18: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Stable Randomized QuickHull (cont.)

Std-Qhull(p1,p2, s)– Eliminate points under

p1p2 to get s’– Pick max from p1p2– Qhull (p1, max, s’)– Qhull (max, p2, s’)

• Idea: Randomly pair up points, and ensure that at least a fraction of points are eliminated with certain probability.

• Build on idea in Wenger’97 and B. Bhattacharya et al ’97, and T. Chan ’95.

Page 19: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Stable Randomized QuickHull (cont.)

• Replace the step marked in red by– Pair up points above the line p1p2

– Pick a random pair, define a line and find the maximizer above that line.

– Apply elimination (as extending from Chan’s)

• There are n/4 pairs on expectation, and max {subproblem L, subproblem R} · 13/16 with probability ¸ 1/2

0 1 0 0 0 1 1

Page 20: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Stable Randomized QuickHull (cont.)

• Extended Chan’s Elimination

• Initial Runtime: O(nlog n) is obvious.• Theorem: Randomized QuickHull

supports insertion/deletion in O(log2 n) • Also perform well practically in kinetic

setting, but QuickHull still outperforms it.

max

Page 21: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Convex Hull in 3D

• Incremental Hull– Simple and efficient – Generalizeable to arbitrary dimension

• Idea: insert points one by one. remove visible faces, and tent new faces.

Page 22: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Incremental Hull in 3D

• Key Requirements– Given a point p, find a

face f that p sees.– Given a face f, find

adjacent faces.

• Solutions– For each face, keep a list of points that

“belongs to” it.– Keep a mapping from points to faces.– Purely functional dictionary: treap

Page 23: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Incremental Hull in 3D (cont.)

DynamizedTreap

IncrementalConvex Hull

in 3D

KineticConvex Hull

in 3D

Page 24: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Incremental Hull in 3D (cont.)

• Fact: In a dynamized treap with uniform distribution of keys, an insertion/deletion takes O(log n)

• Theorem:– O(nlog2 n) for initial run– O(log2 n) for each insert/delete (assuming

the communist model).

• Also experimentally verified.

TimeTime

Page 25: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Experimental Evaluation

Page 26: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Summary

• Implemented a kinetic framework– Generated the movie we see previously.– Capable of skipping ahead in time.

• Analyzed a few Kinetized/Dynamized examples– Graham-scan, Merge Hull, QuickHull,

Randomized QuickHull, IHull3D• In progress

– Trying to formalize the notion of “when an algorithm performs efficiently in this framework” a.k.a kinetic stability

– Per event?

Page 27: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Questions ?

Page 28: Teaching Geometric Algorithms to Gracefully “Walk” and “Jump” Kanat Tangwongsan ALADDIN 2005 Joint work with Umut Acar, Guy Blelloch, and Jorge Vittes

Thank You