A vehicle spatio-temporal trajectory similarity calculation method and device based on semantic information

By constructing a POI-based spatiotemporal relationship graph and an enhanced time-representation T-LSTM model, the problem of semantic information being ignored in existing trajectory similarity calculations is solved, achieving more efficient and accurate trajectory similarity calculations that are adaptable to complex traffic scenarios.

CN120123787BActive Publication Date: 2025-12-05XIANGJIANG LAB
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202510619442.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-05-14
Publication Date
2025-12-05
Estimated Expiration
2045-05-14

AI Technical Summary

Technical Problem

Existing trajectory similarity calculation methods ignore semantic information when considering vehicle spatiotemporal trajectories, resulting in cumbersome calculation processes and poor generalization ability, making them difficult to adapt to complex traffic scenarios.

Method used

By constructing a spatiotemporal relationship graph based on POIs, a trajectory-aware spatiotemporal integrated random walk strategy and GAT algorithm are used to learn node representations. Combined with a T-LSTM model that enhances temporal representation, a two-level contrastive loss function is designed using a cosine similarity function and a pairwise sampling method. The trajectory similarity is calculated by fusing temporal, spatial and semantic information.

Benefits of technology

It improves the accuracy and efficiency of trajectory similarity calculation, enhances the model's adaptability to complex traffic scenarios and its ability to capture semantic information, and improves the expressive power of trajectory representation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120123787B_ABST
    Figure CN120123787B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of intelligent transportation, and discloses a vehicle space-time trajectory similarity calculation method and equipment based on semantic information, time-space trajectory data is obtained, the time-space trajectory data is divided at an interval of 1 hour, a Voronoi diagram is constructed to generate a Thiessen polygon; multi-dimensional feature extraction is carried out on the Thiessen polygon area containing the trajectory to obtain the spatial feature, the time feature and the POI semantic feature of the area; a space-time relation graph is constructed, a space-time integrated random walk strategy with trajectory perception and a GAT algorithm are sequentially used to learn a high-quality representation of a node; a model T-LSTM with enhanced time expression capability is constructed to learn the final representation of a trajectory sequence; the similarity between nodes and the similarity between trajectories are measured, and a graph-based double-level contrast loss function is designed to train the model; the application helps to improve the capturing capability of trajectory representation on functional semantic information.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of intelligent transportation, in particular to a vehicle space-time trajectory similarity calculation method based on semantic information. BACKGROUND

[0002] With the acceleration of urbanization and the booming development of intelligent transportation systems, the in-depth analysis and effective utilization of vehicle trajectory data in the field of intelligent transportation become increasingly important. Vehicle space-time trajectory data contains rich information, and accurate calculation of its similarity can play a key role in traffic flow prediction, travel mode analysis, intelligent path planning, and traffic accident warning, thereby greatly improving the management efficiency and operation quality of urban transportation.

[0003] Existing trajectory similarity calculation methods mainly have two categories:

[0004] 1. Heuristic measurement method:

[0005] The heuristic measurement method is usually based on the intuitive geometry of the trajectory, using the basic attributes of the trajectory such as the position, order, distance, etc. of the points, to calculate the similarity between trajectories by predefining similarity calculation rules or heuristic algorithms. For example, dynamic time warping (DTW) is used to find the optimal matching path by stretching or compressing the time dimension of the trajectory on the time axis, thereby calculating the similarity. This method usually does not require a large amount of training data, and the calculation process is relatively simple, but it is sensitive to noise, sampling rate differences, and has high computational complexity, and its adaptability to some complex scenarios is also very limited.

[0006] 2. Learning measurement method:

[0007] The basic idea is to map the trajectory data into a low-dimensional vector space using deep learning technology, so that similar trajectories have similar representations in the vector space, and then use vector similarity to represent trajectory similarity. This method can automatically learn the complex features and patterns of trajectories, and has good adaptability and generalization ability to different types of trajectories. However, traditional learning measurement methods have significant defects. On the one hand, most existing methods only consider the spatial features of the trajectory, ignoring the temporal characteristics and hidden semantic information contained in the trajectory. The driving trajectory of a vehicle does not exist in isolation, and the positions it passes through at different time points are often closely related to the surrounding functional areas such as shopping malls, schools, hospitals, etc. The semantic information carried by these functional areas is of great significance to the calculation of vehicle trajectory similarity. On the other hand, existing vehicle trajectory similarity calculation models involving space-time analysis need to set parameters separately for time and space, which not only leads to a very cumbersome calculation process, but also has poor generalization ability, making it difficult to adapt to complex and variable actual traffic scenarios. SUMMARY

[0008] The application aims to solve the above problems, and provides a vehicle spatio-temporal trajectory similarity calculation method based on semantic information, which effectively solves the problems of insufficient generalization and insufficient data utilization of current trajectory similarity calculation models by comprehensively fusing multi-dimensional information, and improves the accuracy of trajectory similarity calculation.

[0009] The application provides a vehicle spatio-temporal trajectory similarity calculation method based on semantic information, comprising the following steps:

[0010] S1, preprocessing vehicle trajectory data to obtain spatio-temporal trajectory data, constructing a similarity matrix, dividing the spatio-temporal trajectory data at an interval of 1 hour, and constructing a Voronoi diagram according to POI data to generate a Thiessen polygon;

[0011] S2, according to the spatio-temporal trajectory data and the POI data, performing multi-dimensional feature extraction on the POI Thiessen polygon region containing the trajectory to obtain the spatial feature, the time feature and the POI semantic feature of the region;

[0012] S3, constructing a POI-based spatio-temporal relationship graph in the divided time interval, and sequentially adopting a spatio-temporal integrated random walk strategy with trajectory perception and a GAT algorithm to learn a high-quality representation of a node;

[0013] S4, constructing a model T-LSTM with enhanced time expression capability according to the spatio-temporal trajectory data and the learned node representation to learn the final representation of a trajectory sequence;

[0014] S5, using a cosine similarity function to measure the similarity between nodes and trajectories, and using a pair sampling method to design a graph-based double-level contrast loss function to train the model.

