2IMG15 Algorithms for Geographic Data

Slides:



Advertisements
Similar presentations
Fundamental tools: clustering
Advertisements

Dynamic Programming Nithya Tarek. Dynamic Programming Dynamic programming solves problems by combining the solutions to sub problems. Paradigms: Divide.
Approximations of points and polygonal chains
On Map-Matching Vehicle Tracking Data
Overview What is Dynamic Programming? A Sequence of 4 Steps
The Divide-and-Conquer Strategy
Comp 122, Fall 2004 Dynamic Programming. dynprog - 2 Lin / Devi Comp 122, Spring 2004 Longest Common Subsequence  Problem: Given 2 sequences, X =  x.
Chapter 3 The Greedy Method 3.
Praktikum zur Analyse von Formen - Abstandsmaße - Helmut Alt Freie Universität Berlin.
Trajectory Simplification
Dynamic Programming Optimization Problems Dynamic Programming Paradigm
1 Theory I Algorithm Design and Analysis (11 - Edit distance and approximate string matching) Prof. Dr. Th. Ottmann.
ADA: 7. Dynamic Prog.1 Objective o introduce DP, its two hallmarks, and two major programming techniques o look at two examples: the fibonacci.
Fundamentals of Algorithms MCS - 2 Lecture # 7
4/28/15CMPS 3130/6130 Computational Geometry1 CMPS 3130/6130 Computational Geometry Spring 2015 Shape Matching Carola Wenk A B   (B,A)
Geometric Matching on Sequential Data Veli Mäkinen AG Genominformatik Technical Fakultät Bielefeld Universität.
CS 8833 Algorithms Algorithms Dynamic Programming.
Greedy Methods and Backtracking Dr. Marina Gavrilova Computer Science University of Calgary Canada.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 14.
Geodesic Fréchet Distance Inside a Simple Polygon Atlas F. Cook IV & Carola Wenk Proceedings of the 25th International Symposium on Theoretical Aspects.
Introduction to Algorithms Jiafen Liu Sept
CS 3343: Analysis of Algorithms Lecture 18: More Examples on Dynamic Programming.
COSC 3101NJ. Elder Announcements Midterms are marked Assignment 2: –Still analyzing.
COSC 3101NJ. Elder Announcements Midterm Exam: Fri Feb 27 CSE C –Two Blocks: 16:00-17:30 17:30-19:00 –The exam will be 1.5 hours in length. –You can attend.
2IMA20 Algorithms for Geographic Data Spring 2016 Lecture 2: Similarity.
TU/e Algorithms (2IL15) – Lecture 3 1 DYNAMIC PROGRAMMING
9/27/10 A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne Adam Smith Algorithm Design and Analysis L ECTURE 16 Dynamic.
TU/e Algorithms (2IL15) – Lecture 4 1 DYNAMIC PROGRAMMING II
Polygon Triangulation
2IMA20 Algorithms for Geographic Data Spring 2016 Lecture 5: Simplification.
Dynamic Programming Typically applied to optimization problems
CS 3343: Analysis of Algorithms
Polygonal Curve Simplification
Distance Functions for Sequence Data and Time Series
JinJu Lee & Beatrice Seifert CSE 5311 Fall 2005 Week 10 (Nov 1 & 3)
2IMA20 Algorithms for Geographic Data
Chapter 8 Dynamic Programming.
CSCE 411 Design and Analysis of Algorithms
Dynamic Programming General Idea
Algorithms (2IL15) – Lecture 2
CS Algorithms Dynamic programming 0-1 Knapsack problem 12/5/2018.
I. The Problem of Molding
Dynamic Programming Dr. Yingwu Zhu Chapter 15.
CS 3343: Analysis of Algorithms
2IMG15 Algorithms for Geographic Data
CMPS 3130/6130 Computational Geometry Spring 2017
Longest Common Subsequence
Haitao Wang Utah State University WADS 2017, St. John’s, Canada
Dynamic Programming Comp 122, Fall 2004.
Lecture 8. Paradigm #6 Dynamic Programming
Ch. 15: Dynamic Programming Ming-Te Chi
2IMG15 Algorithms for Geographic Data
A Note on Useful Algorithmic Strategies
Trevor Brown DC 2338, Office hour M3-4pm
Dynamic Programming-- Longest Common Subsequence
Dynamic Programming General Idea
Introduction to Algorithms: Dynamic Programming
Algorithm Design Techniques Greedy Approach vs Dynamic Programming
Longest Common Subsequence
Dynamic Programming II DP over Intervals
Algorithms and Data Structures Lecture X
Analysis of Algorithms CS 477/677
Major Design Strategies
A Note on Useful Algorithmic Strategies
Longest Common Subsequence
A Note on Useful Algorithmic Strategies
Dynamic Programming.
Major Design Strategies
Algorithm Course Dr. Aref Rashad
Presentation transcript:

