Vehicle trajectory similarity measurement method and system based on spatiotemporal consistency representation

Through the spatial and temporal consistency representation method, the spatial and temporal characteristics in vehicle trajectory data are extracted and processed, and the problem of difficult to model the nonlinear relationship between spatial and temporal characteristics in trajectory data in the prior art is solved, and a more efficient trajectory similarity calculation is achieved.

CN118885824BActive Publication Date: 2024-12-03CHINA UNIV OF GEOSCIENCES (WUHAN)
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411319651.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-23
Publication Date
2024-12-03
Estimated Expiration
2044-09-23

AI Technical Summary

Technical Problem

The existing vehicle trajectory similarity measurement methods are difficult to effectively model the complex nonlinear relationship between spatial and temporal features when processing trajectory data, resulting in insufficient calculation accuracy.

Method used

Using a method based on spatiotemporal consistency representation, the vehicle trajectory data and road network data are obtained for preprocessing and map matching, data enhancement is performed, road segment features and time features are extracted, and spatiotemporal sequence feature embedding is constructed using Transformer encoder, and comparative learning is performed. The space-time consistency trajectory representation is obtained, and the cosine similarity algorithm is finally used to calculate the trajectory similarity.

Benefits of technology

The accuracy of trajectory similarity calculation is improved, and the complex relationship between learning time and spatial characteristics is expressed through space-time consistency, which improves the accuracy and consistency of trajectory representation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118885824B_ABST
    Figure CN118885824B_ABST
Patent Text Reader

Abstract

The present invention discloses a vehicle trajectory similarity measurement method and system based on time-space consistency representation, which relates to the field of intelligent transportation. The method mainly includes: preprocessing vehicle trajectories and corresponding urban road networks, and performing map matching on trajectories and road networks; performing data enhancement on trajectories using time drift and road replacement methods to obtain time and space enhanced views; extracting spatial features from trajectories using road network features, and extracting periodic time features from trajectories using time coding based on weeks and days; learning the sequence pattern of trajectories using Transformer encoders to obtain time-space sequence feature embedding of trajectories; constructing positive sample pairs and negative sample pairs of time and space enhanced views, and using contrastive learning to obtain time-space consistent trajectory representations; and calculating the cosine similarity of trajectory representations as a measurement indicator of trajectory similarity. Implementing the method and system provided by the present invention can improve the accuracy of trajectory similarity calculation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of intelligent transportation, and more specifically, to a vehicle trajectory similarity measurement method based on spatiotemporal consistency representation and a vehicle trajectory similarity measurement system. Background Art

[0002] With the popularization of GPS devices and the rapid development of autonomous driving technology, a massive amount of vehicle trajectory data has been generated. Vehicle trajectory data records the spatial movement of vehicles over a period of time, which also includes a variety of human travel patterns and can be used for many location-based service applications in urban intelligent computing. Trajectory similarity measurement, as an important part of travel pattern mining, serves many urban trajectory data analysis tasks, such as trajectory clustering, trajectory anomaly detection, travel route recommendation, etc. Therefore, it is very important to design an accurate and efficient trajectory similarity measurement method.

[0003] Existing trajectory similarity calculation methods can be roughly divided into two categories:

[0004] (1) Heuristic methods. Heuristic trajectory similarity metrics are mainly aimed at finding point-level matches between two trajectories based on manually formulated rules. For example, Hausdorff uses the Euclidean distance between points on two trajectories to measure trajectory similarity. However, this type of method has extremely high time complexity for calculating large-scale data, and the calculation results are easily affected by noisy data.

[0005] (2) Deep learning methods. The trajectory similarity measurement method based on deep learning uses the deep learning model to calculate the cosine similarity between trajectory representations to measure whether the trajectories are similar. Earlier deep learning methods generally used the Encoder-Decoder architecture to reconstruct trajectory representations. With the development of related technologies, deep representation learning methods using self-supervised training have been applied to this field. This type of method learns trajectory representations through self-supervised tasks such as contrastive learning and is used for trajectory similarity calculation. However, existing methods only integrate the temporal feature encoding and spatial feature encoding of trajectories, and there are still difficulties in modeling the complex nonlinear relationship between spatial features and temporal features in trajectory data. Summary of the invention