[0015] Optionally, in the first implementation manner of the application, the preprocessing of the vehicle trajectory data to obtain the spatio-temporal trajectory data and the construction of the similarity matrix for dividing the spatio-temporal trajectory data at an interval of 1 hour while constructing a Voronoi diagram according to POI data to generate a Thiessen polygon comprises:

[0016] Obtaining vehicle trajectory data, preprocessing the vehicle trajectory data to remove abnormal trajectory points and short trajectories, wherein the short trajectories are less than 5 trajectory points;

[0017] Constructing a similarity matrix for the preprocessed vehicle trajectory data by using a longest common subsequence algorithm of a trajectory similarity calculation method;

[0018] The preprocessed spatio-temporal trajectory data is divided into intervals of 1 hour, and the data set constructed by the preprocessed spatio-temporal trajectory data is divided into a series of sub data sets;

[0019] Based on the position information of the POI points, a series of Voronoi polygons are generated by using a Voronoi diagram, the Voronoi polygons are defined as functional areas served by the corresponding POI points, and the trajectory points in the sub data set are mapped into the Voronoi polygons.

[0020] Optionally, in the second implementation manner of the present application, the multi-dimensional feature extraction is performed on the POI Voronoi polygon area containing the trajectory according to the spatio-temporal trajectory data and the POI data, to obtain the spatial feature, the time feature and the POI semantic feature of the area, including:

[0021] The latitude and longitude of the POI are normalized by using a min-max normalization function, a multi-layer perceptron is used for nonlinear transformation, the GPS coordinates recorded by the POI data are used as the position information of the area, and the spatial feature of the area is obtained;

[0022] The original time stamp of the trajectory sequence is transformed into a sine and cosine feature representation, and a min-max normalization function is used for normalization processing, so that the one-dimensional linear representation of time is changed into a two-dimensional periodic feature, and the time feature is obtained;

[0023] The semantic information of the POI is extracted by time frequency and text mining, and the POI semantic feature is obtained.

[0024] Optionally, in the third implementation manner of the present application, the semantic information of the POI is extracted by time frequency and text mining, and the POI semantic feature is obtained, including:

[0025] 1 hour is taken as a division unit, 1 day is divided into 24 time intervals, the spatio-temporal trajectory data is traversed, for each POI point appearing in the trajectory, the number of appearances in the corresponding time interval is counted, 24-dimensional time features of each POI point are obtained, and normalization processing is performed, the value of each dimension is replaced by the percentage of the appearance frequency in the whole day, so that the sum of the values of the dimensions is 1, and the time attribute of the POI is obtained, wherein the time attribute is the access heat distribution of the POI in different time intervals in 1 day.

[0026] Optionally, in the fourth implementation manner of the present application, the semantic information of the POI is extracted by time frequency and text mining, and the POI semantic feature is obtained, and further including:

[0027] A TF-IDF algorithm is used for text mining, each POI point type is regarded as a word, and the POI sequence passed through by each trajectory sequence can be regarded as a document, and each trajectory can be expressed as a word sequence.

[0028] For each trajectory, the term frequency and inverse document frequency of each POI point type are calculated, the term frequency and inverse document frequency are multiplied to obtain the TF-IDF value of each POI point type in each trajectory as the text attribute of the POI;

[0029] The TF-IDF values of all POI point types are spliced as additional dimensions with the time attribute to obtain the POI semantic feature.

[0030] Optionally, in the fifth implementation manner of the present application, the POI-based spatio-temporal relationship graph is constructed in the divided time interval, and a high-quality representation of a node is learned by sequentially adopting a spatio-temporal integrated random walk strategy with trajectory awareness and a GAT algorithm, including:

[0031] A POI-based spatio-temporal relationship graph is constructed in the divided time interval according to the spatial feature, the time feature and the POI semantic feature of the region;

[0032] An initial representation of a vertex in the spatio-temporal relationship graph is learned by adopting a spatio-temporal integrated random walk strategy with trajectory awareness, and in the sequence sampling stage, a walk is performed in the spatio-temporal relationship graph according to the time of a trajectory sequence sampling point to obtain an initial vector of a node that can simultaneously capture time and spatial features;

[0033] The initial representation of the vertex is obtained, and the GAT algorithm is adopted to capture the neighbor node features of a trajectory for the spatio-temporal network in each time interval.

[0034] Optionally, in the sixth implementation manner of the present application, a model T-LSTM with enhanced time expression capability is constructed according to the spatio-temporal trajectory data and the learned node representation to learn the final representation of a trajectory sequence, including:

[0035] According to the spatio-temporal trajectory data and the learned node representation, an initial vector sequence of a trajectory is obtained, and time features are converted into sine and cosine features as the input of an attention layer;

[0036] Q, K and V vectors are generated through matrix multiplication, attention scores are calculated through scaled dot-product attention, and weighted summation is performed according to the attention scores to obtain a weighted feature representation;

[0037] The node high-quality representation and the time features with the attention mechanism are taken as the input of an LSTM layer, and a final input feature is obtained through a multi-layer perception.

[0038] A model T-LSTM with enhanced time expression capability is constructed by combining time attention and the LSTM layer, and the output of the last time step of the T-LSTM is used as the trajectory embedding.

[0039] Optionally, in the seventh implementation manner of the present application, the graph-based double-level contrast loss function comprises a node-level semantic loss function and a trajectory-level contrast loss function, wherein the node-level semantic loss function is used to strengthen the learning of semantic information of the trajectory representation, and the trajectory-level contrast loss function is used to optimize the overall similarity of trajectories.

[0040] Optionally, in the eighth implementation manner of the present application, the node-level semantic loss function comprises:

[0041] Given a node and , after obtaining the node representation through step S3, the corresponding embedding vectors are and , and a cosine similarity function is used as a function of measuring similarity:

[0042] ;

[0043] The positive and negative sampling strategy of the nodes passed through by the trajectory is used to calculate the point similarity loss, and a contrast loss is used as the node-level semantic loss function.

[0044] Optionally, in the ninth implementation manner of the present application, the trajectory-level contrast loss function comprises:

[0045] In step S1, the similarity matrix is obtained as the real ground distance of the trajectory, the most similar trajectory of the trajectory in the similarity matrix is extracted as the positive sample, the remaining trajectories are negative samples, and the model learning core is to learn a mapping function to encode the trajectory sequence into a representation vector;

[0046] Given any two trajectories passing through the model learning to obtain the representation vectors, a cosine similarity function is used as a function of measuring similarity, the goal is to maximize the cosine similarity between the given trajectory and the most similar trajectory, and minimize the cosine similarity between the given trajectory and the negative sample, and a contrast loss is used as the trajectory-level contrast loss function.

[0047] Compared with the prior art, the present application has the following advantages:

[0048] (1) The present application deeply mines the dimension features, divides the trajectory data according to the time interval, and constructs the space-time structure of the trajectory based on the semantic information of the trajectory in the time interval, realizes the consideration of the temporality, spatiality and semantic information of the trajectory data at the same time, and improves the expression ability of the trajectory representation;

[0049] (2) In view of the problem of weakening time characteristics of the existing model, the application constructs a deep network model T-LSTM based on time attention, the model allocates weights to different time importance by introducing an attention mechanism, the model can better capture the dynamic change rule of the trajectory at different time stages, and provides stronger time dimension support for trajectory similarity calculation;

[0050] (3) In order to further improve the expression ability of the trajectory representation to the functional semantic information, the application designs a double-level contrast loss function based on a graph to guide the training of the model, wherein the loss function at the node level strengthens the expression ability of the trajectory representation to the POI semantic information by calculating the node similarity; the loss function at the trajectory level is used to strengthen the global representation ability of the trajectory sequence representation. Compared with the traditional single loss function, the double-level contrast loss function of the application can simultaneously consider the similarity loss of the semantic node and the trajectory sequence, which is helpful to improve the capturing ability of the trajectory representation to the functional semantic information, so that the model is more targeted when identifying and understanding the trajectory data. BRIEF DESCRIPTION OF DRAWINGS

[0051] Various other advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The accompanying drawings are included only to illustrate preferred embodiments of the application and are not to be considered as limiting of the application.

[0052] Figure 1 is a flowchart of a vehicle spatio-temporal trajectory similarity calculation method based on semantic information proposed by the application;

[0053] Figure 2 is a schematic diagram of a spatio-temporal relationship graph constructed according to the spatio-temporal semantic association of the trajectory proposed by the application;

[0054] Figure 3 is a schematic diagram of a spatio-temporal integrated random walk strategy PTS-walk with trajectory perception proposed by the application;

[0055] Figure 4 is a schematic diagram of a model T-LSTM for enhancing time expression ability proposed by the application. DETAILED DESCRIPTION

[0056] In order to make the purpose, technical scheme and advantages of the application clearer, the application will be further described in detail below in combination with the drawings and examples. It should be understood that the specific examples described herein are only used to explain the application, and are not used to limit the application, that is, the described examples are only a part of the examples of the application, but not all the examples. The components of the embodiments of the application described and shown in the drawings herein can be arranged and designed in various different configurations.

[0057] Therefore, the following detailed description of the embodiments of the application provided in the accompanying drawings is not intended to limit the scope of the application claimed, but merely represents selected embodiments of the application. Based on the embodiments of the application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of the application.

[0058] The specific embodiments of the application are described below in conjunction with the accompanying drawings, a vehicle spatio-temporal trajectory similarity calculation method based on semantic information. The application aims to realize the consideration of the temporality, spatiality and semantic information of trajectory data by dividing the trajectory data according to time and constructing the spatial structure of the trajectory based on the semantic information of the trajectory in the time interval, and then converting the trajectory data into a representation containing high-quality information by using deep learning technology, effectively solving the problems of insufficient generalization and insufficient data utilization of the current trajectory similarity calculation model, and improving the efficiency and accuracy of trajectory similarity calculation.

[0059] In order to achieve the above-mentioned purpose, the application provides a vehicle spatio-temporal trajectory similarity calculation method based on semantic information, the overall process of which is as follows Figure 1 , specifically comprising the following steps:

[0060] S1, pre-processing vehicle trajectory data to obtain spatio-temporal trajectory data, constructing a similarity matrix, dividing the spatio-temporal trajectory data at an interval of 1 hour, and constructing a Voronoi diagram to generate a Thiessen polygon according to POI data;

[0061] In this embodiment, the vehicle spatio-temporal trajectory data is pre-processed, effective trajectory data is selected and retained, the spatio-temporal trajectory data is divided at an interval of 1 hour, and a Voronoi diagram is constructed using points of interest (POI) data to generate a Thiessen polygon. The Thiessen polygon is defined as the service area of the corresponding POI point, serving as the carrier of the functional semantic information of the vehicle trajectory, and the trajectory points are mapped in the divided Thiessen polygon range.

[0062] In this embodiment, for a trajectory set , wherein , represents the longitude and latitude of the trajectory point, represents the time, represents the total number of trajectories, This represents the trajectory length. The data preprocessing refers to removing abnormal trajectory points and short trajectories (less than 5 trajectory points) caused by sampling rate and other factors, and constructing a distance matrix D for the retained effective data using the Longest Common Subsequence (LCSS) algorithm, a traditional trajectory similarity calculation method. Based on the distance matrix D, the distance between trajectories is normalized to obtain a similarity matrix S, which is used for subsequent supervised training of the model.

[0063] It should be noted that the LCSS method is a commonly used algorithm for calculating the similarity between sequences. It measures sequence similarity by finding ordered, discontinuously similar subsequences from two sequences. For example, for the sequences "ABCD" and "ACBD", their longest common subsequence is "ACD", and the LCSS value is 3. This method has wide applications in fields such as trajectory similarity calculation. This invention uses the LCSS method, which considers temporal similarity, to construct a similarity matrix D, primarily to provide the ground truth distance between the trajectories for subsequent model training. Assuming two trajectories are given: a target trajectory and a candidate trajectory, the similarity between the trajectories is determined by setting time and distance thresholds. The calculation formula is as follows:

[0064] ;

[0065] in, It is a trajectory and The longest common subsequence value, Representing the trajectory After removing the first trajectory point, the remaining sequence of trajectory points is... Representing the trajectory and The The distance between trajectory points Representing the trajectory and The The time difference between each trajectory point is used to obtain the distance matrix D, which, after normalization, yields the similarity matrix S.

[0066] Next, the spatiotemporal trajectory data is divided into a series of subsets, each defined as a one-hour interval. Therefore, the entire trajectory data representation problem is transformed into a series of subset representation problems within different time intervals. It should be noted that this invention only performs time-based segmentation of trajectory points; all Points of Interest (POIs) exist in the spatiotemporal graph of each time interval.

[0067] The use of POI data to construct a Voronoi diagram to obtain a Thiessen polygon refers to mapping POI data to trajectory data and performing geometric processing to give trajectory data semantic meaning. Specifically, first, the POI points are regarded as discrete points, and a triangular mesh is constructed by the Delaunay triangulation method. Subsequently, based on the position information of these discrete points, a Voronoi diagram is generated and Thiessen polygons are divided, which are regarded as the approximate area of the POI service range. For the above sub-data set, the trajectory points are mapped into these Thiessen polygons. This process not only effectively handles the noise point problem existing in the trajectory data, but also gives the trajectory data POI semantic information, providing a richer semantic basis for subsequent trajectory analysis and similarity calculation.

[0068] S2, according to the spatio-temporal trajectory data and POI data, multi-dimensional feature extraction is performed on the POI Thiessen polygon region containing the trajectory to obtain the spatial feature, time feature and POI semantic feature of the region.

[0069] In this embodiment, according to the spatio-temporal trajectory data and POI data, multi-dimensional feature extraction is performed on the POI Thiessen polygon region containing the trajectory to obtain the spatial feature, time feature and POI semantic feature of the region.

[0070] In this embodiment, the above divided polygon is taken as a POI region, and a region feature is constructed therefor, and the specific steps are as follows:

[0071] Spatial feature : Record the position information of the region, which is obtained by normalizing the latitude and longitude of the POI, and directly use the GPS coordinates recorded by the POI data as the position information of the region. First, use the min-max normalization function to normalize it, and use the multi-layer perceptron (MLP) for nonlinear transformation. The spatial feature is represented as follows:

[0072] ;

[0073] wherein, represents the dimension of the POI point, represents the longitude of the POI point;

[0074] Time feature : Record the time information of the region, first convert the original data time representation such as '08:00' to the corresponding minute '480' from 0 point in a day, then in order to reflect the periodicity of time, change the one-dimensional linear representation of time to two-dimensional periodic feature, need to transform the trajectory sequence original time stamp to sine and cosine feature representation, also use the min-max normalization function to normalize it, the conversion process is as follows:

[0075] ;

[0076] ;

[0077] ;

[0078] wherein 1440 refers to a time period of one day being 1440 minutes, is a min-max normalization function, a sine feature representation, is a cosine feature representation.

[0079] semantic feature : semantic information of the recording area, in order to better use the semantic information of the POI data in the area, the application extracts the semantic information of the POI from two aspects of time frequency and text mining, as follows:

[0080] 1. Time frequency: first, divide one day into 24 time intervals with 1 hour as the division unit. Then, traverse the trajectory data set, and for the time at which each POI point appears in the trajectory, count the number of occurrences of the POI point in the corresponding time interval to obtain a 24-dimensional time feature of each POI point, and then normalize it, replacing the value of each dimension with the percentage of the occurrence frequency in the time interval to the total occurrence frequency in one day, ensuring that the sum of the values of all dimensions is 1, to obtain This vector can intuitively reflect the access heat distribution of the POI in different time intervals in one day, providing important time semantic information for trajectory analysis;

[0081] 2. Text mining: the TF-IDF algorithm is used to further mine the information of the POI, regarding each POI point type as a "word", and the sequence of POIs passed through by each trajectory sequence as a "document", and each trajectory can be represented as a word sequence. The calculation process is as follows:

[0082] First, calculate the term frequency (TF). For each trajectory (i.e. "document"), the application calculates the term frequency of each POI point type (i.e. "word"). The calculation formula of the term frequency is:

[0083] ;

[0084] wherein P represents the POI type, n is the number of times the POI appears in the trajectory, T represents the trajectory, and N is the total number of times all POI types appear in the trajectory.

[0085] Then calculate the inverse document frequency (IDF), which is used to measure the importance of a POI point type in the entire trajectory data set. The calculation formula is:

[0086] ;

[0087] D is the total number of trajectories. It is the number of trajectories containing POI type P.

[0088] Finally, the TF-IDF value is calculated, and the term frequency is... and inverse document frequency Multiplying these values ​​yields the TF-IDF value for each POI type in each trajectory, which serves as the text attribute of the POI. :

[0089] ;

[0090] To comprehensively consider the semantics of POIs and their importance in the trajectory, the TF-IDF values ​​of all POI point types are concatenated with P1 as an additional dimension to obtain the final POI representation. ;

[0091] ;

[0092] Final regional features It consists of three parts, namely spatial features Time characteristics and semantic features The formula is as follows:

[0093] ;

[0094] S3. Construct a spatiotemporal relationship graph based on POI within the divided time intervals, and sequentially use a trajectory-aware spatiotemporal integrated random walk strategy and the GAT algorithm to learn high-quality representations of nodes.

[0095] In this embodiment, a POI-based spatiotemporal relationship graph is constructed within the divided time intervals by associating trajectories with spatiotemporal semantics. ,in Indicates time arrive POI spatial relationship graph, nodes This represents a Thiessen polygon, i.e., a POI semantic node. The edges between nodes are represented, providing input for the subsequent trajectory similarity calculation model. For the aforementioned spatiotemporal relationship graph, a trajectory-aware spatiotemporal random walk (PTS-walk) strategy is used to learn the nodes of the spatiotemporal relationship graph G. The embedding strategy directly embeds the data in the graph based on the time of the trajectory sequence sampling points during the sequence sampling phase. The process involves walking through nodes to obtain initial node vectors that can capture both temporal and spatial features. Then, graph attention networks (GAT) are used to learn high-quality representations of nodes, capture the features of neighboring nodes, and enhance the expressive power of nodes.

