Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy...

30
Dynamic Point Location Dynamic Point Location via via Self-Adjusting Computation Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska Aladdin Center - Summer 2004
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    213
  • download

    0

Transcript of Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy...

Page 1: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Dynamic Point Location Dynamic Point Location via via

Self-Adjusting ComputationSelf-Adjusting Computation

Kanat Tangwongsan

Joint work withGuy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska

Aladdin Center - Summer 2004

Page 2: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

The Planar Point Location The Planar Point Location ProblemProblem

• Classical geometric retrieval problem.Classical geometric retrieval problem.• Subdivide a Euclidean plane into polygons by line Subdivide a Euclidean plane into polygons by line

segments. (These segments intersect only at their segments. (These segments intersect only at their endpoints).endpoints).

• Identify which polygon the query point (red spot) is Identify which polygon the query point (red spot) is in.in.

Page 3: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Dynamic Point-locationDynamic Point-location

• insert, delete segmentsinsert, delete segments• query for pointquery for point

Page 4: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

ApproachesApproaches

• Approach I: Approach I: dynamic by designdynamic by design– Usually complex, and cannot be composed togetherUsually complex, and cannot be composed together

• Approach II: Approach II: re-run the algorithm when input changesre-run the algorithm when input changes– Very simple Very simple – GeneralGeneral– Poor performancePoor performance

• Approach III: Approach III: smart re-executionsmart re-execution– Identify the affected pieces and re-execute only the Identify the affected pieces and re-execute only the

affected parts affected parts – More efficient. More efficient. – Perhaps, takes only time proportional to the “edit Perhaps, takes only time proportional to the “edit

distance”.distance”.

Page 5: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Smart re-execution in Point-Smart re-execution in Point-LocationLocation

• Identify point-location algorithms that are easily Identify point-location algorithms that are easily adapted to do “smart re-execution” efficiently.adapted to do “smart re-execution” efficiently.

• Sarnak-Tarjan, 1986Sarnak-Tarjan, 1986– Simple and elegantSimple and elegant– Idea: (partial) persistenceIdea: (partial) persistence

• OO(log (log nn))-query-time, -query-time, OO((nn)-)-space solution.space solution.

– Static: unable to insert/delete segments Static: unable to insert/delete segments – Equivalent to storing a “persistent” sorted setEquivalent to storing a “persistent” sorted set

Page 6: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Sarnak-Tarjan IdeasSarnak-Tarjan Ideas

• Draw a vertical line through each vertex, splitting the plane Draw a vertical line through each vertex, splitting the plane into vertical slabs. Yield into vertical slabs. Yield OO(log (log nn)-)-query time. query time. (Dobkin-Lipton)(Dobkin-Lipton)

Page 7: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

• Sets of line segments intersecting contiguous slabs are similar. Sets of line segments intersecting contiguous slabs are similar. (Cole)(Cole)

• Reduces the problem to storing a “persistent” sorted set.Reduces the problem to storing a “persistent” sorted set.

AA BB

Page 8: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Automatic DynamizingAutomatic Dynamizing

MachineMachineSarnak-TarjanSarnak-Tarjan

Dynamic Point-Location Dynamic Point-Location

AlgorithmAlgorithm

• Build an efficient automatic dynamizing machine.Build an efficient automatic dynamizing machine.• Analyze the efficiency of the resulting algorithm.Analyze the efficiency of the resulting algorithm.

Our WorkOur Work

Page 9: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Automatic Dynamizing Automatic Dynamizing MachineMachine

Page 10: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Smart Re-execution (revisitedSmart Re-execution (revisited))

• a.k.a. “self-adjusting computation”a.k.a. “self-adjusting computation”• Pioneer work by Acar et al (in SODA 2004)Pioneer work by Acar et al (in SODA 2004)• IdeaIdea: keep track of who read what and when, so that : keep track of who read what and when, so that

as the input changes, we know exactly who to wake as the input changes, we know exactly who to wake up to re-execute the affected area.up to re-execute the affected area.

• Extensions I worked on:Extensions I worked on:– Previous version: order maintenance is Previous version: order maintenance is OO(log (log nn))

• The need for fast total order set of timestampsThe need for fast total order set of timestamps• New version is amortized O(1)New version is amortized O(1)

– Previously, work only on purely functional programPreviously, work only on purely functional program• Write-onceWrite-once