[0006] The purpose of the present invention is to provide a vehicle trajectory similarity measurement method and a vehicle trajectory similarity measurement system based on spatiotemporal consistency representation, which can effectively solve the modeling problem of the complex nonlinear relationship between spatial features and temporal features in trajectory data and improve the accuracy of trajectory similarity calculation.

[0007] The present invention provides a vehicle trajectory similarity measurement method based on spatiotemporal consistency representation, comprising the following steps: S1: obtaining vehicle trajectory data and road network data of a corresponding city, performing preprocessing, and performing map matching on the vehicle trajectory data and the road network data; S2: performing data enhancement on the vehicle trajectory data to obtain a time enhancement view and a space enhancement view; S3: performing feature extraction on a road section contained in the trajectory according to the road network data and the driving time data, obtaining a road section feature, a position code of the road section and a time feature code of the road, and obtaining a final road section spatiotemporal feature code after fusion; S4: obtaining a spatiotemporal sequence feature embedding of the trajectory according to the final spatiotemporal feature code of the road section in the trajectory by using a Transformer encoder; S5: constructing a positive sample pair and a negative sample pair according to the time enhancement view and the space enhancement view, and obtaining a spatiotemporal consistency trajectory representation by using contrastive learning; S6: obtaining trajectory similarity according to the spatiotemporal consistency trajectory representation by using a cosine similarity algorithm.

[0008] Furthermore, step S2 of the above-mentioned vehicle trajectory similarity measurement method based on spatiotemporal consistency representation includes the following steps: S21: using the time drift enhancement method to enhance the vehicle trajectory data to obtain a time enhanced view, such as formula:

[0009]

[0010] in, is the enhanced travel time of the road, is a random sample, and are the current and historical average travel time of the road respectively; S22: using the road replacement enhancement method to enhance the vehicle trajectory data and obtain a spatial enhanced view.

[0011] Furthermore, step S3 of the vehicle trajectory similarity measurement method based on spatiotemporal consistency representation includes the following steps: S31: extracting spatial features of the trajectory according to the road network data to obtain the road segment features and the location coding of the road segment; S32: extracting periodic time features of the trajectory according to the driving time data using the time coding based on the week and the day to obtain the time feature coding of the road; fusing the road segment features, the location coding of the road segment and the time feature coding of the road to obtain the final spatiotemporal feature coding of the road segment, as shown in the formula:

[0012]

[0013] in, For the road The final spatiotemporal feature encoding of the road section, For the road The access timestamp of is the day-based time embedding vector, is the week-based time embedding vector, Represents the characteristics of the road segment. Indicates the location code of the current road segment.

[0014] Furthermore, step S5 of the vehicle trajectory similarity measurement method based on spatiotemporal consistency representation specifically includes: constructing positive sample pairs and negative sample pairs according to the time-enhanced view and the space-enhanced view, using the spatiotemporal sequence feature embedding of the trajectory; constructing a loss function, and using contrastive learning according to the positive sample pairs, the negative sample pairs and the loss function to obtain the spatiotemporal consistency trajectory representation, such as the formula:

[0015]

[0016] Among them, Losscon is the loss function, N is the batch size, sim() is the cosine similarity function, is the temperature parameter, is the time-enhanced view trajectory representation vector of the i-th trajectory data, is the spatial enhanced view trajectory representation vector of the i-th trajectory data, is a positive sample pair, is a negative sample pair.