[0096] In this embodiment, a spatiotemporal relationship graph based on POI is constructed. Specifically, this refers to constructing a spatiotemporal relationship map based on Points of Interest (POIs) within the divided time intervals by using the regional features obtained through the above process. ,node Represents a Thiessen polygon, i.e., a point of interest (POI) region, connecting the edges. Indicates two POI regions and The connection between them, wherein the construction of the connecting edge e must satisfy one of the following conditions: 1) There is a trajectory sequence between them, so an edge is constructed between the two nodes, 2). Cosine similarity of feature vectors , for The cosine similarity of the Kth similar nodes is used to construct an edge between the two nodes. The specific construction process is as follows:

[0097] 1) There is a trajectory connection:

[0098] Given a POI region node When a continuous trajectory passes through Reach other nodes When, construct an edge between nodes, nodes yes The neighboring nodes, i.e. Used to represent the spatial relationship between two nodes, and the weight of the edge. From the slave node To the node The number of trajectories is obtained;

[0099] 2) resemblance:

[0100] The spatial connection of nodes indicates their spatial similarity. Semantically similar POI nodes should also be connected by edges. Here, the K-nearest neighbor (KNN) algorithm is used to find semantically similar neighbors and add an edge between them. The above steps yield the POI region features. The cosine distance of vectors is used to quantify the similarity of nodes, given the nodes. The formula for calculating the similarity between the two is:

[0101] ;

[0102] Thus, for a node , his neighbor nodes can be obtained. The weight of the edge is obtained by the cosine similarity from node to node .

[0103] The same construction process is performed in each time interval to obtain the POI-based spatio-temporal graph , where denotes the spatial graph of time interval to , node denotes the Thiessen polygon, i.e., the POI node, denotes the edge between nodes, the initial feature vector , d is the dimension of the vector, and the weight of node to is . The obtained spatio-temporal graph is referred to as Figure 2 .

[0104] In this embodiment, a spatio-temporal integrated random walk strategy with trajectory awareness, PTS-walk, is used to learn the embedding of vertex v in the spatio-temporal graph G. In the sequence sampling stage, PTS-walk performs a walk in the spatio-temporal graph according to the time of the trajectory sequence sampling point, thereby obtaining a node initial vector that can capture both time and spatial features. This is achieved through two steps. The first step is to generate a node sequence using random walk to simulate the trajectory of a vehicle object in the time interval graph. The second step uses the generated random walk sequence as input to learn a low-dimensional vector representation of the node using the Skip-gram model. The spatio-temporal integrated random walk strategy with trajectory awareness, PTS-walk, can be referred to in Figure 3 . The algorithm steps are as follows:

[0105] (1) Random walk: Specifically, given a spatio-temporal graph generated for different time intervals, PTS-walk first starts walking from a certain vertex on the POI-based spatio-temporal graph, and selects the next walking point according to a certain walk probability. In order to ensure that the generated random sequence is more consistent with the vehicle trajectory walking rule, the walk probability needs to be combined with the trajectory sequence. If the end time of the next walking point exceeds the time limit of the current spatio-temporal graph, then directly jump to the nearest vertex in the next spatio-temporal graph. The walk probability is as follows:

[0106] ;

[0107] , is the weight of an edge, is a combination of DFS and BFS random walk strategies:

[0108] ;

[0109] where is the shortest path distance between a vertex and a vertex , denotes a set of trajectories, p and q are parameters that determine whether the walk strategy is breadth-first search (BFS) or depth-first search (DFS). When is greater than or equal to , it indicates that the preferred walk strategy is BFS, otherwise DFS. Through these walk strategies, a series of node sequences of length n for learning node representations are generated, as shown in Figure 4 as input to the model.

[0110] (2) Vector representation, using the Skip-gram model to learn the low-dimensional vector representation of the nodes generated by the random walk sequence as input, which aims to maximize the likelihood of the simultaneous presence of words in a specified window in a sentence. All walks are considered as a corpus, and each node in the walk is considered as a word. The purpose of the Skip-gram model is to maximize the average probability:

[0111] ;

[0112] where is an encoder that maps nodes to d-dimensional space vectors, is a probability function, is the neighbor of node . In order to make the objective function easy to calculate, the present invention assumes that the probabilities of the neighbor nodes occurring are mutually independent:

[0113] ;

[0114] Given nodes and , the conditional likelihood of each source-neighbor node pair is modeled as a Softmax unit:

[0115] ;

[0116] However, the normalization factor is very time-consuming during training, so the present invention uses negative sampling to reduce computation time, and the model training obtains the low-dimensional vector representation of the nodes .

[0117] In this embodiment, learning high-quality representation of nodes by GAT means that the initial representation of the vertex is obtained through the above steps, in order to better capture the spatial structure between trajectories, the graph attention network (GAT) is used to capture the neighbor node features of the spatio-temporal network in each time interval (V,E), and the specific steps are as follows:

[0118] Taking the spatio-temporal relation graph G(V,E) as input, the vector learned by random walk is taken as the initial feature vector of the node . For the vertex , the similarity coefficients between its neighbors and itself are calculated one by one:

[0119] ;

[0120] a is a single-layer feedforward neural network. Then, the attention score is normalized by using the Softmax function to obtain the normalized attention coefficient:

[0121] ;

[0122] wherein, denotes the neighbor node set of the node .

[0123] According to the calculated attention coefficient, the neighbor node features of the node are weighted and aggregated to obtain the node update

[0124] ;

[0125] To improve the fitting ability of the model, a multi-head attention mechanism is used, so the formula is updated as:

[0126] ;

[0127] Thus, the high-quality representation of the node with neighbor features is obtained.

[0128] S4, according to the spatio-temporal trajectory data and the learned node representation, a model T-LSTM with enhanced time expression ability is constructed to learn the final representation of the trajectory sequence;

