An Optimization Method for Similarity Query Based on Trajectory Representation Learning

Trajectory similarity query is optimized through road network partitioning and PT-GTree index, and the loss function of GRU encoder-decoder model and spatial topology information is used to embed the trajectory into low-dimensional vector space, solving the problem of low similarity calculation efficiency in large-scale trajectory data, and achieving efficient trajectory similarity query.

CN115544070BActive Publication Date: 2025-07-29SHENYANG AEROSPACE UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211183127.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-27
Publication Date
2025-07-29
Estimated Expiration
2042-09-27

AI Technical Summary

Technical Problem

The existing trajectory similarity calculation methods are inefficient in large-scale trajectory data. Traditional methods rely on expert knowledge and have limited characteristics, making it difficult to adapt to different trajectory scenarios. The feature representation method based on manual design has high computational complexity.

Method used

The trajectory representation learning model PT2vec based on road network partition is adopted, combined with the PT-GTree index, and the trajectory is embedded in the low-dimensional vector space through the GRU encoder-decoder model and the loss function based on spatial topology information. The trajectory similarity is calculated using the Euclidean distance, and the PT-GTree index is established for pruning to improve query efficiency.

Benefits of technology

It effectively solves the problem of excessive calculation time for large-scale trajectory similarity, improves the accuracy and query efficiency of the model, reduces the query space, and supports efficient trajectory similarity calculation and query.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115544070B_ABST
    Figure CN115544070B_ABST
Patent Text Reader

Abstract

The present invention discloses an optimization method for similarity query based on trajectory representation learning. The trajectory similarity query of the present invention represents a trajectory as a vector, and in the vector space, the Euclidean distance between two vectors is used to find the trajectory closest to the query trajectory. The present invention proposes a trajectory representation learning model PT2vec based on road network partitioning. PT2vec takes into account the spatial features of the trajectory and the topological constraints of the underlying road network to embed the trajectory into a low-dimensional vector space, designs a loss function based on spatial and topological information to accelerate the training of the model, improve the accuracy of the model, and effectively solve the problem of excessive calculation time for large-scale trajectory similarity. At the same time, in order to reduce the trajectory query space and improve the query efficiency, the PT-GTree index is used to prune the trajectories in the query database.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of spatio-temporal data management, and particularly relates to an optimization method for similarity query based on trajectory representation learning, a deep representation learning model (PT2vec) based on road network partitioning, and a PT-GTree index for trajectory similarity query, so as to implement similarity query of large-scale trajectory data. Background Art

[0002] With the rapid development of location acquisition in Internet of Things and Internet of Vehicles technologies, trajectory data that can be used to describe the diversity and attributes of moving objects has been generated. Trajectory pattern analysis and management has become a key issue in recent decades, because it supports many fields and applications (such as smart cities, intelligent transportation, location-based services, health management, etc.). Due to the recent development of artificial intelligence technologies, artificial intelligence technologies can be used to analyze trajectory data on an unprecedented scale to evaluate applicable issues related to effectiveness, efficiency, accuracy, and privacy in intelligent transportation systems (ITS). Traditional large-scale trajectory data research mainly focuses on trajectory similarity calculation, trajectory clustering, trajectory anomaly detection, etc., and uses technologies such as R-tree index and grid index to establish index structures. Currently, with the rapid development of deep learning technologies, deep representation learning technologies can not only standardize and simplify the original trajectories formally, but also extract valuable parts from redundant original information, thereby making trajectory pattern analysis and management more efficient.

[0003] Existing trajectory similarity measurement methods, such as dynamic time warping (DTW), longest common subsequence (LCSS), and edit distance on real sequence (EDR). However, existing traditional methods usually use dynamic programming to determine the best alignment of paired points of two trajectories, which results in quadratic computational complexity. However, these methods are not applicable when the trajectory scale is very large.