[0017] The present invention also provides a vehicle trajectory similarity measurement system, comprising the following modules: a data preprocessing module, configured to: obtain vehicle trajectory data and road network data of a corresponding city, perform preprocessing, and perform map matching on the vehicle trajectory data and the road network data; a data enhancement module, configured to: perform data enhancement on the vehicle trajectory data to obtain a time enhancement view and a space enhancement view; a feature extraction module, configured to: perform feature extraction on the road section contained in the trajectory according to the road network data and the driving time data, obtain the road section feature, the position code of the road section and the time feature code of the road, and obtain the final road section spatiotemporal feature code after fusion; a spatiotemporal feature embedding module, configured to: obtain the spatiotemporal sequence feature embedding of the trajectory according to the final spatiotemporal feature code of the road section in the trajectory by using a Transformer encoder; a contrast learning module, configured to: construct positive sample pairs and negative sample pairs according to the time enhancement view and the space enhancement view, and obtain the spatiotemporal consistency trajectory representation by using contrast learning; a similarity calculation module, configured to: obtain the trajectory similarity by using a cosine similarity algorithm according to the spatiotemporal consistency trajectory representation.

[0018] Furthermore, the data enhancement module of the above vehicle trajectory similarity measurement system is specifically configured as follows: the vehicle trajectory data is enhanced using the time drift enhancement method to obtain a time enhanced view, such as the formula:

[0019]

[0020] in, is the enhanced travel time of the road, is a random sample, and are the current and historical average travel time of the road respectively; the vehicle trajectory data is enhanced using the road replacement enhancement method to obtain a spatial enhanced view.

[0021] Furthermore, the feature extraction module of the vehicle trajectory similarity measurement system is specifically configured as follows: according to the road network data, the spatial feature of the trajectory is extracted to obtain the road segment feature and the position coding of the road segment; according to the driving time data, the time coding based on the week and the day is used to extract the periodic time feature of the trajectory to obtain the time feature coding of the road; the road segment feature, the position coding of the road segment and the time feature coding of the road are integrated to obtain the final spatiotemporal feature coding of the road segment, as shown in the formula:

[0022]

[0023] in, For the road The final spatiotemporal feature encoding of the road section, For the road The access timestamp of is the day-based time embedding vector, is the week-based time embedding vector, Represents the characteristics of the road segment. Indicates the location code of the current road segment.

[0024] Furthermore, the contrastive learning module of the vehicle trajectory similarity measurement system is specifically configured as follows: construct positive sample pairs and negative sample pairs based on the temporal enhancement view and the spatial enhancement view, using the temporal and spatial sequence feature embedding of the trajectory; construct a loss function, and use contrastive learning based on the positive sample pairs, the negative sample pairs and the loss function to obtain a temporal and spatial consistency trajectory representation, such as the formula:

[0025]

[0026] Among them, Losscon is the loss function, N is the batch size, sim() is the cosine similarity function, is the temperature parameter, is the time-enhanced view trajectory representation vector of the i-th trajectory data, is the spatial enhanced view trajectory representation vector of the i-th trajectory data, is a positive sample pair, is a negative sample pair.

[0027] Implementing the vehicle trajectory similarity measurement method based on spatiotemporal consistency representation and the vehicle trajectory similarity measurement system provided by the present invention has the following beneficial effects:

[0028] The present invention utilizes trajectory data enhancement methods in two road network scenarios, namely road replacement and time drift, introduces road features and road network topology information, uses road network to constrain trajectory data, converts trajectory data based on sampling point sequence into trajectory data based on road segment representation sequence, realizes spatiotemporal consistency representation learning, and uses two enhanced views of time and space to perform spatiotemporal constraints on the distribution of trajectory representation through spatiotemporal consistency representation learning, thereby learning the complex relationship between temporal and spatial features in the trajectory, incorporating temporal and spatial features into a unified trajectory representation, realizing compensation of spatiotemporal information in trajectory representation, and improving the accuracy of trajectory similarity measurement. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The present invention will be further described below with reference to the accompanying drawings and embodiments, in which:

[0030] Figure 1 It is a flow chart of a vehicle trajectory similarity measurement method based on spatiotemporal consistency representation provided by the present invention;

[0031] Figure 2 It is a schematic diagram of the framework of the algorithm model provided by the present invention;

[0032] Figure 3 is a schematic diagram of the spatial enhancement provided by the present invention;

[0033] Figure 4 is a schematic diagram of time enhancement provided by the present invention;

[0034] Figure 5 The present invention provides a statistical graph of the number of trajectories at different times within a week;

[0035] Figure 6 It is a schematic diagram of representing the spatiotemporal consistency provided by the present invention;

