A trajectory similarity calculation method and system integrating spatiotemporal and geographic semantics
By integrating the method of time and space and geographic semantics, combined with dynamic planning, nuclear density estimation algorithm and text theme model, the problem of inaccurate calculation of trajectory similarity in existing technology, and realizing more accurate trajectory similarity and higher measurement and higher ones. Classification and recommendation accuracy.
Patent Information
- Application Number
- CN202410233953.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-01
- Publication Date
- 2025-01-24
- Estimated Expiration
- 2044-03-01
AI Technical Summary
The existing trajectory similarity calculation methods are inaccurate in multi-dimensional calculations, unable to effectively explore the characteristics of certain dimensions, and the distance formula definition is not accurate enough, resulting in inaccurate calculation results.
Calculate the similarities of the trajectory similarity of time and space and geographical semantics, through dynamic planning and space distance matrix identification trajectory, combined with the nuclear density estimation algorithm and WASSSERSTEIN distance calculation time similarity, and through interest point data and text topic themes The model is transformed into a semantic trajectory, and finally calculates the similarity of each dimension.
It achieves a more accurate measurement of the similarity of each dimension of the trajectory, solves the problem of poor similarity calculation in scenarios such as reverse trajectories, non-overlapping travel periods, and large differences in travel frequency, and improves the accuracy of trajectory clustering and personalized recommendations.
Smart Images

