algorithms for geographic data
play

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


  1. TU/e Prerequisites 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) 33

  2. Calculating DTW  Each warping path w can be found using dynamic programming to evaluate the following recurrence:           ( , ) ( , ) min{ ( 1 , 1 ), ( 1 , ), ( , 1 )} i j d q c i j i j i j i j .  where γ (i, j) is the cumulative distance of the distance d(i, j) and its minimum cumulative distance among the adjacent cells (i-1, j) (i, j) (i-1, j-1) (i, j-1)

  3. Incorporating time  To align points with similar time stamp: limit warping C C C C Q Q Q Q Sakoe-Chiba Band Itakura Parallelogram  Also useful for other measures in this lecture

  4. Similarity measures: Aligning sequences  Input: Two polygonal curves P and Q in R d  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.

  5. 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 other)  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

  6. 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 other)  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

  7. Fréchet Distance  Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d .  The Fréchet distance between P and Q is: 𝜀 𝐺 (P,Q) = inf 𝑢 ∈[0,1] |𝑄(𝛽 𝑢 ) − 𝑅(𝛾 𝑢 )| max 𝛽:[0,1]→𝑄 𝛾:[0,1]→𝑅  where  and  range over all continuous non-decreasing reparametrizations with  (0)=p 1 ,  (1)=p n ,  (0)=q 1 and  (1)=q m .

  8. 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:          ( i , j ) max{ d ( p , q ), min{ ( i 1 , j 1 ), ( i 1 , j ), ( i , j 1 )}} i j May give large errors!

  9. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  10. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  11. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  12. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q r Q

  13. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  14. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P r P Q Q

  15. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P r P Q Q

  16. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  17. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  18. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  19. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  20. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  21. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  22. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  23. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  24. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? P P Q Q

  25. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ? Freespace diagram of P and Q free P space Q

  26. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . Decision problem:  F ( P, Q) ≤ r ?  How do we find a reparametrization between P and Q that realises the Fréchet distance r? P Q

  27. Compute the Fréchet distance Input: Two polygonal chains P=  p 1 , … , p n  and Q=  q 1 , … , q m  in R d . 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, P non-decreasing, q 1  p 1 and q m  p n . Q

  28. Compute the Fréchet distance q 1  p 1  P Q

  29. Compute the Fréchet distance q 1  p 1  q m  p n  P Q

  30. Compute the Fréchet distance q 1  p 1  q m  p n   must lie in the free space Not valid! P Q

  31. Compute the Fréchet distance q 1  p 1  q m  p n   must lie in the free space  continuous P Q

  32. Compute the Fréchet distance q 1  p 1  q m  p n   must lie in the free space  continuous  non-decreasing P Q

  33. Compute the Fréchet distance q 1  p 1  q m  p n   must lie in the free space P  continuous  non-decreasing Q  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.

  34. Free Space Diagram  Decision version  Is the Fréchet distance between two paths at most r? P P Q Q r

  35. Free Space Diagram  Decision version  Is the Fréchet distance between two paths at most r? P Q r

  36. Free Space Diagram  If there exists a non-decreasing path in the free space from (q 1 ,p 1 ) to (q m ,p n ) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r. (q m , p n ) P P Q Q ( q 1 ,p 1 ) r

  37. Free Space Diagram  If there exists a non-decreasing path in the free space from (q 1 ,p 1 ) to (q m ,p n ) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r. (q m , p n ) P P Q Q ( q 1 ,p 1 ) r

  38. Free Space Diagram  If there exists a non-decreasing path in the free space from (q 1 ,p 1 ) to (q m ,p n ) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r. (q m , p n ) P P Q Q ( q 1 ,p 1 ) r

  39. Free Space Diagram  If there exists a non-decreasing path in the free space from (q 1 ,p 1 ) to (q m ,p n ) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r. (q m , p n ) P P Q Q ( q 1 ,p 1 ) r

  40. Free Space Diagram  If there exists a non-decreasing path in the free space from (q 1 ,p 1 ) to (q m ,p n ) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r. (q m , p n ) P P Q Q ( q 1 ,p 1 ) r

  41. Free Space Diagram  If there exists a non-decreasing path in the free space from (q 1 ,p 1 ) to (q m ,p n ) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r. (q m , p n ) P P Q Q ( q 1 ,p 1 ) r

  42. Free Space Diagram  If there exists a non-decreasing path in the free space from (q 1 ,p 1 ) to (q m ,p n ) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r. (q m , p n ) P P Q Q ( q 1 ,p 1 ) r

  43. Free Space Diagram  If there exists a non-decreasing path in the free space from (q 1 ,p 1 ) to (q m ,p n ) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r. (q m , p n ) P P Q Q ( q 1 ,p 1 ) r

  44. Free Space Diagram  If there exists a non-decreasing path in the free space from (q 1 ,p 1 ) to (q m ,p n ) which is non-decreasing in both coordinates, then curves P and Q have Fréchet distance at most r. (q m , p n ) P P Q Q ( q 1 ,p 1 ) r

  45. 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).

  46. 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 P Q Q

  47. 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 P Q Q

  48. 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 P Q Q

  49. 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 P Q Q

  50. 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 P Q Q

  51. 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 P Q Q

  52. Decision algorithm: free space algorithm Algorithm: 1. Compute Free Space diagram O(mn) time Critical points 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).

  53. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  54. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  55. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  56. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  57. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  58. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  59. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  60. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  61. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  62. Decision algorithm: compute path Algorithm: 1. Compute Free Space diagram O(mn) time (q m ,p n ) 2. Compute a non-xy-decreasing path from (q 1 ,p 1 ) to (q m ,p n ). P ( q 1 ,p 1 ) Q

  63. 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?

  64. 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.

  65. 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 (q 1 ,p 1 ) to (q m ,p n ). This can only occur in one of the following cases: r is minimal with (q 1 ,p 1 ) to (q m ,p n ) in the free space, 1. r is minimal when a new vertical or horizontal passage opens up 2. between two adjacent cells in the free space. r is minimal when a new vertical or horizontal passage opens up 3. between two non-adjacent cells in the free space.

  66. Compute the Fréchet distance r is minimal with (q 1 ,p 1 ) to (q m ,p n ) in the free space, 1. r is minimal when a new vertical or horizontal passage opens up 2. between two adjacent cells in the free space. r is minimal when a new vertical or horizontal passage opens up 3. between two non-adjacent cells in the free space. Case 1 is easy to test in constant time.

  67. Compute the Fréchet distance r is minimal with (q 1 ,p 1 ) to (q m ,p n ) in the free space, 1. r is minimal when a new vertical or horizontal passage opens up 2. between two adjacent cells in the free space. r is minimal when a new vertical or horizontal passage opens up 3. between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2:

  68. Compute the Fréchet distance r is minimal with (q 1 ,p 1 ) to (q m ,p n ) in the free space, 1. r is minimal when a new vertical or horizontal passage opens up 2. between two adjacent cells in the free space. r is minimal when a new vertical or horizontal passage opens up 3. between two non-adjacent cells in the free space. Case 1 is easy to test in constant time. Case 2:

Recommend


More recommend