Trajectories Spatiotemporally
2.4 DivST: Spatiotemporal Trajectory Dividing
In this section, we shall introduce the design of spatiotemporal trajectory dividing algorithm, DivST, which solves Problem Definition 2.1. To partition a long
trajec-Table 2.1: DivCluST : List of notations TR {pt1, pt2, ..., ptN} Trajectory
pti (pi, ti) Data point
ST R ptm, ptm+1, ..., ptq Sub-trajectory L L : (pts; pte), where ts < te Directional line
dL d(ps, pe) Line length
sL s(pts, pte) = d(p(t s,pe)
e−ts) Line speed
tory efficiently, we apply a sliding-window based algorithm that can online divide a given trajectory, without suffering from loading in the entire trajectory at one time and searching exhaustively for the global optimum partition of a trajectory.
Moreover, we want to provide the flexibility on controlling the number of gener-ated replacement lines. In this way, our dividing method not only can generate quality replacement lines but also can adjust the data amount to meet the resource constraints such as limited memory space. We introduce the algorithm in Section 2.4.1 and give remarks on the threshold selection in Section 2.4.2.
2.4.1 Spatiotemporal Trajectory Dividing Algorithm
Essentially, given a trajectory, we start the test from its initial element line. Then, we sequentially add each of the following element lines to form a new sub-trajectory, and test whether the new sub-trajectory fulfills both the spatial and temporal criteria, which would be explained later. If the inclusion of a certain element line, say Le, fails to meet any of the dividing criteria, a replacement line is generated from the sub-trajectory without including Le. Then, the same dividing test restarts from Le to form next sub-trajectory and determine its replacement line. The spatiotemporal trajectory dividing algorithm is shown in Algorithm 2.1.
How the spatial and temporal criteria work is the key of proper trajectory dividing. In the spatial domain, as indicated in Problem Definition 2.1, the direc-tion variadirec-tion of each element line in a sub-trajectory is supposed to be as small as possible. In other word, we want a replacement line to represent a sub-trajectory containing element lines with similar directions. Our computation checks the length difference between a replacement line and its corresponding sub-trajectory based on
Algorithm 2.1 DivST: Spatiotemporal Trajectory Dividing
Input: a trajectory TR : {pt1, pt2, ..., ptN}, dividing criteria thlenand thspd Output: a set of replacement lines: L1, L2, ..., LM
Set start and end points of current sub-trajectory as m = 1, q = 2. that STRcurrent : {pt1, pt2}
while m < N − 1 and q < N do
Test inclusion of next element line Le : (ptq, ptq+1) on the corresponding sub-trajectory STRnext : {ptm, ..., ptq, ptq+1} and the candidate replacement line L : (ptm, ptq+1) by dividing criteria thlen and thspd
if criterion (3.1) or (3.2) is not fulfilled then
Output L : (ptm, ptq) as a replacement line of STRcurrent : {ptm, ptm+1, ..., ptq} Set m = q, q = q + 1
else
Set q = q + 1 end if
end while
Output the last line LM : (ptm, ptN)
the property of triangle inequality, the length of one edge of a triangle would be close to the sum of the other two edges when an inner angle is close to 180◦ and the other two are near 0◦. Since each divided sub-trajectory is replaced by a replacement line, we may ensure a small direction variation of element lines inside a sub-trajectory by examining the difference between the length of its replacement line and the length sum of all its corresponding element lines.
Suppose the current sub-trajectory STRcurrent : {ptm, ptm+1, ..., ptq} has met the spatial criterion, and the coming element line is Le : (ptq, ptq+1). We check the length difference between STRnext : {ptm, ..., ptq, ptq+1} and the candidate replacement line L : (ptm, ptq+1). Given the threshold thlen, if the following condition in (3.1) is met, the coming element line Le : (ptq, ptq+1) would then be included. Then we renew STRcurrent to {ptm, ..., ptq, ptq+1}, and continue the test on the next element line Le+1: (ptq+1, ptq+2). Otherwise, the replacement line L : (ptm, ptq) is generated and the dividing test is restarted from Le, by assigning STRcurrent as {ptq, ptq+1} and
the next element line Le+1 as (ptq+1, ptq+2).
difflen Pq−1
i=md(pi, pi+1) < thlen, (2.1) where difflen =Pq−1
i=md(pi, pi+1) − d(pm, pq).
In the temporal domain, we consider only the variance of forward speeds. To be more specific, we want to ensure a replacement line can represent a sub-trajectory containing element lines with similar speeds. We sum the speed difference between a candidate replacement line and each element line contained in STRnextand normalize the result by the total speed sum of each element line as in (3.2). Note that we use speed, which indicates the forward moving measurement, rather than velocity, which includes both speed and direction, since the influence of direction has been computed in the spatial domain thlen.
diffspd Pq−1
i=ms(pti, pti+1) < thspd, (2.2) where diffspd =Pq−1
i=m|s(pti, pti+1) − s(ptm, ptq)|.
To show how the designed spatial and temporal criteria (3.1) and (3.2) work, we list three examples in Fig. 2.4. Suppose L1 and L2 are two element lines which span equal time duration. We would like to check if it is acceptable to include them in the same sub-trajectory and replace them by LR. Fig. 2.4(a) and Fig. 2.4(b) are two conditions that would pass the spatial domain test in (3.1), while Fig. 2.4(a) and Fig. 2.4(c) are two conditions that would fulfill the temporal domain criterion in (3.2). For Fig. 2.4(a), the two element lines L1 and L2 have almost the same direc-tion, so the sum of their lengths approximates to the length of LR. For Fig. 2.4(b), although the direction difference between L1 and L2 is rather big, it can satisfy the spatial dividing criterion since their lengths are also very different and the length of L1 dominates the test. However, it would not satisfy the temporal criterion as the speed variance is large between L1 and L2. In both Fig. 2.4(a) and Fig. 2.4(c), L1 and L2 have similar speed value and pass the temporal test (3.2), the dividing is then decided by the spatial criterion (3.1).
(a) thlen and thspd. (b) Only thlen. (c) Only thspd.
Figure 2.4: Illustrations of element lines L1, L2 passing the dividing criteria thlen and thspd and being replaced by LR.
2.4.2 Selection of Thresholds in DivST
The goal of DivST is to generate a minimum number of replacement lines while ensuring the lines to preserve as many spatiotemporal properties of the original trajectory data as possible, as stated in Problem Definition 2.1. The goal can be reached through a proper selection of thresholds thlen and thlen, to find the balance between concision (quantity) and precision (quality) when dividing a given trajectory data set.
A better precision can be reached by setting lower thlen and thspd such that the differences of length and speed between a original sub-trajectory and its replacement line would be smaller. However, by doing so, more replacement lines would be generated, which increases the computation load of later steps. On the other hand, suppressing the number of replacement lines sacrifice precision. Hence, we make a proper selection of thlen and thspd through evenly taking both preciseness and conciseness into account when dividing trajectories and generating replacement lines.
Regarding this, we propose the two measurements, Rprecise and Rconcise, defined as follows.
Rprecise = (thlen+ thspd)/2, and (2.3)
Rconcise = f (thlen, thspd) = total replacement lines total element lines .
The Rprecise would be lower as thlen and thspd are smaller, which makes the criteria more strict. On the other hand, Rconcise would be lower as the number of total replacement lines decreased, which is reached by assigning larger thlen and thspd. Thus, the decrease of Rprecise and Rconcise contradicts to each other by natural. To make the best trade-off between precision and concision, we choose thlen and thspd
that derive the minimum sum of Rprecise and Rconcise as follows.
(thlen, thspd) = arg min(Rprecise+ Rconcise). (2.4) The best-fit criteria thlen and thspd can be determined heuristically by observing the historical trajectories. They can also be adjusted dynamically to meet different precise and concise requirements and produce line segments accordingly while intro-ducing proper weights to the criteria in (2.3) and obtaining thresholds according to (2.4). This shows DivST can provide better flexibility when dealing with huge amounts of trajectory data under different available memory space or other computing resources.