Figure CN118551232B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of spatiotemporal trajectory data analysis, and in particular to a trajectory similarity calculation method and system integrating spatiotemporal and geographic semantics. Background Art
[0002] Trajectory similarity is used to calculate the relationship / distance between two trajectories. It is an important preprocessing task in the field of trajectory mining and is used to support downstream tasks such as trajectory clustering, trajectory retrieval, and trajectory prediction. Therefore, it is of great significance for applications such as human mobility behavior analysis, personalized recommendation, traffic planning, and urban management.
[0003] From the working principle, the existing trajectory similarity calculation methods can be divided into deep learning methods and heuristic methods. Deep learning methods usually take the spatial, temporal and geographic semantic features of the trajectory as input, encode the trajectory into a vector through modules such as recurrent neural networks, attention mechanisms, and calculate the cosine distance between vectors to obtain the similarity. The deep learning model has a strong learning ability and can effectively learn the temporal information and various dimensional features of the trajectory, but this type of method requires manual annotation of similarity or uses the calculation results of the heuristic method as prior knowledge. The model implementation is complex and has poor interpretability.
[0004] Heuristic methods usually require pre-definition of distance formulas for each dimension, and then match the point pairs between two trajectories through specific rules to calculate the similarity. In such models, how to define the distance formulas for each dimension and reasonable matching rules is the difficulty in research. Heuristic methods have attracted widespread attention due to their strong interpretability, easy implementation, no need to rely on a large number of trajectory samples for model training, and the ability to provide prior knowledge for deep learning models. However, the existing heuristic methods have the problem of inaccurate calculation of multi-dimensional similarity of trajectories, which is specifically manifested as follows: 1) For different dimensions, the idea of "point pair matching" is adopted, resulting in the inability to accurately mine the characteristics of certain dimensions. For example, time is continuous, and a single moment information or stay period cannot characterize the travel time characteristics of the current trajectory, resulting in excessive focus on local details and ignoring the global time distribution during the matching process; 2) The characteristics of each dimension are not considered comprehensively, ignoring the characteristics of certain dimensions and the connection between features. For example, in the spatial dimension, existing methods do not adequately consider the balance between the order of trajectory sequences and the spatial proximity of trajectory points, resulting in poor calculation results for reverse trajectory similarity; in the temporal dimension, the periodicity of time is ignored, resulting in large time distances in the late night and early morning, and inaccurate calculations; in the semantic dimension, existing methods for semantic mining of trajectory points mostly stay at statistical-based methods, resulting in low accuracy of semantic expression; 3) The distance formulas in some dimensions are not accurately defined. For example, in the temporal dimension, the Jaccard coefficient cannot accurately measure temporal similarity in scenarios such as "close but non-overlapping stay periods" and "large differences in travel and stay frequencies". Summary of the invention
[0005] The present invention provides a trajectory similarity calculation method and system integrating time, space and geographic semantics, so as to solve the defects existing in trajectory similarity calculation in the prior art.
[0006] In a first aspect, the present invention provides a trajectory similarity calculation method integrating spatiotemporal and geographic semantics, comprising:
[0007] Based on dynamic programming and spatial distance matrix, the key points and common points of the trajectory are identified, and the common points are corrected according to their spatial neighboring objects. The spatial similarity of the trajectory pair is solved by combining the similarity of key points and common points.
[0008] The kernel density estimation algorithm is used to transform the time information of the trajectory into a probability density curve, and the time similarity of the trajectory pair is solved based on the cyclic time coding distance and Wasserstein distance;
[0009] According to the POI data and text topic model, the original trajectory is converted into a semantic trajectory, and the geographic semantic similarity of the trajectory is solved;
[0010] The trajectory comprehensive similarity is obtained by integrating the spatial similarity of the trajectory, the temporal similarity of the trajectory and the geographic semantic similarity of the trajectory.
[0011] According to a trajectory similarity calculation method integrating spatiotemporal and geographic semantics provided by the present invention, key points and common points of the trajectory are identified based on dynamic programming and spatial distance matrix, similarity of the common points is corrected according to the spatial neighboring objects of the common points, and spatial similarity of the trajectory pairs is solved by combining the similarity of key points and the similarity of common points, including:
[0012] Step S11, using the Haversine formula, calculate the first trajectory A respectively: <a1,a2,a3,…,a m > and second trajectory B: <b1,b2,b3,…,b n >The spherical distance h_dis(a i ,b j ), for h_dis(a i ,b j ) is normalized to obtain the spatial distance matrix
[0013]
[0014]
[0015] Where r is the average radius of the Earth, φ1 and φ2 are the i and b j , Δφ is the latitude difference, Δλ is the longitude difference, and σ is the Gaussian kernel bandwidth;
[0016] Step S12: Based on the spatial distance matrix C_S, the first trajectory and the second trajectory are sequence aligned using the dynamic time warping algorithm DTW to obtain an alignment result, and the points a in the first trajectory A are determined by inverse calculation of the alignment result. i Respectively with each point b in the second trajectory B j The alignment point is a i The DTW matching point set P i ;
[0017] Step S13, based on the spatial distance matrix C_S, determine a i The DTW matching point set P i Is there a second trajectory B that is similar to a i The point with the smallest distance. If it is determined that there is a point with the smallest distance, then a i With distance a i The smallest point is matched, and a i Marked as key point, a i Costi Determine the minimum distance, otherwise a i Mark as a common point. If all points in the first trajectory A are key points, go to step S15, otherwise go to step S14;
[0018] Step S14, in a i The DTW matching point set P i Determine the i The point b with the smallest distance l , get the distance C_S il , based on the spatial distance matrix C_S, the second trajectory B obtained with a i Distance is less than or equal to C_S il Add a i Adaptive K nearest neighbor set In the above example, the distance decay factor is determined based on the order constraints of the time series data and the spatial proximity between trajectory points. And calculate the normalized weight of each neighbor
[0019]
[0020]
[0021] After weighted summation, we get the corrected cost of common points:
[0022]
[0023] Among them, r k Indicates a i Adaptive K nearest neighbor set R i The kth element in the second trajectory B is the rth element in the second trajectory B. k points, n represents the number of trajectory points of the second trajectory B, Represents the rth row in the spatial distance matrix k Column element value, i.e. point a in the first trajectory A i and the midpoint of the second trajectory B , l represents the lth track point in the second track B;
[0024] Step S15, sum the costs of all points in the first trajectory A, and perform normalization and similarity calculation:
[0025]
[0026] Where m represents the number of trajectory points of the first trajectory A
[0027] Step S16, repeat steps S12 to S15 for the second trajectory B, and calculate Score(B,A). The spatial similarity of the trajectory pair of trajectories A and B is:
[0028]
[0029] According to a trajectory similarity calculation method integrating spatiotemporal and geographic semantics provided by the present invention, the time information of the trajectory is converted into a probability density curve using a kernel density estimation algorithm, and the time similarity of the trajectory pair is solved according to the cyclic time coding distance and the Wasserstein distance, including:
[0030] Step S21, extract the time information of the trajectory point, convert any time into the standard time T, T∈[0,24), and calculate the polar coordinate angle of the standard time T Map polar angles to 2D coordinates Get the first time series T A =<t a1 ,t a2 ,…,t am > and second time series T B =<t b1 ,t b2 ,…,t bm >;
[0031] Step S22, calculate the first time series T A and the second time series T B The normalized cyclic time encoding distance between any two moments in Construct the first time series T A and the second time series T B The time distance matrix Where C_T ij =t_dis(t ai ,t bj );
[0032] Step S23, calculate the first time series T according to the kernel density estimation algorithm and the time distance matrix C_T A and the second time series T B A travel time distribution curve, wherein the x-axis of the travel time distribution curve represents the standard time and the y-axis represents the probability density;
[0033] Step S24, respectively, the first time series T A and the second time series T B The travel time distribution curve is uniformly sampled and normalized to obtain the first discrete probability density distribution P = {(t1, p1), (t2, p2), … (t L ,p L )} and the second discrete probability density distribution Q={(t1,q1),(t2,q2),…(t L ,q L)}, where L represents the number of uniform sampling, t i represents the time information of the i-th sampling, p i Indicates T A The probability density curve of the normalized probability density of the i-th sampling, q i Indicates T B The probability density curve of is the normalized probability density of the i-th sampling;
[0034] Step S25: constructing a transportation cost matrix of the first discrete probability density distribution P and the second discrete probability density distribution Q Calculate the Wasserstein distance W(P,Q) between distributions P and Q:
[0035]
[0036]
[0037] in, and Respectively represent t i and t j Polar coordinate angle at time, C_TP ij Indicates t i With t j The normalized cyclic time encoding distance between time points, ∏(P,Q) is the set of all joint distributions whose marginal distributions are P and Q, satisfying that for all i, For all j,
[0038] Step S26, solving the similarity of the trajectory pair in the time dimension according to the Wasserstein distance:
[0039] Sim time (A,B)=1-W(P,Q).
[0040] According to a trajectory similarity calculation method integrating spatiotemporal and geographic semantics provided by the present invention, the original trajectory is converted into a semantic trajectory according to the point of interest data and the text topic model, and the trajectory to geographic semantic similarity is solved, including:
[0041] Step S31, dividing the area corresponding to the trajectory into regular grids, and obtaining different types of interest point data in each regular grid;
[0042] Step S32, calculate the term frequency inverse document frequency TF-IDF code of the regular grid <x1,x2,…,x k >, where k represents the number of interest points in the current grid, n irepresents the number of interest points of the i-th category in the current grid, N is the total number of interest points in the current grid, is the inverse frequency of the i-th type of interest point in the entire POI dataset, D represents the total number of grids in the study area, and d i It represents the number of grids containing the i-th type of interest point. The denominator is increased by one to prevent the denominator from being zero, which has little effect on the calculation result.
[0043] Step S33, calculate the density of each type of interest point in each regular grid <d1,d2,…,d k >, Where area is the current grid area;
[0044] Step S34, calculating the interest point entropy of each regular grid in Represents the proportion of the i-th type of POI in the grid;
[0045] Step S35: Concatenate the TF-IDF codes, interest point density and interest point entropy of each regular grid to construct grid metadata. <x1,x2,…,x k ,d1,d2,…,d k ,e>, grid metadata <x1,x2,…,x k ,d1,d2,…,d k ,e> Input the Dirichlet polynomial regression topic model to obtain the topic distribution of each regular grid Where Y represents the number of topics, represents the weight of the i-th topic;
[0046] Step S36, convert the first trajectory A: <a1,a2,a3,…,a m > and second trajectory B: <b1,b2,b3,…,b n > are mapped to the grid, and the topic distribution of the grid where the trajectory point is located is used as the trajectory point representation, which is converted into the first semantic trajectory S A = a1 ,s a2 ,…,s am > and the second semantic track S B = b1 ,s b2 ,…,s bn >, where Represents the topic distribution of the i-th grid, and S is calculated by cosine distance A and S B The distance between the vectors Constructing semantic distance matrix
[0047] Step S37, based on the semantic distance matrix C_G, the improved edit distance algorithm is used to perform normalization and transformation to obtain the geographic semantic similarity of the trajectory pair:
[0048]
[0049]
[0050] Where D(i,j) represents S A The first i elements and S B The minimum editing cost between the first j elements, replace(i,j) represents S A The i-th element and S A The semantic distance of the jth element, that is, the cosine distance g_ids(s ai ,s bj ), Sim geosemantic (A, B) represents the normalized semantic similarity between trajectory A and trajectory B.
[0051] According to a trajectory similarity calculation method integrating spatiotemporal and geographic semantics provided by the present invention, the trajectory similarity to space, the trajectory similarity to time and the trajectory similarity to geographic semantics are integrated to obtain the trajectory comprehensive similarity, including:
[0052] Different weights are assigned to the spatial similarity of the trajectory pair, the temporal similarity of the trajectory pair, and the geographic semantic similarity of the trajectory pair, and the weighted sum is taken to obtain the comprehensive similarity of the trajectory.
[0053] In a second aspect, the present invention further provides a trajectory similarity calculation system integrating spatiotemporal and geographic semantics, comprising:
[0054] The spatial calculation module is used to identify the key points and common points of the trajectory based on dynamic programming and spatial distance matrix, perform similarity correction on the common points according to their spatial neighboring objects, and solve the spatial similarity of the trajectory pair by combining the similarity of key points and the similarity of common points;
[0055] The time calculation module is used to convert the time information of the trajectory into a probability density curve using the kernel density estimation algorithm, and solve the time similarity of the trajectory pair based on the cyclic time coding distance and Wasserstein distance;
[0056] The semantic calculation module is used to convert the original trajectory into a semantic trajectory based on the POI data and the text topic model, and calculate the geographic semantic similarity of the trajectory;
[0057] The comprehensive calculation module is used to comprehensively calculate the spatial similarity of the trajectory, the temporal similarity of the trajectory and the geographic semantic similarity of the trajectory to obtain the comprehensive similarity of the trajectory.
[0058] In a third aspect, the present invention further provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method for calculating trajectory similarity integrating spatiotemporal and geographic semantics as described in any one of the above is implemented.
[0059] In a fourth aspect, the present invention further provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements any of the above-described methods for calculating trajectory similarity integrating spatiotemporal and geographic semantics.
[0060] The trajectory similarity calculation method and system integrating spatiotemporal and geographic semantics provided by the present invention abandon the idea of "using the same point pair matching rules in multiple dimensions" in the existing method, and construct corresponding measurement methods based on the characteristics of each dimension of space, time and geographic semantics to more accurately measure the similarity of each dimension of the trajectory, and finally calculate the comprehensive similarity of the trajectory by weighted summation. In the spatial dimension, the present invention combines the dynamic time warping (DTW) algorithm and the heuristic cost correction algorithm, not only considering the sequence order of the trajectory data, but also taking into account the proximity relationship of the trajectory points in two-dimensional space, and has good robustness for scenes such as reverse trajectory. In the time dimension, the method converts discrete moment information into a travel time distribution curve, and pays attention to the periodicity of time based on cyclic time coding, which better describes the travel time characteristics, and the Wasserstein distance can accurately measure the overlap and distance relationship between the two distributions, and can measure the time similarity between trajectories with adjacent but no overlap travel time, large differences in travel stops and frequency. In the semantic dimension, the Dirichlet Multinomial Regression (DMR) text topic model and grid-level metadata can more accurately mine the topic distribution of each geographic grid, explicitly explore the activity semantics at each trajectory point, and make the semantic similarity measurement of the trajectory more reasonable. The calculation method proposed in the present invention includes multiple dimensions that can be freely matched by users, such as the combination of time and space dimensions can be used to mine spatiotemporal trajectory characteristics, and the combination of time and semantics can assist in studying human activity chain patterns. In addition, the present invention can provide reliable prior knowledge for the trajectory similarity deep learning model, which does not require manual labeling in some application scenarios; provide accurate distance measurement for trajectory clustering, improve the accuracy of clustering algorithms; find similar users for personalized recommendation applications, and achieve more accurate recommendations. BRIEF DESCRIPTION OF THE DRAWINGS
[0061] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0062] Figure 1 It is one of the flow charts of the trajectory similarity calculation method integrating spatiotemporal and geographic semantics provided by the present invention;
[0063] Figure 2 This is the second flow chart of the trajectory similarity calculation method integrating spatiotemporal and geographic semantics provided by the present invention;
[0064] Figure 3 It is a schematic diagram of identifying key points and common points when solving spatial similarity provided by the present invention;
[0065] Figure 4 It is a schematic diagram of representative experimental data screened in the spatial dimension provided by the present invention;
[0066] Figure 5 It is a comparison diagram of the results of the present invention and the existing method in terms of the change of trajectory length, adding noise and changing the sampling rate in the spatial dimension;
[0067] Figure 6 It is a comparison diagram of the results of the reverse trajectory similarity calculation in the spatial dimension provided by the present invention and the existing method;
[0068] Figure 7 It is a schematic diagram of a flow chart of solving time similarity provided by the present invention;
[0069] Figure 8 It is a schematic diagram of an experiment on the change of the degree of overlap of travel time in the time dimension provided by the present invention;
[0070] Fig. 9 It is a comparison diagram of experimental results on the change of the degree of overlap of travel time in the time dimension provided by the present invention;
[0071] Fig.10 It is a schematic diagram of an experiment on the change of travel frequency in the time dimension provided by the present invention;
[0072] Fig.11 It is a comparison chart of experimental results on the change of travel frequency in the time dimension provided by the present invention;
[0073] Fig.12 It is the experimental result of topics and their composition generated in the semantic dimension provided by the present invention;
[0074] Fig.13 It is a structural schematic diagram of a trajectory similarity calculation system integrating spatiotemporal and geographic semantics provided by the present invention;
[0075] Fig.14 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION
[0076] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0077] In view of the various limitations of the existing trajectory similarity calculation, the present invention constructs similarity measurement methods according to the characteristics of the spatial, temporal and geographic semantic dimensions, which helps to solve the problems of poor similarity calculation effect and inaccurate trajectory semantic expression in scenarios such as reverse trajectories, non-overlapping travel periods and large differences in travel frequencies, so as to achieve accurate calculation of trajectory similarity under different requirements and provide support for related research tasks and applications in the field of trajectory mining.
[0078] Figure 1 FIG. 1 is a flow chart of a method for calculating trajectory similarity integrating spatiotemporal and geographic semantics provided in an embodiment of the present invention. Figure 1 As shown, including:
[0079] Step 100: identifying key points and common points of the trajectory based on dynamic programming and spatial distance matrix, correcting the similarity of the common points according to their spatial neighboring objects, and solving the spatial similarity of the trajectory pair by combining the key point similarity and the common point similarity;
[0080] Step 200: using a kernel density estimation algorithm to convert the time information of the trajectory into a probability density curve, and solving the time similarity of the trajectory pair according to the cyclic time coding distance and the Wasserstein distance;
[0081] Step 300: According to the POI data and the text topic model, the original trajectory is converted into a semantic trajectory, and the geographic semantic similarity of the trajectory is solved;
[0082] Step 400: Integrate the spatial similarity of the trajectory, the temporal similarity of the trajectory and the geographic semantic similarity of the trajectory to obtain a trajectory comprehensive similarity.
[0083] Specifically, Figure 2As shown, the embodiment of the present invention first identifies the key points and common points of the trajectory based on dynamic programming and spatial distance matrix, corrects the similarity of the common points according to their adaptive K neighboring objects, and solves the spatial similarity of the trajectory pair by combining the similarities of the key points and the common points.
[0084] Then, the temporal information of the trajectory is converted into a probability density curve based on kernel density estimation, and the temporal similarity of the trajectory pairs is solved according to the cyclic time encoding distance and Wasserstein distance.
[0085] Based on the Points Of Interest (POI) data and text topic model, the original spatial trajectory is converted into a semantic trajectory, and then the semantic similarity of the trajectory pair is solved.
[0086] Finally, combined with the specific application scenarios, weights are assigned to the similarities in each dimension, and the weighted sum is used to obtain the comprehensive similarity of the trajectory.
[0087] The present invention deeply explores the dimensional characteristics and constructs similarity calculation schemes for each dimension respectively, which solves the problems of poor similarity calculation effect and inaccurate trajectory semantic expression in scenarios such as reverse trajectories, non-overlapping travel periods, and large differences in travel frequencies, and provides support for tasks such as trajectory clustering and retrieval.
[0088] The present invention is actually applied to the private car trajectory and POI data set of a certain city, and the data includes private car trajectory data and POI data. The private car dataset is recorded by the car navigation system installed on multiple anonymous private cars. The data recording lasts for the whole year of 2019, covering Shenzhen and its surrounding areas. The trajectory points contain information such as longitude and latitude and timestamp. The POI data records the POI situation in Shenzhen in 2022, which is obtained from the AutoNavi open platform. It includes 23 major categories such as companies, residential communities, life services, shopping services, etc., 267 subcategories, and a total of 1,151,815 data.
[0089] Combination Figure 2 The specific algorithm flow chart of the embodiment of the present invention includes:
[0090] 1. In the spatial dimension
[0091] The embodiment of the present invention simulates two trajectories Traj A = <a1,a2,…,a 16 > and Traj B = <b1,b2,…,b 14 >, its morphology and spatial distribution are as follows Figure 3 (a) shows the identification of key points and common points, and sets the parameter σ = 10. The steps for calculating the spatial similarity between the two are as follows:
[0092] Calculate Traj separatelyA and Traj B The spherical distance between two pairs of points in the space is normalized to obtain the spatial distance matrix like Figure 3 According to the DTW algorithm, the DTW cost matrix is constructed. like Figure 3 (c) DTW cost matrix. 16,14 The value of is the minimum cost. 16,14 Start the search at the position just above the current position D 15,14 , Left D 16,13 and D 15,13 , move to the position with the minimum value of the three. Repeat this process until the upper left corner of D is found. 1,1 Stop. The entire search path is the DTW minimum cost path, and the DTW matching result can be inferred from this path, such as Figure 3 (a) Identification of key points and common points and (d) DTW optimal path are shown.
[0093] With Traj A For example, let point a i The DTW matching result is the point set P i Next, query the matrix C_S to determine P i Is there a trajectory B that is similar to a i The point with the smallest distance. If it exists, then a i Match it with the point with the smallest distance, and put a i Marked as a key point, its cost Cost i Set to this distance. Otherwise, set a i Marked as a normal point. Figure 3 From (a) in the above, we can see that <a1,a2,a4,a6,a7,a8,a 14 > is a key point, and the others are common points.
[0094] Cost correction is performed on common points. Taking common point a3 as an example, in its matching point set P3 = {b3}, find the point b3 with the smallest distance to a3. The distance between the two is C_S 33 Query the distance matrix C_S and find the distance between a3 and a3 in trajectory B that is less than or equal to C_S 33 points, and add these points to the adaptive K nearest neighbor set R3 of a3<b3,b4> In this case, the adaptive K value of a3 is 2. The cost Cost3 of the common point a3 is corrected by calculating the distance attenuation factor χ value of each neighbor and its normalized weight ω. For b3, For b4, then, Finally, the weighted sum can give the corrected cost of a3: Cost3 = 0.506*0.38+0.494*0.34≈0.36.
[0095] Sum and normalize the cost of all key points of trajectory A and the corrected cost of common points:
[0096]
[0097] The spatial similarity of trajectory A to B can be obtained. Considering the asymmetry of this method, it is necessary to repeat the above steps for trajectory B to obtain the similarity of trajectory B to A. The spatial similarity Sim between trajectories A and B can be obtained by averaging the two results. spatial (A,B).
[0098] In particular, in order to verify the robustness and superiority of the method proposed in this invention, six advanced heuristic models were selected in the spatial dimension, including sequential-based methods (DTW, N-DTW, SW-ED, FLCSS) and greedy-based methods (MSM, SMSM). 100 representative private car trajectory data were selected for the experiment, which consisted of four typical trajectories: straight line, broken line, ring and self-intersection, such as Figure 4 As shown, Figure 4 (a) Trajectory visualization, Figure 4 The (b1) straight line trajectory in Figure 4 The discounted trajectory (b2) in Figure 4 The (b3) circular trajectory in Figure 4 (b4) Self-intersecting trajectories in . In order to study the robustness of each method, the present invention performs operational transformations on these trajectories, including: 1) length truncation (70%, 80%, 90%), that is, only retaining the sub-trajectory segment of the original trajectory starting from the first point and ending at the specified length position; 2) adding noise (10%, 20%, 30%), that is, randomly inserting a specified proportion of noise points in the trajectory; 3) changing the sampling frequency (40%, 60%, 80%), that is, resampling according to the corresponding ratio of the original sampling frequency to form a new trajectory. Finally, the Top50 search results of the original trajectory in the data set and the Top50 search results of the transformed trajectory in the data set are calculated respectively, and the HR@50 indicator of the overlap of the similarity Top50 search results is used to evaluate the effectiveness of the method. The experimental results are shown in the following figure. Figure 5The results show that the proposed method has better robustness than the existing methods, as shown in the figure below: L=70%, L=80% and L=90% for (a1-a3), N=10%, N=20% and N=30% for (b1-b3), S=40%, S=60% and S=80% for (c1-c3). In addition, the present invention also explores the reverse trajectory scenario experiment, that is, measuring the similarity between the forward and reverse order of a trajectory. We Figure 4 The similarity between all trajectories in the data set and their own reverse trajectories is calculated, and the distribution of 100 similarity results is statistically analyzed. The experimental results are as follows: Figure 6 As shown in the figure. The average similarity of the reverse trajectory measured by this method is 0.52, and most of the similarities are stable around 0.5. However, the order-based method strictly considers the sequence order, resulting in a small reverse similarity value, which fluctuates between 0.2 and 0.3. In the greedy method, MSM completely ignores the sequence order, resulting in the reverse and forward similarities of the trajectory being exactly the same. The SMSM method considers the OD order, and the average similarity is 0.39, but the value distribution is relatively scattered and is greatly affected by the trajectory characteristics.
[0099] 2. In the time dimension
[0100] The embodiment of the present invention simulates two trajectories Traj A =<a1,a2,…,a9> and Traj B = <b1,b2,…,b 10 >, and set the kernel function to Gaussian kernel. The steps for calculating time similarity are as follows:
[0101] like Figure 7 As shown in (a) of the figure, the time information of each track point of the two tracks is extracted and mapped onto the time axis to obtain the time series T of the two tracks. A = <t a1 ,t a2 ,…,t a9 > and T B = <t b1 ,t b2 ,…,t b10 >.
[0102] Based on the kernel density estimation algorithm and cyclic time coding, the trajectory time series is converted into a travel time distribution curve, such as Figure 7 (b) in Figure 1 shows the conversion of discrete travel times into travel time distribution curves based on kernel density estimation.
[0103] like Figure 7 As shown in (c) uniform sampling, the travel time distribution curve is fine-grainedly sampled with a sampling frequency set to 30 minutes, converting the continuous distribution into discrete distributions P and Q.
[0104] Constructing a transportation cost matrix based on cycle time coding By calculating the Wasserstein distance between distributions P and Q and simply converting them, we can get the temporal similarity Sim time (A,B).
[0105] In particular, in order to verify the effectiveness and superiority of the method proposed in the present invention. In the time dimension, the present invention simulates two special but common time similarity calculation scenarios, namely 1) the travel time periods of the two trajectories are close but have little or no overlap. 2) The travel time periods of the two trajectories are similar but have large differences in frequency. In the above experimental scenarios, the uniform sampling frequency is set to 1 minute. For scenario 1), Figure 8 As shown in Figure 2, two originally identical travel time distributions are dynamically moved to change the overlap degree and distance relationship of the two time distributions, which are Figure 8 (a) Original travel time distribution, Figure 8 (b) The travel time is delayed by 2 hours. Figure 8 (c) The travel time is delayed by 9 hours and Figure 8 (d) The departure time is delayed by 17 hours. Fig. 9 The experimental results show that this method based on KDE and Wasserstein distance can achieve smooth attenuation of similarity, while other methods (Jaccard coefficient, KDE+KL divergence, KDE+JS divergence) will have the problem of sudden drop and inability to measure. For scenario 2), such as Fig.10 As shown in Figure 2, the travel and stay frequencies are dynamically increased in the same period, respectively. Fig.10 (a) Original travel time distribution, Fig.10 (b) travel frequency = 2, Fig.10 (c) travel frequency = 4 and Fig.10 (d) The travel frequency in = 6. Fig.11 From the experimental results, it can be seen that the kernel density estimation algorithm used in this method, whether combined with Wasserstein distance or KL, JS divergence, has a calculation result that is closer to human cognition, while the Jaccard coefficient has a poor effect.
[0106] 3. In the semantic dimension
[0107] In the embodiment of the present invention, the number of topics generated is set to Y=7. A = <a1,a2,…,a m > and Traj B = <b1,b2,…,n n The similarity calculation steps of > are as follows:
[0108] The POI dataset was selected and merged, and the original 23 categories were reduced to 14 categories, namely: residential areas, catering services, shopping services, life services, companies and enterprises, transportation facilities, government agencies, car services, medical institutions, science and education culture, hotel services, leisure and entertainment, financial services and scenic spots. At the same time, a city was gridded in units of 500 meters, and a total of 9696 grids were obtained, and the number of different types of POIs in each grid was counted.
[0109] Build grid-level metadata, including TF-IDF encoding <x1,x2,…,x 14 >, POI density <d1,d2,…,d 14 >, POI entropy e. Metadata is concatenated into a 29-dimensional vector <x1,x2,…,x 14 ,d1,d2,…,de 14 ,e>.
[0110] The metadata and POI data of each grid are input into the DMR model to generate seven themes and the vocabulary distribution under each theme, such as Fig.12 shown.
[0111] Map the trajectory points to the grid and obtain the topic distribution vector of the corresponding grid Get geographic semantic track and
[0112] Calculate S based on cosine distance A and S B The distance between two vectors in the construct semantic distance matrix By using the improved edit distance, normalizing and simply transforming, we can get the geographic semantic similarity Sim of two trajectories. geosemantic (A,B).
[0113] Fourth, based on the similarity calculation results of spatial, temporal and geographic semantic dimensions and specific application scenarios, the influence weights of each dimension <ω1,ω2,ω3> can be customized to obtain the comprehensive similarity of the trajectory.
[0114] Sim(A,B)=ω1Sim spatial (A,B)+ω2Sim time (A,B)+ω3Sim geosemantic (A,B).
[0115] The following is a description of a trajectory similarity calculation system for integrating spatiotemporal and geographic semantics provided by the present invention. The trajectory similarity calculation system for integrating spatiotemporal and geographic semantics described below and the trajectory similarity calculation method for integrating spatiotemporal and geographic semantics described above can be referred to each other.
[0116] Fig.13 is a schematic diagram of the structure of a trajectory similarity calculation system integrating spatiotemporal and geographic semantics provided by an embodiment of the present invention. Fig.13 As shown, it includes: a spatial calculation module 1301, a time calculation module 1302, a semantic calculation module 1303 and a comprehensive calculation module 1304, wherein:
[0117] The spatial calculation module 1301 is used to identify the key points and common points of the trajectory based on dynamic programming and spatial distance matrix, perform similarity correction on the common points according to the spatial neighboring objects of the common points, and solve the spatial similarity of the trajectory by integrating the similarity of the key points and the similarity of the common points; the time calculation module 1302 is used to convert the time information of the trajectory into a probability density curve using the kernel density estimation algorithm, and solve the temporal similarity of the trajectory according to the cyclic time coding distance and the Wasserstein distance; the semantic calculation module 1303 is used to convert the original trajectory into a semantic trajectory according to the point of interest data and the text topic model, and solve the geographic semantic similarity of the trajectory; the comprehensive calculation module 1304 is used to integrate the spatial similarity of the trajectory, the temporal similarity of the trajectory and the geographic semantic similarity of the trajectory to obtain the comprehensive similarity of the trajectory.
[0118] Fig.14 An example of a physical structure diagram of an electronic device is shown in FIG. Fig.14 As shown, the electronic device may include: a processor (processor) 1410, a communication interface (Communications Interface) 1420, a memory (memory) 1430 and a communication bus 1440, wherein the processor 1410, the communication interface 1420, and the memory 1430 communicate with each other through the communication bus 1440. The processor 1410 can call the logic instructions in the memory 1430 to execute a trajectory similarity calculation method that integrates time, space and geographic semantics. The method includes: identifying key points and common points of the trajectory based on dynamic programming and spatial distance matrix, correcting the similarity of the common points according to the spatial neighboring objects of the common points, and solving the spatial similarity of the trajectory by combining the similarity of key points and the similarity of common points; using the kernel density estimation algorithm to convert the time information of the trajectory into a probability density curve, and solving the temporal similarity of the trajectory according to the cyclic time coding distance and the Wasserstein distance; according to the point of interest data and the text topic model, converting the original trajectory into a semantic trajectory, solving the geographic semantic similarity of the trajectory; and combining the spatial similarity of the trajectory, the temporal similarity of the trajectory and the geographic semantic similarity of the trajectory to obtain the comprehensive similarity of the trajectory.
[0119] In addition, the logic instructions in the above-mentioned memory 1430 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention can be essentially or partly embodied in the form of a software product that contributes to the prior art. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.
[0120] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.
[0121] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0122] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A trajectory similarity calculation method integrating spatiotemporal and geographic semantics, characterized in that: include: Based on dynamic programming and spatial distance matrix, the key points and common points of the trajectory are identified, the common points are corrected according to their spatial neighboring objects, and the spatial similarity of the trajectory pair is solved by combining the similarity of key points and common points. The kernel density estimation algorithm is used to transform the time information of the trajectory into a probability density curve, and the time similarity of the trajectory pair is solved based on the cyclic time coding distance and Wasserstein distance; According to the POI data and text topic model, the original trajectory is converted into a semantic trajectory, and the geographic semantic similarity of the trajectory is solved; The spatial similarity of the trajectory, the temporal similarity of the trajectory and the geographic semantic similarity of the trajectory are integrated to obtain a comprehensive trajectory similarity; Based on dynamic programming and spatial distance matrix, the key points and common points of the trajectory are identified. The common points are corrected according to their spatial neighboring objects. The spatial similarity of the trajectory is solved by combining the key point similarity and the common point similarity, including: Step S11, using the Haversine formula, calculate the first trajectory A respectively: <a1,a2,a3,…,a m > and second trajectory B: <b1,b2,b3,…,b n >The spherical distance h_dis(a i ,b j ), for h_dis(a i ,b j ) is normalized to obtain the spatial distance matrix Where r is the average radius of the Earth, φ1 and φ2 are the o and b j , Δφ is the latitude difference, Δλ is the longitude difference, and σ is the Gaussian kernel bandwidth; Step S12: Based on the spatial distance matrix C_S, the first trajectory and the second trajectory are sequence aligned using the dynamic time warping algorithm DTW to obtain an alignment result, and the points a in the first trajectory A are determined by inverse calculation of the alignment result. i Respectively with each point b in the second trajectory B j The alignment point is a i The DTW matching point set P i ; Step S13, based on the spatial distance matrix C_S, determine a i The DTW matching point set P i Does it exist in The second trajectory B and a i The point with the smallest distance. If it is determined that there is a point with the smallest distance, then a i With distance a i The smallest point is matched, and a i Marked as key point, a i Cost i Determine the minimum distance, otherwise a i Mark as a common point. If all points in the first trajectory A are key points, go to step S15, otherwise go to step S14; Step S14, in a i The DTW matching point set P i Determine the i The point b with the smallest distance l , get the distance C_S il , based on the spatial distance matrix C_S, the second trajectory B obtained with a i Distance is less than or equal to C_S il Add a i Adaptive K nearest neighbor set In the above example, the distance decay factor is determined based on the order constraints of the time series data and the spatial proximity between trajectory points. And calculate the normalized weight of each neighbor After weighted summation, we get the corrected cost of common points: Among them, r k Indicates a i Adaptive K nearest neighbor set R i The kth element in the second trajectory B is the rth element in the second trajectory B. k points, n represents the number of trajectory points of the second trajectory B, Represents the rth row in the spatial distance matrix k Column element value, i.e. the midpoint a of the first trajectory A i and the midpoint of the second trajectory B , l represents the lth track point in the second track B; Step S15, sum the costs of all points in the first trajectory A, and perform normalization and similarity calculation: Where m represents the number of trajectory points of the first trajectory A Step S16, repeat steps S12 to S15 for the second trajectory B, and calculate Score(B,A). The spatial similarity of the trajectory pair of trajectories A and B is: The kernel density estimation algorithm is used to convert the time information of the trajectory into a probability density curve, and the time similarity of the trajectory pair is solved according to the cyclic time coding distance and Wasserstein distance, including: Step S21, extract the time information of the trajectory point, convert any time into the standard time T, T∈[0,24), and calculate the polar coordinate angle of the standard time T Map polar angles to 2D coordinates Get the first time series T A = <t a1 , t a2 , ..., t am > and second time series T B = <t b1 , t b2 , ..., t bm > Step S22, calculate the first time series T A and the second time series T B The normalized cyclic time encoding distance between any two moments in Construct the first time series T A and the second time series T B The time distance matrix Where C_T ij =t_dis(t ai , t bj ); Step S23, calculate the first time series T according to the kernel density estimation algorithm and the time distance matrix C_T A and the second time series T B A travel time distribution curve, wherein the x-axis of the travel time distribution curve represents the standard time and the y-axis represents the probability density; Step S24, respectively, the first time series T A and the second time series T B The travel time distribution curve is uniformly sampled and normalized to obtain the first discrete probability density distribution P = {(t1, p1), (t2, p2), ... (t L , p L )} and the second discrete probability density distribution Q = {(t1, q1), (t2, q2), ... (t L ,q L )}, where L represents the number of uniform sampling, t i represents the time information of the i-th sampling, p i Indicates T A The probability density curve of the normalized probability density of the i-th sampling, q i Indicates T B The probability density curve of is the normalized probability density of the i-th sampling; Step S25: constructing a transportation cost matrix of the first discrete probability density distribution P and the second discrete probability density distribution Q Calculate the Wasserstein distance W(P,Q) between distributions P and Q: in, and Respectively represent t i and t j Polar coordinate angle at time, C_TP ij Indicates t i With t j The normalized cyclic time coding distance between time points, Π(P, Q) is the set of all joint distributions whose marginal distributions are P and Q, satisfying that for all i, For all j, Step S26, solving the similarity of the trajectory pair in the time dimension according to the Wasserstein distance: Sim time (A,B)=1-W(P,Q); According to the POI data and text topic model, the original trajectory is converted into a semantic trajectory, and the trajectory to geographic semantic similarity is solved, including: Step S31, dividing the area corresponding to the trajectory into regular grids, and obtaining different types of interest point data in each regular grid; Step S32, calculate the term frequency inverse document frequency TF-IDF code of the regular grid <x1,x2,...,x k >, where k represents the number of interest points in the current grid, n i represents the number of interest points of the i-th category in the current grid, N is the total number of interest points in the current grid, is the inverse frequency of the i-th type of interest point in the entire POI dataset, D represents the total number of grids in the study area, and d i It represents the number of grids containing the i-th type of interest point. The denominator is increased by one to prevent the denominator from being zero, which has little effect on the calculation result. Step S33, calculate the density of each type of interest point in each regular grid <d1,d2,...,d k >, Where area is the current grid area; Step S34, calculating the interest point entropy of each regular grid in Represents the proportion of the i-th type of POI in the grid; Step S35: Concatenate the TF-IDF codes, interest point density and interest point entropy of each regular grid to construct grid metadata. <x1,x2,...,x k , d1, d2, ..., d k , e>, grid metadata <x1,x2,...,x k , d1, d2, ..., d k , e> Input the Dirichlet polynomial regression topic model to obtain the topic distribution of each regular grid Where T represents the number of topics, represents the weight of the i-th topic; Step S36, convert the first trajectory A: <a1,a2,a3,...,a m > and second trajectory B: <b1,b2,b3,...,b n > are mapped to the grid, and the topic distribution of the grid where the trajectory point is located is used as the trajectory point representation, which is converted into the first semantic trajectory S A = <sa1,s a2 , ..., s am > and the second semantic track S B = b1 ,s b2 , ..., s bn >, where Represents the topic distribution of the i-th grid, and S is calculated by cosine distance A and S B The distance between the vectors Constructing semantic distance matrix Step S37, based on the semantic distance matrix C_G, the improved edit distance algorithm is used to perform normalization and transformation to obtain the geographic semantic similarity of the trajectory pair: Where D(i, j) represents S A The first i elements and S B The minimum editing cost between the first j elements, replace(i, j) represents S A The i-th element and S A The semantic distance of the jth element, that is, the cosine distance g_dis(s ai ,s bj ), Sim geosemantic (A, B) represents the normalized semantic similarity between trajectory A and trajectory B.
2. The trajectory similarity calculation method integrating spatiotemporal and geographic semantics according to claim 1 is characterized in that: The trajectory comprehensive similarity is obtained by integrating the spatial similarity of the trajectory, the temporal similarity of the trajectory and the geographic semantic similarity of the trajectory, including: Different weights are assigned to the spatial similarity of the trajectory pair, the temporal similarity of the trajectory pair, and the geographic semantic similarity of the trajectory pair, and the weighted sum is taken to obtain the comprehensive similarity of the trajectory.
3. A trajectory similarity calculation system integrating spatiotemporal and geographic semantics, based on the trajectory similarity calculation method integrating spatiotemporal and geographic semantics according to claim 1 or 2, characterized in that: include: The spatial calculation module is used to identify the key points and common points of the trajectory based on dynamic programming and spatial distance matrix, perform similarity correction on the common points according to their spatial neighboring objects, and solve the spatial similarity of the trajectory pair by combining the similarity of key points and the similarity of common points; The time calculation module is used to convert the time information of the trajectory into a probability density curve using the kernel density estimation algorithm, and solve the time similarity of the trajectory pair based on the cyclic time coding distance and Wasserstein distance; The semantic calculation module is used to convert the original trajectory into a semantic trajectory based on the POI data and the text topic model, and calculate the geographic semantic similarity of the trajectory; The comprehensive calculation module is used to comprehensively calculate the spatial similarity of the trajectory, the temporal similarity of the trajectory and the geographic semantic similarity of the trajectory to obtain the comprehensive similarity of the trajectory.
4. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the trajectory similarity calculation method integrating spatiotemporal and geographic semantics as described in claim 1 or 2 is implemented.
5. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the trajectory similarity calculation method integrating spatiotemporal and geographic semantics as claimed in claim 1 or 2 is implemented.
6. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the trajectory similarity calculation method integrating spatiotemporal and geographic semantics as claimed in claim 1 or 2 is implemented.
Citation Information
Patent Citations
Social media user behavior pattern mining method
CN115687429A
Vehicle trajectory prediction method based on spatio-temporal characteristics, geographic semantics and driving state
CN117407711A