[0129] In this embodiment, according to the spatio-temporal trajectory data and the learned node representation, a model T-LSTM (time-enhanced long short-term memory) with enhanced time representation ability is designed to learn the final representation of the trajectory sequence. The model effectively distinguishes the importance of different time points in the trajectory by embedding a time attention layer at the front end of the traditional LSTM structure, thereby finely depicting the time sequence features in the trajectory data and improving the ability of trajectory sequence representation learning.

[0130] In this embodiment, a model T-LSTM with enhanced time representation ability is designed to learn the final representation of the trajectory sequence, Figure 4 is a T-LSTM model framework diagram. In order to better utilize the time information, the model effectively distinguishes the importance of different time points in the trajectory by embedding a time attention layer at the front end of the traditional LSTM structure, thereby finely depicting the time sequence features in the trajectory data and improving the representation learning effect of the trajectory sequence. Specifically as follows:

[0131] 1. Input layer

[0132] Input data: the initial vector sequence of the trajectory point obtained through the above process, for the time feature , the present application converts it into sin and cos features separately using the above method as the input of the attention layer;

[0133] 2. Attention layer:

[0134] Q, K, V generation: for the time feature, generate Q, K, V vectors through matrix multiplication. Then calculate the attention score through the scaled dot-product attention:

[0135] ;

[0136] According to the attention score, weighted sum is performed to obtain the weighted feature representation:

[0137] ;

[0138] Where a is the attention score, and this residual connection helps the model to better propagate the gradient during training, avoids the problem of gradient vanishing, and enables the model to learn more complex features;

[0139] 3. LSTM layer

[0140] Through the above process, the node high-quality representation and the time feature with attention mechanism , both of which are input to the LSTM model, and the final input features are obtained through a multi-layer perceptron (MLP) Thus, the model can dynamically select more important features according to the context:

[0141] ;

[0142] The basic update equation of the LSTM is as follows:

[0143] ;

[0144] ;

[0145] wherein denotes the input gate, denotes the forget gate, is the candidate cell state, is a sigmoid function, and are the weight matrix and bias vector of the input gate, is the hidden state at the previous time, is the input at the current time, denotes the output gate, and are the cell state and the hidden state, respectively.

[0146] By combining the time attention and the LSTM model, in the above update formula .

[0147] The output of the last time step of the T-LSTM is used as the trajectory embedding .

[0148] S5, a cosine similarity function is used to measure the similarity between nodes and trajectories, and a pair sampling method is used to design a graph-based two-level contrast loss function to train the model.

[0149] In this embodiment, according to the node representation and the trajectory sequence representation, a cosine similarity function is used to measure the similarity between nodes and trajectories. Finally, a pair sampling method is used to design a graph-based two-level contrast loss function to train the model, wherein the node-level loss function is calculated by calculating the node similarity, and the expression ability of the trajectory representation to the POI semantic information is strengthened; the trajectory-level loss function is used to strengthen the global representation ability of the trajectory sequence representation, so that the model can simultaneously consider the similarity loss of the POI semantic node and the trajectory sequence, and effectively improve the expression ability of the trajectory representation to the functional semantic information.

[0150] In this embodiment, the specific content of the designed graph-based double-level contrast loss function is as follows: 1. A node-level semantic loss function is used to strengthen the learning of semantic information in the trajectory representation. 2. A trajectory-level contrast loss function is used to optimize the overall similarity of the trajectory. Therefore, the model can simultaneously consider the similarity loss of semantic nodes and trajectory sequences, effectively improving the expression ability of the trajectory representation for functional semantic information.

[0151] 1. Node-level semantic loss function

[0152] In order to strengthen the learning of semantic information in the trajectory representation, the present application proposes a node-level semantic loss function based on POI points. Specifically, given nodes and , after obtaining the node representation through the S3 step, the corresponding embedding vectors are and , and the cosine similarity function is used as the function to measure similarity.

[0153]

[0154] Then, the positive and negative sampling strategies for the nodes passed by the trajectory are used to calculate the point similarity loss, as follows: for the POI node , there is a trajectory sequence passing through to reach other POI nodes , the most similar node in the k nodes is taken as the positive sample of , and a node randomly sampled from the set of other POI nodes that do not appear in the trajectory is taken as the negative sample . Based on this, the similarity loss function for POI point pairs is defined as follows:

[0155]

[0156] where represents the positive sample pair, represents the negative sample pair, is the cosine similarity function, represents the temperature parameter, is the negative sample set.

[0157] 2. Trajectory-level contrast loss function

[0158] ​​In step S1, the trajectory similarity matrix S is obtained by the LCSS algorithm as the real ground distance of the trajectory, in order to train the model, so that the trajectory vector representation learned by the model can be closer to the real trajectory similarity calculation function, the most similar trajectory of the trajectory in the similarity matrix S is extracted as a positive sample, and the remaining trajectories are negative samples. The core of model learning is to learn a mapping function The trajectory sequence is encoded into a representation vector , The following formula needs to be satisfied:

[0159] ;

[0160] is the positive sample similar to the trajectory , is the negative sample not similar to , represents a function of measuring the similarity between samples, the goal of the model is to maximize the similarity score of the positive sample and minimize the similarity score of the negative sample, and the cosine similarity function is used as the function of measuring the similarity. Given any two trajectories and , the representation vectors obtained by model learning are and ,

[0161] ;

[0162] Under this calculation method, the goal of the present application is to maximize the cosine similarity between the given trajectory and its most similar trajectory, and to minimize the cosine similarity between the negative sample. Therefore, the contrast loss is used as the target loss function here. Given the trajectory training set , the loss function is defined as:

[0163] ;

[0164] wherein, represents a trajectory positive sample pair, represents a trajectory negative sample pair, is a cosine similarity function, represents a temperature parameter, is a negative sample set generated for the trajectory .

[0165] The accuracy of trajectory spatio-temporal similarity is optimized by simultaneously considering the point similarity loss of the trajectory and the network node. The final loss function of the model is: ;