[0004] Most early trajectory representation methods were based on manually designed features to represent trajectories, so such methods are also called trajectory feature extraction. Because such trajectories contain a large amount of time, space, and semantic information. The core idea of trajectory feature extraction is to use the existing spatio-temporal information to mine new features and transform the original trajectory point sequence into a feature sequence. However, the current scale of trajectory data is very large. The trajectory representation method based on manually designed features relies on expert knowledge, and for different trajectory scenarios, features need to be reselected, and the types of features are limited, so it increases the application difficulty of such methods. On the contrary, if a model is used to automatically learn the relevant information of the trajectory sequence and generate a trajectory representation, the above problems can be solved. Summary of the Invention

[0005] In order to solve the efficiency problem of large-scale trajectory similarity query, this paper proposes a similarity query optimization method based on trajectory representation learning, which includes the following steps:

[0006] S1: Partition the road network and assign label words to each partition and boundary edge in order to build a vocabulary;

[0007] S2: Obtain multiple original trajectories, perform road network matching on the original trajectories based on the above vocabulary, and convert the matched trajectory sequence into a word sequence;

[0008] S3: Construct a PT-GTree based on the partitioning results, store the matched trajectories in step S2 into the PT-GTree minimum common ancestor node, and use the PT-GTree to prune the query database for trajectory similarity queries to determine the query candidate trajectory set;

[0009] S4: Build an encoder-decoder model based on GRU (Gated Recurrent Unit), use the word sequence in step S2 as input, encode it into a vector v through the encoder, and then decode it into an output sequence y through the decoder. At the same time, design a loss function based on spatial and topological information to train the model;

[0010] S5: Use the trained encoder-decoder model to embed the candidate trajectories determined in step S3 into a low-dimensional vector space, represent the candidate trajectories in the form of vectors, and use the Euclidean distance between two trajectory vectors to represent the similarity of the trajectories. The smaller the distance, the more similar the trajectories.

[0011] Furthermore, in step S1, the road network is divided using a multi-layer division algorithm. Specifically,

[0012] Coarsening the vertices and edges of the road network to reduce the network size;

[0013] The Kernighan-Lin network partitioning algorithm is used to partition the coarsened road network graph into multiple subgraphs. The partitioning is performed by setting two parameters m and n, where m is the number of road network nodes in each subgraph and n is the number of subgraphs.

[0014] The subgraph is coarsened to generate the final partition of the original network. The final partition and boundary edges are labeled in sequence. Each label corresponds to a corresponding word, and these words form the vocabulary.

[0015] Furthermore, the trajectory similarity query pruning method based on PT-GTree index is as follows:

[0016] Construct a PT-GTree using the partitioning result in step S2, find all the leaf nodes passed by the original trajectories, find the least common ancestor node of all the leaf nodes, and store the original trajectories in the corresponding tree nodes;

[0017] Given a trajectory to be queried, first find all the leaf nodes passed by the trajectory to be queried, then find the least common ancestor node of the trajectory to be queried according to these leaf nodes, and use the least common ancestor node and the original trajectories stored in its child nodes as the candidate set.

[0018] Furthermore, the loss function is as follows

[0019]

[0020]

[0021] where W is the projection matrix that projects h t from the hidden state space to the word list space, and W u represents its u-th row, D(u, y t ) represents the shortest road network distance between words, λ is a distance scale parameter, TK(y t ) represents the K words close to y t , and T(y t ) represents the words directly connected to the target word in the topological structure.

[0022] Furthermore, in step S5, input the word sequence into the encoder of the improved model, and encode the trajectory sequence into a low-dimensional latent vector v through the embedding and the computing units of the 3-layer GRU network;

[0023] The decoder calculates the conditional probability of the output sequence at each position accordingly; specifically, at a certain position, the decoder converts the output sequence and the latent vector before this position into a hidden state, which retains the sequence information of the word sequence and the output sequence, then predicts the output at this position through the hidden state, and finally obtains the output sequence y. Calculate the loss between the output sequence y and the target sequence using the loss function, and the model adjusts the parameters according to the loss to make the model more accurate.

[0024] The beneficial effects of the present invention are as follows:

