Trajectory similarity calculation method and system based on road network topology perception and multi-view fusion

CN121682322BActive Publication Date: 2026-10-09EAST CHINA NORMAL UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511903491.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-12-17
Publication Date
2026-10-09
Estimated Expiration
2045-12-17

AI Technical Summary

Technical Problem

多数基于网格单元的模型受限于网格的固定性和粗粒度,难以应对轨迹分布不均和时空动态变化

Benefits of technology

1、本发明能够在保障计算速度达到最优的同时,有效应对轨迹数据采样不均匀、定位噪声以及数据偏态分布等问题,生成更具鲁棒性和区分度的轨迹向量表示,以实现更准确、高效的轨迹相似度计算方法。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121682322B_ABST
    Figure CN121682322B_ABST
Patent Text Reader

Abstract

The application provides a trajectory similarity calculation method and system based on road network topology perception and multi-view fusion, comprising a road section encoder, a road section-trajectory joint encoding module, an image encoder and a sequence encoder; the road section encoder is used for encoding road sections to form a road section sequence, the road section-trajectory joint encoding module is used for encoding trajectories according to the road section sequence to generate a road section granularity trajectory vector representation of the trajectory; the image encoder is used for encoding visual images of the trajectory to generate a geometric shape vector representation of the trajectory; the sequence encoder is used for generating a motion state vector of the trajectory; and the three vectors are aggregated to form a final vector representation. The application can effectively deal with problems such as uneven sampling of trajectory data, positioning noise and data skew distribution while ensuring that the calculation speed is optimal, and generates a trajectory vector representation with higher robustness and discrimination, so that a more accurate and efficient trajectory similarity calculation method is realized.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer data processing technology. Specifically, it relates to a trajectory similarity calculation method and system based on road network topology perception and multi-view fusion, and in particular, a trajectory similarity calculation method and system based on road network topology perception and multi-view fusion applicable to various location-based services and data mining applications. Background Technology

[0002] With the rapid development and widespread adoption of positioning technologies such as GPS, Wi-Fi, and the BeiDou Navigation Satellite System, obtaining geographic location information has become increasingly convenient. This has spurred a surge in location-based services and data mining applications, creating massive trajectory databases by recording and accumulating real-time location information such as latitude, longitude, and time of user devices. For example, map navigation services, ride-hailing platforms, telecommunications operators, and social media can all collect mobile trajectory data from devices. These real-world trajectory data resources demonstrate immense application value and potential in areas such as autonomous driving, drone flight path management, smart city traffic management, popular route discovery, personalized services and behavioral analysis, and public safety and risk prevention. Trajectory similarity calculation is a fundamental and core technology in trajectory data mining, serving as a crucial link in downstream tasks such as trajectory clustering, anomaly detection, trajectory retrieval, and trajectory prediction. Therefore, developing accurate, efficient, and robust trajectory similarity measurement methods has significant theoretical and practical value.

[0003] Various trajectory similarity calculation methods have been proposed in existing technologies. Traditional methods mainly quantify the similarity between trajectories based on point-pair matching. Early studies used Euclidean distance for measurement, but this method requires the two trajectories to have the same length and is extremely sensitive to noise points. To handle trajectories of varying lengths, the Dynamic Time Warping (DTW) algorithm was introduced, but its performance in handling noise points is poor. Subsequent shape-based measurement methods, such as Hausdorff distance and Fréchet distance, while considering the order of points, are very sensitive to local differences and sample noise. To mitigate the impact of localization noise, some studies have proposed methods based on edit distance, such as EDR and ERP. These methods determine whether two points match by setting a distance threshold, but the threshold setting depends on experience and remains sensitive to changes in the sampling rate. Although subsequent algorithms have attempted to alleviate the sampling rate and noise problems through point supplementation or spatiotemporal evaluation, these traditional methods generally suffer from high time complexity (usually quadratic level), making it difficult to effectively handle large-scale trajectory data and failing to deeply mine the hidden features within the trajectory data.

[0004] In recent years, with the development of deep learning technology, researchers have begun to use deep learning models to transform trajectory sequences into fixed-length vector representations, and then perform measurement by calculating the similarity between vectors, thereby reducing the time complexity to linear. For example, some models utilize a sequence encoder-decoder structure to learn potential continuous route information from discrete trajectory points to generate trajectory representations robust to noise and uneven sampling. Some studies have also introduced spatiotemporal-aware loss functions or contrastive learning models to simultaneously capture the spatiotemporal and point-level features of the trajectory, further improving the robustness of the representation. To more accurately capture fine-grained information about the trajectory, the latest research has begun to incorporate road network information into the model. These methods utilize the topological structure of the road network, combined with pre-trained road segment vector representations, to constrain and optimize the vector learning process of the trajectory. In this way, the model can learn more accurate trajectory embeddings. Although the above-mentioned deep learning-based methods have made some progress in trajectory similarity calculation, they still have shortcomings. Most grid-based models are limited by the fixed and coarse-grained nature of the grid, making it difficult to cope with uneven trajectory distribution and spatiotemporal dynamic changes. While existing methods that incorporate road network information have improved accuracy to some extent, they generally fail to fully and simultaneously consider the combined impact of positioning noise and uneven sampling rates on model robustness.

[0005] However, both traditional methods and existing deep learning models still face the following technical challenges when processing trajectory data collected from the real world: (1) Uneven trajectory sampling: Due to factors such as the performance of the acquisition equipment and network signals, the sampling rate of trajectory data is often inconsistent, and data loss may even occur, resulting in uneven distribution of trajectory points and introducing bias when measuring the similarity between trajectories. (2) Presence of positioning noise: The positioning process is easily affected by environmental interference and the system's own bias, causing random drift in the acquired trajectory point data, which directly affects the accuracy of similarity calculation. (3) Skewed distribution: In the trajectory dataset, the frequency of some popular paths is much higher than that of other paths, resulting in an unbalanced data distribution. Traditional similarity calculation methods are difficult to effectively handle this skewed distribution, thus affecting the accuracy of the calculation results.

