25
February 6, 2007 Lecture 1: Introduction to Geometr Geometric Computation: Introduction Piotr Indyk

Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Geometric Computation: Introduction

Piotr Indyk

Page 2: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Welcome to 6.850 !

• Overview and goals

• Course Information

• Closest pair• Signup sheet

Page 3: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Geometric Computation

• Geometric computation occurs everywhere:– Robotics: motion planning,

map construction and localization

– Geographic Information Systems (GIS): range search, nearest neighbor

– Simulation: collision detection

– Computer graphics: visibility tests for rendering

– Computer vision: pattern matching

– Computational drug design: spatial indexing

Page 4: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Computational Geometry

• Started in mid 70’s

• Focused on design and analysis of algorithms for geometric problems

• Many problems well-solved

• Many other problems remain open

Page 5: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Course Goals

• Introduction to Computational Geometry– “Classic” results and techniques– New directions

Page 6: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Syllabus• Part I - Classic CG:

– Closest pair– Segment intersection– LP in low dimensions– Polygon triangulation– Range searching– Point location– Arrangements and duality– Voronoi diagrams– Delaunay triangulations– Binary space partitions– Motion planning and Minkowski

sum

Use “Computational Geometry: Algorithms and Applications” by de Berg, van Kreveld, Overmars, Schwarzkopf (2nd edition).

• Part II - New directions in CG:– Approximate nearest neighbor in low

dimensions– Approximate nearest neighbor in high

dimensions: LSH– Low-distortion embeddings– Low-distortion embeddings II

– Geometric algorithms for external memory – Geometric algorithms for streaming data

– Kinetic algorithms– Pattern matching– Combinatorial geometry– Geometric optimization– …

Page 7: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Higher dimensions

Best match for this ?

Page 8: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Course Information

• 3-0-9 H-level Graduate Credit• Grading:

– 4 problem sets (see calendar):• In each PSet:

– Core component (mandatory): 6.046-style– Two optional components:

» More theoretical problems» Java programming assignments

– Can collaborate, but solutions written separately– Midterm (but no final )

• Prerequisites: understanding of algorithms and probability (6.046 level)

Page 9: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Closest pair(one algorithm)

Page 10: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Closest Pair

• Find a closest pair among p1…pn ∈Rd

• Easy to do in O(dn2) time – For all pi ≠pj, compute ||pi – pj||

and choose the minimum

• We will aim for better time, as long as d is “small”

• For now, focus on d=2

Page 11: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Divide and conquer

• Divide: – Compute the median of x-

coordinates

– Split the points into PL and PR, each of size n/2

• Conquer: compute the closest pairs for PL and PR

• Combine the results (the hard part)

Page 12: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Combine

• Let k=min(k1,k2)• Observe:

– Need to check only pairs which cross the dividing line

– Only interested in pairs within distance < k

• Suffices to look at points in the 2k-width strip around the median line

k1

k2

2k

Page 13: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Scanning the strip

• Sort all points in the strip by their y-coordinates, forming q1…qt, t ≤ n.

• Let yi be the y-coordinate of qi

• kmin= k• For i=1 to t

– j=i-1– While yi-yj < k

• If ||qi–qj||<kmin then kmin=||qi–qj||• j:=j-1

• Report kmin (and the corresponding pair)

kk

k

k k

Page 14: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Analysis

• Correctness: easy• Running time is more

involved• Can we have many

qj’s that are within distance k from qi ?

• No• Proof by packing

argument

k

Page 15: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Analysis, ctd.

Theorem: there are at most 7 qj’s , j<i, such that yi-yj ≤ k.

Proof: • Each such qj must lie either

in the left or in the right k × k square

• Within each square, all points have distance distance ≥ k from others

• We can pack at most 4 such points into one square, so we have 8 points total (incl. qi)

qi

Page 16: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

At most 4

• Split the square into 4 sub-squares of size k/2 × k/2

• Diameter of each square is k/21/2 < k → at most one point per sub-square

Page 17: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Running time

• Divide: O(n)• Combine: O(n log n) because we sort by y• However, we can:

– Sort all points by y at the beginning– Divide preserves the y-order of pointsThen combine takes only O(n)

• We get T(n)=2T(n/2)+O(n), so T(n)=O(n log n)

Page 18: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Closest pair ctd. (two more algorithms for the curious; will try to cover this

later in the term)

Page 19: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Closest Pair with Help

• Given: P={p1…pn} of points from Rd, such that the closest distance is in (t,c t]

• Goal: find the closest pair

• Will give an O((2c d1/2)d n) time algorithm

• Note: by scaling we can assume t=1

Page 20: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Algorithm• Impose a cubic grid onto Rd, where

each cell is a 1/d1/2 ×1/d1/2 cube• Put each point into a bucket

corresponding to the cell it belongs to

• Diameter of each cell is ≤1, so at most one point per cell

• For each p∈P, check all points in cells intersecting a ball B(p,c)

• How many cells are there ?– All are contained in a d-dimensional

box of side 2(c+1/d1/2) ≤ 2(c+1)– At most (2 d1/2 (c+1) )d such cells

• Total time: O((2c d1/2)d n)

p

Page 21: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

How to find good “resolution” t ?

• Repeat:– Choose a random point p in P– Let t=NN(p)=minq∈P-{p} ||p-q||– Impose a grid with side t’=t/(2d1/2)-δ– Put the points into the grid cells– Remove all points whose all adjacent cells

are empty• Until P is empty• Observations:

– The diameter of two adjacent cells is 2t’d1/2 < t ⇒ points p’ with NN(p’)≥t never survive– Points p’ with NN(p’)<t’ always survive

p

t’

t

Page 22: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Correctness

• Consider t computed in the final iteration– There is a pair of points with distance t (it defines t)– There is no pair of points with distance less

than t’ (as per previous slide)– We get c=t/t’~ 2 d1/2

Page 23: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Running time

• Consider NN(p1)…NN(pm)

• An iteration is lucky if NN(pi) ≥ t for at last half of points pi

• The probability of being lucky is ≥1/2 • Expected #iterations till a lucky one is ≤2• After we are lucky, the number of points is

≤ m/2• Total expected time = 3d times

O(n+n/2+n/4+…+1)

Page 24: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Conclusions

• Closest pair:– O(n log n) for d=2– ndO(d) for general d

Page 25: Geometric Computation: Introductionweb.mit.edu/alexmv/Public/6.850-lectures/lecture01.pdf · 2007-12-20 · February 6, 2007 Lecture 1: Introduction to Geometric Computation Algorithm

February 6, 2007 Lecture 1: Introduction to Geometric Computation

Higher dimensions (sketch)

• Divide: split P into PL and PR using the hyperplane x=t

• Conquer: as before• Combine:

– Need to take care of points with x in [t-k,t+k]– This is essentially the same problem, but in d-1

dimensions– We get:

• T(n,d)=2T(n/2, d)+T(n,d-1)• T(n,1)=Od(1) n

– Solves to: T(n,d)=n logd-1 n