[0025] The present invention provides an optimization method for similarity query based on trajectory representation learning. By using deep learning methods, trajectories are embedded into low-dimensional latent vectors, thus supporting efficient calculation and query of trajectory similarity. The present invention proposes a trajectory representation learning model PT2vec based on road network partitioning. PT2vec takes into account the spatial features of trajectories and the topological constraints of the underlying road network to embed trajectories into a low-dimensional vector space, designs a loss function based on spatial and topological information, accelerates the training of the model, improves the accuracy of the model, and effectively solves the problem of excessive calculation time for large-scale trajectory similarity. At the same time, in order to reduce the trajectory query space and improve the query efficiency, a PT-GTree index is established to prune the trajectories in the query database.

[0026] The loss function of the sequence encoder-decoder model of the present invention is designed based on road network topology and spatial information. The original sequence encoder-decoder does not model the topological and spatial correlations between words. The original loss function penalizes output words with the same weight. However, in the road network space, output words closer to the target word are more acceptable than those farther away. When attempting to decode a word from the decoder, a weight is assigned to each word, and the weight of the word is inversely proportional to its road network distance from the target word. Therefore, the closer the word is to the target word, the greater the weight assigned to it. At the same time, in order to accelerate the training of the model, the loss function is further optimized according to the topological structure of the road network. Since most other words should have very small weights except for the words topologically connected to the target word, as long as the loss function can encourage the decoder to assign probabilities to the words topologically connected to the target word. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] For the convenience of those skilled in the art to understand, the present invention will be further described below with reference to the accompanying drawings:

[0028] Figure 1 It is a framework diagram of the trajectory representation learning and similarity query method based on road network partitioning provided by the present invention;

[0029] Figure 2 It is a structural diagram of road network partitioning in the embodiment;

[0030] Figure 3 It is a road network matching diagram in the embodiment;

[0031] Figure 4 It is a GRU-based encoder-decoder model diagram in the embodiment;

[0032] Figure 5 It is a diagram of the distance and topological relationship between words in the loss function in the embodiment;

[0033] Figure 6The PT-GTree structure diagram in the embodiment; Detailed implementation manners

[0034] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0035] The present invention provides an optimization method for similarity query based on trajectory representation learning. The trajectory is embedded into a low-dimensional vector by using a trajectory representation learning model based on road network partitioning, and the encoder-decoder model based on GRU in the text problem is extended to trajectory data. Another encoder-decoder model based on GRU for large-scale trajectory data is proposed. At the same time, a loss function based on spatial and topological information is designed to improve the accuracy and efficiency of the model. Finally, a PT-GTree index is established to prune the query database to determine the query candidate set. The candidate trajectories are converted into vectors by using the trained model, and the Euclidean distance between two trajectory vectors is used to calculate the query result, indicating the similarity degree of the trajectories. The smaller the distance, the more similar the trajectories. The method includes the following steps:

[0036] Step 1: Partition the road network to obtain a partitioning result, and construct a vocabulary according to the partitioning result, where the vocabulary is composed of partitions and boundary edges. Then, perform road network matching on the original trajectory, and convert the matched trajectory sequence into a word sequence. Next, construct an encoder-decoder model based on GRU, and design a loss function based on spatial and topological information to train the model.

[0037] Step 1.1: Partition the road network by using a multi-level partitioning algorithm;

[0038] First, reduce the network scale by coarsening the vertices and edges, and then use a traditional network partitioning algorithm, such as the Kernighan-Lin algorithm, to partition the coarsened graph. Finally, uncoarsen the subgraphs to generate the final partitioning of the original network. At the same time, the size of the subgraphs is determined by two parameters: m and n, where m is used to control the leaf nodes, that is, after the final partitioning, the number of road network nodes in each subgraph. n is used to control how many small subgraphs a large subgraph is divided into when partitioning the subgraphs.

[0039] Then, sequentially number the final partitions and boundary edges, and these labels are the corresponding words, and these words form the vocabulary.

[0040] The encoder-decoder model based on GRU includes the following structure;

[0041] Step 1.2: Number the final partitions and boundary edges in the above Step 1.1 in sequence. These tags are corresponding words, and these words form a vocabulary. Convert the trajectory sequence after road network matching into a word sequence as the input of the model;

[0042] Step 1.3: Input the trajectory sequence x into the encoder of the model, and encode the trajectory sequence into a low-dimensional latent vector v through the calculation units of embedding and a 3-layer GRU network;