[0006] In the prior art, patent document "A Trajectory Similarity Calculation Method" (CN106776482A) discloses a method for calculating trajectory similarity by combining point-segment distance and Euclidean distance to reduce the impact of trajectory sampling frequency on algorithm accuracy. Similarly, patent document "Trajectory Similarity Determination Method and Apparatus" (CN110555061A) discloses a method for constructing trajectories in a spatiotemporal coordinate system using position and time information and calculating the minimum edit distance to determine similarity. Furthermore, patent document "A Flight Trajectory Similarity Calculation Method Based on Representation Learning" (CN118427628A) proposes a flight trajectory representation learning model, FT2Vec, for flight trajectory data. However, these prior art technologies still have limitations in application. For example, gridding and segmented averaging of trajectories may lead to the loss of fine-grained information of the true trajectory; over-reliance on accurate road network matching can significantly affect model performance if the quality of road network matching declines, making it difficult to distinguish subtle differences between trajectories within the same path. Meanwhile, the robustness of existing models still needs to be improved when trajectory sampling is sparse or GPS positioning has large errors, making it difficult to maintain high accuracy in similarity calculation under low-quality data conditions.

[0007] Therefore, there is an urgent need for a method that can effectively address various challenges such as uneven trajectory data sampling, positioning noise, and skewed data distribution, thereby generating more robust and discriminative trajectory vector representations to achieve a more accurate and efficient trajectory similarity calculation method. Summary of the Invention

[0008] To address the shortcomings of existing technologies, the purpose of this invention is to provide a trajectory similarity calculation method and system based on road network topology perception and multi-view fusion.

[0009] The trajectory similarity calculation method based on road network topology sensing and multi-view fusion provided by the present invention includes: Step S1: Input the road network map into the trajectory similarity calculation system and convert it into a line graph structure; Step S2: After inputting the trajectory into the trajectory similarity calculation system, it is matched with the line map structure and converted into a vector representation by the road segment encoder to form a road segment sequence; A trajectory image is generated based on the sequence of coordinate points of the trajectory. The geometric shape vector representation and motion state vector representation of the trajectory are generated by an image encoder and a sequence encoder, respectively. Step S3: Generate a trajectory vector representation at the road segment level by encoding the road segment sequence through the road segment-trajectory joint encoding module; Step S4: The trajectory vector representation, geometric shape vector representation, and motion state vector representation at the road segment level are fused to generate a hybrid trajectory representation vector.

[0010] Preferably, the method further includes step S6: Training methods using multi-view data augmentation and contrastive learning are employed for each trajectory in the original trajectory dataset. Data augmentation is performed to generate two semantically consistent but differently represented augmented views, forming a positive sample pair.

[0011] For each trajectory in the original trajectory dataset Perform semantic enhancement on the data to generate two semantically inconsistent but very similar hard samples, forming a negative sample pair.

[0012] The original trajectory set and the generated enhanced trajectory view set are encoded into embedding vectors respectively, and a loss function for contrastive learning is constructed. The loss function is then used to perform end-to-end optimization of the trajectory encoder RNT2Vec.

[0013] Preferably, step S1 includes: Step S1.1: Obtain the input road network diagram Initialize an empty line chart. And create an empty segment-vertex mapping table; in, The data format for representing open street maps; Represents the set of intersections of a road segment; Represents a set of road segments; Representation diagram The adjacency matrix; A line map centered on a road segment; This represents a set of road segments on a line map. This represents the set of intersections along a road segment in a line diagram. Line chart The adjacency matrix.

[0014] Step S1.2: Traverse the road network graph Each section of the road Create the corresponding vertices and all Add to In the process, road segments are recorded in the road segment-vertex mapping table. To a new peak The mapping relationship.

[0015] Step S1.3: Traverse the road network graph Each road intersection Determine the set of all input road segments that converge at the intersection of the road. and the set of output road segments originating from that intersection. .

[0016] Step S1.4, Traversal , All input segments Output section By querying the road segment-vertex mapping table, the corresponding line graph vertices of the combined pairs can be found. and Online chart Create a path from the vertex Pointing to the vertex Directed edge And add the directed edge to the edge set of the line graph. middle.

[0017] Step S1.5: Update the adjacency matrix of the line graph based on the intersection points and the constructed directed edges. Output a directed graph .

[0018] Preferably, step S2 includes: The road segment coding steps involve matching the continuous trajectory space and discrete trajectory data points with the line graph structure to form a road segment identifier sequence, which is then input into the road segment encoder and encoded into a vector representation of the road segment. Based on line chart The initial feature matrix of the road segment is used to generate a road segment embedding vector that is context-aware.

[0019] The format of the trajectory data points is:

[0020] in,

[0021] .

[0022] The vector representation steps are as follows: Based on the sequence of coordinate points of the trajectory, a two-dimensional trajectory image representing the geometry of the trajectory is generated using a graphical method. An image encoder is then used to encode the image, generating a vector representation of the trajectory's geometry. ; A sequence encoder is used to generate a motion state vector representation of the trajectory by taking the coordinates of the trajectory as input. .

[0023] Preferably, the road segment coding step includes: Step S2.A.1: Traverse each edge representing a valid turn in the line graph. Based on historical trajectory data, statistics are compiled from the vertex Directly turn to each of its vertices The frequency of each turning edge is calculated, and the transition probability corresponding to each turning edge is also calculated. :

[0024] in, Represents vertices The set of all direct successor road segments; k represents the ordinal number.

[0025] Step S2.A.2, for the first segment encoder Layered network, for each vertex Update its embedding vector, for Each Combined with the first Layered road segment embedding vector , and transition probability Unnormalized attention scores are calculated using an attention function that includes learnable weight parameters. The attention scores are normalized using the Softmax function to obtain the attention weights. :

[0026]

[0027] in, Each represents a different learnable weight parameter; This indicates a vector concatenation operation.

[0028] Step S2.A.3: Employ a multi-head attention mechanism, for each attention head... Use the corresponding attention weights The embedding vectors of subsequent vertices are weighted and summed, and all attention heads are traversed to obtain the outputs of all attention heads.

[0029] Step S2.A.4: Concatenate the outputs of all attention heads and process them using the activation function ELU to generate vertices. In the Layer embedding vector :

[0030] in, Indicates the number of attention heads; Indicates the first The learnable weight matrix for each size; j represents the ordinal number.

[0031] Step S2.A.5: Repeat steps S2.A.2 to S2.A.4 for a total of... Next, the embedding matrix output from the previous layer... As input to the next layer, calculate the first... The final embedding matrix of the layer As a road segment embedding vector; in, This indicates the preset number of network layers.