2IMG15 Algorithms for Geographic Data Fall 2017 Lecture 2: Similarity

Trajectories Model for the movement of a (point) object; f : [ time interval ] 2D or 3D The path of a trajectory is just any curve

Trajectories vs trajectory data

Trajectory data The data as it is acquired by e.g. GPS: sequence of triples (2D spatial + time) or quadruples (3D spatial + time) (xn,yn,tn) (x2,y2,t2) (xi,yi,ti) (x1,y1,t1)

Trajectory data Typical assumption for sufficiently densely sampled data: constant velocity between consecutive samples ➨ velocity/speed is a piecewise constant function (xn,yn,tn) (x2,y2,t2) (xi,yi,ti) (x1,y1,t1)

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

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?”

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

Similarity is fundamental 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

Similarity is fundamental 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

When are two trajectories similar? Often, spatial similarity is more important than temporal similarity

Many measures exist… 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 ...

A simple approach Input: Two polygonal curves P and Q of size m in Rd Approach: Map curve into a point in dm-dimensional space  2D 10D

A simple approach Input: Two polygonal curves P and Q of size m in Rd Approach: Map curve into a point in dm-dimensional space  Similar? 10D 2D

A simple approach 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  Not similar? 2D 6D

Hausdorff distance Input: Two polygonal curves P and Q in Rd Distance: Hausdorff distance H(PQ) = maxpP minqQ |p-q| dH(P,Q) = max [H(PQ), H(QP)] P Q P Q

Hausdorff distance Input: Two polygonal curves P and Q in Rd Distance: Hausdorff distance Drawback: Fails 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)] P Q

Aligning sequences Input: Two polygonal curves P and Q in Rd Some interesting measures are: Dynamic Time Warping (DTW) Longest Common Subsequence (LCSS) Model-Driven matching (MDM)

Dynamic Time Warping (DTW) Euclidean Distance One-to-one alignments Time Warping Distance Non-linear alignments are allowed

Calculating DTW Q C Warping path w distance matrix

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

Longest common subsequence [Prerequisite] 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 …)

[Prerequisite] 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)

LCS: structure what are the choices that need to be made? [Prerequisite] LCS: structure 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? or is last character of X or Y unmatched? greedy choice? overlapping subproblems? x1 x2 xn optimal solution 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 y1 y2 ym

5 steps to Dynamic Programming [Prerequisite] 5 steps to Dynamic Programming  define subproblems guess first choice give recurrence for the value of an optimal solution algorithm: fill in table for m [..] in suitable order (or recurse & memoize) solve original problem 

LCS: recurrence give recurrence for the value of an optimal solution [Prerequisite] LCS: recurrence give recurrence for the value of an optimal solution 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 ? define variable c [..] = value of optimal solution for subproblem c [i,j] = length of LCS of Xi and Yj give recursive formula for c [..] X0 is empty string

LCS: recurrence give recursive formula for c [..] [Prerequisite] LCS: recurrence give recursive formula for c [..] 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 x1 x2 xn 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 y1 y2 ym 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] }

5 steps to Dynamic Programming [Prerequisite] 5 steps to Dynamic Programming  define subproblems guess first choice give recurrence for the value of an optimal solution algorithm: fill in table for m [..] in suitable order (or recurse & memoize) solve original problem  

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

LCS: algorithm Fill table for c [..] in suitable order [Prerequisite] LCS: algorithm Fill table for c [..] in suitable order LCS-Length(X[1..n],Y[1..m]) for i ← 0 to n do c[i,0] ← 0 for j ← 0 to m do c[0,j] ← 0 for i ← 1 to n do for j ← 1 to m do if X[i] = Y[j] then c[i,j] ← c[i-1,j-1] + 1 else c[i,j] ← max { c[i-1,j], c[i,j-1] } return c[n,m] c [i,j] = 0 if i = 0 or j = 0 c[i-1,j-1] + 1 if i,j > 0 and xi = yj max { c[i-1,j], c[i,j-1] } if i,j > 0 and xi ≠ yj j m i n

LCS: time analysis LCS-Length(X[1..n],Y[1..m]) [Prerequisite] LCS: time analysis LCS-Length(X[1..n],Y[1..m]) for i ← 0 to n do c[i,0] ← 0 for j ← 0 to m do c[0,j] ← 0 for i ← 1 to n do for j ← 1 to m do if X[i] = Y[j] then c[i,j] ← c[i-1,j-1] + 1 else c[i,j] ← max { c[i-1,j], c[i,j-1] } return c[n,m] Θ(n) Θ(m) Θ(1) Lines 4 – 8: ∑1≤i≤n ∑1≤j≤m Θ(1) = Θ(nm)