[0043] Step 1.4: The decoder calculates P(y t |y1,...,y t-1 ,v) at each position t in turn. Specifically, at position t, the decoder converts the output sequence y1,...,y t-1 before this position and the latent vector v into a hidden state h t , which retains the sequence information of the word sequence x and the output sequence y1,...,y t-1 , and then predicts y t through h t , and finally obtains the predicted sequence y.

[0044] Step 1.5: Model training. The goal is to obtain an output sequence with the highest probability. A loss function based on spatial and topological information is designed, and the loss is reduced by an optimization method to learn the parameters of the model. At the same time, in order to avoid the limitation of the model performance by the same context variables, an attention mechanism is added to the encoder-decoder model.

[0045] Step 2: Construct a PT-GTree according to the partitioning result, and store the trajectories in its lowest common ancestor node. Then, for trajectory similarity queries, use the PT-GTree to prune the query database to determine the query candidate set. Finally, use the representation learning model trained in Step 1 to embed the candidate trajectories into low-dimensional vectors, and calculate the results using the Euclidean distance between the vectors.

[0046] The pruning method for trajectory similarity queries based on the PT-GTree index in Step 2 is as follows:

[0047] Step 2.1: Use the partitioning result in Step 1.1 to construct a PT-GTree, find all the leaf nodes passed by the trajectory, find the lowest common ancestor node of all the leaf nodes, and store the trajectory in the corresponding tree node;

[0048] Step 2.2: Given a query trajectory, first find all the leaf nodes passed by the query trajectory, and then, based on these leaf nodes, find the lowest common ancestor node of the query trajectory, and use the lowest common ancestor node and the trajectories stored in its child nodes as the candidate set;

[0049] Step 2.3. Embed the query trajectory and the trajectories in the candidate set into low-dimensional vectors using the trained GRU-based encoder-decoder model, and calculate the query results using the Euclidean distance between the vectors.

[0050] Among them, in Step 1.5, the loss function based on spatial and topological information is designed as follows:

[0051] Step 1.5.1. In the road network space, output words closer to the target are more acceptable than those farther away. Therefore, assign a weight to each word, and the weight of the word is inversely proportional to its road network distance to the target word.

[0052] Step 1.5.2. Except for the words directly connected to the target word in the topological structure, the weights of most other words should be very small. Therefore, it is not necessary to calculate the exact value of the logarithmic probability, as long as it can encourage the decoder to assign probabilities to the words directly connected to the target word in the topological structure.

[0053] Step 1.5.3. Therefore, according to the generated sub-partitions connected by boundary edges, starting from the target word, heuristically select K words (denoted as TK(y t )) that approach the target word in a breadth-first manner. Therefore, these K words mainly come from the surrounding sub-partitions and boundary edges. In addition, since the words directly connected to the target word in the topological structure (denoted as T(y t )) are more important, they are given greater probabilities. And the probabilities of other words are directly assigned to 0.

[0054] Embodiment:

[0055] As Figure 1 shown, the trajectory representation learning and similarity query method based on road network partitioning includes the following steps:

[0056] First, partition the road network to obtain the result of the road network partition as Figure 2 shown. Each partition contains no more than m road network nodes, Figure 3 shows an example of a road network partition, is a partition. Sub-partitions and both have 9 road network vertices and can be further recursively partitioned. Therefore, is another partition with smaller sub-partitions, and its word labels are 1, 2, 3, and 4 respectively. Considering the complete partition P3, it has 5 boundary edges, so there are whose labels are 5, 6, 7, 8, and 9. Therefore, form a vocabulary with the partitions and boundary edges, and the labels are the numbers corresponding to the words.

[0057] Next, the original trajectory sequence is converted into a word sequence. To obtain the word sequence, each original trajectory needs to be mapped onto the road network to obtain a sequence of road segments. Figure 3 Figure 172 shows an example of mapping the original trajectory points onto the road network. The matching trajectory is represented as an edge of the underlying road network. Figure 2 For example, for partition P3, the trajectory passes through two sub - partitions and a boundary edge whose labels are 1, 2, 7 respectively. Therefore, the word sequence of T2 is {1, 7, 2}. Similarly, the word sequence of T1 is {1, 5, 3, 8, 4, 9, 2}.