[0032] Preferably, step S3 includes: Step S3.1: Obtain the road segment embedding vector corresponding to each road segment. For each position in the trajectory Generate a position encoding vector ; The input token is obtained by summing the road segment embedding vector and its corresponding location encoding vector. Combine all tokens into a complete input sequence. :

[0033]

[0034]

[0035] The location encoding vector Generated using sine and cosine functions:

[0036]

[0037] in, Indicates the position of the token in the sequence; The ordinal number of the dimension index of the encoded vector; This represents the total dimension of the embedding vector.

[0038] Step S3.2: Generate the input sequence The input is fed into a multi-head self-attention layer, linearly mapped to three spaces: query Q, key K, and value V. Attention scores are computed in parallel across multiple attention heads and then summed using weighted averages.

[0039] in, Indicates the first The output of each attention head; They represent the first The Q, K, and V projection matrices of the size; This represents the dimension of the key vector.

[0040] Step S3.3, put all The outputs of each element are concatenated and then processed through a final linear projection layer. The output of the MHA layer is obtained:

[0041] The output of the MHA layer and Perform residual connections and apply layer normalization to obtain intermediate outputs. :

[0042] Step S3.4: Transfer intermediate output The input is fed into a feedforward network consisting of two linear layers and a ReLU activation function, which independently performs a nonlinear transformation on each vector in the sequence:

[0043] in, express The first in One vector; These represent different weight matrices; These represent different bias terms.

[0044] Step S3.5: Match the output of FFN with the corresponding intermediate input. Perform residual connections and apply layer normalization again to obtain the final output sequence. :

[0045] For the final output sequence Mean pooling yields a trajectory vector representation at the road segment level.

[0046] Preferably, step S4 includes: By using attention mechanisms or vector concatenation and linear transformations, the trajectory vector representation, geometric shape vector representation, and motion state vector representation at the road segment level are concatenated along the feature dimension to obtain a fused vector. :

[0047] The fused vector is input into a multilayer perceptron containing two fully connected layers and an activation function. After a nonlinear transformation, the features of different modalities are mapped to the same semantic space, generating a hybrid trajectory representation vector. :

[0048] in, , , These represent the trajectory vector representation, geometric shape vector representation, and motion state vector representation at the road segment level, respectively. This represents a vector concatenation operation; These represent different weight matrices; These represent different bias terms.

[0049] The present invention provides a trajectory similarity calculation system based on road network topology perception and multi-view fusion, comprising: a road segment encoder, a road segment-trajectory joint encoding module, an image encoder, and a sequence encoder.

[0050] The road segment encoder encodes the road segments to form a road segment sequence. The road segment-trajectory joint encoder module encodes the trajectory according to the road segment sequence to generate a road segment-granular trajectory vector representation of the trajectory. The visualized image of the trajectory is encoded by an image encoder to generate a geometric vector representation of the trajectory. The motion state vector of the trajectory is generated by a sequence encoder; By concatenating and nonlinearly transforming the segment-level trajectory vector representation, geometric shape vector representation, and motion state vector representation, they are mapped to the same semantic space to form the final hybrid trajectory vector representation.

[0051] Preferably, the image encoder is a convolutional neural network model and / or a visual transformer model.

[0052] The sequence encoder is a long short-term memory network model and / or a converter model.

[0053] By employing a training method that combines multi-view data augmentation and contrastive learning, the consistency between different augmented views of the same trajectory is maximized while minimizing the similarity between different trajectory views, thus iteratively optimizing the trajectory similarity calculation system.

[0054] Preferably, for each trajectory in the original trajectory dataset Data augmentation is performed to generate two semantically consistent but differently represented augmented views, forming a positive sample pair.

[0055] For each trajectory in the original trajectory dataset Perform semantic enhancement on the data to generate two semantically inconsistent but very similar hard samples, forming a negative sample pair.

[0056] The original trajectory set and the generated enhanced trajectory view set are encoded into embedding vectors respectively, and a loss function for contrastive learning is constructed. :

[0057] The parameters of the trajectory encoder are iteratively updated by minimizing the loss function until convergence.

[0058] in, Indicates the batch size; i and k both represent different ordinal numbers; Represents the cosine similarity function; A view representing the trajectory; Indicates a positive sample; Indicates a negative sample; The set of embedding vectors representing the original trajectory; Represents the set of embedding vectors of the augmented view; This represents the temperature hyperparameter used to control the shape of the distribution.

[0059] Compared with the prior art, the present invention has the following beneficial effects: 1. This invention can effectively address issues such as uneven trajectory data sampling, positioning noise, and skewed data distribution while ensuring optimal computation speed, generating more robust and discriminative trajectory vector representations to achieve a more accurate and efficient trajectory similarity calculation method.

[0060] 2. This invention dynamically captures the complex temporal dependencies within the trajectory by jointly processing the location information of the embedded sequence of road segments and the trajectory, thereby generating a representation vector with high generalization and context awareness of the entire trajectory.

[0061] 3. This invention improves the generalization ability and robustness of trajectory representation by maximizing the consistency between different enhanced views of the same trajectory while minimizing the similarity between different trajectory views, effectively addressing common noise and data sparsity problems in trajectory data. Attached Figure Description

[0062] Other features, objects, and advantages of the invention will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings: Figure 1 This is a schematic diagram illustrating the conversion of the original road network OSM diagram into a line diagram in an embodiment of the present invention; Figure 2 This is a schematic diagram of a road segment encoder in an embodiment of the present invention; Figure 3 This is a schematic diagram of a road segment-track joint encoder in an embodiment of the present invention; Figure 4 This is a schematic diagram of trajectory geometry vector generation in an embodiment of the present invention; Figure 5 This is a schematic diagram illustrating the generation of trajectory motion shape vectors in an embodiment of the present invention; Figure 6 This is a schematic diagram illustrating the comparison of TOPK queries on the Porto dataset in an embodiment of the present invention.

[0063] Appendix Figure 1 The text shows: , , , These represent different vertices. Detailed Implementation