5 steps to Dynamic Programming [Prerequisite] 5 steps to Dynamic Programming  define subproblems guess first choice give recurrence for the value of an optimal solution algorithm: fill in table for m [..] in suitable order (or recurse & memoize) solve original problem Approaches for going from optimum value to optimum solution: store choices that led to optimum retrace/deduce sequence of solutions that led to optimum backwards   

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 . (i-1, j) (i, j-1) (i, j) (i-1, j-1)

Incorporating time If we also want to consider temporal similarity Combine space+time for point-to-point distance Make sure of “sensible scale”... Limit warping to points with similar time stamp Also useful for other measures in this lecture

Incorporating time If we also want to consider temporal similarity Combine space+time for point-to-point distance Make sure of “sensible scale”... Limit warping to points with similar time stamp Also useful for other measures in this lecture Sakoe-Chiba Band Itakura Parallelogram

Aligning sequences Input: Two polygonal curves P and Q in Rd Some 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) Makes clustering complicated

Fréchet distance Fréchet distance measures the similarity of two curves Analogy Person is walking his dog (person on one curve, dog on other) Can vary their speeds but cannot go back! Fréchet distance: minimal leash length necessary for both to walk the curves from beginning to end

Fréchet distance Fréchet distance measures the similarity of two curves Analogy Person is walking his dog (person on one curve, dog on other) Can vary their speeds but cannot go back! Fréchet distance: minimal leash length necessary for both to walk the curves from beginning to end

Fréchet distance Input: polygonal lines 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] |𝑃(𝛼 𝑡 )−𝑄(𝛽 𝑡 )| reparamterized monotonous curve

Discrete Fréchet distance The discrete Fréchet distance uses “jumps” from vertex to vertex; the interior of an edge is never used in measurements. Recurrence: reparamterized monotonous curve May give large errors!

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? r P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P r P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? P P Q Q

Fréchet distance: analysis Input: polygonal lines P=p1, … , pn and Q=q1, … , qm in Rd Decision problem: F(P, Q) ≤ r ? Free-space diagram of P and Q free space P Q

Fréchet distance: analysis Input: polygonal lines 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 realizes the Fréchet distance r? P Q

Fréchet distance: analysis Input: polygonal lines 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 realizes the Fréchet distance r? Recall that it has to be continuous, non-decreasing, q1  p1 and qm  pn P Q

Fréchet distance: analysis q1  p1 P Q

Fréchet distance: analysis q1  p1 qm  pn P Q

Fréchet distance: analysis q1  p1 qm  pn must lie in the free space Not valid! P Q

Fréchet distance: analysis q1  p1 qm  pn must lie in the free space continuous P Q

Fréchet distance: analysis q1  p1 qm  pn must lie in the free space continuous non-decreasing: monotone in x- and y-direction P Q

Fréchet distance: analysis q1  p1 qm  pn must lie in the free space continuous non-decreasing: monotone in x- and y-direction A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r P Q

Free-space diagram r Decision version Is the Fréchet distance between two paths at most r? P P for each edge in the graph let Q r Q

Free-space diagram A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r (q1,p1) (qm,pn) P Q P Q r

Free-space diagram A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r (q1,p1) (qm,pn) P Q P Q r

Free-space diagram A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r (q1,p1) (qm,pn) P Q P Q r

Free-space diagram A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r (q1,p1) (qm,pn) P Q P Q r

Free-space diagram A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r (q1,p1) (qm,pn) P Q P Q r

Free-space diagram A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r (q1,p1) (qm,pn) P Q P Q r

Free-space diagram A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r (q1,p1) (qm,pn) P Q P Q r

Free-space diagram A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r (q1,p1) (qm,pn) P Q P Q r

Free-space diagram A monotone path exists in the free space from the bottom-left to the top-right corner of the diagram, if and only if the Fréchet distance is at most r (q1,p1) (qm,pn) P Q P Q r

Fréchet distance: decision algorithm Compute free-space diagram in O(mn) time

Computing the free-space diagram One cell can be constructed in O(1) time Free space is a cell is convex (ellipsoid) Square and ellipsoid intersect in at most 8 (critical) points

Computing the free-space diagram One cell can be constructed in O(1) time Free space is a cell is convex (ellipsoid) Square and ellipsoid intersect in at most 8 (critical) points We need only these critical points Q P P Q