[0036] Figure 7 It is a comparison diagram of the vector space distribution provided by the present invention. DETAILED DESCRIPTION

[0037] In order to have a clearer understanding of the technical features, purposes and effects of the present invention, specific embodiments of the present invention are now described in detail with reference to the accompanying drawings.

[0038] Figure 1 A schematic diagram of the vehicle trajectory similarity measurement method based on spatiotemporal consistency representation of this embodiment is shown. In this embodiment, the vehicle trajectory similarity measurement method based on spatiotemporal consistency representation includes the following steps:

[0039] S1: Obtain vehicle trajectory data and road network data of the corresponding city, perform preprocessing, and perform map matching on the vehicle trajectory data and road network data;

[0040] Specifically, the length of vehicle trajectory data varies, which makes it difficult to represent the learning trajectory. Therefore, the trajectory data with less than 5 sampling points in the vehicle trajectory data are removed. Considering the complex structure of the road network data and the frequency of vehicle travel, the roads with a level below the critical value are removed from the collected road network data of the corresponding city. Considering the widespread noise and uneven sampling points in the vehicle trajectory data, and the spatial distribution of the vehicle trajectory data is usually limited by the road network, a fast map matching (FMM) algorithm combining hidden Markov model and pre-calculation is used for trajectory map matching, which converts the trajectory sequence based on sampling points into the trajectory sequence based on road segments, reduces the noise of the trajectory data, and introduces the topological information of the road network into the trajectory data.

[0041] S2: Perform data enhancement on the vehicle trajectory data to obtain a time enhancement view and a space enhancement view;

[0042] Specifically, step S2 specifically includes: S21: using the time drift enhancement method to enhance the vehicle trajectory data to obtain a time enhanced view, such as the formula:

[0043]

[0044] in, is the enhanced travel time of the road, is a random sample, and are the current and historical average travel time of the road respectively; S22: using the road replacement enhancement method to perform data enhancement on the vehicle trajectory data to obtain a spatial enhancement view;

[0045] Optionally, step S2 specifically includes: using the time drift and road replacement method to enhance the trajectory data, and obtain two enhanced views of time and space. and ,in Figure 3 Schematic diagram of spatial enhancement, T is the anchor trajectory, and the rest are spatial enhancement trajectories. The purpose of data enhancement is to generate enhanced trajectories with the same temporal features as the anchor trajectory but different spatial features; Figure 4 The schematic diagram of time enhancement is that the purpose of data enhancement is to generate an enhanced trajectory with the same spatial features as the anchor trajectory but different temporal features; where T is the anchor trajectory and T' is the time enhanced trajectory; the specific process is as follows: For the time drift enhancement method: given a trajectory, randomly select a subset of the trajectory and perform random perturbations using the following formula, where is a random sample of 0.15~0.30, and are the current and historical average travel times of the road respectively; using this enhancement method helps capture similar trajectories in the time dimension, is the enhanced travel time of the road, and the specific calculation is shown in formula (1):

[0046] (1)

[0047] For the road replacement enhancement method: the trajectory is based on the road segment, so if the commonly used random noise, downsampling and trajectory masking methods are used for enhancement, the continuous semantics and spatial structure of the trajectory will be destroyed. Therefore, a road replacement method is designed to enhance the trajectory under the constraint of the road network; for the trajectory T, the goal is to generate a trajectory with the same starting point and end point as T ( and ), randomly select a road segment contained in the trajectory and select a neighboring road segment within k hops of the road segment in the road network. Then take the shortest path from Go to , and then follow the shortest path from Go to , the trajectory obtained through the above process is the enhanced trajectory, and in this embodiment, k is set to 1 by default;

[0048] S3: Based on the road network data and travel time data, feature extraction is performed on the road sections contained in the trajectory to obtain the road section features, the location code of the road section and the time feature code of the road, and the final spatiotemporal feature code of the road section is obtained after fusion;

[0049] Specifically, step S3 specifically includes: S31: extracting spatial features of the trajectory according to the road network data to obtain the road section features and the location code of the road section; S32: extracting periodic time features of the trajectory according to the driving time data using the time code based on the week and day to obtain the time feature code of the road; fusing the road section features, the location code of the road section and the time feature code of the road to obtain the final road section spatiotemporal feature code, as shown in the formula:

[0050]

[0051] in, For the road The final spatiotemporal feature encoding of the road section, For the road The access timestamp of is the day-based time embedding vector, is the week-based time embedding vector, Represents the characteristics of the road segment. Indicates the location code of the current road segment;

[0052] Optionally, step S3 specifically includes: using road network features to extract spatial features of the trajectory, and using time encoding based on weeks and days to extract periodic time features of the trajectory; this embodiment uses a graph attention network (GAT) to extract the relationship between roads, because it can dynamically assign weights to neighboring nodes by calculating the attention weights between node pairs; mainly consider three features in road network data, namely road type, road length, in-degree and out-degree. Use the attention weights to combine its neighborhood features to obtain the road The output feature representation , that is, the road segment characteristics, which include the characteristics of the current road and the characteristics of the adjacent roads; Figure 5 After counting the number of trajectories at different times within a week, it is found that the distribution of trajectories within a day and a week shows obvious periodic characteristics. Based on this finding, the embodiment of the present invention uses two time embedding vectors to extract the periodicity of the week and the day respectively. For the road Timestamp of each access , using the embedding vector and To embed two periodic patterns, and Yes Functions to convert to minute embeddings (of dimension 1440) and day-of-week embeddings (of dimension 7); then paths are obtained by summing over several representations Fusion embedding ; As shown in formula (2), Represents the characteristics of the road segment. Indicates the location code of the current road segment:

[0053] (2)

[0054] S4: According to the final spatiotemporal feature encoding of the road section in the trajectory, the spatiotemporal sequence feature embedding of the trajectory is obtained using the Transformer encoder;

[0055] Specifically, step S4 includes: using a Transformer encoder to learn the sequence pattern of the trajectory to obtain a trajectory representation, that is, embedding the spatiotemporal sequence features of the trajectory; in order to extract the sequence relationship between roads in the trajectory and capture the context information containing the road trajectory, a 6-layer Transformer encoder is used to encode the trajectory to achieve full interaction between roads; as described in formula (3), each road segment encoding obtained in step S3 is concatenated into X, that is, a trajectory vector; the trajectory X is sent to the Transformer encoder, and the attention head described in formula (4) transforms the trajectory vector X into a query matrix , key matrix Sum Matrix ,in , , are all learnable parameter matrices; X is then connected to the output of the H attention head and passed Projection is performed to obtain the output X′, and the specific calculation is described in formula (5); layer normalization and residual connection operations are used after Transformer; finally, referring to formula (6), a feed-forward network (FFN) composed of two layers of linear transformation and a ReLU activation function are used to obtain the spatiotemporal sequence feature embedding Z (a feature vector with a dimension of 256) of the trajectory T, where , , , All are learnable parameters:

[0056] (3)

[0057] (4)

[0058] (5)

[0059] (6)

[0060] S5: Based on the temporal and spatial enhancement views, the spatiotemporal sequence feature embedding of the trajectory is used to construct positive and negative sample pairs, and contrastive learning is used to obtain spatiotemporal consistent trajectory representation;

[0061] Specifically, step S5 includes: constructing positive sample pairs and negative sample pairs according to the time-enhanced view and the space-enhanced view by embedding the spatiotemporal sequence features of the trajectory; constructing a loss function, and obtaining a spatiotemporal consistent trajectory representation by contrastive learning according to the positive sample pairs, the negative sample pairs and the loss function, as shown in the formula:

[0062]

[0063] Among them, Losscon is the loss function, N is the batch size, sim() is the cosine similarity function, is the temperature parameter, is the time-enhanced view trajectory representation vector of the i-th trajectory data, is the spatial enhanced view trajectory representation vector of the i-th trajectory data, is a positive sample pair, is a negative sample pair;