[0064] The present invention will now be described in detail with reference to specific embodiments. These embodiments will help those skilled in the art to further understand the present invention, but do not limit the invention in any way. It should be noted that those skilled in the art can make several changes and improvements without departing from the concept of the present invention. These all fall within the scope of protection of the present invention.

[0065] This invention provides a trajectory similarity calculation method based on road network topology perception and multi-view fusion, relating to the fields of artificial intelligence and spatiotemporal data analysis. By fusing road network topology, trajectory geometry, and motion state information, and combining it with contrastive learning training, the method improves the accuracy and robustness of trajectory similarity calculation under complex conditions such as uneven sampling and the presence of positioning noise. It can be applied to various location-based services and data mining applications, including but not limited to autonomous driving, drone trajectory management, smart city traffic management, popular route mining, personalized services and behavior analysis, and public safety and risk prevention, achieving accurate, efficient, and robust trajectory similarity calculation. Specifically, it includes the following steps: Step S1: Construct the RNT2Vec model, i.e., the trajectory similarity calculation system. The RNT2Vec model includes a road segment encoder and a road segment-trajectory joint encoding module, as well as an image encoder based on trajectory geometry and a sequence encoder based on trajectory motion state.

[0066] The RNT2Vec model addresses various challenges such as uneven trajectory data sampling, positioning noise, and skewed data distribution through a segment encoder module and a segment-trajectory joint encoder module. This results in the generation of a segment-level trajectory vector representation; a geometric vector representation of the trajectory via an image encoder; and a motion state vector representation of the trajectory via a sequence encoder. These three vectors are then aggregated to form the final vector representation.

[0067] The Road-Segment Encoder encodes road segments centered on them.

[0068] The segment-trajectory joint attention encoder takes the segment sequence as input and encodes the segment sequence of the trajectory.

[0069] The image encoder module uses a vision transformer to encode the visualized image of the trajectory.

[0070] The sequence encoder uses a long short-term memory (LSTM) network to encode the original trajectory sequence.

[0071] The aggregation operation concatenates and transforms the trajectory vector representation at the road segment granularity, the geometric shape vector representation, and the motion state vector representation, mapping the features of different modalities to the same semantic space, and finally generating a hybrid trajectory representation vector.

[0072] Step S2: Transform the actual road network Convert to line chart The structure, which uses road segments as basic units, is used to introduce prior constraints on road network topology in trajectory representation learning. The specific transformation steps include: like Figure 1 As shown, the input road network map is obtained. Initialize an empty line chart. And create an empty "segment-vertex" mapping table.

[0073] Traversing the road network graph Each section of the road For each road segment Create a new corresponding vertex and all newly created vertices Vertex set added to the line graph In the process, road segments are simultaneously recorded in the "Road Segment-Vertex" mapping table. To a new peak The mapping relationship.

[0074] Traversing the road network graph Each road intersection For each intersection point Determine the set of all input road segments that converge at the intersection. (i.e., the head of the road section is) The road segment), and the set of all output road segments originating from that intersection. (i.e., road segments with a "u" at the end).

[0075] For each identified intersection point Iterate through all its input segments and output section The combination of each pair of input segments. and output section By querying the "segment-vertex" mapping table, the corresponding line graph vertices can be found respectively. and Online chart In the middle, create a path from vertex Pointing to the vertex Directed edge And add the directed edge to the edge set of the line graph. In the middle. The directed edge represents the path segment. to section of road A specific shift. With Figure 1 For example, i takes the values ​​1, 2, 3, 4, and j takes the values ​​1, 2, 3, 4.

[0076] After traversing all intersections and constructing turning edges, update the adjacency matrix of the line graph. To reflect all created edges, the final output is a constructed directed graph that explicitly expresses turning information. ; in, For Open Street Map data format, Represents the set of intersections of road segments. Represents a set of road segments. It is a picture The adjacency matrix; The for The line map centered on road segments is obtained through algorithmic transformation. Represents a set of road segments. Represents the set of intersections of road segments. It is a picture The adjacency matrix.

[0077] Step S3: Input the trajectory, match the trajectory to road segments on the road network, and then use a road segment encoder to convert the matched road segments into vector representations. The specific steps are as follows: The continuous spatial coordinates of the trajectory are matched into a road segment identifier sequence, and then the road segment identifier sequence is input into the road segment encoder for encoding; the discrete spatial trajectory coordinates are matched to the corresponding road segments.

[0078] The trajectory of normal movement is continuous, but the data collected by GPS devices is discrete (recording the current position at intervals), so the data processed by the algorithm is essentially discrete. Therefore, the collected discrete trajectory data points are matched with the line graph structure from the previous step to form a road segment identifier sequence, which is then input into the road segment encoder to be encoded into a vector representation of the road segment. The format of the trajectory data points is as follows:

[0079] in, , , , These represent the longitude, latitude, time, and trajectory length of the trajectory points collected by the device, respectively.

[0080] Based on a directed graph and the initial feature matrix of the road segment This generates context-aware embedding vectors for road segments. For example... Figure 2 As shown, it specifically includes: Calculate empirical move priors. Traverse each edge representing a valid turn in the directed graph. Based on historical trajectory data, statistics are compiled from the vertex Directly turn to each of its successor vertices The frequency of each turning edge is calculated, and the transition probability corresponding to each turning edge is also calculated. This allows us to obtain empirical prior information representing real-world trajectory patterns. The formula for calculating the transition probability is as follows:

[0081] in, It is the vertex The set of all direct successor vertices.

[0082] Perform single-layer motion-aware attention aggregation. For the first layer in the encoder... Layered network, for each road segment Update its embedding vector. First, for Each successor vertex Combined with the first Layered road segment embedding vector and and the calculated transition probability The unnormalized attention score is calculated using an attention function that includes learnable weight parameters. Then, the attention score is normalized using the Softmax function to obtain the attention weights. The expression is:

[0083]

[0084] in, All of these are learnable weight parameters. This indicates a vector concatenation operation.

[0085] Update and output the multi-head attention embedding vector. Employing a multi-head attention mechanism, the steps are executed in parallel multiple times to obtain multiple independent sets of attention weights. For each attention head... Use its corresponding attention weight The weighted summation of the embedding vectors of subsequent road segments yields the output of this attention head.

[0086] The output vectors of all attention heads are concatenated and processed by the activation function ELU to generate road segments. In the Layer embedding vector The expression is:

[0087] in, For the number of attention heads, For the first Learnable weight matrix for each size.

[0088] Finally, stack the network layers and generate the final embedding matrix. Repeat the above steps. Next, among them This indicates the preset number of network layers, and the embedding matrix output from the previous layer. As input to the next layer, until the first layer is calculated. The final embedding matrix of the layer The matrix This refers to a road segment context-aware embedding vector matrix that deeply integrates road network topology and experience-based mobility patterns.

[0089] Step S4: Encode the output of step S3 through the road segment-trajectory joint coding module to generate a trajectory vector representation at the road segment level.

[0090] By jointly processing the location information of road segment embedding sequences and trajectories, the complex temporal dependencies within the trajectory are dynamically captured, thereby generating a representation vector with high generalization and context awareness of the entire trajectory. The specific steps are as follows: like Figure 3 As shown, the road segment embedding vector corresponding to each road segment in the trajectory is obtained from step S3. At the same time, for each position in the trajectory ( Generate a position encoding vector This vector is used to inject sequence information into the model. The road segment embedding vector and its corresponding location encoding vector are summed to obtain an input token that integrates semantic and location information. Combine all tokens into a complete input sequence. .

[0091] The location encoding vector It can be generated using sine and cosine functions, and its calculation formula is as follows:

[0092]

[0093] in, It is the position of the token in the sequence. It is the dimension index of the encoded vector. It is the total dimension of the embedded vector.

[0094] Next, the generated input sequence The input is fed into a multi-head self-attention layer. This layer first processes the input sequence... A linear mapping is performed to three spaces: query Q, key K, and value V. Attention scores are then calculated in parallel across multiple attention heads and summed using weighted averages. Specifically: For the Each attention head, its output The calculation method is scaled dot product attention:

[0095] in, They are the first The Q, K, and V projection matrices of the size, It is the dimension of the key vector.

[0096] All The outputs of each element are concatenated and then passed through a final linear projection layer. The output of the MHA layer is obtained:

[0097] Compare the output of the MHA layer with the original input. Perform residual connections and apply layer normalization to obtain intermediate outputs. :

[0098] The intermediate output obtained The input is fed into a position-wise feedforward network, which typically consists of two linear layers and a ReLU activation function, performing a nonlinear transformation independently on each position vector in the sequence:

[0099] in, It is a sequence The first in A vector, This is the weight matrix. This is a bias term.

[0100] The output of FFN is compared with the input of this layer. Perform residual connections and apply layer normalization again to obtain the final output sequence of the Transformer encoder module. :

[0101] For the output sequence The mean pooling operation is applied, which calculates the average of all vectors in the sequence to obtain a fixed-dimensional segment-level representation vector that can represent the entire trajectory.

[0102] Step S5: Generate a trajectory image based on the original trajectory data points, use an image encoder to generate a geometric shape vector representation of the trajectory; and use a sequence encoder to encode the coordinate point sequence of the trajectory to generate a motion state vector representation of the trajectory.

[0103] The original trajectory data points, or the sequence of trajectory coordinate points, are the trajectory point data collected by the original device. The image encoder is, for example, a convolutional neural network (CNN) model or a visual transformer (ViT) model, and the sequence encoder is, for example, a long short-term memory network (LSTM) model or a transformer model. The specific steps are as follows: Based on the sequence of coordinate points of the trajectory, such as Figure 4 , Figure 5 As shown, a two-dimensional trajectory image representing the geometry of the trajectory is generated using a graphical method. Then, an image encoder, such as VIT or CNN, is used to encode the image, thereby generating a vector representation of the trajectory's geometric shape. Using a sequence encoder LSTM or Transformer, the original trajectory coordinates are used as input to generate a motion state vector representation of the trajectory. .

[0104] Step S6: Input the trajectory vector representation at the road segment granularity, the geometric shape vector representation, and the motion state vector into an aggregation module for fusion processing to generate the final hybrid trajectory representation vector.

[0105] The aggregation module uses an attention mechanism or vector concatenation and linear transformation. It concatenates the three vectors along their feature dimensions:

[0106] Obtain the fusion vector The fused vector is then input into a multilayer perceptron (MLP), which contains two fully connected layers and an activation function (ReLU), through which a nonlinear transformation is performed:

[0107] in, This is the weight matrix. This is a bias term.

[0108] Features from different modalities are mapped to the same semantic space, ultimately generating a hybrid trajectory representation vector. .

[0109] Step S7: Improve the robustness of the RNT2Vec model through unsupervised training using a multi-view data augmentation and contrastive learning training method. By maximizing the consistency between different augmented views of the same trajectory while minimizing the similarity between different trajectory views, the generalization ability and robustness of the trajectory representation are improved, effectively addressing common noise and data sparsity issues in trajectory data. The specific steps are as follows: For each trajectory in the original trajectory dataset Data augmentation is performed to generate two semantically consistent but differently represented augmented views, forming a positive sample pair. The specific augmentation operations include: Trajectory point downsampling: To simulate different trajectory sampling rates, a preset probability is used. Independently and randomly discard some intermediate points in the trajectory; Track point disturbance: To simulate signal noise in the Global Positioning System, a preset probability is used. The positions of some points in the trajectory are perturbed by adding random noise that follows a Gaussian distribution to their coordinates.

[0110] Simultaneously, for each trajectory in the original trajectory dataset Perform semantic-aware augmentation on the data to generate two semantically inconsistent but highly similar hard samples, forming a negative sample pair. The specific augmentation operations include: Effective detour replacement: Use an external routing planning engine (such as the A* algorithm) to find a connecting trajectory on the line graph constructed above. The alternative path with a different start and end point than the original path is used to replace the original sub-path with this new alternative path, generating a new trajectory that is semantically similar (same start and end point) but different in path details; Intersection path combination: Find two trajectories in the dataset that meet at a certain intersection (i.e., a node in the line graph). and By swapping their paths after the intersection, two entirely new, but physically feasible, trajectories are generated. and These synthesized trajectories can serve as new samples in the training set, greatly enriching the diversity of the training data.

[0111] Using the RNT2Vec model, the original trajectory set and the generated enhanced trajectory view set are encoded into embedding vectors, respectively. This yields the set of embedding vectors for the original trajectory. and the set of embedding vectors for the enhanced view. .

[0112] Constructing the loss function for contrastive learning The loss function is then used to perform end-to-end optimization of the trajectory encoder RNT2Vec. The goal of this loss function is to bring any trajectory view (e.g., ...) closer within the embedding space. ) and its corresponding augmented view (i.e., positive sample) The distance between the view and all other trajectories in the dataset (i.e., negative samples) is also considered. The distance between them.

