Algorithms for Geographic Data Spring 2016 Lecture 2: Similarity - - PowerPoint PPT Presentation

algorithms for geographic data
SMART_READER_LITE
LIVE PREVIEW

Algorithms for Geographic Data Spring 2016 Lecture 2: Similarity - - PowerPoint PPT Presentation

2IMA20 Algorithms for Geographic Data Spring 2016 Lecture 2: Similarity Trajectories Model for the movement of a (point) object; f : [ time interval ] 2D or 3D Trajectories Model for the movement of a (point) object; f : [ time


slide-1
SLIDE 1

2IMA20 Algorithms for Geographic Data

Spring 2016 Lecture 2: Similarity

slide-2
SLIDE 2

Trajectories

 Model for the movement of a (point) object;

f : [ time interval ] 2D or 3D

slide-3
SLIDE 3

Trajectories

 Model for the movement of a (point) object;

f : [ time interval ] 2D or 3D

 The path of a trajectory is just any curve

slide-4
SLIDE 4

Trajectories vs trajectory data

slide-5
SLIDE 5

Trajectory data

 The data as it is acquired by e.g. GPS:

sequence of triples (spatial plus time-stamp); quadruples for trajectories in 3D (xi,yi,ti) (x2,y2,t2) (x1,y1,t1) (xn,yn,tn)

slide-6
SLIDE 6

Trajectory data

 Typical assumption for sufficiently densely sampled data:

constant velocity between consecutive samples ➨ velocity/speed is a piecewise constant function (xi,yi,ti) (x2,y2,t2) (x1,y1,t1) (xn,yn,tn)

slide-7
SLIDE 7

Trajectory data analysis

Questions “How much time does a gull typically spend foraging on a trip from the colony and back?”

slide-8
SLIDE 8

Trajectory data analysis

Questions “How much time does a gull typically spend foraging on a trip from the colony and back?” “If customers look at book display X, do they more often than average also go to and look at bookshelf Y?”

slide-9
SLIDE 9

Trajectory data analysis

Questions “How much time does a gull typically spend foraging on a trip from the colony and back?” “If customers look at book display X, do they more often than average also go to and look at bookshelf Y?” “Is this Alzheimer patient in need of assistance?”

slide-10
SLIDE 10

Abstract / general purpose questions

Single trajectory

 simplification, cleaning  segmentation into semantically meaningful parts  finding recurring patterns (repeated subtrajectories)

Two trajectories

 similarity computation  subtrajectory similarity

Multiple trajectories

 clustering, outliers  flocking/grouping pattern detection  finding a typical trajectory or computing a mean/median

trajectory

 visualization

slide-11
SLIDE 11

Fundamental tools: clustering

When are two trajectories similar? In many cases the spatial similarity is more important than the temporal aspect.

slide-12
SLIDE 12

Similarity of curves … many measures

  • Agrawal, Lin, Sawhney & Shim, 1995
  • Alt & Godau, 1995
  • Yi, Jagadish & Faloutsos, 1998
  • Gaffney & Smyth, 1999
  • Kalpakis, Gada & Puttagunta, 2001
  • Vlachos, Gunopulos & Kollios, 2002
  • Gunopoulos, 2002
  • Mamoulis, Cao, Kollios, Hadjieleftheriou, Tao & Cheung, 2004
  • Chen, Ozsu & Oria, 2005
  • Nanni & Pedreschi, 2006
  • Van Kreveld & Luo, 2007
  • Gaffney, Robertson, Smyth, Camargo & Ghil, 2007
  • Lee, Han & Whang, 2007
  • Buchin, Buchin, van Kreveld & Luo, 2009
  • Agarwal, Aranov, van Kreveld, Löffler & Silveira, 2010
  • Sankaraman, Agarwal, Molhave, Pan and Boedihardjo, 2013
  • ...
slide-13
SLIDE 13

Similarity measures

 Input: Two polygonal curves P and Q of size m in Rd  Approach: Map curve into a point in dm-dimensional space

2D 10D

slide-14
SLIDE 14

Similarity measures

 Input: Two polygonal curves P and Q of size m in Rd  Approach: Map curve into a point in dm-dimensional space

2D 10D Similar?

slide-15
SLIDE 15

Similarity measures

 Input: Two polygonal curves P and Q of size m in Rd  Approach: Map curve into a point in dm-dimensional space  Drawbacks: P and Q must have same number points only takes the

vertices into consideration

2D 6D Not similar

slide-16
SLIDE 16

Similarity measures

 Input: Two polygonal curves P and Q of size m in Rd  Approach: Map curve into a point in dm-dimensional space  Drawbacks: P and Q must have same number points only takes the

vertices into consideration

2D 6D Not similar

slide-17
SLIDE 17

Similarity measures: Hausdorff

 Input: Two polygonal curves P and Q in Rd  Distance: Hausdorff distance

P P Q Q H(PQ) = maxpP minqQ |p-q| dH(P,Q) = max [H(PQ), H(QP)]

slide-18
SLIDE 18

Similarity measures: Hausdorff

P Q

 Input: Two polygonal curves P and Q in Rd  Distance: Hausdorff distance  Drawbacks: Fail to capture the distance between curves.

H(PQ) = maxpP minqQ |p-q| dH(P,Q) = max [H(PQ), H(QP)]

slide-19
SLIDE 19

Similarity measures: Aligning sequences

 Input: Two polygonal curves P and Q in Rd  Other interesting measures are:

  • Dynamic Time Warping (DTW)
  • Longest Common Subsequence (LCSS)
  • Model-Driven matching (MDM)
slide-20
SLIDE 20

Dynamic Time Warping (DTW)

Euclidean Distance One-to-one alignments Time Warping Distance Non-linear alignments are allowed

slide-21
SLIDE 21

Calculating DTW

Q C

   

 

K k k

w C Q DTW

1

min ) , (

Warping path w

Q C Q C

distance matrix

slide-22
SLIDE 22

TU/e

Prerequisites

22

5 steps in designing dynamic-programming algorithms 1. define subproblems [#subproblems] 2. guess first choice [#choices] 3. give recurrence for the value of an optimal solution [time/subproblem treating recursive calls as (1))] i. define subproblem in terms of a few parameters ii. define variable m[..] = value of optimal solution for subproblem iii. relate subproblems by giving recurrence for m[..] 4. algorithm: fill in table for m [..] in suitable order (or recurse & memoize) 5. solve original problem Running time: #subproblems * time/subproblem Correctness: (i) correctness of recurrence: relate OPT to recurrence (ii) correctness of algorithm: induction using (i)

Q C Q C

slide-23
SLIDE 23

TU/e

Prerequisites

23

Longest common subsequence substring of a string: string that can be obtained by omitting zero or more characters string: A C C A T T G example substrings: A C C A T T G or A C C A T T G or … LCS(X,Y) = a longest common subsequence of strings X and Y = a longest string that is a subsequence of X and a subsequence of Y X = A C C G T A A T C G A C G Y = A C G A T T G C A C T G LCS(X,Y) = ACGTTGACG (or ACGTTCACG …)

slide-24
SLIDE 24

TU/e

Prerequisites

24

The LCS problem Input: strings X = x1 , x2 , … , xn and Y = y1 , y2 , … , ym Output: (the length of) a longest common subsequence of X and Y So we have valid solution = common subsequence profit = length of the subsequence (to be maximized)

slide-25
SLIDE 25

TU/e

Prerequisites

25

X = A C C G T A A T C G A C G Y = A C G A T T G C A C T G LCS for x1…xn-1 and y1…ym-1 so: optimal substructure x1 x2 xn y1 y2 ym Let’s study the structure of an optimal solution

  • what are the choices that need to be made?
  • what are the subproblems that remain? do we have optimal substructure?

first choice: is last character of X matched to last character of Y ?

  • r is last character of X unmatched ?
  • r is last character of Y unmatched ?

greedy choice ?

  • verlapping subproblems ?
  • ptimal solution
slide-26
SLIDE 26

TU/e

Prerequisites

26

5 steps in designing dynamic-programming algorithms 1. define subproblems 2. guess first choice 3. give recurrence for the value of an optimal solution 4. algorithm: fill in table for c [..] in suitable order (or recurse & memoize) 5. solve original problem

slide-27
SLIDE 27

TU/e

Prerequisites

27

X = A C C G T A A T C G A C G Y = A C G A T T G C A C T G x1 x2 xn y1 y2 ym

X0 is empty string

3. Give recursive formula for the value of an optimal solution i. define subproblem in terms of a few parameters Find LCS of Xi := x1 … xi and Yj := y1 … yj , for parameters i, j with 0 ≤ i ≤ n and 0 ≤ j ≤ m ? ii. define variable c [..] = value of optimal solution for subproblem c [i,j ] = length of LCS of Xi and Yj iii. give recursive formula for c [..]

slide-28
SLIDE 28

TU/e

Prerequisites

28

X = A C C G T A A T C G A C G Y = A C G A T T G C A C T G x1 x2 xn y1 y2 ym Xi := x1 … xi and Yj := y1 … yj , for 0 ≤ i ≤ n and 0 ≤ j ≤ m we want recursive formula for c [i,j ] = length of LCS of Xi and Yj Lemma: c [i,j ] = if i = 0 or j = 0 if i,j > 0 and xi = yj if i,j > 0 and xi ≠ yj c[i-1,j-1] + 1 max { c[i-1,j], c[i,j-1] }

slide-29
SLIDE 29

TU/e

Prerequisites

29

5 steps in designing dynamic-programming algorithms 1. define subproblems 2. guess first choice 3. give recurrence for the value of an optimal solution 4. algorithm: fill in table for c [..] in suitable order (or recurse & memoize) 5. solve original problem

slide-30
SLIDE 30

TU/e

Prerequisites

30

i j m n solution to original problem c [i,j ] = if i = 0 or j = 0 if i,j > 0 and xi = yj if i,j > 0 and xi ≠ yj c[i-1,j-1] + 1 max { c[i-1,j], c[i,j-1] } 4. Algorithm: fill in table for c [..] in suitable order

slide-31
SLIDE 31

TU/e

Prerequisites

31

LCS-Length(X,Y) 1. n ← length[X]; m ← length[Y] 2. for i ← 0 to n do c[i,0] ← 0 3. for j ← 0 to m do c[0,j] ← 0 4. for i ← 1 to n 5. do for j ← 1 to m 6. do if X[i] = Y[j] 7. then c[i,j] ← c[i-1,j-1] + 1 8. else c[i,j] ← max { c[i-1,j], c[i,j-1] } 9. return c[n,m] c [i,j ] = if i = 0 or j = 0 if i,j > 0 and xi = yj if i,j > 0 and xi ≠ yj c[i-1,j-1] + 1 max { c[i-1,j], c[i,j-1] } 4. Algorithm: fill in table for c [..] in suitable order

j m i n

slide-32
SLIDE 32

TU/e

Prerequisites

32

Θ(n) Θ(m) Θ(1) Θ(1) Lines 4 – 8: ∑1≤i≤n ∑1≤j≤m Θ(1) = Θ(nm) LCS-Length(X,Y) 1. n ← length[X]; m ← length[Y] 2. for i ← 0 to n do c[i,0] ← 0 3. for j ← 0 to m do c[0,j] ← 0 4. for i ← 1 to n 5. do for j ← 1 to m 6. do if X[i] = Y[j] 7. then c[i,j] ← c[i-1,j-1] + 1 8. else c[i,j] ← max { c[i-1,j], c[i,j-1] } 9. return c[n,m] Analysis of running time

slide-33
SLIDE 33

TU/e

Prerequisites

33

5 steps in designing dynamic-programming algorithms 1. define subproblems 2. guess first choice 3. give recurrence for the value of an optimal solution 4. algorithm: fill in table for c [..] in suitable order (or recurse & memoize) 5. solve original problem Approaches for going from optimum value to optimum solution: i. store choices that led to optimum (e.g. s[i,j] for matrix multiplication) ii. retrace/deduce sequence of solutions that led to optimum backwards (next slide)

slide-34
SLIDE 34

Calculating DTW

 Each warping path w can be found using dynamic programming to

evaluate the following recurrence:

 where γ(i, j) is the cumulative distance of the distance d(i, j) and its

minimum cumulative distance among the adjacent cells

)} 1 , ( ), , 1 ( ), 1 , 1 ( min{ ) , ( ) , (       j i j i j i c q d j i

j i

   

.

(i-1, j) (i, j-1) (i, j) (i-1, j-1)

slide-35
SLIDE 35

Incorporating time

 To align points with

similar time stamp: limit warping

 Also useful for other measures in this lecture C Q C Q C Q C Q

Sakoe-Chiba Band Itakura Parallelogram

slide-36
SLIDE 36

Similarity measures: Aligning sequences

 Input: Two polygonal curves P and Q in Rd  Other interesting measures are:

  • Dynamic Time Warping (DTW)
  • Longest Common Subsequence (LCSS)
  • Model-Driven matching (MDM)

 often work well  Drawback: Non-metrics (triangle inequality does not hold)

which makes clustering complicated.

slide-37
SLIDE 37

Similarity measure: Fréchet Distance

 Fréchet Distance measures the similarity of two curves.  Dog walking example  Person is walking his dog (person on one curve and the dog on

  • ther)

 Allowed to control their speeds but not allowed to go backwards!  Fréchet distance of the curves: minimal leash length

necessary for both to walk the curves from beginning to end

slide-38
SLIDE 38

Similarity measure: Fréchet Distance

 Fréchet Distance measures the similarity of two curves.  Dog walking example  Person is walking his dog (person on one curve and the dog on

  • ther)

 Allowed to control their speeds but not allowed to go backwards!  Fréchet distance of the curves: minimal leash length

necessary for both to walk the curves from beginning to end

slide-39
SLIDE 39

Fréchet Distance

 Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in

Rd.

 The Fréchet distance between P and Q is:  where  and  range over all continuous non-decreasing

reparametrizations with (0)=p1, (1)=pn, (0)=q1 and (1)=qm.

𝜀𝐺(P,Q) =

inf

𝛽:[0,1]→𝑄 𝛾:[0,1]→𝑅

max

𝑢 ∈[0,1] |𝑄(𝛽 𝑢 ) − 𝑅(𝛾 𝑢 )|

slide-40
SLIDE 40

Discrete Fréchet Distance

 The discrete Fréchet distance considers only positions of the leash

where its endpoints are located at vertices of the two polygonal curves and never in the interior of an edge.

 Recurrence:

May give large errors!

)}} 1 , ( ), , 1 ( ), 1 , 1 ( min{ ), , ( max{ ) , (      j i j i j i q p d j i

j i

   

slide-41
SLIDE 41

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-42
SLIDE 42

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-43
SLIDE 43

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-44
SLIDE 44

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P r

slide-45
SLIDE 45

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-46
SLIDE 46

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P r

slide-47
SLIDE 47

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P r

slide-48
SLIDE 48

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-49
SLIDE 49

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-50
SLIDE 50

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-51
SLIDE 51

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-52
SLIDE 52

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-53
SLIDE 53

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-54
SLIDE 54

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-55
SLIDE 55

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-56
SLIDE 56

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? P Q Q P

slide-57
SLIDE 57

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ? Q P Freespace diagram of P and Q free space

slide-58
SLIDE 58

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ?

 How do we find a reparametrization

between P and Q that realises the Fréchet distance r? Q P

slide-59
SLIDE 59

Compute the Fréchet distance

Input: Two polygonal chains P=p1, … , pn and Q=q1, … , qm in Rd. Decision problem: F(P, Q) ≤ r ?

 How do we find a reparametrization

between P and Q that realises the Fréchet distance r?

 Recall that it has to be continuous,

non-decreasing, q1  p1 and qm  pn. Q P

slide-60
SLIDE 60

Compute the Fréchet distance

q1  p1 Q P

slide-61
SLIDE 61

Compute the Fréchet distance

q1  p1

qm  pn Q P

slide-62
SLIDE 62

Compute the Fréchet distance

q1  p1

qm  pn

must lie in the free space Q P Not valid!

slide-63
SLIDE 63

Compute the Fréchet distance

q1  p1

qm  pn

must lie in the free space

continuous Q P

slide-64
SLIDE 64

Compute the Fréchet distance

q1  p1

qm  pn

must lie in the free space

continuous

non-decreasing Q P

slide-65
SLIDE 65

Compute the Fréchet distance

q1  p1

qm  pn

must lie in the free space

continuous

non-decreasing

If there exists an xy-non-decreasing path inside the freespace from the bottom left to the top right corner of the diagram then the Fréchet distance is at most r. Q P

slide-66
SLIDE 66

Free Space Diagram

 Decision version 

Is the Fréchet distance between two paths at most r?

r

P P Q Q

slide-67
SLIDE 67

Free Space Diagram

 Decision version 

Is the Fréchet distance between two paths at most r?

r

P Q

slide-68
SLIDE 68

Free Space Diagram

 If there exists a non-decreasing path in the free space from (q1,p1)

to (qm,pn) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r.

(q1,p1)

(qm, pn)

r

P Q P Q

slide-69
SLIDE 69

Free Space Diagram

 If there exists a non-decreasing path in the free space from (q1,p1)

to (qm,pn) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r.

(q1,p1)

(qm, pn)

r

P Q P Q

slide-70
SLIDE 70

Free Space Diagram

 If there exists a non-decreasing path in the free space from (q1,p1)

to (qm,pn) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r.

(q1,p1)

(qm, pn)

r

P Q P Q

slide-71
SLIDE 71

Free Space Diagram

 If there exists a non-decreasing path in the free space from (q1,p1)

to (qm,pn) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r.

(q1,p1)

(qm, pn)

r

P Q P Q

slide-72
SLIDE 72

Free Space Diagram

 If there exists a non-decreasing path in the free space from (q1,p1)

to (qm,pn) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r.

(q1,p1)

(qm, pn)

r

P Q P Q

slide-73
SLIDE 73

Free Space Diagram

 If there exists a non-decreasing path in the free space from (q1,p1)

to (qm,pn) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r.

(q1,p1)

(qm, pn)

r

P Q P Q

slide-74
SLIDE 74

Free Space Diagram

 If there exists a non-decreasing path in the free space from (q1,p1)

to (qm,pn) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r.

(q1,p1)

(qm, pn)

r

P Q P Q

slide-75
SLIDE 75

Free Space Diagram

 If there exists a non-decreasing path in the free space from (q1,p1)

to (qm,pn) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r.

(q1,p1)

(qm, pn)

r

P Q P Q

slide-76
SLIDE 76

Free Space Diagram

 If there exists a non-decreasing path in the free space from (q1,p1)

to (qm,pn) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r.

(q1,p1)

(qm, pn)

r

P Q P Q

slide-77
SLIDE 77

Decision algorithm: free space diagram

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time A square and an ellipsoid can intersect in at most 8 points. (critical points) The free space in a cell is a convex region.  One cell can be constructed in time O(1).

slide-78
SLIDE 78

Compute the Fréchet distance

 One cell can be constructed in time O(1). How?  Note that we do not need the exact shape. We only need the

intersection points between the cell boundary and the ellipsoid. P Q Q P

slide-79
SLIDE 79

Compute the Fréchet distance

 One cell can be constructed in time O(1). How?  Note that we do not need the exact shape. We only need the

intersection points between the cell boundary and the ellipsoid. P Q Q P

slide-80
SLIDE 80

Compute the Fréchet distance

 One cell can be constructed in time O(1). How?  Note that we do not need the exact shape. We only need the

intersection points between the cell boundary and the ellipsoid. P Q Q P

slide-81
SLIDE 81

Compute the Fréchet distance

 One cell can be constructed in time O(1). How?  Note that we do not need the exact shape. We only need the

intersection points between the cell boundary and the ellipsoid. P Q Q P

slide-82
SLIDE 82

Compute the Fréchet distance

 One cell can be constructed in time O(1). How?  Note that we do not need the exact shape. We only need the

intersection points between the cell boundary and the ellipsoid. P Q Q P

slide-83
SLIDE 83

Compute the Fréchet distance

 One cell can be constructed in time O(1). How?  Note that we do not need the exact shape. We only need the

intersection points between the cell boundary and the ellipsoid. P Q Q P

slide-84
SLIDE 84

Decision algorithm: free space algorithm

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time A square and an ellipsoid can intersect in at most 8 points. The free space in a cell is a convex region.  One cell can be constructed in time O(1). Critical points

slide-85
SLIDE 85

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-86
SLIDE 86

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-87
SLIDE 87

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-88
SLIDE 88

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-89
SLIDE 89

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-90
SLIDE 90

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-91
SLIDE 91

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-92
SLIDE 92

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-93
SLIDE 93

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-94
SLIDE 94

Decision algorithm: compute path

Algorithm:

  • 1. Compute Free Space diagram

O(mn) time

  • 2. Compute a non-xy-decreasing

path from (q1,p1) to (qm,pn).

(q1,p1)

(qm,pn) P Q

slide-95
SLIDE 95

Compute the Fréchet distance

 Theorem: Given two polygonal curves P, Q and r0 one can decide

in O(mn) time, whether (P,Q)  r.

 How can we use the algorithm to compute the Fréchet distance?  Binary search on r?  But what do we do binary search on?

slide-96
SLIDE 96

Compute the Fréchet distance

 Theorem: Given two polygonal curves P, Q and r0 one can decide

in O(mn) time, whether (P,Q)  r.

 How can we use the algorithm to compute the Fréchet distance?  In practice: Determine r bit by bit

 O(mn log “accuracy”) time.

slide-97
SLIDE 97

Compute the Fréchet distance

Assume r=0 and the let r grow.  The free space will become larger and larger. Aim: Determine the smallest r such that it contains a montone path from (q1,p1) to (qm,pn). This can only occur in one of the following cases:

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space.

slide-98
SLIDE 98

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time.

slide-99
SLIDE 99

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2:

slide-100
SLIDE 100

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2:

slide-101
SLIDE 101

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2:

slide-102
SLIDE 102

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2: Number of events?

slide-103
SLIDE 103

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2: Number of events: O(mn)

slide-104
SLIDE 104

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2: O(mn) events Case 3:

slide-105
SLIDE 105

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2: O(mn) events Case 3:

slide-106
SLIDE 106

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2: O(mn) events Case 3:

slide-107
SLIDE 107

Compute the Fréchet distance

1.

r is minimal with (q1,p1) to (qm,pn) in the free space,

2.

r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space.

3.

r is minimal when a new vertical or horizontal passage opens up between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2: O(mn) events Case 3:

slide-108
SLIDE 108

Compute the Fréchet distance

Case 1: easy to test in constant time. Case 2: O(mn) possible events Case 3: O(m2n+mn2) possible events Perform binary search on the events  O((m2n+mn2) log mn) time.

slide-109
SLIDE 109

Compute the Fréchet distance

Case 1: easy to test in constant time. Case 2: O(mn) possible events Case 3: O(m2n+mn2) possible events Improvement: Use parametric search [Meggido’83, Cole’88]  O(mn log mn) time.

slide-110
SLIDE 110

Parametric search

The decision version F(r) of the Fréchet distance depends on the parameter r, and it is monotone in r. Aim: Find minimum r such that F(r) is true. Our algorithm As can solve F(r) in Ts=O(mn) time. Meggido’83 and Cole’88 (simplified): If there exists a parallel algorithm Ap that can solve F(r) in Tp time using P processors then there exists a sequential algorithm with running time O(PTp+TpTs+Ts log P). For our problem we get (details are involved): O(mn log mn) time using a parallel sorting network [n processors and O(log n) time]

slide-111
SLIDE 111

Summary: Similarity of Trajectories

 Many different similarity measures. Which is best depends on the

application and the data.

 We use the Fréchet distance, or variants of it.  Theorem: Given two polygonal curves P, Q and r  0 one can

decide in O(mn) time, whether (P,Q)  r.

 Theorem: The Fréchet distance between two polygonal curves P

and Q can be computed in O(mn log mn) time.

slide-112
SLIDE 112

Examples: Previous MSc theses

 Algorithms for comparing moving complex shapes, Tim Ophelders,

2014, results published at Europ. Symposium on Algorithms, computational complexity and algorithms for similarity between moving curves

 A novel algorithm for computing the Fréchet distance, Rolf van

Leusden, 2013, results published at Europ. Symposium on Algorithms, avoids parametric search, O(mn) for specific metrics

 Detecting the moving-along pattern in trajectory data, Teng Li,

2012, about partial matches, for instance bird to coastline

slide-113
SLIDE 113

References

  • H. Alt and M. Godau. Computing the Fréchet distance between two

polygonal curves. IJCGA, 1995.