Page 11: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Closer Look: Order-Maintenance Closer Look: Order-Maintenance ProblemProblem

• Maintain a list of recordsMaintain a list of records• OperationsOperations

– insert (x, r)insert (x, r) insert a new record insert a new record rr after after xx– delete (r)delete (r) delete record delete record rr from the list from the list– order (x, y)order (x, y) tells if x comes before y in the list tells if x comes before y in the list

• Naïve approach: use standard linked-list Naïve approach: use standard linked-list

• Better tricks?Better tricks?– Dietz, Tsakalidis, Dietz-Sleator, Bender et al.Dietz, Tsakalidis, Dietz-Sleator, Bender et al.

x y a p q r t l b

Page 12: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Closer Look: Order-Maintenance Closer Look: Order-Maintenance ProblemProblem(cont.)(cont.)

• Dietz-Sleator, 1987Dietz-Sleator, 1987– Amortized Amortized OO(log (log nn) ) algorithm for insert and algorithm for insert and OO(1)(1) for for

delete/order.delete/order.– Label each record with a special tagLabel each record with a special tag– Size limit at for Size limit at for nn-bit machine-bit machine– Explain the use of two-level constructions to achieve Explain the use of two-level constructions to achieve

OO(1)(1)

• Bender et al, 2002Bender et al, 2002– Same doubly linked-list ideaSame doubly linked-list idea– Achieve similar boundsAchieve similar bounds– Less constrained on sizeLess constrained on size– Also suggest the possibility to achieve Also suggest the possibility to achieve OO(1)(1) bounds bounds

Page 13: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Our SolutionOur Solution

• HybridHybrid– Two levels: Dietz-Sleator’s constructionTwo levels: Dietz-Sleator’s construction– Bender’s for each list (each list is circular, and doubly Bender’s for each list (each list is circular, and doubly

linked)linked)

• Top level contains pointers to the child-level listsTop level contains pointers to the child-level lists• Split the child-level list in half, if #nodes exceeds the Split the child-level list in half, if #nodes exceeds the

constant constant cc (on an (on an nn-bit machine, -bit machine, cc ~ ~ nn) )

xx

Top-levelTop-level

Child-levelChild-level

yy

Page 14: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Running TimeRunning Time

• orderorder//deletedelete: obvious worst-case : obvious worst-case OO(1)(1)• insertinsert: :

– cc is chosen to be roughly is chosen to be roughly loglog NN , , NN = largest = largest integer.integer.

– Intuitively: each ring has ~ Intuitively: each ring has ~ log log nn, , nn = = #records #records

– Since the child ring is small, the bottom level Since the child ring is small, the bottom level is no big deal.is no big deal.

– Roughly, there are top-level nodesRoughly, there are top-level nodes– Thus, spending per Thus, spending per log log nn insertions insertions

Page 15: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Other ChangesOther Changes

• Revised interface: support imperative programRevised interface: support imperative program– Experiment on merge sort, insertion sort, quick sort, Experiment on merge sort, insertion sort, quick sort,

graham scan (convex hull), etc.graham scan (convex hull), etc.

• (in progress) design new techniques for multiple (in progress) design new techniques for multiple writes to each location.writes to each location.– Naturally occur in imperative settingsNaturally occur in imperative settings

Page 16: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Efficiency of Our Efficiency of Our “dynamized” Point-Location “dynamized” Point-Location

Page 17: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Persistent Sorted SetPersistent Sorted Set

Page 18: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

• Skip-listSkip-list– Alternative to balanced search tree – same Alternative to balanced search tree – same OO(log (log nn)) bound bound– Allow searching in a totally ordered set of keysAllow searching in a totally ordered set of keys

• Skip tree [see Motwani-Raghavan Skip tree [see Motwani-Raghavan Randomized AlgorithmsRandomized Algorithms]]– Unique path between any two nodesUnique path between any two nodes– Each right pointer ends at the tallest node of the keyEach right pointer ends at the tallest node of the key

Review: Skip TreeReview: Skip Tree

0

0

1

1

1

1

2 3

3

4 5 6

6

6

7

7

7

7

8 9

9

!

!

!

!

Page 19: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Simplified Point-LocationSimplified Point-Location