Computing the free-space diagram One cell can be constructed in O(1) time Free space is a cell is convex (ellipsoid) Square and ellipsoid intersect in at most 8 (critical) points We need only these critical points P P Q Q

Computing the free-space diagram One cell can be constructed in O(1) time Free space is a cell is convex (ellipsoid) Square and ellipsoid intersect in at most 8 (critical) points We need only these critical points P P Q Q

Computing the free-space diagram One cell can be constructed in O(1) time Free space is a cell is convex (ellipsoid) Square and ellipsoid intersect in at most 8 (critical) points We need only these critical points P P Q Q

Computing the free-space diagram One cell can be constructed in O(1) time Free space is a cell is convex (ellipsoid) Square and ellipsoid intersect in at most 8 (critical) points We need only these critical points P P Q Q

Computing the free-space diagram One cell can be constructed in O(1) time Free space is a cell is convex (ellipsoid) Square and ellipsoid intersect in at most 8 (critical) points We need only these critical points P P Q Q

Fréchet distance: decision algorithm Compute free-space diagram in O(mn) time

Fréchet distance: decision algorithm Compute free-space diagram in O(mn) time Compute a monotone path from (q1,p1) to (qm,pn) in O(mn) time (q1,p1) (qm,pn) P Q

Computing a monotone path Per cell boundary Find the earliest reachable point that can be reached with a monotone path from (q1,p1) This must lie in the free space For reaching the right side (top is analogous) If we can reach the bottom side, we can reach all free space on the right side If we can reach the left side, we can reach free space on the right side that is at least as high If left is reachable, the right side may not be, even if it has free space!

Computing a monotone path Per boundary Find the earliest reachable point that can be reached with an non-xy-decreasing path from (q1,p1) This must lie in the free space (q1,p1) (qm,pn) P Q

Computing a monotone path A non-xy-decreasing path in the free space exists if the last cell’s boundary is reachable and |qm - pn|  r (q1,p1) (qm,pn) P Q

Fréchet distance: decision algorithm Compute free-space diagram in O(mn) time Compute a monotone path from (q1,p1) to (qm,pn) in O(mn) time Theorem: Given two polygonal curves P, Q and r  0, one can decide in O(mn) time, whether (P,Q)  r.

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? Assume r = 0 and then let r grow. The free space will only extend Once there is a monotone path, there will always be one We can do binary search on r? In practice: determine r bit by bit  O(mn log “accuracy”) time Can we get exact computation?

Compute the Fréchet distance Aim: Determine the smallest r such that the free-space diagram contains a monotone path from (q1,p1) to (qm,pn) This minimal r must coincide with one of the three critical events

Critical events r is minimal with (q1,p1) and (qm,pn) in the free space Case 1 is easy to test in constant time

Critical events r is minimal with (q1,p1) and (qm,pn) in the free space r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space Case 1 is easy to test in constant time Case 2:

Critical events r is minimal with (q1,p1) and (qm,pn) in the free space r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space Case 1 is easy to test in constant time Case 2:

Critical events r is minimal with (q1,p1) and (qm,pn) in the free space r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space Case 1 is easy to test in constant time Case 2: Number of events?

Critical events r is minimal with (q1,p1) and (qm,pn) in the free space r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space Case 1 is easy to test in constant time Case 2: Number of events: O(mn)

Critical events r is minimal with (q1,p1) and (qm,pn) in the free space r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space 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:

Critical events r is minimal with (q1,p1) to (qm,pn) in the free space, r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space. 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:

Critical events r is minimal with (q1,p1) to (qm,pn) in the free space, r is minimal when a new vertical or horizontal passage opens up between two adjacent cells in the free space. 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: O(m2n+mn2) possible events

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 Binary search on the events  O((m2n+mn2) log mn) time

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 Binary search on the events  O((m2n+mn2) log mn) time Improvement: use parametric search [Meggido’83, Cole’88]  O(mn log mn) time

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 decide 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]

Fréchet distance Aligns the full geometry of the curves Drawback: bottleneck measure Only the place of “worst match” (or “maximal leash length”) matters

Fréchet distance variants Continuous and discrete (this lecture) Weak Fréchet distance (allow walking backwards) With shortcuts (allow avoiding parts of a curve) ...

Invariants Invariants describe that operations do not affect the measure Translation invariance Scale invariance Rotation invariance

Invariants Invariants describe that operations do not affect the measure Translation invariance Scale invariance Rotation invariance In this lecture, measures did not have invariants Which are relevant depends on application

Summary Many different similarity measures Which is best depends on the application and the data We often 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

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

References H. Alt and M. Godau. Computing the Fréchet distance between two polygonal curves. IJCGA, 1995.