[0064] Specifically, step S5 may also include: constructing positive sample pairs and negative sample pairs of temporal and spatial enhanced views, and using contrastive learning to obtain the temporal and spatial consistency trajectory representation for trajectory similarity measurement; referring to Figure 6 After the above encoding process, the trajectory representation is presented. In order to learn the complex relationship between the temporal features and the spatial features in the trajectory data, this embodiment proposes a temporal and spatial consistency representation learning method, which adopts a contrastive learning method and uses two enhanced views of time and space. and Constrained trajectory representation optimizes the spatiotemporal distribution of trajectory representation, thereby improving the calculation accuracy of trajectory similarity measurement; in the contrastive learning method, the depth representation pairs under different views of the same trajectory are regarded as positive sample pairs, while other samples under the same batch are regarded as negative samples; the optimization goal is to make the temporal enhancement view and spatial enhancement view of the same trajectory sample as consistent as possible in the vector representation space, while as far away from other negative samples in the same batch as possible. The specific loss function is shown in formula (7), where N is the batch size, the sim() function is the cosine similarity function, is the temperature parameter, is the time-enhanced view trajectory representation vector of the i-th trajectory data, is the spatial enhanced view trajectory representation vector of the i-th trajectory data, is a positive sample pair, For negative sample pairs:

[0065] (7)

[0066] S6: According to the spatiotemporal consistency trajectory representation, the trajectory similarity is obtained using the cosine similarity algorithm;

[0067] Specifically, step S6 includes: calculating the cosine similarity of the trajectory representation as a measurement indicator of trajectory similarity; in the embodiment, considering that the traditional trajectory similarity measurement method cannot be directly used for the similarity calculation of trajectory representation, the cosine similarity of the trajectory representation is used as the final measurement indicator of trajectory similarity, and can be used for similarity calculation tasks such as the most similar trajectory query and the k-nearest trajectory query.

[0068] refer to Figure 7,This figure shows the vector space distribution of the spatiotemporal consistency representation processed by step S5 and the trajectory representation without step S5 processing. The dark gray is the trajectory representation distribution before optimization, and the light gray is the trajectory representation distribution after optimization. After optimization, the distribution of similar trajectory representations is more compact, making the subsequent trajectory spatiotemporal similarity calculation more accurate.

[0069] The computational model of this embodiment is implemented based on pytorch. Figure 7 The results in the experiment were run on a 32-core Intel Xeon CPU, two 16G NVIDIA Tesla T4s, an Ubuntu 22.04.3 LTS operating system, 30 training epochs, and a learning rate of 0.0002. The dataset used contains 1,372,725 trajectories and 38,479 road segments.

[0070] This embodiment provides a vehicle trajectory similarity measurement system, including the following modules:

[0071] The data preprocessing module is configured to: obtain vehicle trajectory data and road network data of the corresponding city, perform preprocessing, and map match the vehicle trajectory data and the road network data;

[0072] A data enhancement module is configured to: perform data enhancement on the vehicle trajectory data to obtain a time enhancement view and a space enhancement view;

[0073] Specifically, the data enhancement module of the above vehicle trajectory similarity measurement system is specifically configured as follows: the vehicle trajectory data is enhanced using the time drift enhancement method to obtain a time enhancement view, such as the formula:

[0074]

[0075] in, is the enhanced travel time of the road, is a random sample, and are the current and historical average travel time of the road respectively; the vehicle trajectory data is enhanced by using the road replacement enhancement method to obtain a spatial enhanced view;

[0076] The feature extraction module is configured to: extract features of the road sections contained in the trajectory according to the road network data and the travel time data, obtain the road section features, the location code of the road section and the time feature code of the road, and obtain the final spatiotemporal feature code of the road section after fusion;

[0077] Specifically, the feature extraction module of the vehicle trajectory similarity measurement system is specifically configured as follows: according to the road network data, the spatial feature of the trajectory is extracted to obtain the road segment feature and the position coding of the road segment; according to the driving time data, the time coding based on the week and the day is used to extract the periodic time feature of the trajectory to obtain the time feature coding of the road; the road segment feature, the position coding of the road segment and the time feature coding of the road are integrated to obtain the final spatiotemporal feature coding of the road segment, as shown in the formula:

[0078]