• Only horizontal lines Only horizontal lines ((xx11, , xx22, , yy))• Given Given qq = = ((xx**, , yy**)), find the closest line above that point, find the closest line above that point..

• In persistent sorted set,In persistent sorted set,– Line Line ((xx11, , xx22, , yy) ) means insert means insert yy at time at time xx1 1 and delete it at and delete it at xx22

– To look up To look up qq = = ((xx**, , yy**)), do a search at time, do a search at time xx**

• Previous work showsPrevious work shows– Equivalent to the original planar point-location problemEquivalent to the original planar point-location problem

Page 20: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Running Sarnak-TarjanRunning Sarnak-Tarjan

• II = the set of segments i.e. input = the set of segments i.e. input

• AA = our Sarnak-Tarjan algorithm (using skip tree) = our Sarnak-Tarjan algorithm (using skip tree)

• The execution of The execution of AA on on II is a series of insert/delete at is a series of insert/delete at various time.various time.

ppqq

rr

Page 21: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Re-executionRe-execution

• I I ** = the set of segments differing from = the set of segments differing from II by one by one segmentsegment

• For ease, For ease, I I ** = = I I + + {{ss}}, where , where s s = = ((xx11, , xx22, , yy)) is a is a segmentsegment..

• So, So,

ppqq

rr

ss

Insert Insert ss Delete Delete ss

Page 22: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

An IllustrationAn Illustration

ppqq

rr

ss

Page 23: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

• Recall: each Recall: each consists of a search consists of a search• Each search path is a sequence of visited nodes.Each search path is a sequence of visited nodes.• Same search paths except forSame search paths except for

ObservationsObservations

Page 24: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Lemma A: Ancestor relationshipLemma A: Ancestor relationship

• Consider a skip tree with ordered set of keys {Consider a skip tree with ordered set of keys {11, , 22, , …, …, nn}}

• Pr [Pr [i i is on the path to is on the path to ii++dd] = ] = (1/(1/dd).).

ii ii++dd

dd

Page 25: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Lemma A: Ancestor relationshipLemma A: Ancestor relationship(cont.)(cont.)

• Consider a skip tree with ordered set of keys {Consider a skip tree with ordered set of keys {11, , 22, , …, …, nn}}

• Pr [Pr [i i is on the path to is on the path to ii++dd] = ] = (1/(1/dd).).

• Proof:Proof:– level of the keys in between level of the keys in between · · that of that of i i

– Level of each key is independent Level of each key is independent

of one anotherof one another– Thus, Thus,

ii ii++dd

Page 26: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Lemma B: Difference in search-Lemma B: Difference in search-pathpath

• Consider a search to the key Consider a search to the key yy* * (any key)(any key)

• Same path unless happening between Same path unless happening between IIss and and DDss

• The difference is expected The difference is expected (1/(1/dd), where ), where dd = #keys = #keys between between yy and and yy**

Old WorldOld World

yy**

New World

yy**yy

AA((II))AA((II*)*)

Page 27: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

yy**yy

Cost BCost B

Cost ACost A• Let Let VV = #nodes with key = #nodes with key yy visited visited • Pr[Pr[VV = = mm] ]

= Pr[= Pr[VV = = mm|visit |visit yy]]££Pr[visit Pr[visit yy]]

= = 22--m m ££ (1/(1/dd))• Cost A = E[Cost A = E[VV] = ] = (1/(1/dd))

Cost ACost A

Cost BCost B

• Proof omittedProof omitted• Yield same Yield same (1/(1/dd))

Lemma B (cont.)Lemma B (cont.)

Page 28: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

SummarySummary

• Lemma B gives an immediate lower-bound for point-location in Lemma B gives an immediate lower-bound for point-location in this framework. this framework.

where where y’ y’ is the is the yy’s of those lines overlapping with ’s of those lines overlapping with yy, and , and

dd((yy, , y’y’)) = #lines in between = #lines in between yy and and y’ y’ (when searching (when searching for for y’y’) )

• Close to match this boundClose to match this bound– Introducing partial path-copying and probability node Introducing partial path-copying and probability node

copyingcopying

Page 29: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Questions?Questions?

Page 30: Dynamic Point Location via Self-Adjusting Computation Kanat Tangwongsan Joint work with Guy Blelloch, Umut Acar, Srinath Sridhar, Virginia Vassilevska.

Thank Thank you!you!