A Segment-Based Trajectory Similarity Measure in

0 downloads 0 Views 4MB Size Report
Mar 6, 2017 - spots and visualizing in OpenStreetMap [1,2]. In the intelligent .... discrete trajectory points is constructed as a natural sub-trajectory segment.
sensors Article

A Segment-Based Trajectory Similarity Measure in the Urban Transportation Systems Yingchi Mao 1 , Haishi Zhong 1 , Xianjian Xiao 2 and Xiaofang Li 2, * 1 2

*

College of Computer and Information, Hohai University, Nanjing 210098, China; [email protected] (Y.M.); [email protected] (H.Z.) School of Computer Information & Engineering, Changzhou Institute of Technology, Changzhou 213032, China; [email protected] Correspondence: [email protected]; Tel.: +86-519-8521-8382

Academic Editor: Simon X. Yang Received: 7 January 2017; Accepted: 1 March 2017; Published: 6 March 2017

Abstract: With the rapid spread of built-in GPS handheld smart devices, the trajectory data from GPS sensors has grown explosively. Trajectory data has spatio-temporal characteristics and rich information. Using trajectory data processing techniques can mine the patterns of human activities and the moving patterns of vehicles in the intelligent transportation systems. A trajectory similarity measure is one of the most important issues in trajectory data mining (clustering, classification, frequent pattern mining, etc.). Unfortunately, the main similarity measure algorithms with the trajectory data have been found to be inaccurate, highly sensitive of sampling methods, and have low robustness for the noise data. To solve the above problems, three distances and their corresponding computation methods are proposed in this paper. The point-segment distance can decrease the sensitivity of the point sampling methods. The prediction distance optimizes the temporal distance with the features of trajectory data. The segment-segment distance introduces the trajectory shape factor into the similarity measurement to improve the accuracy. The three kinds of distance are integrated with the traditional dynamic time warping algorithm (DTW) algorithm to propose a new segment–based dynamic time warping algorithm (SDTW). The experimental results show that the SDTW algorithm can exhibit about 57%, 86%, and 31% better accuracy than the longest common subsequence algorithm (LCSS), and edit distance on real sequence algorithm (EDR) , and DTW, respectively, and that the sensitivity to the noise data is lower than that those algorithms. Keywords: GPS trajectory; GPS sensor; trajectory similarity measure; spatial-temporal data

1. Introduction With the rapid development of sensors technology and the popularization of personal smart devices, GPS sensors are widely used to track moving objects, such as people, cars, and animals. A large number of trajectory data emerges every day. The trajectory data from GPS sensors are the spatio-temporal data sequences of mobile objects with the space-time variation. With the development of the Internet of Things, urban computing, and other research fields, the analysis of spatio-temporal data-based transportation systems have become a hot topic in the fields of machine learning. The trajectory data analysis can be a great driving force for all of the fields, for example, through applying the trajectory similarity measure algorithm, the distance matrix can be computed, which can be used to cluster the trajectory of peoples’ activities for finding the popular routes and hot spots and visualizing in OpenStreetMap [1,2]. In the intelligent transportation systems, it is of great practical value to measure the similarity of the trajectories of moving objects in a real-time, accurate, and reliable way. Intelligent trajectory measurement cannot only provide accurate location-based services, but also monitor and estimate traffic jams [3]. Sensors 2017, 17, 524; doi:10.3390/s17030524

www.mdpi.com/journal/sensors

Sensors 2017, 17, 524

2 of 16

In trajectory data mining, one of the most important and fundamental works is to compute the similarity between different trajectories. Based on the similarity measurement of trajectory data, the trajectories can be clustered, classified, and retrieved [4]. The accuracy of the similarity measurement significantly affects the accuracy of the trajectory data mining. In recent years, some mainstream algorithms for trajectory similarity measurement have been proposed, such as the dynamic time warping algorithm (DTW) [5], longest common subsequence algorithm (LCSS) [6], and edit distance on real sequence algorithm (EDR) [7]. Those algorithms can obtain the results of similarity measurement through computing spatial point-to-point distances or temporal distances. However, there are common drawbacks resulting in the low accuracy. For example, the DTW algorithm just directly calculates the point-point distance, ignoring the influence of the different trajectory sampling methods on the generated trajectory sequence. The LCSS algorithm neglects optimizing the temporal distance of the trajectory data. The EDR algorithm does not consider the trajectory shape factor. In order to improve the accuracy, a segment-based dynamic time warping algorithm (SDTW) is proposed to measure the trajectory similarity. First, the proposed SDTW adopts the point-segment distance to reduce the sensitivity influence from the trajectory sampling methods. Then, considering the temporal distance factor, SDTW introduces the prediction distance to convert the temporal distance into the spatial distance. Finally, SDTW introduces the segment-segment distance to improve the computation accuracy by adjusting the parameters of shape factors. The remainder of this paper is organized as follows. Section 2 discusses the related work and analyzes their drawbacks. Some definitions and problem statements are described in Section 3. Section 4 presents the proposed SDTW algorithm, and the performance evaluations are given in Section 5. Discussion and conclusions are given in Section 6. 2. Related Work Trajectory sequence data can be regarded as time sequence data. Many approaches to the trajectory similarity measurement are introduced from the similarity measurement to the time sequence data. The simplest trajectory similarity measurement is the Euclidean distance, but it cannot obtain better accuracy when the local time shifts or when those trajectories lack the same length [8]. In order to improve the accuracy of similarity measurement, the dynamic time warping algorithm (DTW), longest common subsequence algorithm (LCSS), and edit distance on real sequence algorithm were proposed and widely applied. Based on the idea of dynamic programming to find the optimal match point pairs between the trajectory points, the DTW can effectively solve the problem of local time shifting and various trajectory lengths [5]. The DTW algorithm was firstly introduced for speech recognition, then applied to the time sequence analysis later. The LCSS adopted a threshold ε to identify the match point pairs [6], but it is a similarity measurement in rough granularity without considering non-match pairs of points. The EDR is an edit distance-based algorithm, which uses a threshold ε to identify the match point pairs and the non-match points, different from the LCSS. Those similarity measurement algorithms can be divided into two types [8]: the one based on L1 and L2 paradigms, such as the DTW; and the other computing similarity scores based on the matching threshold, such as the LCSS and the EDR. Wang et al. have evaluated the performance on the accuracy of main similarity measurement algorithms, DTW, LCSS, ERP [9], EDR, and SpaDe [10], in the different time sequence datasets [11]. The experimental results demonstrate that the DTW algorithm can obtain the most accurate results of the similarity measurement in the majority of datasets although its computation speed is slow. Based on the evaluation results, many similarity measurement algorithms, such as Kim [12], Keogh [13], and Improved [14], have been proposed to reduce the computation complexity at the same measurement accuracy as the DTW algorithm. From the above analysis, it can be found that those algorithms have common drawbacks affecting the accuracy of similarity measurement.

Sensors 2017, 17, 524

3 of 16

Sensors 2017, 17, 524

3 of 16

(1)

The DTW, LCSS, and EDR algorithms only consider the comparison of two individual points. significant negative impact methods on the final [15]. sequences, As shown in Figure 1a, the In fact, different sampling canmeasurement form differentresults trajectory which results in trajectory sequence data of a curve trajectory with an arrow may have two-point sampling a significant negative impact on the final measurement results [15]. As shown in Figure 1a, methods T1 and T2. Two trajectories essentially identical, but their trajectory the trajectory sequence dataoriginal of a curve trajectoryare with an arrow may have two-point sampling sequences quite different. In Figure 1b, two trajectories intersect at point P, and their methods Tare and T . Two original trajectories are essentially identical, but their trajectory 1 2 trajectory sequences and sample the point P. An obvious difference between the two T T sequences are quite different. In2Figure 1b, two trajectories intersect at point P, and their trajectory 1

trajectories but the point difference weakened due to the intersection P. Thus, sequences Tis1 produced, and T2 sample P. Anisobvious difference between the twopoint trajectories is computing the trajectory similarity completely based on the discrete trajectory points will cause produced, but the difference is weakened due to the intersection point P. Thus, computing the the loss ofsimilarity the details of the trajectories. necessary to find points a way will to keep a trajectory completely based on It theisdiscrete trajectory causethe thedetails loss ofto the certain details extent. of the trajectories. It is necessary to find a way to keep the details to a certain extent. (2) Only Only considering considering the the distances distances between between the the pairs pairs of points, the mentioned algorithms cannot take take shape shape factors factors into into account account [16]. [16]. However, However, shape shape factor factor is an important feature of a natural trajectory. It may result in the loss of computation accuracy when the shape factors are ignored. trajectory. It may result in the loss of computation (3) Most sequence similarity similarity (3) Most algorithms algorithms of of similarity similarity measurement measurement are are derived derived from from the the time time sequence computation without considering the temporal distance computation between two trajectory computation without considering the temporal distance computation between two trajectory points. Since the time measurement is different from the space measurement, it makes points. Since the time measurement is different from the space measurement, it makes no no sense sense just just to to simply simply add add two two weights. weights. To To solve solve that that problem, problem, Lee Lee et et al. al. proposed proposed aa trajectory trajectory distance distance measurement parallel distance, distance, the the perpendicular perpendicular measurement method method with with the the weighted weighted addition addition of of the the parallel distance, Unfortunately, thethe proposed measurement method by Lee distance,and andthe theangle angledistance distance[1]. [1]. Unfortunately, proposed measurement method by et al. cannot solve problems (1) and (2). Lee et al. cannot solve problems (1) and (2).