[0113] The loss function The specific form is as follows:

[0114] in, It refers to the batch size. The cosine similarity function is used. This is a temperature hyperparameter used to control the shape of the distribution. By minimizing this loss function, the parameters of the trajectory encoder are iteratively updated until the model converges.

[0115] The present invention provides a trajectory similarity calculation system based on road network topology perception and multi-view fusion, comprising: a road segment encoder, a road segment-trajectory joint encoding module, an image encoder, and a sequence encoder.

[0116] The road segment encoder encodes the road segments to form a road segment sequence. The road segment-trajectory joint encoder module encodes the trajectory according to the road segment sequence to generate a road segment-granular trajectory vector representation of the trajectory. The visualized image of the trajectory is encoded by an image encoder to generate a geometric vector representation of the trajectory. The motion state vector of the trajectory is generated by a sequence encoder; By concatenating and nonlinearly transforming the segment-level trajectory vector representation, geometric shape vector representation, and motion state vector representation, they are mapped to the same semantic space to form the final hybrid trajectory vector representation.

[0117] In more preferred embodiments, the image encoder is a convolutional neural network model or a visual transformer model.

[0118] The sequence encoder is a long short-term memory network model or a converter model.

[0119] By employing a training method that combines multi-view data augmentation and contrastive learning, the consistency between different augmented views of the same trajectory is maximized while minimizing the similarity between different trajectory views, thus iteratively optimizing the trajectory similarity calculation system.

[0120] For each trajectory in the original trajectory dataset Data augmentation is performed to generate two semantically consistent but differently represented augmented views, forming a positive sample pair.

[0121] For each trajectory in the original trajectory dataset Perform semantic enhancement on the data to generate two semantically inconsistent but very similar hard samples, forming a negative sample pair.

[0122] The original trajectory set and the generated enhanced trajectory view set are encoded into embedding vectors respectively, and a loss function for contrastive learning is constructed. :

[0123] in, Indicates the batch size; i and k both represent different ordinal numbers; Represents the cosine similarity function; A view representing the trajectory; Indicates a positive sample; Indicates a negative sample; The set of embedding vectors representing the original trajectory; Represents the set of embedding vectors of the augmented view; This represents the temperature hyperparameter used to control the shape of the distribution.

[0124] The parameters of the trajectory encoder are iteratively updated by minimizing the loss function until convergence.

[0125] In more preferred examples, the tests were conducted on a Linux server equipped with an NVIDIA Tensor Core A100 GPU (80GB of VRAM), and all model algorithms were implemented based on the PyTorch deep learning framework.

[0126] The evaluation uses two publicly available large-scale taxi trajectory datasets, specifically: The Porto dataset contains 1,359,550 taxi trajectories, sampled at 15-second intervals. Chengdu Dataset: This dataset originates from Didi Chuxing's Big Data Open Plan and contains 1,133,463 trajectories with a sampling interval of 2 to 4 seconds.

[0127] The RNT2Vec model, a trajectory similarity calculation system based on road network topology sensing and multi-view fusion, has the following key parameter settings: The dimension of the representation vectors for both the trajectory and the road segment is set to 128; the number of layers L in the road segment encoder is set to 2; both attention modules in the road segment encoder (the spatiotemporal joint attention module and the attention module based on the transition probability) adopt a multi-head attention mechanism; the number of attention heads (H) is set to 4, and a dropout rate of 0.2 is used in the module to prevent overfitting; in model training, the temperature coefficient (λ) of the contrastive learning loss function is set to 0.07.

[0128] To comprehensively evaluate performance and demonstrate its beneficial effects, the following three evaluation metrics are used: Mean Rank (MR): Used to evaluate the accuracy of trajectory search tasks. The lower the value, the better the model's search performance.

[0129] Cross-Similarity (CS): This measures the robustness of a model to changes in the data sampling rate or data perturbations. The lower the value, the stronger the robustness of the model.

[0130] Precision@K: Used to evaluate the consistency of trajectory retrieval results. The higher the value, the more accurate the similar trajectories retrieved by the model.

[0131] To demonstrate the superiority of the method of this invention, representative baseline methods were selected for comparison, mainly divided into two categories: Distance-based methods include Dynamic Time Warping (DTW), Edit Distance-based Similarity (EDR), and Fréchet distance. Learning-based methods include T2Vec and RSTS (Recurrent Trajectory Sequence-to-Sequence), both of which are sequence-to-sequence (Seq2Seq) models that use the encoder's final state as an embedded representation of the trajectory. T2Vec, in particular, is a model for learning spatiotemporal trajectory data representation. Based on the seq2Seq model, it employs novel embedding techniques, including data augmentation methods, to handle variations in sampling rate and noisy sampling points.

[0132] The search accuracy is shown in Table 1. On both the Porto and Chengdu datasets, regardless of the database size, the method provided by this invention achieved the lowest average ranking (MR), demonstrating its search accuracy.

[0133] Table 1. Accuracy Comparison of RNT2Vec Models:

[0134] Robustness is shown in Table 2 and Figure 6 As shown, when facing common data quality issues such as downsampling and data distortion, the method provided by this invention outperforms existing state-of-the-art methods (such as T2Vec) in both cross-similarity (CS) and Precision@K metrics. This fully demonstrates that the road network sensing representation method adopted in this invention can effectively alleviate data sparsity and noise problems, and has superior overall performance.

[0135] Table 2. Robustness comparison of RNT2Vec models:

[0136] The noise resistance is shown in Table 3. To further verify the stability of the model, different levels of noise were artificially introduced into the trajectory points in the test set. Experimental results show that the method provided by this invention maintains optimal performance under different intensities of noise interference, highlighting its strong stability against data perturbations.

[0137] Table 3. Robustness comparison on the Porto dataset:

[0138] In more preferred examples, as shown in Table 4, ablation experiments were designed on the Porto dataset to compare the complete model with the following variants: 1. w / o LG: without using the transformation from the original road network map (such as OSM map) to the line graph, neighborhood aggregation is performed directly on the original road network map; 2. w / o TPAttn: the transition-probability-based attention module in the model is replaced with a regular graph convolutional network (GCN) for neighborhood aggregation; 3. w / o JointAttn: without using the spatiotemporal joint attention module for end-to-end training, pre-trained Node2Vec embedding vectors are used as the initial representation of road segments.

[0139] Table 4. Ablation experimental results of the RNT2Vec model:

[0140] Ablation experiments show that removing any core component of the RNT2Vec model leads to a significant decrease in model performance. Among them, removing the transition probability-based attention mechanism (TPAttn) has the most significant impact on performance, which fully demonstrates the necessity of modeling directional transition dependencies between road segments that conform to traffic logic.

[0141] In summary, through extensive experiments on standard datasets, the technical solution proposed in this invention has been verified to effectively learn deep representations of trajectories. It has achieved superior performance compared to existing technologies in tasks such as trajectory search and similarity calculation, and exhibits excellent robustness and stability.

[0142] Specific embodiments of the present invention have been described above. It should be understood that the present invention is not limited to the specific embodiments described above, and those skilled in the art can make various changes or modifications within the scope of the claims, which do not affect the essence of the present invention. Unless otherwise specified, the embodiments and features described in this application can be arbitrarily combined with each other.

Claims

1. A trajectory similarity calculation method based on road network topology sensing and multi-view fusion, characterized in that, include: Step S1: Input the road network map into the trajectory similarity calculation system and convert it into a line graph structure; Step S2: After inputting the trajectory into the trajectory similarity calculation system, it is matched with the line map structure and converted into a vector representation by the road segment encoder to form a road segment sequence; A trajectory image is generated based on the sequence of coordinate points of the trajectory. The geometric shape vector representation and motion state vector representation of the trajectory are generated by an image encoder and a sequence encoder, respectively. Step S3: Generate a trajectory vector representation at the road segment level by encoding the road segment sequence through the road segment-trajectory joint encoding module; Step S4: The trajectory vector representation, geometric shape vector representation, and motion state vector representation at the road segment level are fused to generate a hybrid trajectory representation vector; Step S5: Using a multi-view data augmentation and contrastive learning training method, train each trajectory in the original trajectory dataset. Perform data augmentation to generate two semantically consistent but differently represented augmented views, forming a positive sample pair; For each trajectory in the original trajectory dataset Perform semantic enhancement on the data to generate two semantically inconsistent but very similar hard samples, forming a negative sample pair; The data semantic awareness enhancement includes effective detour replacement and intersection path combination; The effective detour replacement includes: using a routing planning engine to find a connecting trajectory on the line graph structure. For alternative paths with different starting and ending points than the original path, replace the sub-paths of the original trajectory with the alternative paths to generate a new trajectory with the same starting and ending points but different path details. The intersection path combination includes: identifying two trajectories that meet at the same intersection in the original trajectory dataset, exchanging the paths of the two trajectories after the intersection, and generating a physically feasible new trajectory. The original trajectory set and the generated enhanced trajectory view set are encoded into embedding vectors respectively. The enhanced trajectory views are used as positive samples and the difficult samples are used as negative samples to construct a loss function for contrastive learning. And use this loss function to perform end-to-end optimization of the trajectory encoder.

2. The trajectory similarity calculation method based on road network topology sensing and multi-view fusion according to claim 1, characterized in that, Step S1 includes: Step S1.1: Obtain the input road network diagram Initialize an empty line chart. And create an empty segment-vertex mapping table; in, The data format for representing open street maps; Represents the set of intersections of a road segment; Represents a set of road segments; Representation diagram The adjacency matrix; A line map centered on a road segment; This represents a set of road segments on a line map. This represents the set of intersections for a road segment on a line map. Line chart The adjacency matrix; Step S1.2: Traverse the road network graph Each section of the road Create the corresponding vertices and all Add to In the process, road segments are recorded in the road segment-vertex mapping table. To a new peak The mapping relationship; Step S1.3: Traverse the road network graph Each road intersection Determine the set of all input road segments that converge at the intersection of the road. and the set of output road segments originating from that intersection. ; Step S1.4, Traversal , All input segments Output section By querying the road segment-vertex mapping table, the corresponding line graph vertices of the combined pairs can be found. and Online chart Create a path from the vertex Pointing to the vertex Directed edge And add the directed edge to the edge set of the line graph. middle; Step S1.5: Update the adjacency matrix of the line graph based on the intersection points and the constructed directed edges. Output a directed graph .

3. The trajectory similarity calculation method based on road network topology sensing and multi-view fusion according to claim 1, characterized in that, Step S2 includes: The road segment coding steps involve matching the continuous trajectory space and discrete trajectory data points with the line graph structure to form a road segment identifier sequence, which is then input into the road segment encoder and encoded into a vector representation of the road segment. Based on line chart The initial feature matrix of the road segment is used to generate a road segment embedding vector with road segment context awareness; The format of the trajectory data points is: in, , , These represent the data collected by the device at the [number]th [time]. The longitude, latitude, and time of each trajectory point; Take a positive integer to represent the trajectory length; The vector representation steps are as follows: Based on the sequence of coordinate points of the trajectory, a two-dimensional trajectory image representing the geometry of the trajectory is generated using a graphical method. An image encoder is then used to encode the image, generating a vector representation of the trajectory's geometry. ; A sequence encoder is used to generate a motion state vector representation of the trajectory by taking the coordinates of the trajectory as input. .