[0166] In the training process, for the trajectory training set , after calculating the similarity of all POI nodes passed in the trajectory , the nearest POI node is taken as the positive sample of , and the rest of the nodes not appearing in the trajectory are taken as negative samples. The trajectory similarity matrix S is obtained by the LCSS algorithm, and the most similar trajectories in the matrix S are extracted as the positive samples of the target trajectory for the calculation of , and the last k trajectories are negative samples.

[0167] The trajectory data is first mapped in the POI nodes through division, so the trajectory sequence is converted into sequence data composed of POI nodes. These data are divided by time to form a spatio-temporal graph , the PTS-walk captures the time-space characteristics of the nodes by performing random walk in the spatio-temporal graph, and then aggregates the time-space neighbor features of the nodes to learn the high-quality vector representation of the nodes. Then the positive and negative trajectory samples for training are converted into vector sequence form and input into the model T-LSTM with enhanced time expression capability to learn the final vector representation of the trajectory, and finally the model weight parameter is updated by the double-level contrast loss function based on the graph designed by the application, and the next round of model training is performed by using the new weight parameter.

[0168] The basic principles, main features and advantages of the present application are shown and described above. It should be understood by those skilled in the art that the present application is not limited by the above examples, and the above examples and descriptions in the specification are only preferred examples of the present application and are not intended to limit the present application. Without departing from the spirit and scope of the present application, various changes and improvements can be made to the present application, and these changes and improvements all fall within the scope of the claimed present application. The scope of protection of the present application is defined by the appended claims and their equivalents.

Claims

1. A method for calculating the spatiotemporal trajectory similarity of vehicles based on semantic information, characterized in that, Includes the following steps: S1. Preprocess the vehicle trajectory data to obtain spatiotemporal trajectory data, construct a similarity matrix, divide the spatiotemporal trajectory data into intervals of 1 hour, and at the same time, construct a Voronoi diagram based on POI data to generate Thiessen polygons. Define the Thiessen polygons as the service areas of the corresponding POI points, which serve as the carriers of vehicle trajectory functional semantic information. The trajectory points are mapped within the divided Thiessen polygon range. S2. Based on the spatiotemporal trajectory data and POI data, perform multi-dimensional feature extraction on the POI Thiessen polygon region containing the trajectory to obtain the spatial features, temporal features and POI semantic features of the region. S3. Construct a spatiotemporal relationship graph based on POIs within the divided time intervals. The system sequentially employs a trajectory-aware spatiotemporal integrated random walk strategy and the GAT algorithm to learn high-quality node representations. Indicates time interval arrive Spatial map, nodes This represents the Thiessen polygon, i.e., the POI node. Representing the edges between nodes, PTS-walk first starts walking from a vertex on the POI-based spatiotemporal graph, and selects the next walking point according to a certain walking probability. In order to ensure that the generated random sequence is more in line with the vehicle trajectory walking pattern, the walking probability needs to be combined with the trajectory sequence. If the end time of the next walk exceeds the time limit of the current spatiotemporal graph, it directly jumps to the nearest vertex in the next spatiotemporal graph. S4. Based on the spatiotemporal trajectory data and the learned node representations, construct a model T-LSTM to enhance the temporal representation capability, so as to learn the final representation of the trajectory sequence; S5. Use the cosine similarity function to measure the similarity between nodes and trajectories, and use the pairwise sampling method to design a graph-based two-level contrastive loss function training model.

2. The method for calculating the spatiotemporal trajectory similarity of vehicles based on semantic information as described in claim 1, characterized in that, The process involves preprocessing vehicle trajectory data to obtain spatiotemporal trajectory data, constructing a similarity matrix, dividing the spatiotemporal trajectory data into 1-hour intervals, and simultaneously generating Thiessen polygons from a Voronoi diagram based on POI data. This includes: Acquire vehicle trajectory data and preprocess the vehicle trajectory data to remove abnormal trajectory points and short trajectories, where short trajectories have fewer than 5 trajectory points; A similarity matrix is ​​constructed for the preprocessed vehicle trajectory data using the longest common subsequence algorithm, a trajectory similarity calculation method. The preprocessed spatiotemporal trajectory data is divided into intervals of 1 hour. The dataset constructed from the preprocessed spatiotemporal trajectory data is divided into a series of sub-datasets. The entire trajectory data representation problem is transformed into a series of sub-data representation problems spanning different time intervals. Based on the location information of POIs, a series of Thiessen polygons are generated using Voronoi diagrams. The Thiessen polygons are defined as the functional areas served by the corresponding POIs. The trajectory points in the subset are mapped to the Thiessen polygons, thus giving the trajectory data semantic information.

3. The method for calculating the spatiotemporal trajectory similarity of vehicles based on semantic information as described in claim 1, characterized in that, The process involves extracting multi-dimensional features from the POI (Tysen polygon) region containing the trajectory based on spatiotemporal trajectory data and POI data, yielding spatial features, temporal features, and POI semantic features, including: The latitude and longitude of the POI are normalized using the minimum-maximum normalization function, and a nonlinear transformation is performed using a multilayer perceptron. The GPS coordinates recorded by the POI data are used as the location information of the region to obtain the spatial characteristics of the region. The original timestamps of the trajectory sequence are transformed into sine and cosine feature representations, and then normalized using the minimum-maximum normalization function to transform the one-dimensional linear representation of time into two-dimensional periodic features, thus obtaining the time features. Semantic information of POIs is extracted through time frequency and text mining to obtain POI semantic features.

4. The method for calculating the spatiotemporal trajectory similarity of vehicles based on semantic information as described in claim 3, characterized in that, Semantic information of POIs is extracted through time frequency and text mining to obtain POI semantic features, including: Time frequency: Dividing a day into 24 time intervals with 1 hour as the unit, the spatiotemporal trajectory data is traversed, and for each POI point, the time it appears in the trajectory is counted, and the number of times it appears in the corresponding time interval is counted to obtain the 24-dimensional time feature of each POI point. After normalization, the value of each dimension is replaced with the percentage of the frequency of occurrence in that time interval out of the total frequency of occurrence in the whole day, so that the sum of the values ​​of the dimensions is 1, and the time attribute of the POI is obtained. The time attribute is the distribution of the access popularity of the POI in different time intervals in a day. Text mining: The TF-IDF algorithm is used for text mining. Each POI type is regarded as a word, the POI sequence traversed by each trajectory sequence can be regarded as a document, and each trajectory can be represented as a word sequence. For each trajectory, calculate the term frequency and inverse document frequency for each POI type, multiply the term frequency and inverse document frequency to obtain the TF-IDF value of each POI type in each trajectory, which is used as the text attribute of the POI; The TF-IDF values ​​of all POI types are concatenated with the time attribute as an additional dimension to obtain the semantic features of the POI.