(a)

(b)

Figure 1. Various point sampling methods of the same trajectory. (a) A trajectory of two sampling Figure 1. Various point sampling methods of the same trajectory. (a) A trajectory of two sampling methods; and (b) two trajectories take the same point. methods; and (b) two trajectories take the same point.

To solve the above three problems, a segment-based trajectory similarity measurement To solve the abovetothree problems, a segment-based trajectory similarity measurement algorithm algorithm is proposed improve the accuracy. is proposed to improve the accuracy. 3. Problems and Definitions 3. Problems and Definitions Mobile objects generally have time and space attributes, respectively. Space attributes can be Mobile objects generally have time and space attributes, respectively. Space attributes can be three-dimensional or two-dimensional. Two-dimension is the most widely used, so all of the words three-dimensional or two-dimensional. Two-dimension is the most widely used, so all of the words “space” refers to two-dimension space in this paper. A trajectory records a continuous movement “space” refers to two-dimension space in this paper. A trajectory records a continuous movement trace trace of a mobile object. Due to the limitations of the GPS sensors, a trajectory T consists of a series of of a mobile object. Due to the limitations of the GPS sensors, a trajectory T consists of a series of points (x, y,t) x, y) is(x, is the recorded spatial recorded t is the recorded time. For convenience, a (points x, y, t), where, (where they)spatial point, t point, is the recorded time. For convenience, a natural natural trajectory and a trajectory sequence aredistinct. strictly distinct. trajectory and a trajectory sequence are strictly Definition (natural trajectory). trajectory). A A continuous continuous trajectory trajectory of of aa mobile mobile object. object. Definition 11 (natural Definition (trajectory sequence). sequence). With With aa given given Euclidean Euclidean space, space, aa natural natural trajectory trajectory can can be be expressed expressed as as Definition 22 (trajectory T ={ P , P ,..., P } P T = {1P12, P2 , ..., the discrete trajectory points ordered by time,i Prefers thetrajectory trajectorypoint pointii,, the discrete trajectory points are are ordered by time, n }, where i referstotothe n ,Pwhere PPi =( =x(,xyi,,zy)i ,, zand n represents the number of points in the trajectory. T is the recorded trajectory sequence i ), and n represents the number of points in the trajectory. T is the recorded trajectory sequence from i i i i from the natural trajectory. the natural trajectory.

Sensors 2017, 17, 524

4 of 16

Definition 3 (sub-trajectory segment). Two adjacent discrete trajectory points to form a trajectory segment

Pi and Pi+1 are connected

PP i i+1 , which is a sub-trajectory segment.

524 Sensors 2017, 17, 524

4 of 16

Definition 4 (natural sub-trajectory segment). A part of the natural trajectory between two adjacent Definition 3 (sub-trajectory segment). adjacent discrete trajectory discrete trajectory points is constructed as aTwo natural sub-trajectory segment.points Pi and Pi+1 are connected Definition 3 (sub-trajectory segment). Two adjacent discrete trajectory points Pi and Pi+1 are connected to , which a sub-trajectory segment. to form a trajectory segment i 1i+1 form a trajectory Pi PiPP , which is aaissub-trajectory segment. + A trajectorysegment sequence consists of series of discrete points. Two adjacent discrete points are connected to form a sub-trajectory segment. Moreover, a real trajectory segment must exist between Definition 44 (natural (natural sub-trajectory sub-trajectory segment). segment). A part of the the natural natural trajectory trajectory between two adjacent Definition two adjacent discrete points. In Figure 2, S T 1 and S T 2 are a sub-trajectory segment and a natural constructed as as aa natural natural sub-trajectory sub-trajectory segment. segment. discrete trajectory points is constructed sub-trajectory segment, respectively. discrete points. points. Two adjacent discrete points are A trajectory sequence consists of a series of discrete connected to form a sub-trajectory segment. Moreover, a real trajectory segment segment must must exist exist between between connected to form a sub-trajectory segment. Moreover, a real trajectory two adjacent areaasub-trajectory sub-trajectory segment segment and and aa natural natural T 1 1 and S T22 are two adjacent discrete discrete points. points. InInFigure Figure2,2, SST and ST sub-trajectory segment, respectively. respectively.

Figure 2. A sub-trajectory segment and a natural sub-trajectory segment.

Definition 5 (proxy natural sub-trajectory segment). In Figure 3, Pseg1 is denoted as a medium point of the natural sub-trajectory segment between

Pi

and

Pi-1 .

Pseg2 is denoted as the medium point of the natural

Figure 2. A sub-trajectory sub-trajectory segment and natural sub-trajectory Figure 2. A and aanatural natural sub-trajectory sub-trajectory segment. segment. sub-trajectory segment between . The proxy segment of trajectory point Pi and Pi+ 1segment Pi is the natural sub-trajectory segment between Pseg1 and Pseg2 . Definition 5 (proxy natural sub-trajectory segment). In Figure 3, Pseg1 is denoted as a medium point of Definition 5 (proxy natural sub-trajectory segment). PIn Figure 3, Pseg1 is denoted as a medium point of and Pi-1 . aseg assub-trajectory the medium point of the natural the natural sub-trajectory segment between 2 is denoted Definition 6 (proxy sub-trajectory). midpoint of theas segment of natural Pmid 1 Pisi marked Pi and the natural sub-trajectory segment between Pi and Pi−1as . Pseg2 is denoted the medium point of the sub-trajectory segment between and . The proxy natural sub-trajectory segment of trajectory point P P is marked as thePmidpoint of . The sub-trajectory i i+ 1 the sub-trajectory segment of Pi and Pi+ Pi-1 , and Pm id 2 segment sub-trajectory between of1 trajectory point Pi is i and Pi+1 . The proxy natural sub-trajectory segment PsegP Pseg2P.i . is the sub-trajectory between and. of and Pi segment isbetween the proxy sub-trajectory formed by natural Pi natural the Pseg1 and Psub-trajectory Pm id 2 segment 1 seg2 mid 1 Pi

Definition 6 (proxy sub-trajectory). Pi-1 ,

and

Pm id 2

formed by

Pmid 1

is marked as a midpoint of the sub-trajectory segment of

is marked as the midpoint of the sub-trajectory segment of

Pmid 1 Pi

and

Pi Pm id 2

is the proxy sub-trajectory of

Pi

Pi

and

Pi+ 1

Pi

and

. The sub-trajectory

.

Figure 3. A Proxy of a natural sub-trajectory. Figure 3. A Proxy of a natural sub-trajectory.

A discrete trajectory sequence represents a whole natural trajectory. A trajectory point on its Definitionrepresents 6 (proxy sub-trajectory). Pmid1 trajectory, is marked ascalled a midpoint the sub-trajectory segment of of Pi and sequence a part of the natural as theofproxy natural sub-trajectory the P , and P is marked as the midpoint of the sub-trajectory segment of P and P . The sub-trajectory i i−1 A natural i+1proxy natural submid2 trajectory can only be stored as a trajectory sequence; thus, point. the Figure 3. A Proxy of a natural formed by Psegment Pi Pmid2 the proxy of Psub-trajectory. i .the proxy sub-trajectory of the trajectory mid1 Pi and trajectory cannot be isobtained. Itsub-trajectory can only obtain points. A discrete trajectory point on on its A discrete trajectory trajectory sequence sequence represents representsaawhole wholenatural naturaltrajectory. trajectory.A A trajectory point The problem to be solved in this paper is to compute the distance D ist( R , S ) between two given sequence represents a part of the trajectory, calledcalled as theasproxy natural sub-trajectory of the its sequence represents a part of natural the natural trajectory, the proxy natural sub-trajectory and S ={ SP longer the distance, trajectory sequences R andcan S, where Rstored = { P1 , P2 ,..., Pan }trajectory } . The 1 , SP2 ,..., SPmthus, point. A natural trajectory only be as sequence; the proxy natural subof the point. A natural trajectory can only be stored as a trajectory sequence; thus, the proxy the less similarity . S im ( R , S ) trajectory segment cannot be obtained. It can only obtain the proxy sub-trajectory of the trajectory natural sub-trajectory segment cannot be obtained. It can only obtain the proxy sub-trajectory of points. the trajectory points. The problem problem to to be be solved between two two given given D ist((R The solved in in this this paper paper is is to to compute compute the the distance distance Dist R,, SS)) between and S ={SSP= . The longer the distance, and S, S, where whereRR= = {{ P1P , P12, ,..., ,...,1SP trajectory sequences R and P2 ,P..., , SP {2SP n } Pn } and 1 , SP m } 2 , ..., SPm }. The longer the distance, the less similarity the less similarity . ( R, S). S im ( R , S )Sim

Sensors Sensors2017, 2017,17, 17,524 524

55ofof16 16

4. SDTW Algorithm 4. SDTW Algorithm Due to ignoring the relationship between a trajectory sequence and a natural trajectory, the current Due similarity to ignoringmeasurement the relationship between aare trajectory sequence and a natural trajectory, the current trajectory algorithms sensitive to the sampling methods. To reduce the trajectory of similarity measurement algorithms are sensitive to the sampling methods. To reduce the sensitivity the points sampling methods, a point-point distance can be converted to a distance from the points sampling methods, a point-point distance can be converted to a distance from asensitivity point to aofspecific segment, which is defined as a point-segment distance. There is fundamental a point tobetween a specific segment, is defined a point-segment distance.points. There In is athis fundamental difference the temporalwhich distance and theas spatial distance of trajectory paper, the difference between the temporal distance and thetospatial of trajectory points. In this paper, time difference and trajectory’ shape are integrated convertdistance a temporal distance into a spatial distance the time difference distance and trajectory’ shape are to convert a temporal intodistance, a spatial and the prediction is presented. Theintegrated DTW algorithm only uses the distance point-point distanceconsidering and the prediction distance important is presented. The DTW algorithm only uses thein point-point without the trajectory’s characteristic—shape—which results the low distance,of without considering theIftrajectory’s results in the accuracy the DTW algorithm. the shapeimportant factors arecharacteristic—shape—which included, the accuracy of the similarity low accuracy can of the algorithm. If the shape factors are included, the accuracy of the trajectory similarity measurement be DTW improved. A trajectory sequence is regarded as multiple continuous measurement can belies improved. A trajectory is regarded as multiple continuous trajectory segments, the shape in the difference of ansequence angle between trajectory segments. An included angle segments, the shape the difference of an angle between segments. Andistance. included angle can be considered intolies theinsimilarity calculation, and its result istrajectory the segment-segment can be into the similarity calculation, and result is the segment-segment distance. Theconsidered above three distances are integrated with theits traditional DTW algorithm to propose a new The abovedynamic three distances are integrated with the traditional DTW the algorithm to propose a new segment–based time warping algorithm (SDTW). SDTW adopts point-segment distance, segment–based dynamic time warping algorithm (SDTW). SDTWthe adopts the point-segment prediction distance, and segment-segment distance to compute accumulative distancedistance, of two predictionsequences, distance, which and segment-segment distance to compute the accumulative distance of two trajectory can improve the accuracy. trajectory sequences, which can improve the accuracy. 4.1. Point-Segment Distance 4.1. Point-Segment Distance The spatial distance of two trajectory points can be converted to the spatial distance of their spatial distance of the two point-segment trajectory pointsdistance can be converted to the distance spatial distance their proxyThe trajectories. In fact, is the spatial of the of pair of proxy two trajectories. In fact, the point-segment distance the spatial distance of the of twoby trajectory points. trajectory points. The distance of the two proxyistrajectories, areapair enclosed them (Figure S true is the TheThe distance two proxy trajectories, Struecomputation is the area enclosed by The them (Figure The plane 4a). planeof is the an irregular polygon area, the is difficult. sum of S 14a). enclosed by is an irregular polygon area, the computation is difficult. The sum of S1 enclosed by P1 and Seg2 P1 and S e g 2 and S 2 enclosed by P2 and S eg1 (Figure 4b) shows a positive correlation with S true . and S2 enclosed by P2 and Seg1 (Figure 4b) shows a positive correlation with Strue . That is, when the That is, when the relative displacement the two proxy trajectories trend of S 1 as+ that S 2 is relative displacement of the two proxyof trajectories occurs, the trendoccurs, of S1 +the S2 is the same of the same thatcan of be . So, S truewith canthe besum replaced sum of S true S 1 and S 2 . Strue . So,as Strue replaced of S1 with and Sthe . 2

(a)

(b)

Figure 4. Two computation methods of the proxy sub-trajectory distance. (a) The area enclosed by the Figure 4. Two computation methods of the proxy sub-trajectory distance. (a) The area enclosed by the two proxy trajectories; and (b) a simplified calculation method. two proxy trajectories; and (b) a simplified calculation method.

It is obvious that the distance calculation method based on the area is not an effective approach, It is obvious that the distance calculation methodsub-trajectory, based on the area is not an effective approach, especially for a trajectory point with a long proxy which results in a larger sum especially for a trajectory point with a long proxy sub-trajectory, which results in a larger sum enclosed enclosed by it and other proxy trajectories. From the above analysis, the length of Seg1 and Seg 2 by it and other proxy trajectories. From the above analysis, the length of Seg and Seg2 shows a positive shows a positive correlation with the condition of a trajectory point with a 1long proxy sub-trajectory. correlation with the condition of a trajectory point with a long proxy sub-trajectory. The longer a The longer a trajectory is, the worse the result is. It can adopt S / S eg to convert the spatial distance trajectory is, the worse the result is. It can adopt S/Seg to convert the spatial distance between P1 and between P1 and P2 into the sum of the distance from P1 and S e g 2 , and the distance from P2 and P2 into the sum of the distance from P1 and Seg2 , and the distance from P2 and Seg1 . That is, S/Seg is Thatofis,point-segment sum of point-segment distances. S / S eg is the distances. Sthe eg1 .sum  trajectory point on trajectory the trajectory sequence Assume Assume that PP point i oni the sequence R, andR, SPand x j , ySP  xtrajectory i (i xxii,,yyi ) isistrajectory j j jis j , y j  is  point j onpoint the trajectory sequence S. Define dist the distance ofdistance Pi and SP ps Pi , SP j as P dist , SPpoint-segment as the point-segment ofj . trajectory j on the trajectory sequence S. Define ps



i

j



Sensors 2017, 17, 524

6 of 16

Sensors 2017, 17, 524

Pi

6 of 16

and

SPj . Define dist ps  SPj , Pi  as the point-segment distance of SPj





and

, and

P

i    Define dist SP , P as the point-segment distance of SP and P , and dist P , SP 6 = dist SP , P ps ps ps i j i j i j j i . dist ps Pi , SPj  dist ps SPj , Pi . Figure 5 illustrates the point-segment distance computation. Figure 5 illustrates the point-segment distance computation.





Figure 5. Point-segment Point-segmentdistance. distance. Figure 5.

 SPj SPand, SPj-1 , To To compute tocompute compute midpoint ofj and 1  x,mid 1, ymid 1  SP j  j, ,ititis computedist distpsps PiP, SP is first first to thethe midpoint Pmid1P xmid1 ymid1 (mid ) of i , SP j −1 midpoint PPmid2(xxmid2, ,yymid2 ) of of SP SPj+1 . Pmid1 ( xmid1 , ymid1 ) and Pmid2 ( xmid2 , ymid2 ) can j and SP andand thethe midpoint j and SPj 1 . Pmid1  xmid1, ymid1  and Pmid 2  xmid 2 , ymid 2  can mid 2 mid 2 mid 2 computed as follows Equation (1):

computed as follows Equation (1): (

   , ymid1 ) = x j−1 + x j /2, y j−1 + y j /2 ( xmid1   xmid  / 2, y j 1  y j / 2    x 1 x x j /2, 1, ymid  , ymid2 y j + y j+1 /2 ( xmid2 ) 1= x j j+ j +1   xmid 2 , ymid 2   x j  x j 1 / 2, y j  y j 1 / 2  distance between P and R . dist P , R Then it computes the shortest

 

i

q between Then it computes the shortest distance 2     q

   

   

seg

ps

i

(1)

(1) seg



is [17]:

and Rseg . dist ps  Pi , Rseg  is [17]:

Pi

( xi − xmid1 ) + (yi − ymid1 )2

if r ≤ 0

2 2 (2) (xi − xxmid2 )2 + (2 y − ymid2 ymid) 1  if i rf  r0≥ Lseg  i  xmid 1  i  yi  q      ( x − dx )2 + − dy)22 otherwice 2 (y  dist ps ( Pi , Rseg )    xii  xmid 2    ymid1 y if r  Lseg (2) i mid 2   2 2 where r = ( xmid2 − xmid1 ) × ( xi − xmid1) + (xymid2 − ymid1 ) ×(dy yi − ymid1 ); Lseg is the length of the otherwice  1  i  dx    ymid derivation segment, dx = ( xmid1 + ( xmid2− xmid1 ) × r/Lseg ):dy = (ymid1 + (ymid2 − ymid1 ) × r/Lseg ).    The formula for dist ps SPj , Pi is the same as dist ps Pi , SPj , and the spatial distance dist p Pi , SPj r  x and xmid1with  xSDTW ymid  ymid1  in   Equation yi  ymid1  (3):    xithe ; Lseg is the length of the derivation where 2  SP mid1    is betweenPimid as2 shown j segment, dx  ( xmid1   xmid 2  xmid1   r / Lseg  ) : dy  ( ymid 1  ymid 2  ymid1   r / Lseg ) . dist p Pi , SPj = dist ps Pi , SPj + dist ps SPj , Pi (3) The formula for dist ps SPj , Pi is the same as dist ps Pi , SPj , and the spatial distance dist p Pi , SPj

dist ps ( Pi , Rseg ) =





















4.2. Prediction Distance SP

between

Pi

and

j

with the SDTW is as shown in Equation (3):

Most of the trajectory similarity measurement algorithms are introduced from the time sequence dist ps SPj ,data. Pi similarity algorithms without dist considering todist optimize the However, the time series (3) p Pi , SPj  ps Pi , SP j trajectory data measurement and space measurement of the trajectory are essentially different, so it is necessary to figure out a solution to calculate the temporal distance integrated with spatial distance. 4.2. Prediction Distance In Figure 6, the time distance between Pi on trajectory R and SPj on trajectory S is computed. The timestamp of Pi is tisimilarity , the timestamp of SPj is talgorithms between ti from and t jthe cantime actually j . The difference Most of the trajectory measurement are introduced sequence be reflected on a specific trajectory. Assume that Pi is regarded as a mobile object. When ti < t j , similarity algorithms without considering to optimize the trajectory data. However, the time series its space location after the time interval t j − ti is the space location of R at the timestamp t j , known as data measurement and space measurement of the trajectory are essentially different, so it is necessary a prediction position of Pi , denoted as Pi0 .













to figure out a solution to calculate the temporal distance integrated with spatial distance. In Figure 6, the time distance between The timestamp of

Pi

is

ti

Pi

on trajectory R and SPj on trajectory S is computed.

, the timestamp of SPj is t j . The difference between

actually be reflected on a specific trajectory. Assume that

Pi

ti

and t j can

is regarded as a mobile object. When

ti

< t j , its space location after the time interval t j  ti is the space location of R at the timestamp t j , known as a prediction position of

Pi

, denoted as

Pi ' .

Sensors 2017, 17, 524

7 of 16

Sensors 2017, 17, 524

7 of 16

Figure 6. 6. Prediction Prediction distance. distance. Figure

SPis The temporal temporal distance andSP is converted into the spatial distance between the Pi and The distance between between P i j j converted into the spatial distance between the 0 prediction SPj ,SP known as theas prediction distance. It can convert temporal distance and the prediction distance. It can aconvert a temporal predictionlocation locationofofPi Pand j , known i' into a spatial distance, and reflect the time distance of trajectory points on the trajectory. It can be distance into a spatial distance, and reflect the time distance of trajectory points on the trajectory. It seen thatseen he prediction distance distance has goodhas interpretability. It can effectively improve the accuracy can be that he prediction good interpretability. It can effectively improve the of similarity measurements. Therefore, the natural trajectory cannot be recorded, so the similarity accuracy of similarity measurements. Therefore, the natural trajectory cannot be recorded, so the measurement should be based trajectory similarity measurement shouldonbethe based on thesequence trajectorydata. sequence data.  Assume that Pi ( xi , yi , ti ) represents a trajectory point i on trajectory R and SPj x j , y j , t j is Assume that Pi  xi , yi ,ti  represents a trajectory point i on trajectory R and SP  x , y , t  is a a trajectory point j on trajectory S. To compute the prediction distance between Pij ( xij, yij, tji ) and   xi , yi ,ti  and trajectory on compares trajectorythe S. timestamps To compute prediction distance SP , one jfirst of the Pi and SPj . The point withbetween an earlierPitimestamp is j x j , y j , t jpoint set as A, and the other with the later timestamp as B. Their time difference is ∆t = t − t . B timestamp SPj  x j , y j , t j  , one first compares the timestamps of Pi and SPj . The point with an A earlier The next step is to compute the prediction location of point B with the later timestamp, named as is set as A, and the other with the later timestamp as B. Their time difference is  t  t  t . B0 . Since the information stored in the trajectory sequence is limited and the positionsA ofBthe moving nextbe step is to compute the prediction location of point B only with an theapproximate later timestamp, named objectThe cannot obtained at any time, the prediction location B0 is position of B ' as . Since the information stored in the trajectory sequence is limited and the positions of the point B. Then, it traverses the timestamp for each trajectory point to search the track range of point B moving object cannot beSuppose obtainedatat time, thet prediction location B ' is only an approximate at the timestamp t B + ∆t. theany timestamp B + ∆t, point B is located between point i − 1 and position of point B. Then, it traverses the timestamp for each trajectory point to search the track range i. The spatial coordinates ( x B0 , y B0 ) of the prediction position B0 can be calculated as follows: of point B at the timestamp t B   t . Suppose at the timestamp t B   t , point B is located between ( x x B0 = xi− x1B+ ∆t − ti−1 ) position B ' can be calculated as (tthe point i  1 and i. The spatial coordinates B +prediction  , yvBi ×of (4) y y = y + v × t + ∆t − t i −1 ) 0 ( B i −1 B follows: i x Suppose that it is a uniform linearmotion on the trajectory, it can compute  ttwo  ti 1points xB  xi between  1  vi   tBany (4)  y the velocity between two points as follows:  yB  yi 1  vi   tB  t  ti 1  ( = ( xi −between xi−1 )/∆tany Suppose that it is a uniform linearvixmotion two points on the trajectory, it can i (5) y (yi − yi−1 )/∆ti compute the velocity between two pointsvias=follows:

vix   xi trajectory xi 1  / ti point B at the timestamp t B + ∆t, the B0 If there does exist the corresponding recorded (5)  y can be estimated as follows: vi   yi  yi 1  / ti ( If there does exist the corresponding x B0 = x B +recorded /(t N − t1 point ( x N − x1 )trajectory ) × ∆tB at the timestamp t B   t , the (6) B ' can be estimated as follows: y B0 = y B + (y N − y1 )/(t N − t1 ) × ∆t  xB  on xB  t1  which  x1  /  t N on t  xNtrajectory, where N is the total number of the points the point B is located.  y y y y / t t t             B B N 1 N 1  The prediction distance between A and B is calculated as follows:

 which point B is located. where N is the total number of the points on the trajectory, on distt ( A, B) = dist A, B0 The prediction distance between A and B is calculated as follows:

(6) (7)

where dist(A, B0 ) is the Euclidean distance between A and B0 in the coordination. dist (7) t  A, B  dist  A, B The prediction distance between A and B also presents the point-segment distance between point  is the Euclidean distance between A and B ' in the coordination. A and segment dist  A, BBB’. where

The prediction distance between A and B also presents the point-segment distance between point A and segment BB’.

Sensors 2017, 17, 524

8 of 16

4.3. Segment-Segment Distance Sensors 2017, 17, 524

Suppose that

8 of 16

Si

is one segment i on the trajectory R, and SS j is one segment j on the trajectory

two endpoints are Pi  xi , yi  and Pi 1  xi 1, yi 1  , and SS j ’s two endpoints are S. Suppose that S i ’sDistance 4.3. Segment-Segment S Pj  x j , y j  and SPj 1  x j 1 , y j 1  , respectively. The segment-segment distance is dists  Pi , SPj  can be Suppose that Si is one segment i on the trajectory R, and SS j is one segment j on the trajectory S. calculatedthat as follows. Suppose Si ’s two endpoints are Pi ( xi , yi ) and Pi+1 ( xi+1 , yi+1 ), and SS j ’s two endpoints are    The point-point the spatial and the temporal SPj x j , y j and SPj+1 distance x j+1 , y j+1includes , respectively. Thedistance segment-segment distancedistance. is dists The Pi , SPspatialj can dist st  Pi , SPj  between Pi and SPj is calculated as shown in Equation (8): temporal distance be calculated as follows. The point-point distance includes the spatial distance and the temporal distance. The ,SPj SP  t is dist  Pji, SPbetween  Pi i and j   dist p P t  Pi ,SPj  as shown in Equation (8):(8) spatial-temporal distance distst dist Pi , stSP calculated j  The larger parameter   sensitive the distance to where t is the time sensitivity parameter. t is, the more distst Pi , SPj = dist p Pi , SPj + t × distt Pi , SPj (8) the time dimension is. When parameter t = 0, the time dimension cannot be neglected. segment-segment distance is thet is, sum spatial-temporal distances whereThe t is the time sensitivity spatial-temporal parameter. The larger parameter the of more sensitive the distance to between the two ends of the segments. thebesegment-segment spatial Si , SSdimension j  represents the time dimension is. When parameter t = 0,dist thest time cannot neglected. The segment-segment spatial-temporal distance is the sum of spatial-temporal distances between SS j , as shown temporal distance of S i and  in Figure 7. distst  Si , SS j  can be calculated as follows: the two ends of the segments. distst Si , SS j represents the segment-segment spatial-temporal distance  of Si and SS j , as shown in Figure SSstj  Pcan asj 1follows: dist7. Si , SSstj Si ,dist distst  Pi 1 , SP  (9) st dist i , SPbe j  calculated    andst the angle calculate the segment-segment Then, distst  Si , SS j  dist Si , SS distst Pican , SPjbe+combined distst Pi+1to , SP (9) j =distance j +1  included angle between S and SS j in Equation (10), denoted as  : distance. It computes the Then, distst Si , SS j and the angle distance can ibe combined to calculate the segment-segment distance. It computes the included angle between S and SS in Equation  arctan2  y  y , x  x  i arctan2 j y  y , x (10), x  denoted as θ: (10) i 1

i

i 1

i

j 1

j

j 1

j

 arctan2(yif θ =condition, yi , xi+1 −angle xi ) − arctan2 y j+1 −dist y jst, xSj+ x (10) i +the 1 − included 1− Under the same  increases, i , SS j  jshould be multiplied should be integrated diststshould withUnder a certain forcondition, the computation. Thus, angle  Si , SS j be: multiplied thetime same if the included θ increases, diststwith Si , SS j  with a certain time for the computation. Thus, θ should be integrated with distst Si , SS j : dists  Si , SS j   f ( )distst  Si , SS j  (11)   dists Si , SS j = f (θ )distst Si , SS j (11) where f ( ) can be computed in Equation (12): distsmid (Si , SS j ) where f (θ ) can be computed in Equation (12):  (   ) f ( )  (12) distmax (R, S ) distsmid (Si , SS j ) f (θ ) = × (ω + θ ) (12) where  is an adjustable parameter and dist the max shape factor. The greater  , the less sensitive ( R,negative S)

the distance to the shape factor. If there are no special requirements, let   1 . distsmid (Si , SS j ) is the where ω is an adjustable parameter and the shape negative factor. The greater ω, the less sensitive SS j . dist max ( R , Slet and requirements, spatial-temporal between midpoints ) is i the distance to thedistance shape factor. If there are no Sspecial ω the = 1.maximum distsmid (Stemporal i , SS j ) is distance between any two points of trajectory sequences Rj and Furthermore, it makes no sense to the spatial-temporal distance between midpoints Si and SS . distS. ( R, S ) is the maximum temporal max comparebetween the shapes two trajectory sequences with a long The shorter the distance, distance anyoftwo points of trajectory sequences R anddistance. S. Furthermore, it makes no sensethe to distsmid (Si ,with SS j ) a long distance. The shorter the distance, the compare the shapes of two trajectory sequences more important the shape factor. Thus, distsmid (Si ,SS j ) is used to dynamically adjust the weight of the more important the shape factor. Thus, dist max ( R, S ) is used to dynamically adjust the weight of the shape shapefactor. factor.

distmax ( R,S)

Figure7.7. Segment-Segment Segment-Segment Distance. Distance. Figure

Sensors 2017, 17, 524

9 of 16

4.4. SDTW Computation Sensors 2017, 17, the 524 segment-segment distances between trajectory sequences R and S have 9 of 16been After all of calculated, the accumulative distance is computed derived from the idea of the DTW algorithm. 4.4. SDTW Computation Similar to the DTW algorithm, the similarity measurement of the SDTW is as follows:

After all of the segment-segment distances between trajectory sequences R and S have been  calculated, theaccumulative distance is computed frommthe 0 , i f nderived = 0 and = 0idea of the DTW algorithm.   Similar to the  DTW algorithm, the similarity∞measurement themSDTW  , i f n = 0ofor = 0 is as follows:

SDTW ( R, S) =





(13) 0 ,if n m  0 ( T, Rest (S ))  0 andSDTW      dist Head R , Head S + min otherwise ( ( ) ( )) SDTW S, Rest T ( ( ))    , if n 0 or m 0 s        ( T S), Rest(S))  SDTW SDTW(Rest T , Rest SDTW  R, S    (13) dist  Head  R  , Head  S    min  SDTW  S , Rest T   otherwise   s number of line segments on the trajectory sequence R, m is the number of line segments   SDTW  Rest T  , Rest  S   

where n is the on the trajectory sequence S, and Head( R) indicates the first trajectory sequence S1 , and Rest( R) is the where n is sequence the number of line segments onHead the trajectory m iss (the number of line new trajectory after R eliminated ( R). Thatsequence is to say,R,dist Head ( R), Head (Ssegments )) represents indicates the first trajectory sequence , and on the trajectory sequence S, and Head ( R ) R e st ( R ) is S the segment-segment distance between Head( R) and Head(S). 1 distsimilarity say,the the new trajectory sequence after R eliminated  S   the Head ( R ) . That is to The computed accumulative distance is negative correlation with between s  Head  R  , Head trajectory sequences. The accumulative distances of different two trajectories will be quite different, represents the segment-segment distance between Head ( R ) and Head ( S ) . thus, it cannot directly compare the accumulative distances. It is necessary convert the accumulative The computed accumulative distance is negative correlation with thetosimilarity between the trajectory sequences. The distances of different two trajectories will be quite different, distance into the range [0, 1],accumulative where 0 means the two trajectories are irrelevant and 1 means the two thus, itarecannot directly thefunction accumulative distances. It kernel is necessary to convert the trajectories the same. The compare conversion uses the Gaussian function. The conversion accumulative distance into the range [0, 1], where 0 means the two trajectories are irrelevant and 1 function is shown as Equation (14): means the two trajectories are the same. The conversion function uses the Gaussian kernel function. The conversion function is shown as Equation (14): − D2 ( R,S)/2σ2

∈ [0, 1]

Sim( R, S) = e

Sim  R , S   e

 D 2 ( R , S )/ 2 2

 [0,1]

(14)

(14)

where D represents the accumulative distance of R and S, σ is used to describe the sensitivity of the is used toisdescribe the sensitivity of and wheretoDthe represents the accumulative distance R and similarity accumulative distance. With the of same D, S, thesimilarity higher when σ is larger, the similarity to the accumulative distance. With the same D, the similarity is higher when  is the similarity is lower when σ is small. In Figure 8, when d = 10, with the increase of σ, the value of larger, and the similarity is lower when  is small. In Figure 8, when d  10 , with the increase of sim grows within the range σ from 0 to 1.5. When σ is in the range from 1.5 to 6, the value of  , theslowly value of sim grows slowly within the range  from 0 to 1.5. When  is in the range from 1.5 sim grows rapidly. σ is greater andgrows approaches 1. approaches 1. to 6, the value ofWhen sim grows rapidly. than When6,sim is grows greater slowly than 6, sim slowly and

Figure 8. The sensitivity analysis about the value of  .

Figure 8. The sensitivity analysis about the value of σ.

To sum up, the pseudocode of the SDTW algorithm proposed in the paper for the similarity computation two trajectory is as follows: proposed in the paper for the similarity To sum up, for thethe pseudocode of sequences the SDTW algorithm As described in Algorithm 1, it first calculates the point-segment distance between each track computation for the two trajectory sequences is as follows: point in the two trajectories according to Equation (3). If there is a temporaldistance attributebetween in the trajectory As described in Algorithm 1, it first calculates the point-segment each track data, it also needs to use Equation (7) to calculate the prediction distance. The segment-segment point in the two trajectories according to Equation (3). If there is a temporal attribute in the trajectory distance between each segment is then calculated using Equations (11) and (12). The subsequent data, it also needs to use Equation (7) to calculate the prediction distance. The segment-segment calculation is the same as the DTW, and the final result is calculated using Equations (13) and (14) distance between each segment is then calculated using Equations (11) and (12). The subsequent after initializing the accumulation distance matrix. calculation is the same as the DTW, and the final result is calculated using Equations (13) and (14) after initializing the accumulation distance matrix.

Sensors 2017, 17, 524

10 of 16

Algorithm 1. SDTW Input: Two trajectory sequences R = { P1 , P2 , ..., Pn } and S = {SP1 , SP2 , ..., SPm } Output: Sim, the similarity between R and S 1: for i = 0 to n //Calculate all point-segment distance 2: for j = 0 to m 3: psDist[i][j] = caclPSDistance (p[i], sp[j]) 4: for i = 0 to n //Calculate all prediction distance 5: for j = 0 to m 6: tDist[i][j] = caclTDistance (p[i], sp[j]) 7: for i = 0 to n − 1 //Calculate all segment-segment distance 8: for j = 0 to m − 1 9: sDist[i][j] = caclSDistance (s[i], ss[j], psDist, tDist) 10: init(matrix) //Initial accumulation matrix 11: for i = 1 to n − 1 //Calculate accumulation distance 12: for j = 1 to m − 1 13: matrix[i][j] = sDist[i][j]+min (matrix[I − 1][j − 1], matrix[I − 1][j], matrix[i][j − 1]) 14: return gaussianKernel (matrix[n − 2][m − 2])

SDTW needs to traverse every trajectory point of the two trajectories when calculating the point-segment distance, the prediction distance and the segment-segment distance. caclPSDistance( ) is used to calculate the point-segment distance of two points in the two different trajectory sequences based on Equation (3). caclTDistance is used to calculate the prediction distance of two points in the two different trajectory sequences based on Equation (7). caclSDistance is to calculate the segment-segment distance based on Equation (11). caclPSDistance and caclSDistance only involve the calculated points or segments, without considering the other points or segments. The computational complexity of function caclPSDistance and caclSDistance is constant order O(mn). In Equation (7), the dichotomy is used to find the trajectory point interval where the predicted point is located. The computational complexity of caclTDistance is O(log(m + n)mn). The computational complexity of DTW is also O(mn). The computational complexity of SDTW is O(mn) for the trajectory data without the timestamp attribute, otherwise the computational complexity of SDTW is O(log(m + n)mn) for the data with the time-stamp attribute. In this paper, the SDTW algorithm does not change the core concept of the DTW, and just replaces the DTW distance computation method with three types of distance. The SDTW can also use the lower limit of the DTW distance algorithm to improve the execution efficiency. Moreover, the point-segment distance, prediction distance and segment-segment distance can be integrated with the LCSS, EDR, and other algorithms to propose new approaches to the similarity measurement. 5. Performance Evaluation 5.1. Experimental Dataset and Metrics The dataset used in the experiments are the GPS GeoLife Trajectories dataset from Microsoft Research [18] and CVRR Trajectory Analysis Dataset [19]. The experiments use the GeoLife dataset to compare DTW and SDTW. The dataset consists of GPS trajectory data of 182 users over five years, for a total length of 1,292,951 km, but the single trajectory sequence is too long, leading to rare trajectories with a high similarity, so the trajectory sequences in the dataset is split into about 500,000 shorter ones indexed with an R* tree. The dataset does not give the trajectory sequence relationship, so the experiment results can be evaluated through visual analysis. The experiment uses the CVRR dataset to quantitatively analyze the accuracy, the robustness of the measurement algorithms, and the effects of the parameters. The dataset is specifically for assessing the trajectory analysis algorithm, and it mainly includes three types of trajectory data: the I5 dataset, the driving trajectory of a car on a two-way highway; the Labomni dataset, the data of people walking

Sensors 2017, 17, 524

11 of 16

Sensors 2017, 17, 524

11 of 16

in the laboratory 9a); and(Figure the Cross the simulation of simulation vehicles driving straight and people walking in(Figure the laboratory 9a); dataset, and the Cross dataset, the of vehicles driving turning at crossroads (Figure 9b). All of these datasets mark the clusters of each trajectory. These straight and turning at crossroads (Figure 9b). All of these datasets mark the clusters of each datasets can be clustered onclustered the trajectory measure similarity algorithm.measure The obtained clustering trajectory. These datasetsbased can be basedsimilarity on the trajectory algorithm. The results can be compared with the correct clusters, which have been marked in the dataset, and give the obtained clustering results can be compared with the correct clusters, which have been marked in the accuracy analysis of the proposed SDTW algorithm. It should be noted that the I5 dataset is comprised dataset, and give the accuracy analysis of the proposed SDTW algorithm. It should be noted that the of mainly trajectories, and most algorithms can obtain good results. Therefore, thegood experiments I5 dataset linear is comprised of mainly linear trajectories, and most algorithms can obtain results. only use the Cross dataset and Labomni dataset. Therefore, the experiments only use the Cross dataset and Labomni dataset.

(a)

(b)

Figure 9. Labomni dataset (a) and Cross dataset (b). Figure 9. Labomni dataset (a) and Cross dataset (b).

In the experiments, the error rate is included as one of metrics to evaluate the performance. In the experiments, the error rate is included as one of metrics to evaluate the performance. Definition 8 (error rate). The error rate (ER) is the rate of wrongly-clustered trajectory sequences, which is Definition 7 (error rate). The errortherate (ER)the is higher the ratethe of accuracy wrongly-clustered trajectory sequences, which of is different from CCR [20]. The lower value, of the algorithm. Suppose the number different from CCR [20]. The lower higherofthe accuracy thethe algorithm. Supposeofthe of the known trajectory sequences is N,the thevalue, total the number clusters is k,ofand correct number thenumber sequence the known trajectory sequences is N, the total number of clusters is k, and the correct number of the sequence belonging to the class c is p c . The error rate is defined as follows: belonging to the class c is pc . The error rate is defined as follows: 1 k ER  1  1k pc ER = 1 − N c ∑ 1 pc N c= 1

(15) (15)

5.2. Search Search Similar Similar Trajectory Trajectory 5.2. The experiments use the same dataset of trajectory sequences for the trajectory queries. It can compute and obtain the top 15 most similar trajectory sequences with the original query trajectory in the dataset, thethe SDTW andand DTW algorithm, respectively. The computational results dataset,through throughexecuting executing SDTW DTW algorithm, respectively. The computational are visually displayed on the map. The original trajectory is shown is inshown Figure in 10a, and the query results are visually displayed on the map. The query original query trajectory Figure 10a, and results of the SDTW algorithm and DTWand algorithm are shownare in shown Figure in 10b,c, respectively. the query results of the SDTW algorithm DTW algorithm Figure 10b,c, respectively. In Figure 10b, most of the query results of the trajectory sequence are close to the original query trajectory, and results have low similarity in trajectory, and have havehigh highsimilarity similarityininshape. shape.InInFigure Figure10c, 10c,many manyquery query results have low similarity shape, compared with the original query trajectory. The reason is that the SDTW algorithm considers in shape, compared with the original query trajectory. The reason is that the SDTW algorithm the shape the factor of the natural trajectory uses the distance todistance reduce the loss of the considers shape factor of the natural and trajectory andpoint-segment uses the point-segment to reduce sampling onmethod the accuracy, the SDTW algorithm more accurate than the DTW loss of themethod sampling on theso accuracy, so the SDTW is algorithm is more accurate thanalgorithm. the DTW

algorithm.

Sensors 2017, 17, 524

12 of 16

Sensors 2017, 17, 524

12 of 16

Sensors 2017, 17, 524

12 of 16

(a)

(b)

(c)

Figure 10. Query results of trajectory sequences with the SDTW and DTW algorithms. (a) The original

Figure 10. Query results trajectory sequences with the SDTW algorithms. (a) Theoforiginal query trajectory; (b)ofQuery results of trajectory sequences withand the DTW SDTW; (c) Query results query trajectory; (b) Query results of trajectory sequences with the SDTW; (c) Query results of trajectory trajectory sequences with the DTW algorithms. (a) (b) (c) sequences with the DTW algorithms. 5.3. Clustering Error Rate Comparison Figure 10. Query results of trajectory sequences with the SDTW and DTW algorithms. (a) The original query trajectory; (b)based Queryonresults of trajectory (c) Query results The experiment is the CVRR datasetsequences with clutowith [21] the as aSDTW; clustering tool. cluto is aoflow5.3. Clustering Error Rate Comparison trajectory clustering sequences with DTW algorithms. data software package for the analysis of the dimensional andthehigh-dimensional

The experimentof is basedcategories. on the CVRR cluto [21] as a clustering clustering tool. cluto is a characteristics various cluto candataset provide with a variety of optimized algorithms, 5.3. Clustering Error Rate Comparison low-dimensional clustering and high-dimensional data software package for the analysis of the and support the trajectory clustering based on the similarity matrix. In order to evaluate the accuracy of similarity measurement, LCSS, EDR, characteristics of various categories. cluto candataset provide variety ofaalgorithms, optimized clustering The experiment is based on the CVRR withacluto [21]four as clustering tool. cluto is DTW, a algorithms, lowand SDTW areclustering selected toand cluster the trajectory First, the trajectory similarity matrix of dimensional high-dimensional data software package for the analysis of the and support the trajectory clustering based on thesequences. similarity matrix. two datasets are generated with the similarity measurement algorithm. Then, it is clustered with characteristics of various categories.ofcluto can provide a variety of optimized clusteringLCSS, algorithms, In order to evaluate the accuracy similarity measurement, four algorithms, EDR, DTW, agglomerative hierarchical (AHC)on and with global optimization. Finally, the maximum and support the trajectory clustering based therbr similarity matrix. and SDTW are selected to cluster the trajectory sequences. First, the trajectory similarity matrix of ER ofIneach dataset is regarded as the of final result of clustering error As to the LCSS andDTW, EDR order to evaluate the accuracy similarity measurement, fourrate. algorithms, LCSS, EDR, two datasets are generated with the similarity measurement algorithm. Then, it is clustered  . In the experiments, algorithms, necessary specify threshold sequences. LCSS and EDR algorithms and SDTW it areis selected to to cluster thea trajectory First, the trajectory similarity matrix of with  varying agglomerative hierarchical clustering (AHC) and measurement rbr with global Finally, thewith maximum should calculate maximum ERthe with the threshold inoptimization. range from to is 5, clustered when the step two datasets arethe generated with similarity algorithm. Then,1 it is setdataset to 1.0. As to the SDTW it is necessary to specify the rate. parameter . The SDTW agglomerative clustering (AHC) and rbr global optimization. Finally, the maximum ER of each ishierarchical regarded as algorithm, the final result of with clustering error As tothe LCSS and EDR  error algorithm calculate the maximum ERresult with parameter varying 1 tothe 10, when the EDR step ER ofiteach dataset is regarded as the final clustering rate.from AsLCSS to LCSS and algorithms, is should necessary to specify a threshold ε.of In the experiments, and EDR algorithms  in Gaussian set to 1.0. it It should be to noted that threshold letting the . In parameter function algorithms, necessary experiments, LCSS and1 kernel EDR should calculate theismaximum ERspecify with athe threshold ε the varying in range from to 5, algorithms when the step is 1  should thecan maximum with theclustering threshold results varying range11from 1 to 5, the when the step produceER very good [22].in Figure illustrates compared simij  0.1  calculate set to 1.0. SDTW algorithm N 2Asi to jthe SDTW algorithm, it is necessary to specify the parameter ω. The is set to 1.0. As to the SDTW algorithm, it is necessary to specify the parameter  . The SDTW of the clustering error rate with the four algorithms. should results calculate the maximum ER with parameter ω varying 1 to 10,1 to when the the step set to 1.0.  from algorithm should calculate the maximum ER with parameter varying from 10, when step 1 It should letting parameter σ inthe Gaussian kernel  infunction ∑i ∑ j sim setbetonoted 1.0. Itthat should be the noted that letting parameter GaussianN 2kernel function ij = 0.1 can 1 produce very good resultsvery [22]. Figure 11 illustrates the compared results the clustering good clustering results [22]. Figure 11 illustrates the of compared simij clustering  0.1 can produce i j N2 error rate with the four algorithms. results of the clustering error rate with the four algorithms.

(a)

(b)

Figure 11. Comparison of Clustering Error rates. (a) Clustering error rates based on the Cross dataset; and (b) clustering error rates based on the Labomni dataset.

(a)

(b)

Figure 11. Comparison of Clustering Error rates. (a) Clustering error rates based on the Cross dataset;

Figure 11. of Clustering (a) dataset. Clustering error rates based on the Cross dataset; andComparison (b) clustering error rates basedError on therates. Labomni and (b) clustering error rates based on the Labomni dataset.

Sensors 2017, 17, 524

13 of 16

Sensors 2017, 17, 524

13 of 16

As shown in Figure 11, the algorithms with various datasets lead to various error rates, but the order of the error rate is the same. The LCSS, DTW, and SDTW can obtain good clustering results, As shown in Figure 11, theisalgorithms datasets to lowest, variousand error and the EDR’s clustering effect poor. The with error various rate of the SDTWlead is the therates, errorbut ratethe of order the error ratethat is the same. TheThe LCSS, DTW, SDTW canisobtain good clustering and LCSS of is higher than of the DTW. error rateand of the SDTW 80%, 96.12%, and 44%results, lower than the effect with is poor. error rate ofrespectively; the SDTW isand the 35.82%, lowest, and the error rate of lower LCSS the EDR’s LCSS, clustering EDR, and DTW theThe Cross dataset, 77.01%, and 18.87% is higher than that dataset, of the DTW. The errorTorate of up, the the SDTW is 80%, 96.12%, and 44% better lower accuracy than the with the Labomni respectively. sum SDTW algorithm can obtain LCSS, EDR,ofand with the Cross dataset, respectively; 77.01%, and 18.87% lower with than that theDTW DTW, LCSS, and EDR. The reason is and that35.82%, the SDTW algorithm introduces the the Labomnidistance dataset,to respectively. Totemporal sum up, the SDTWinto algorithm can obtain better accuracy than prediction convert the distance the spatial distance, considering the that of thedistance DTW, LCSS, and EDR. The reason that the SDTW algorithm introduces the to prediction temporal factor. Additionally, SDTWisintroduces the segment-segment distance improve distance to convert the temporal distance into the spatialofdistance, considering the temporal distance the computation accuracy by adjusting the parameters shape factors. factor. Additionally, SDTW introduces the segment-segment distance to improve the computation 5.4. Noiseby Effect Analysis accuracy adjusting the parameters of shape factors.

To evaluate the robustness of various algorithm, noisy data at different levels is superimposed 5.4. Noise Effect Analysis into the original trajectory sequence data. The noise rate reflects the deviation points ratio in the To evaluate the robustness of various algorithm, at different is superimposed trajectory sequence. When the noise rate is ≤ 1), data it indicates that levels the trajectory points of  (0 ≤  noisy into the original trajectory sequence data. The noise rate reflects the deviation points ratio the toinnoise 100 % in the original data have been deviated to a certain extent. It is noted that due trajectory sequence. When the noise rate is λ (020≤times λ ≤ 1),and it indicates that the trajectory points of 100λ% randomness, the experiments are repeated the average value is taken to ensure the in the original data have been deviated to a certain extent. It is noted that due to noise randomness, the accuracy of the results. experiments are repeatedthe 20 times and the value is taken thestep accuracy of the results. In the experiment, variation of average is in the range [0.1, to 1] ensure with the 0.1. The deviation In the experiment, the variation of λ is in the range [0.1, 1] with the step 0.1. The deviation degree degree uses a random number. The deviation degrees of most deviation points are greater than the uses a random number. The deviation degrees of most deviation points are greater than the maximum maximum threshold  in the LCSS and EDR. The other parameters are set to the same value, as in threshold ε in the LCSS and EDR. The other parameters are set to the same value, as in the Section 5.3. the Section 5.3. Figure 12a,b Figure 12a,b illustrates illustrates the the experiment experiment results results with with the the Cross Cross and and Labomni Labomni datasets, datasets, respectively. respectively. The results of the clustering error rate are roughly consistent with the results Section 5.3. It can The results of the clustering error rate are roughly consistent with the results inin Section 5.3. It can be be seen LCSS, DTW, SDTW exhibit better accuracy the of case of noisy seen thatthat thethe LCSS, DTW, andand SDTW exhibit better accuracy thanthan EDR,EDR, eveneven in theincase noisy data. data. Onother the other the increase of amount the amount of noisy data, clustering error rates of On the hand,hand, with with the increase of the of noisy data, the the clustering error rates of all all algorithms increase gradually. From Figure themaximum maximumerror errorrate rateof of the the LCSS, LCSS, DTW, DTW, and algorithms increase gradually. From Figure 12,12,the and SDTW is below 0.15 when the noise ratio varies from 0.1 to 1.0, which indicates good robustness to SDTW is below 0.15 when the noise ratio varies from 0.1 to 1.0, which indicates good robustnessthe to noisy data for above three algorithms. However, EDR exhibits performance on the robustness the noisy datathefor the above three algorithms. However, EDR poor exhibits poor performance on the during the increase of noisy data. robustness during the increase of noisy data.

(a)

(b)

Figure 12. 12. Comparison Comparison of of noise noise effect effect on on the the algorithms. algorithms. (a) (a) Clustering Clustering error error rates rates based based on on the the Cross Cross Figure dataset; and (b) clustering error rates based on the Labomni dataset. dataset; and (b) clustering error rates based on the Labomni dataset.

On the other hand, In the Cross dataset, the average change ratio of ER in the LCSS, EDR, DTW, On the other hand, In the Cross dataset, the average change ratio of ER in the LCSS, EDR, DTW, and SDTW is 23.35%, 14.88%, 14.15%, and 13.64%, respectively. In the Labomni dataset, that is 11.1%, and SDTW is 23.35%, 14.88%, 14.15%, and 13.64%, respectively. In the Labomni dataset, that is 11.1%, 9.38%, 6.71%, and 4.21%, respectively. EDR and LCSS present poorer robustness than the DTW and 9.38%, 6.71%, and 4.21%, respectively. EDR and LCSS present poorer robustness than the DTW and SDTW. The conclusion that the robustness of the LCSS and EDR algorithms is better than the DTW SDTW. The conclusion that the robustness of the LCSS and EDR algorithms is better than the DTW when the deviation degree is greater than  from [4] is not correct. The above conclusion is similar when the deviation degree is greater than ε from [4] is not correct. The above conclusion is similar with [23]. The SDTW algorithm exhibits the best performance in terms of robustness, which benefits with [23]. The SDTW algorithm exhibits the best performance in terms of robustness, which benefits

Sensors 2017, 17, 524

14 of 16

Sensors 2017, 17, 524

14 of 16

from which decreases thethe effect of sampling methods on the and fromthe thepoint-segment point-segmentdistance, distance, which decreases effect of sampling methods onaccuracy the accuracy also improves the robustness to noise. and also improves the robustness to noise. 5.5. Parameter Effect Analysis 5.5. Parameter Effect Analysis In the SDTW algorithm, ωis an important parameter and determines the weight of the shape In the SDTW algorithm, is an important parameter and determines the weight of the shape factor in the similarity computation. The experiments evaluate the effect of parameter ω varying from factor in the similarity computation. The experiments evaluate the effect of parameter  varying 0.3 to 20, as listed in Table 1. The experiment dataset is based on Labomni dataset. Two metrics are from 0.3 to 20, as listed in Table 1. The experiment dataset is based on Labomni dataset. Two metrics used to compute the error rate, AHC and rbr, respectively. are used to compute the error rate, AHC and rbr, respectively. Table 1. Error rate with various ω values. Table 1. Error rate with various  values.

 0.3 0.3 0.5 0.5 1 1 1.51.5 22 2.5 2.5 AHC 0.061 0.019 0.013 0.006 0.006 0.006 AHC 0.061 0.019 0.013 0.006 0.006 0.006 rbr rbr0.2170.2170.061 0.0610.009 0.009 0.009 0.009 0.008 0.008 0.009 0.009 ω

33 0.006 0.006 0.01 0.01

3.5 3.5 66 10 10 20 20 0.007 0.008 0.010 0.007 0.008 0.0100.010 0.010 0.01 0.01 0.0110.011 0.011 0.01 0.01 0.011

FromTable Table11and andFigure Figure13, 13,when whenthe theω value value is relatively small, weight of the shape factor From is relatively small, thethe weight of the shape factor is  is quite large, which results in the high error rate. When the value lies in the range below 1.0, its quite large, which results in the high error rate. When the ω value lies in the range below 1.0, its small  small change will cause a great change in the error rate. When the value is larger than 1.0, its change will cause a great change in the error rate. When the ω value is larger than 1.0, its change will change will make effect on results. The show no with largethe difference with theFrom optimal make little effect on little the results. Thethe results show noresults large difference optimal results. the results. From the experimental results, the SDTW algorithm can obtain the optimal results with experimental results, the SDTW algorithm can obtain the optimal results with the appropriate value the of  . Furthermore, appropriate of parameter shape factors shouldotherwise, be properly parameter ω. value Furthermore, the shape factors shouldthe be properly optimized, theoptimized, improper otherwise, theshape improper weights of the factors may on result poor performance the error weights of the factors may result inshape poor performance the in error rate, as shown inonFigure 13. rate, as shown in Figure 13.

Figure 13. ER values. ER with with various various ωvalues.

Conclusions 6.6.Conclusions Withthe therapid rapiddevelopment developmentof ofsensor sensortechnology technologyand andthe thepopularization popularizationof ofpersonal personalsmart smart With devices, GPS sensors are widely used to track moving objects. A trajectory similarity measure is devices, GPS sensors are widely used to track moving objects. A trajectory similarity measure is oneone of of the most important steps trajectory data mining humanactivity activityand andvehicle vehiclemoving movingpatterns. patterns. the most important steps in in trajectory data mining ofofhuman Unfortunately,the themain mainsimilarity similarity measure algorithms with trajectory data have been found to Unfortunately, measure algorithms with thethe trajectory data have been found to be be inaccurate, highly sensitive to sampling methods, and have low robustness to the noise data. In inaccurate, highly sensitive to sampling methods, and have low robustness to the noise data. In order order solve theproblem, above problem, a segment-based dynamic timealgorithm warping algorithm to solvetothe above a segment-based dynamic time warping (SDTW) is (SDTW) proposedis proposed to measure the trajectory similarity. First, the proposed SDTW adopts the point-segment to measure the trajectory similarity. First, the proposed SDTW adopts the point-segment distance to distance to reduce the sensitivity influence of the trajectory sampling method. Then, considering the temporal distance factor, SDTW introduces the prediction distance to convert the temporal distance

Sensors 2017, 17, 524

15 of 16

reduce the sensitivity influence of the trajectory sampling method. Then, considering the temporal distance factor, SDTW introduces the prediction distance to convert the temporal distance into the spatial distance. Finally, SDTW introduces the segment-segment distance to improve the computation accuracy by adjusting the parameters of the shape factors. The experimental results indicate that the SDTW algorithm can obtain about 57%, 86%, and 31% better accuracy than the LCSS, EDR, and DTW, respectively. Meanwhile, the SDTW algorithm exhibits better robustness to the noise than that of the other algorithms. Acknowledgments: This study was supported by the National Key Technology Research and Development Program of the Ministry of Science and Technology of China under Grant No. 2013BAB06B04, 2016YFC0400910; Key Technology Project of China Huaneng Group under Grant No. HNKJ13_H17_04; Science and Technology Program of Yunnan Province under Grant No. 2014GA007; the Fundamental Research Funds for the Central Universities under Grant No. 2015B22214; NSF-China and Guangdong Province Joint Project: U1301252; the NSF of Changzhou Institute of Technology under Grant No. YN1303, the NSF of Colleges and Universities in Jiangsu Province under Grant No. 14KJB520003 and the Qing Lan Project of Jiangsu Province. The authors are grateful to the viewers for their comments which greatly improved the quality of the paper. Author Contributions: All four authors have contributed to the work presented in this paper. Yingchi Mao, Haishi Zhong, and Xiaofang Li formed the initial idea. Yingchi Mao, Haishi Zhong, and Xianjian Xiao developed the overall theoretical structure of the research. Yingchi Mao and Haishi Zhong conceived and designed the experiments. Haishi Zhong performed the experiments; Yingchi Mao and Haishi Zhong analyzed the data. Xianjian Xiao and Xiaofang Li provided the experiment dataset. All authors worked collaboratively on writing main text paragraph. Conflicts of Interest: The authors declare no conflict of interest.

References 1.

2. 3. 4.

5. 6. 7.

8.

9. 10.

11.

Lee, J.G.; Han, J.; Whang, K.Y. Trajectory clustering: A partition-and-group framework. In Proceedings of the ACM SIGMOD International Conference on Management of Data, Beijing, China, 11–14 June 2007; pp. 593–604. Das, R.D.; Winter, S. Automated urban travel interpretation: A bottom-up approach for trajectory segmentation. Sensors 2016, 16, 1962. [CrossRef] [PubMed] Basiri, A.; Amirian, P.; Mooney, P. Using crowdsourced trajectories for automated OSM data entry approach. Sensors 2016, 9, E1510. [CrossRef] [PubMed] Magdy, N.; Sakr, M.A.; Mostafa, T.; El-Bahnasy, K. Review on trajectory similarity measures. In Proceedings of the 2015 IEEE Seventh International Conference on Intelligent Computing and Information Systems, Cairo, Egypt, 12–14 December 2015; pp. 613–619. Kruskal, J.B. An Overview of Sequence Comparison: Time Warps, String Edits, and Macromolecules. SIAM Rev. 1983, 25, 201–237. [CrossRef] Kearney, J.K.; Hansen, S. Stream Editing for Animation; Department of Computer Science, Iowa University: Iowa City, IA, USA, 1990. Chen, L.; Zsu, M.T.; Oria, V. Robust and fast similarity search for moving object trajectories. In Proceedings of the ACM SIGMOD International Conference on Management of Data, Baltimore, MD, USA, 14–16 June 2005; pp. 491–502. Morse, M.D.; Patel, J.M. An efficient and accurate method for evaluating time series similarity. In Proceedings of the ACM SIGMOD International Conference on Management of Data, Beijing, China, 12–14 June 2007; pp. 569–580. Chen, L.; Ng, R. On the marriage of Lp-norms and edit distance. In Proceedings of the Thirtieth International Conference on Very Large Data Bases, Toronto, ON, Canada, 31 August–3 September 2004; pp. 792–803. Chen, Y.; Nascimento, M.A.; Ooi, B.C.; Tung, A.K.H. Spade: On shape-based pattern detection in streaming time series. In Proceedings of the IEEE 23rd International Conference on Data Engineering, Istanbul, Turkey, 11–15 April 2007; pp. 786–795. Wang, X.; Mueen, A.; Ding, H.; Trajcevski, G.; Scheuermann, P.; Keogh, E. Experimental comparison of representation methods and distance measures for time series data. Data Min. Knowl. Discov. 2013, 26, 275–309. [CrossRef]

Sensors 2017, 17, 524

12.

13. 14. 15. 16. 17. 18. 19.

20.

21. 22.

23.

16 of 16

Kim, S.W.; Park, S.; Chu, W.W. An Index-Based Approach for Similarity Search Supporting Time Warping in Large Sequence Databases. In Proceedings of the International Conference on Data Engineering, Heidelberg, Germany, 2–6 April 2001; pp. 607–614. Keogh, E.; Ratanamahatana, C.A. Exact indexing of dynamic time warping. Knowl. Inf. Syst. 2005, 7, 358–386. [CrossRef] Lemire, D. Faster retrieval with a two-pass dynamic-time-warping lower bound. Pattern Recognit. 2009, 42, 2169–2180. [CrossRef] Su, H.; Zheng, K.; Huang, J.; Wang, H.; Zhou, X. Calibrating trajectory data for spatio-temporal similarity analysis. VLDB J. 2015, 24, 93–116. [CrossRef] Nakamura, T.; Taki, K.; Nomiya, H.; Seki, K.; Uehara, K. A shape-based similarity measure for time series data with ensemble learning. Pattern Anal. Appl. 2013, 16, 535–548. [CrossRef] Wang, H. Two concise proofs of the formula of point to space linear distance. Stud. Coll. Math. 2006, 9, 38–40. Zheng, Y.; Xie, X.; Ma, W.Y. GeoLife: A Collaborative Social Networking Service among User, Location and Trajectory. Bull. Tech. Comm. Data Eng. 2010, 33, 32–39. Morris, B.T.; Trivedi, M.M. Trajectory learning for activity understanding: Unsupervised, multilevel, and long-term adaptive approach. IEEE Trans. Pattern Anal. Mach. Intell. 2011, 33, 2287–2301. [CrossRef] [PubMed] Zhang, Z.; Huang, K.; Tan, T. Comparison of Similarity Measures for Trajectory Clustering in Outdoor Surveillance Scenes. In Proceedings of the International Conference on Pattern Recognition, Hong Kong, China, 20–24 August 2006; pp. 1135–1138. Data Clustering Software| Karypis Lab. Available online: http://glaros.dtc.umn.edu/gkhome/views/cluto (accessed on 21 September 2016). Morris, B.; Trivedi, M. Learning trajectory patterns by clustering: Experimental studies and comparative evaluation. In Proceedings of the IEEE Conference on Computer Vision & Pattern Recognition, Miami, FL, USA, 20–25 June 2009; pp. 312–319. Wang, H.; Su, H.; Zheng, K.; Sadiq, S.; Zhou, X. An effectiveness study on trajectory similarity measures. In Proceedings of the Twenty-Fourth Australasian Database Conference, Adelaide, Australia, 29 January–1 February 2013; pp. 13–22. © 2017 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).