[0079] in, For the road The final spatiotemporal feature encoding of the road section, For the road The access timestamp of is the day-based time embedding vector, is the week-based time embedding vector, Represents the characteristics of the road segment. Indicates the location code of the current road segment;

[0080] The spatiotemporal feature embedding module is configured as follows: according to the final spatiotemporal feature encoding of the road section in the trajectory, the spatiotemporal sequence feature embedding of the trajectory is obtained using the Transformer encoder;

[0081] The contrastive learning module is configured as follows: based on the temporal enhancement view and the spatial enhancement view, the spatiotemporal sequence feature embedding of the trajectory is used to construct positive sample pairs and negative sample pairs, and contrastive learning is used to obtain the spatiotemporal consistent trajectory representation;

[0082] Specifically, the contrastive learning module of the vehicle trajectory similarity measurement system is specifically configured as follows: construct positive sample pairs and negative sample pairs according to the time-enhanced view and the space-enhanced view, and embed the spatiotemporal sequence features of the trajectory; construct a loss function, and use contrastive learning to obtain a spatiotemporal consistency trajectory representation according to the positive sample pairs, the negative sample pairs and the loss function, as shown in the formula, as shown in the formula:

[0083]

[0084] Among them, Losscon is the loss function, N is the batch size, sim() is the cosine similarity function, is the temperature parameter, is the time-enhanced view trajectory representation vector of the i-th trajectory data, is the spatial enhanced view trajectory representation vector of the i-th trajectory data, is a positive sample pair, is a negative sample pair;

[0085] The similarity calculation module is configured to obtain trajectory similarity using a cosine similarity algorithm based on the spatiotemporal consistency trajectory representation.

[0086] The embodiments of the present invention are described above in conjunction with the accompanying drawings, but the present invention is not limited to the above-mentioned specific implementation modes, which are merely illustrative rather than restrictive. Under the guidance of the present invention, ordinary technicians in this field can also make many forms without departing from the scope of protection of the present invention and the claims, all of which are within the protection of the present invention.

Claims

1. A vehicle trajectory similarity measurement method based on spatiotemporal consistency representation, characterized in that: The following steps are involved: S1: Obtain vehicle trajectory data and road network data of the corresponding city, perform preprocessing, and perform map matching on the vehicle trajectory data and road network data; S2: performing data enhancement on the vehicle trajectory data to obtain a time enhancement view and a space enhancement view; S3: extracting features of the road sections included in the trajectory according to the road network data and the travel time data, obtaining the road section features, the location codes of the road sections and the time feature codes of the roads, and fusing them to obtain the final spatiotemporal feature codes of the road sections; S4: according to the final spatiotemporal feature encoding of the road section in the trajectory, using a Transformer encoder to obtain spatiotemporal sequence feature embedding of the trajectory; S5: constructing positive sample pairs and negative sample pairs according to the temporal enhancement view and the spatial enhancement view, using the spatiotemporal sequence feature embedding of the trajectory, and obtaining a spatiotemporal consistent trajectory representation by contrastive learning; S6: According to the spatiotemporal consistency trajectory representation, a cosine similarity algorithm is used to obtain trajectory similarity.

2. The vehicle trajectory similarity measurement method based on spatiotemporal consistency representation according to claim 1 is characterized in that: Step S2 includes the following steps: S21: Use the time drift enhancement method to enhance the vehicle trajectory data and obtain a time enhanced view, as shown in the formula: , in, is the enhanced travel time of the road, is a random sample, and are the current and historical average travel times for the road, respectively; S22: Use the road replacement enhancement method to enhance the vehicle trajectory data and obtain a spatial enhanced view.

3. The vehicle trajectory similarity measurement method based on spatiotemporal consistency representation according to claim 1 is characterized in that: Step S3 includes the following steps: S31: Extracting spatial features of the trajectory according to the road network data to obtain road section features and location codes of the road sections; S32: According to the driving time data, the trajectory is subjected to periodic time feature extraction using the time coding based on the week and the day to obtain the time feature coding of the road; the road section feature, the position coding of the road section and the time feature coding of the road are integrated to obtain the final spatiotemporal feature coding of the road section, as shown in the formula: , in, For the road The final spatiotemporal feature encoding of the road section, For the road The access timestamp of is the day-based time embedding vector, is the week-based time embedding vector, Represents the characteristics of the road segment. Indicates the location code of the current road segment.