[0058] Converting the trajectory into a word sequence serves as the input to the model. Here, a GRU - based encoder - decoder model is used. As Figure 4 shown, there are two sequences x = <x1,...,x m > and y = <y1,...,y n >, where x i represents the i - th token of the input sequence, and y i represents the j - th token of the output sequence. The purpose of the sequence encoder - decoder model is to encode the sequence x into a low - dimensional latent vector v, which represents that v decodes to return y by maximizing the conditional probability in the decoder (the vector v preserves the sequence information in x).

[0059] The vector v output by the encoder encodes the entire information of the input sequence x = <x1,...,x m >. The decoder generates the output sequence by decoding the information in the vector v, where the hidden state h t captures the sequential information in <x,y1,..,y t-1 >. Therefore, to understand how the model establishes the conditional probability P(y|x) = P(y1,...,y n |x1,...,x m ), the chain rule is used to obtain the joint probability function

[0060]

[0061] To train the sequence encoder - decoder model, a loss function is needed to optimize the objective, that is, to maximize the joint probability of the output sequence. To achieve the maximum probability, maximum likelihood estimation (MLE) can be used, which is equivalent to minimizing the negative log - likelihood (NLL). Therefore, the loss function for processing text sequences is designed as the following equation.

[0062] maxP(y1,...,y n |x1,...,x m) = min - logP(y1,...,y n |x1,...,x m )

[0063]

[0064] The above loss function penalizes the output words with the same weight. However, when learning the representation of the trajectory sequence, words that are close to the target word or topologically connected to the target should have a higher output probability, rather than being equal. For example, in Figure 5 , assuming that the rectangle is the generated leaf partition and the decoded target word is y1, then it is clearly not a good strategy to penalize the output y3 and y9 with equal probability during the decoding process. Words such as y2, y3, and y5 that are adjacent to or closer to y1 should have a higher probability.

[0065] The loss function is improved according to the topological attributes in the road network, and the model is trained using it.

[0066] Except for the words that are topologically connected to the target unit y t , the weights of most other words should be very small. Therefore, it is not necessary to calculate the exact value of the logarithmic probability, as long as it can encourage the decoder to assign probabilities to the words that are topologically connected to the target word. Then the improved loss function is as follows:

[0067]

[0068]

[0069] where W is the projection matrix that projects h t from the hidden state space to the word list space, W u represents its u - th row, D(u, y t ) represents the shortest road network distance between words, λ is a distance scale parameter, TK(y t ) represents the K words close to y t , and T(y t ) represents the words that are directly topologically connected to the target word.

[0070] By retaining each level of the partition generated by the recursive process, a hierarchical tree structure - PT - GTree can be constructed for the trajectory index in a top - down manner. The root node is the entire road network. The leaf nodes are the sub - partitions used to generate words, and these sub - partitions will have no further sub - partitions. The non - leaf nodes are the intermediate results (sub - partitions) of the partitioning process, and the nodes at the same level are the complete partitions of the original road network. As Figure 6 shown, the PT - Gtree is a height - balanced tree: (1) Each tree node represents a sub - partition (2) Each internal node has n (≥2) child nodes (sub - partitions); (3) Each leaf node contains at most m (≥1) vertices, and all leaf nodes appear at the same level; (4) Each node maintains a list of trajectories As Figure 3 shown, the original trajectory will be mapped onto the road segments and represented by a sequence of road segments. A trajectory can pass through one or more leaf partitions. For each trajectory T, find the lowest - level node that can enclose T in a bottom - up manner, that is, find the lowest common ancestor (LCA) node among the sub - partitions traversed by T. Then insert T into the trajectory list of the LCA.