4. The trajectory similarity calculation method based on road network topology sensing and multi-view fusion according to claim 3, characterized in that, The road segment coding steps include: Step S2.A.1: Traverse each edge representing a valid turn in the line graph. Based on historical trajectory data, statistics are compiled from the vertex Directly turn to each of its vertices The frequency of each turning edge is calculated, and the transition probability corresponding to each turning edge is also calculated. : in, Represents vertices The set of all direct successor road segments; k represents the ordinal number; Step S2.A.2, for the first segment encoder Layered network, for each vertex Update its embedding vector, for Each Combined with the first Layered road segment embedding vector , and transition probability Unnormalized attention scores are calculated using an attention function that includes learnable weight parameters. The attention scores are normalized using the Softmax function to obtain the attention weights. : in, Each represents a different learnable weight parameter; This represents a vector concatenation operation; Step S2.A.3: Employ a multi-head attention mechanism, for each attention head... Use the corresponding attention weights The embedding vectors of subsequent vertices are weighted and summed, and all attention heads are traversed to obtain the outputs of all attention heads; Step S2.A.4: Concatenate the outputs of all attention heads and process them using the activation function ELU to generate vertices. In the Layer embedding vector : in, Indicates the number of attention heads; Indicates the first The learnable weight matrix for each size; j represents the ordinal number; Step S2.A.5: Repeat steps S2.A.2 to S2.A.4 for a total of... Next, the embedding matrix output from the previous layer... As input to the next layer, calculate the first... The final embedding matrix of the layer As a road segment embedding vector; in, This indicates the preset number of network layers.

5. The trajectory similarity calculation method based on road network topology sensing and multi-view fusion according to claim 3, characterized in that, Step S3 includes: Step S3.1: Obtain the road segment embedding vector corresponding to each road segment. For each position in the trajectory Generate a position encoding vector ; The input token is obtained by summing the road segment embedding vector and its corresponding location encoding vector. Combine all tokens into a complete input sequence. : The location encoding vector Generated using sine and cosine functions: in, Indicates the position of the token in the sequence; The ordinal number of the dimension index of the encoded vector; This represents the total dimension of the embedding vector; Step S3.2: Generate the input sequence The input is fed into a multi-head self-attention layer, linearly mapped to three spaces: query Q, key K, and value V. Attention scores are computed in parallel across multiple attention heads and then summed using weighted averages. in, Indicates the first The output of each attention head; They represent the first The Q, K, and V projection matrices of the size; Indicates the dimension of the key vector; Step S3.3, put all The outputs of each element are concatenated and then processed through a final linear projection layer. The output of the MHA layer is obtained: The output of the MHA layer and Perform residual connections and apply layer normalization to obtain intermediate outputs. : Step S3.4: Transfer intermediate output The input is fed into a feedforward network consisting of two linear layers and a ReLU activation function, which independently performs a nonlinear transformation on each vector in the sequence: in, express The first in One vector; These represent different weight matrices; These represent different bias terms; Step S3.5: Match the output of FFN with the corresponding intermediate input. Perform residual connections and apply layer normalization again to obtain the final output sequence. : For the final output sequence Mean pooling yields a trajectory vector representation at the road segment level.

6. The trajectory similarity calculation method based on road network topology sensing and multi-view fusion according to claim 1, characterized in that, Step S4 includes: By using attention mechanisms or vector concatenation and linear transformations, the trajectory vector representation, geometric shape vector representation, and motion state vector representation at the road segment level are concatenated along the feature dimension to obtain a fused vector. : The fused vector is input into a multilayer perceptron containing two fully connected layers and an activation function. After a nonlinear transformation, the features of different modalities are mapped to the same semantic space, generating a hybrid trajectory representation vector. : in, , , These represent the trajectory vector representation, geometric shape vector representation, and motion state vector representation at the road segment level, respectively. This represents a vector concatenation operation; These represent different weight matrices; These represent different bias terms.

7. A trajectory similarity calculation system based on road network topology sensing and multi-view fusion, characterized in that, include: Segment encoder, segment-trajectory joint encoding module, image encoder, and sequence encoder; Transform the road network map into a line graph structure and match the trajectory with the line graph structure; The road segment encoder encodes the road segments to form a road segment sequence. The road segment-trajectory joint encoder module encodes the trajectory according to the road segment sequence to generate a road segment-granular trajectory vector representation of the trajectory. The visualized image of the trajectory is encoded by an image encoder to generate a geometric vector representation of the trajectory. The motion state vector of the trajectory is generated by a sequence encoder; By concatenating and nonlinearly transforming the road segment granular trajectory vector representation, geometric shape vector representation, and motion state vector representation, they are mapped to the same semantic space to form the final hybrid trajectory vector representation; Training methods using multi-view data augmentation and contrastive learning are employed for each trajectory in the original trajectory dataset. Perform data augmentation to generate two semantically consistent but differently represented augmented views, forming a positive sample pair; For each trajectory in the original trajectory dataset, perform data semantic awareness enhancement to generate two semantically inconsistent but very similar hard samples, which form a negative sample pair; The data semantic awareness enhancement includes effective detour replacement and intersection path combination; The effective detour replacement includes: using a routing planning engine to find a connecting trajectory on the line graph structure. For alternative paths with different starting and ending points than the original path, replace the sub-paths of the original trajectory with the alternative paths to generate a new trajectory with the same starting and ending points but different path details. The intersection path combination includes: identifying two trajectories that meet at the same intersection in the original trajectory dataset, exchanging the paths of the two trajectories after the intersection, and generating a physically feasible new trajectory. The original trajectory set and the generated enhanced trajectory view set are encoded into embedding vectors respectively. The enhanced trajectory views are used as positive samples and the difficult samples are used as negative samples to construct a loss function for contrastive learning. And use this loss function to perform end-to-end optimization of the trajectory encoder.

8. The trajectory similarity calculation system based on road network topology perception and multi-view fusion according to claim 7, characterized in that, The image encoder is a convolutional neural network model and / or a visual transformer model; The sequence encoder is a long short-term memory network model and / or a converter model; By employing a training method that combines multi-view data augmentation and contrastive learning, the consistency between different augmented views of the same trajectory is maximized while minimizing the similarity between different trajectory views, thus iteratively optimizing the trajectory similarity calculation system.

9. The trajectory similarity calculation system based on road network topology perception and multi-view fusion according to claim 8, characterized in that, The loss function for constructing contrastive learning : The parameters of the trajectory encoder are iteratively updated by minimizing the loss function until convergence. in, Indicates batch size; i and k both represent different ordinal numbers; Represents the cosine similarity function; A view representing the trajectory; Indicates a positive sample; Indicates a negative sample; The set of embedding vectors representing the original trajectory; Represents the set of embedding vectors of the augmented view; This represents the temperature hyperparameter used to control the shape of the distribution.

Citation Information

Patent Citations

  • Track similarity calculating method

    CN106776482A

  • Track similarity determination method and device

    CN110555061A