4. The vehicle trajectory similarity measurement method based on spatiotemporal consistency representation according to claim 1 is characterized in that: Step S5 specifically includes: constructing positive sample pairs and negative sample pairs according to the temporal enhanced view and the spatial enhanced view, using the spatiotemporal sequence feature embedding of the trajectory; constructing a loss function, and using contrastive learning according to the positive sample pairs, the negative sample pairs and the loss function to obtain a spatiotemporal consistent trajectory representation, such as the formula: , Among them, Losscon is the loss function, N is the batch size, sim() is the cosine similarity function, is the temperature parameter, is the time-enhanced view trajectory representation vector of the i-th trajectory data, is the spatial enhanced view trajectory representation vector of the i-th trajectory data, is a positive sample pair, is a negative sample pair.

5. A vehicle trajectory similarity measurement system, characterized in that: The vehicle trajectory similarity measurement system includes the following modules: The data preprocessing module is configured to: obtain vehicle trajectory data and road network data of the corresponding city, perform preprocessing, and map match the vehicle trajectory data and the road network data; A data enhancement module is configured to: perform data enhancement on the vehicle trajectory data to obtain a time enhancement view and a space enhancement view; The feature extraction module is configured to: extract features of the road sections included in the trajectory according to the road network data and the travel time data, obtain the road section features, the position code of the road section and the time feature code of the road, and obtain the final spatiotemporal feature code of the road section after fusion; The spatiotemporal feature embedding module is configured to: obtain the spatiotemporal sequence feature embedding of the trajectory using a Transformer encoder according to the final spatiotemporal feature encoding of the road section in the trajectory; A contrastive learning module is configured to: construct positive sample pairs and negative sample pairs according to the temporal enhancement view and the spatial enhancement view, and use contrastive learning to obtain a temporal and spatial consistency trajectory representation; The similarity calculation module is configured to obtain trajectory similarity using a cosine similarity algorithm according to the spatiotemporal consistency trajectory representation.

6. The vehicle trajectory similarity measurement system according to claim 5, characterized in that: The data enhancement module is specifically configured as follows: The vehicle trajectory data is enhanced using the time drift enhancement method to obtain a time enhanced view, as shown in the formula: , Among them, taug is the enhanced travel time of the road, is a random sample, and are the current and historical average travel times for the road, respectively; The vehicle trajectory data is enhanced using the road replacement enhancement method to obtain a spatially enhanced view.

7. The vehicle trajectory similarity measurement system according to claim 5, characterized in that: The feature extraction module is specifically configured as follows: Extracting spatial features of trajectories according to the road network data to obtain road section features and location codes of the road sections; According to the driving time data, the time coding based on week and day is used to extract the periodic time features of the trajectory and obtain the time feature coding of the road; The road section features, the location code of the road section and the time feature code of the road are integrated to obtain the final spatiotemporal feature code of the road section, as shown in the formula: , in, For the road The final spatiotemporal feature encoding of the road section, For the road The access timestamp of is the day-based time embedding vector, is the week-based time embedding vector, Represents the characteristics of the road segment. Indicates the location code of the current road segment.

8. The vehicle trajectory similarity measurement system according to claim 5, characterized in that: The contrastive learning module is specifically configured as follows: constructing positive sample pairs and negative sample pairs according to the temporal enhancement view and the spatial enhancement view, using the spatiotemporal sequence feature embedding of the trajectory; constructing a loss function, and using contrastive learning according to the positive sample pairs, the negative sample pairs and the loss function to obtain a spatiotemporal consistency trajectory representation, such as the formula: , Among them, Losscon is the loss function, N is the batch size, sim() is the cosine similarity function, is the temperature parameter, is the time-enhanced view trajectory representation vector of the i-th trajectory data, is the spatial enhanced view trajectory representation vector of the i-th trajectory data, is a positive sample pair, is a negative sample pair.