[0071] As Figure 6 shown, the leaf nodes of the constructed PT - Gtree are The internal nodes include P1 1 , In addition, there are 7 trajectories. For T1, it passes through the sub - partitions of and . The LCA of these nodes is So insert T1 into . Similarly, all other trajectories are inserted into their corresponding LCAs. Intuitively, trajectories with high similarity are adjacent in space. If a node can encapsulate all the segments of a specified trajectory T q , then the trajectories outside the node space may not be very similar and can thus be safely filtered out. T1 is the query trajectory, and it can be seen that its LCA is and its trajectory list contains two other trajectories. Therefore, the candidate trajectories are set as CndT = {T4, T7}. Further calculate the vector Euclidean distance between T1 to obtain the similarity query result.

[0072] The above - mentioned is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent replacements, and improvements made within the spirit and principle of the present invention shall be included within the protection scope of the present invention.

Claims

1. A method for trajectory representation learning and similarity query based on road network division, characterized in that It includes the following steps: S1: Partition the road network, assign label words to each partition and boundary edges in sequence, and construct a vocabulary; S2: Obtain multiple original trajectories, based on the above vocabulary, perform road network matching on the original trajectories, and convert the matched trajectory sequence into a word sequence; S3: Construct a PT-GTree according to the partitioning result, store the trajectories matched in step S2 into the lowest common ancestor nodes of the PT-GTree, and for trajectory similarity queries, use the PT-GTree to prune the query database to determine the query candidate trajectory set; S4: Construct an encoder-decoder model based on GRU, use the word sequence in step S2 as the input, encode it into a low-dimensional latent vector v through the encoder, and then decode an output sequence y through the decoder. At the same time, design a loss function based on spatial and topological information to train this model; S5: Use the trained encoder-decoder model to embed the candidate trajectories determined in step S3 into a low-dimensional vector space, represent the candidate trajectories in the form of vectors, and use the Euclidean distance between two trajectory vectors to represent the similarity degree of the trajectories. The smaller the distance, the more similar the trajectories; where, The pruning method for trajectory similarity query based on PT-GTree indexing is as follows: Use the partitioning result in step S2 to construct a PT-GTree, find all the leaf nodes passed by all the original trajectories, find the lowest common ancestor nodes of all the leaf nodes, and store the original trajectories into the corresponding tree nodes; Given a query trajectory, first find all the leaf nodes passed by the query trajectory, and then find the lowest common ancestor node of the query trajectory according to these leaf nodes. Take the lowest common ancestor node and the original trajectories stored in its child nodes as the candidate set.

2. The method for trajectory representation learning and similarity query based on road network partitioning according to claim 1, wherein: In step S1, use a multi-layer partitioning algorithm to partition the road network. Specifically, Coarsen the vertices and edges of the road network to reduce the network scale; Use the Kernighan-Lin network partitioning algorithm to partition the coarsened road network graph to form multiple subgraphs; perform the partitioning by setting two parameters m and n, where m is the number of road network nodes in each subgraph; n is the number of partitioned subgraphs; Perform uncoarsening on the subgraphs to generate the final partition of the original network, number the final partition and boundary edges in sequence and assign labels, each label corresponds to a corresponding word, and these words form a vocabulary.

3. The method for trajectory representation learning and similarity query based on road network division according to claim 1, characterized in that: The loss function is as follows Among them, W projects h t from the hidden state space to the word list space. The u-th row of W u is denoted as such, and D(u, y t ) represents the shortest road network distance between words. λ is a distance scale parameter, and TK(y t ) represents the K words close to y t , while T(y t ) represents the words directly connected to the target word in terms of topological structure.

4. The method for trajectory representation learning and similarity query based on road network partitioning according to claim 1, wherein: In step S5, input the word sequence into the encoder of the improved model, and encode the trajectory sequence into a low-dimensional latent vector v through the embedding and the computing units of 3 layers of GRU networks; The decoder calculates the conditional probability of the output sequence at each position accordingly; specifically, at a certain position, the decoder converts the output sequence and the latent vector before this position into a hidden state, which retains the sequence information of the word sequence and the output sequence, then predicts the output at this position through the hidden state, and finally obtains the output sequence y. The loss function is used to calculate the loss between the output sequence y and the target sequence, and the model adjusts the parameters according to the loss to make the model more accurate.

Citation Information

Patent Citations

  • Traffic track prediction method based on high-dimensional road network and circulating neural network

    CN108629978A

  • Trajectory similarity calculation method

    CN113128607A