5. The method for calculating the spatiotemporal trajectory similarity of vehicles based on semantic information as described in claim 1, characterized in that, The process involves constructing a spatiotemporal relationship graph based on Points of Interest (POIs) within the divided time intervals. The high-quality representations of nodes are learned sequentially using a trajectory-aware spatiotemporal integrated random walk strategy and the GAT algorithm, including: Based on the spatial and temporal characteristics of the region and the semantic features of POIs, a spatiotemporal relationship graph based on POIs is constructed within the divided time intervals. The construction of connecting edge e requires two conditions to be met: 1) There is a trajectory sequence passing through between them, 2) Cosine similarity of feature vectors ; A trajectory-aware spatiotemporal integrated random walk strategy is employed to learn the initial representation of vertices in the spatiotemporal relationship graph. During the sequence sampling phase, the system walks across the spatiotemporal relationship graph based on the time of the trajectory sequence sampling points to obtain initial node vectors that can simultaneously capture temporal and spatial features. This is mainly achieved through two steps: the first step is to generate a node sequence using random walks to simulate the trajectory of vehicle objects in the time interval relationship graph; the second step uses the generated random walk sequence as input and employs a Skip-gram model to learn the low-dimensional vector representation of the nodes.

6. The method for calculating the spatiotemporal trajectory similarity of vehicles based on semantic information as described in claim 1, characterized in that, The step involves constructing a T-LSTM model with enhanced temporal representation capabilities based on spatiotemporal trajectory data and learned node representations to learn the final representation of the trajectory sequence, including: Based on the spatiotemporal trajectory data and the learned node representations, an initial vector sequence of the trajectory is obtained, and the temporal features are converted into sine and cosine features as input to the attention layer; Q, K, and V vectors are generated through matrix multiplication. Attention scores are calculated by scaling dot product attention. Weighted summation is performed based on the attention scores to obtain the weighted feature representation. High-quality node representations and temporal features with attention mechanisms are used as inputs to the LSTM layer, and the final input features are obtained through a multilayer perceptron. By combining temporal attention and LSTM layers, a model T-LSTM with enhanced temporal representation capabilities is constructed, and the output of the last time step of T-LSTM is used as the trajectory embedding.

7. The method for calculating the spatiotemporal trajectory similarity of vehicles based on semantic information as described in claim 1, characterized in that, The graph-based two-level contrastive loss function includes a node-level semantic loss function and a trajectory-level contrastive loss function. The node-level semantic loss function is used to enhance the trajectory representation's learning of semantic information, while the trajectory-level contrastive loss function is used to optimize the overall trajectory similarity.

8. The method for calculating the spatiotemporal trajectory similarity of vehicles based on semantic information as described in claim 7, characterized in that, Node-level semantic loss functions include: Given a node and After obtaining the node representations in step S3, the corresponding embedding vectors are respectively and The cosine similarity function is used as the function to measure similarity. The strategy involves positive and negative sampling of the nodes traversed by the trajectory, calculating point similarity loss, and using contrastive loss as the semantic loss function at the node level. The most similar node traversed by the trajectory is taken as the positive sample. Randomly sampled nodes that never appeared in other POI node sets in this trajectory as negative samples Based on this, the similarity loss function for POI point pairs is defined as follows: That Indicates a positive sample pair. Indicates negative sample pairs, It is the cosine similarity function. Indicates temperature parameter, It is a set of negative samples.

9. The method for calculating the spatiotemporal trajectory similarity of vehicles based on semantic information as described in claim 7, characterized in that, Trajectory-level contrastive loss functions include: In step S1, the similarity matrix is ​​obtained as the true ground distance of the trajectory. The trajectory most similar to the one in the similarity matrix is ​​extracted as a positive sample, and the remaining trajectories are negative samples. The core of model learning is to learn a mapping function. Make trajectory sequence Encode into representation vectors , The following formula needs to be satisfied: in That is, the trajectory Similar positive samples, Is and Dissimilar negative samples, This represents a function that measures the similarity between samples. The goal of the model is to maximize the similarity score of positive samples and minimize the similarity score of negative samples. Given any two trajectories, their representation vectors are learned through model training. A cosine similarity function is used to measure similarity, with the goal of maximizing the cosine similarity between a given trajectory and its most similar trajectory, and minimizing the cosine similarity with negative samples. A contrastive loss function is used as the trajectory-level contrastive loss function; the loss function is defined as: in, Indicates positive sample pairs of trajectories. Indicates negative sample pairs of trajectories. It is the cosine similarity function. Indicates temperature parameter, This is the trajectory The generated set of negative samples; The accuracy of the final model in calculating the spatiotemporal similarity of the trajectory is optimized by simultaneously considering the point similarity loss of the trajectory and network nodes; the final loss function of the model is: During training, for the trajectory training set For trajectory For all POI nodes traversed, after calculating their similarity, the nearest POI node is taken as... The positive samples, while the rest did not appear in the trajectory. The middle node is used as a negative sample; the trajectory similarity matrix S is obtained through the LCSS algorithm, and the most similar trajectory in matrix S is extracted as a positive sample of the target trajectory. The calculation shows that the last k trajectories are negative samples.

Citation Information

Patent Citations

  • Semantic track similarity calculation system and method based on self-attention mechanism

    CN112328721A

  • Method for discovering traveling vehicles based on natural semantic processing

    CN114186582A

  • Deep learning-based key person trajectory destination multi-step prediction method

    CN118430010A