A data recovery method for complex morphological trajectories
By using technologies such as graph attention network and Transformer encoder in the complex morphological trajectory recovery method, combined with the cross attention mechanism and gated recurrent unit, the missing problem in complex morphological trajectory data recovery is solved, the recovery accuracy is improved, and the traffic is improved. Research provides an accurate data base.
Patent Information
- Application Number
- CN202410402504.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-04-03
- Publication Date
- 2024-10-22
- Estimated Expiration
- 2044-04-03
AI Technical Summary
Existing technologies are not effective in restoring missing data of complex morphological trajectories, especially in urban traffic environments. The loss of road information due to the lack of GPS data hinders traffic research.
Using a data recovery method for complex morphological trajectories, by dividing the geographical space area into grid units, extracting trajectory behavioral characteristics and motion characteristics, constructing a trajectory transfer graph and using graph attention network and Transformer encoder, combined with cross-attention mechanism and Gated recurrent unit to adaptively restore missing trajectory points.
It improves the recovery accuracy of complex morphological trajectories, provides a better data basis, provides accurate trajectory data for traffic research tasks, and optimizes the adversarial training of the model through generative adversarial networks.
Smart Images

Figure BDA0004776062220000033 
Figure BDA0004776062220000034 
Figure BDA0004776062220000035
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of trajectory mining, and in particular relates to a data recovery method for complex morphological trajectories. Background Art
[0002] In order to alleviate the adverse effects caused by urban traffic congestion, many cities are building more complex urban traffic roads, such as viaducts, underpasses, subways, etc. Although these traffic measures have effectively alleviated urban traffic pressure, for vehicles driving on roads under viaducts or driving in underground passages and on roads with dense buildings and lush vegetation, the collected GPS data will be lost because the positioning conditions of 4 satellites cannot be achieved within the GPS field of view. The loss of these data will cause the loss of part of the road information, which will bring certain obstacles to traffic research. Therefore, a data recovery method for complex morphological trajectories is urgently needed.
[0003] At present, there are three types of methods for recovering missing trajectory data. The first type is linear interpolation, which performs linear interpolation between the starting point and the end point. When the mobile object moves along a straight line, this method has a good filling effect, but in fact the mobile object has the behavior of driving along a curve or turning, resulting in poor linear interpolation effect. The second type is path reasoning filling method, which requires first generating a routable graph based on historical trajectory data, and then considering the transition probability between points in the graph for path reasoning. However, the routable graph constructed using the original trajectory itself has errors. The third type is the position prediction filling method, which uses a deep learning model to model the sequential dependency relationship (position transfer relationship) between trajectory points, and then predicts the missing position; however, in order to better model the sequential dependency relationship between trajectory points, this type of method usually uses a grid sequence to represent the trajectory, which introduces additional noise, and the prediction effect fluctuates when there are a large number of missing points in the historical trajectory data. Summary of the invention
[0004] In order to solve the deficiencies in the prior art, the purpose of the present invention is to provide a data recovery method for complex morphological trajectories, which can recover missing trajectory segments with complex morphology and provide a data basis for traffic research tasks based on trajectory data.
[0005] In order to achieve the above technical objectives, the technical solution adopted by the present invention is:
[0006] A data recovery method for complex morphological trajectories includes the following steps:
[0007] S1: Divide the geographic space area into grid units, and extract the trajectory behavior features of each grid based on the historical incomplete trajectories in different grid units, and extract the motion features at each trajectory point for the current incomplete trajectory to be restored.
[0008] S2: Based on the grid features obtained in step S1, a trajectory transfer graph is constructed and the graph attention network is used to adaptively aggregate the features of adjacent grids to obtain a grid representation that integrates the neighboring trajectory information.
[0009] S3: Based on the motion features obtained in step S1 and the grid representation obtained in step S2, the current incomplete trajectory is embedded and represented, and the global correlation of the current incomplete trajectory is modeled using a Transformer encoder to obtain a representation of the current incomplete trajectory.
[0010] S4: Based on the grid representation obtained in step S2 and the trajectory representation obtained in step S3, a combined model of a cross-attention mechanism and a gated recurrent unit is used to decode the missing trajectory points in the incomplete trajectory to be restored.
[0011] To optimize the above technical solutions, the specific measures taken also include:
[0012] The above step S1 specifically includes:
[0013] Step 1.1: Divide the geographic space into discrete and non-intersecting grid cells, and set the side length of each grid cell to 25-100 meters.
[0014] Step 1.2: Extract the features of each grid unit including trajectory point density, trajectory segment density, and trajectory point set direction distribution according to the historical incomplete trajectory in the grid units divided in step 1.1; the trajectory point density is the number of trajectory points in each grid unit; the trajectory segment density is the number of trajectory segments passing through each grid unit, and the trajectory segments are obtained by connecting two adjacent trajectory points; the trajectory point set direction distribution is the direction distribution of the trajectory point set in each grid unit, and the direction of each trajectory point is the angle between the line segment connecting the trajectory point and the next trajectory point and the true north direction. Here, the direction of each trajectory point is mapped to 8 standardized equal-size direction histograms (for example: 0°~45°, 45°~90°, etc.). Thus, a 10-dimensional feature vector f is obtained for each grid unit. grid And the grid feature matrix G of the entire geographic space; the 10 in each grid cell is a feature vector including the above-mentioned trajectory point density, trajectory line segment density, and trajectory point set direction distribution information; the grid feature matrix is composed of the feature vectors f of all grid cells grid The matrix composed of.
[0015] Step 1.3: Since each moving object has its own unique motion pattern, for the incomplete trajectory to be restored, the motion feature f of each trajectory point is obtained by calculating the relative position between the current trajectory point and the previous trajectory point. move , fmove is a two-dimensional feature vector, f move = [Δx, Δy]:
[0016] Δx = p i .lon - p i-1 .lon, Δy = p i .lat - p i-1 .lat
[0017] where p i .lon and p i-1 .lon respectively represent the longitudes of the positions where the current trajectory point and the previous trajectory point are located, and p i .lat and p i-1 .lat respectively represent the latitudes of the positions where the current trajectory point and the previous trajectory point are located.
[0018] The above step S2 specifically includes:
[0019] Step 2.1, construct a trajectory transition graph through historical trajectory data to represent the transition relationship between grid cells; regard each grid cell as a node in the trajectory transition graph, and given an incomplete historical trajectory tr i = {p 0 , p 1 , …, p i , p j …, p n} (1 ≤ i < j ≤ n and j - i > 1), segment the incomplete historical trajectory into two or more complete sub-trajectories according to the number of breakpoints in the incomplete historical trajectory, and then for each pair of adjacent trajectory points (p x , p x+1 ) in the complete sub-trajectory, construct an edge between the corresponding grid cells of p x and p x+1 ; when the incomplete historical trajectory is segmented into two, the sub-trajectories are and when there is more than one breakpoint on the incomplete historical trajectory, segment according to each breakpoint, and process the segmented trajectory;
[0020] When p x and p x+1 are in the same grid cell, connect the corresponding nodes (grid cells) to themselves;
[0021] After processing all the incomplete historical trajectories, obtain a trajectory transition graph, denoted as TG;
[0022] Step 2.2: Use the graph attention network (GAT) to adaptively aggregate the information of adjacent nodes (grid cells) to obtain a richer grid representation that integrates the information of neighboring trajectories: Considering that the graph attention network can recursively aggregate the information of adjacent nodes into the representation of the current node, the present invention first convolves the feature matrix of the grid cell using a 1×1 convolutional layer to obtain the initialized node feature matrix H 0 , and then use the graph attention network to model the influence of neighboring trajectories. i , g j ) The calculation method of the attention score at the l+1 layer is as follows: first, a shared linear transformation is applied to each node through formula (1) to enhance its expressiveness, then a single-layer feedforward neural network with the activation function LeakyReLU is used to calculate the attention score between node gi and node gj (formula (2)), and finally the softmax function is used to normalize it to obtain the final attention score between the node pairs (formula (3)). After obtaining the attention score, it is used as the representation of the weighted aggregation neighboring nodes to obtain the updated node features (formula (4)).
[0023]
[0024]
[0025]
[0026]
[0027] in, is the node representation of node i in layer l, pe i Represented as the sine and cosine position encoding of node i in the feature matrix G, and is a learnable weight matrix. (l) is a learnable weight vector, T represents the transposition operation, and ·||· represents the concatenation operation. i Represents all nodes adjacent to node i in the graph TG. σ is a nonlinear function. After five layers of graph attention layers, a new representation of the grid unit is obtained; in the present invention, five layers of graph attention layers are used for iterative output, and the output of the previous layer is used as the input of the next layer.
[0028] The above step S3 specifically includes:
[0029] Considering that the trajectory points of the same trajectory have a temporal and spatial dependency relationship, the present invention adopts a Transformer-based trajectory encoder to learn the motion pattern of the current incomplete trajectory. The motion features are input into the Transformer encoder to learn the motion pattern of the incomplete trajectory from the sequence. c , whose embedding is as follows:
[0030]
[0031] in, is the trajectory point p c The motion characteristics of h c is the trajectory point p c The characterization vector of the grid cell, pe c is the trajectory point p c The sine and cosine position encoding in the trajectory sequence, ·||· is a concatenation operation; the sine and cosine position encoding is used to represent the position of each element in the sequence. The embedding representation of the current incomplete trajectory consists of the embedding representation of each trajectory point, denoted as T c Then, T c After inputting the Transformer encoder layer, the new trajectory representation T is obtained rc , the Transformer encoder captures the relationship between each trajectory point in the sequence through the self-attention mechanism, and encodes the information of the entire trajectory into the representation of each trajectory point.
[0032] The above step S4 specifically includes:
[0033] In step S4 of the present invention, a gated recurrent unit (GRU) is used to restore the missing trajectory point sequence in an autoregressive manner, in which the prediction of each step is used as the input of the next step. Specifically, the representation of the current incomplete trajectory is first linearly transformed to obtain a hidden state vector representing the entire trajectory, that is, the hidden state vector s 0 =W 3 T rc , where W 3 is a learnable weight matrix; the hidden state vector is used as the initial hidden state of the GRU network. Before starting to recover the trajectory points, the gated recurrent unit (GRU) network has obtained preliminary information about the entire trajectory, which helps to improve the accuracy and efficiency of recovering the missing points.
[0034] Considering that the influence of sampled trajectory points on different missing trajectory points is different, the present invention adaptively captures the influence of sampled trajectory points in the current incomplete trajectory on the missing trajectory points through the cross-attention mechanism, obtains the importance of different sampled trajectory points to restore specific missing trajectory points, and thus obtains "customized" global information. The specific formula is as follows:
[0035]
[0036]
[0037]
[0038] Among them, u ki Represents the sampling trajectory point p i For the missing trajectory point p k The attention score, a ki Indicates the use of softmax function for u ki The normalized result, W s and W t is the learnable weight matrix, v is the learnable weight vector, T represents the transpose operation, s k-1 represents the hidden state of the GRU output of the previous time step, Represents the sampling trajectory point p i The embedded representation of .
[0039] In addition, since the motion state of the missing trajectory point is usually similar to that of the previous trajectory point, and its motion state is also usually similar to that of the neighboring trajectory points, by combining the predicted position of the previous missing trajectory point (Δp k-1 ), the representation vector of the grid cell where the previous trajectory point is located (h k-1 ), and the global information customized for the kth missing trajectory point (a k ), to predict the location of each missing point;
[0040] The predicted position is the change relative to the previous trajectory point (Δx k , Δy k ), these changes are then used to calculate the absolute longitude and latitude coordinates of the kth missing trajectory point;
[0041] The input x of the GRU at the kth time step k It is expressed as:
[0042] x k =Δp k-1 ||h k-1 ||a k
[0043] Among them, Δp k-1 =(Δx k-1 ,Δy k-1 ) is the prediction result of the previous time step, h k-1 is the characterization vector of the grid cell where the previous missing trajectory point is located, a k It is the global information “customized” for the k-th trajectory point.
[0044] After getting the output s of GRU at the kth time step k After that, the linear layer is further applied to predict the relative position of the kth missing trajectory point, i.e., Δp k =W 4 s k , where W 4 is a learnable weight matrix, and the longitude and latitude coordinates of the kth missing trajectory point are obtained according to the absolute position of the k-1th missing trajectory point:
[0045] (lon k ,lat k )=(lon k-1 +Δx k ,lat k-1 +Δy k )
[0046] In order to further optimize the model used to restore complex morphological trajectories in the present invention, the above data recovery method also includes the following steps:
[0047] A generative adversarial network architecture is introduced, the model in steps S1-S4 is used as the generator, and the combined model of bidirectional GRU and multi-layer perceptron is used as the discriminator. Through adversarial training, the model can learn a better representation of the trajectory point sequence and optimize the trajectory point recovery result.
[0048] The optimization steps specifically include:
[0049] Considering that the vehicle's driving trajectory is usually consistent with motion consistency and smooth, in the process of model training, in addition to using the mean square error loss commonly used in existing solutions, the constraints on the trajectory in terms of morphology and motion state changes should also be considered. By introducing a generative adversarial network, the present invention can learn better sequence representations in adversarial training, and the generative adversarial network includes a generator and a discriminator. Specifically, the model in steps S1-S4 is used as a generator, and the mean square error MSE is used as the loss function for training optimization:
[0050]
[0051] Where m represents the number of missing trajectory points in the incomplete trajectory, y k represents the true position of the missing trajectory point, represents the predicted position of the model. ||·|| 2 is the L2 norm, which represents the Euclidean distance between two locations.
[0052] The discriminator is a binary classifier used to distinguish between real samples and samples generated by the generator. The present invention designs a combined model of a bidirectional GRU and a multi-layer perceptron as a discriminator; the discriminator inputs the motion feature sequence of the trajectory into the bidirectional GRU in sequence order to obtain a hidden state vector, and then inputs the hidden state vector into the multi-layer perceptron to obtain a prediction result, that is, the probability that the trajectory is a real sample. After obtaining the restored trajectory through the generator, the motion feature of each trajectory point is updated and input into the discriminator to obtain Similarly, the motion features of each trajectory point in the true complete trajectory are extracted and input into the discriminator to obtain Therefore, the loss function of the discriminator consists of the loss of generated samples and the loss of real samples:
[0053]
[0054] in, It represents the result obtained by extracting the motion feature Y of each trajectory point in the true complete trajectory and inputting it into the discriminator model. The result is a scalar value in the interval [0,1], which represents the probability that Y is a true sample; Indicates that after the current incomplete trajectory is restored through the generator, the motion characteristics of each trajectory point are updated to obtain The result obtained by inputting it into the discriminator is a scalar value in the interval [0,1], representing is the probability of being a true sample; Indicates expected value.
[0055] The present invention includes the following beneficial effects:
[0056] In view of the diversity of missing trajectory segments, the present invention adopts a multi-layer graph attention network to aggregate the information of neighboring trajectory points to guide the prediction of each missing trajectory point to improve the recovery accuracy of missing trajectories with complex morphologies.
[0057] The present invention introduces a generative adversarial network architecture into the trajectory recovery model and uses a discriminator to regularize the model at the sequence level so that it can learn a better representation of the trajectory point sequence.
[0058] The present invention uses real trajectory data to conduct an experimental evaluation of the trajectory recovery method, and the experimental results verify the effectiveness of the method of the present invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without paying any creative work.
[0060] Figure 1 It is a framework diagram of a data recovery method for complex morphological trajectories.
[0061] Figure 2 It is a diagram showing the effect of the existing method SimiDTR trajectory recovery in an embodiment of the present invention.
[0062] Figure 3 3 is an effect diagram of trajectory recovery of the method of the present invention in an embodiment of the present invention.
[0063] Figure 4 It is a model diagram of the graph attention network. DETAILED DESCRIPTION
[0064] The present invention is further described in detail with reference to the following specific examples and drawings. The process, conditions, experimental methods, etc. for implementing the present invention, except for the contents specifically mentioned below, are all common knowledge and common common sense in the art and are not particularly limited by the present invention.
[0065] The present invention discloses a data recovery method for complex morphological trajectories, such as Figure 1 As shown in the figure, the geographic space area is first divided into grid units, and the historical trajectory behavior features and current trajectory motion features are extracted. Then, based on the historical incomplete trajectory, a trajectory transfer graph is constructed and the features of adjacent grids are adaptively aggregated using the graph attention network, thereby obtaining a grid representation that integrates the information of neighboring trajectories. At the same time, the current incomplete trajectory is embedded and the global correlation of the current incomplete trajectory is modeled using the Transformer encoder to obtain the representation of the current incomplete trajectory. Finally, a combined model of the cross-attention mechanism and the gated recurrent unit is used to restore the missing trajectory points in the current incomplete trajectory, and the discriminator network is used to enable the model to learn a better representation of the trajectory point sequence.
[0066] like Figure 1 As shown, the present invention provides a data recovery method for complex morphological trajectories, comprising the following steps:
[0067] S1: Divide the geographic space area into grid units, and extract the trajectory behavior features of each grid based on the historical incomplete trajectories in different grid units, and extract the motion features at each trajectory point for the current incomplete trajectory to be restored.
[0068] In the embodiment, step S1 specifically includes:
[0069] Step 1.1: Divide the geographical space into discrete and non - overlapping grid cells, and set the side length of each grid cell to 50 meters.
[0070] Step 1.2: Extract the features of each grid cell according to the historical incomplete trajectories passing through these grid cells, including (1) the trajectory point density, that is, the number of trajectory points in each grid cell; (2) the trajectory segment density, that is, the number of trajectory segments passing through each grid cell, and the trajectory segments are obtained by connecting two adjacent trajectory points; (3) the direction distribution, that is, the direction distribution of the set of trajectory points in each grid cell, and the direction of each trajectory point is the angle between the line segment connecting the trajectory point and its next trajectory point and the due north direction. Here, the direction of each trajectory point is mapped into 8 standardized equal - sized direction histograms (for example: 0° - 45°, 45° - 90°, etc.). Thus, a 10 - dimensional feature vector f of each grid cell is obtained grid and the grid feature matrix G of the entire geographical space.
[0071] Step 1.3: Since each moving object has its own unique motion pattern, for the currently to - be - recovered incomplete trajectory, the motion feature f of each trajectory point is obtained by calculating the relative position between the current trajectory point and the previous trajectory point move .
[0072] S2: Based on the grid features obtained in step S1, construct a trajectory transition graph and adaptively aggregate the features of adjacent grids using a graph attention network, so as to obtain a grid representation that fuses the information of neighboring trajectories.
[0073] In the embodiment, step S2 specifically includes:
[0074] Step 2.1: In the present invention, each grid cell is regarded as a node in the graph. Given a historical incomplete trajectory tr i ={p 0 , p 1 , …, p i , p j …, p n}(1 ≤ i < j ≤ n and j - i > 1), first segment it into two complete sub - trajectories and Then for each pair of adjacent trajectory points (p x , p x+1 ) in the complete sub - trajectory, build an edge between the corresponding grid cells of p x and p x+1 . After processing all the historical incomplete trajectories, the trajectory transition graph is obtained, denoted as TG.
[0075] Step 2.2: Considering that the graph attention network can recursively aggregate the information of adjacent nodes into the representation of the current node, the present invention first convolves the feature matrix of the grid unit using a 1×1 convolutional layer to obtain the initialized node feature matrix H 0 , and then use the graph attention network to model the influence of neighboring trajectories. i , g j )The attention score at layer l+1 is calculated as follows:
[0076]
[0077]
[0078]
[0079]
[0080] in, is the node representation of node i in layer l, pe i Represented as the sine and cosine position encoding of node i in the feature matrix G, and is a learnable weight matrix. (l) is a learnable weight vector, T represents the transposition operation, and || represents the concatenation operation. i represents all nodes adjacent to node i in the graph TG. σ is a nonlinear function. After five layers of graph attention, a new representation of the grid is obtained.
[0081] S3: Based on the motion features obtained in step S1 and the grid representation obtained in step S2, the current incomplete trajectory is embedded and represented, and the global correlation of the current incomplete trajectory is modeled using a Transformer encoder to obtain a representation of the current incomplete trajectory.
[0082] In the embodiment, step S3 specifically includes:
[0083] Considering the temporal and spatial dependencies between the trajectory points of the same trajectory, the present invention adopts a Transformer-based trajectory encoder to learn the motion pattern of the current incomplete trajectory. c , whose embedding is as follows:
[0084]
[0085] in, is the trajectory point p c The motion characteristics of h c is the trajectory point p cThe characterization vector of the grid cell, pe c is the trajectory point p c The sine and cosine position encoding in the trajectory sequence, ·||· is the concatenation operation. The embedding representation of the current incomplete trajectory consists of the embedding representation of each trajectory point, denoted as T c Then, T c After inputting the Transformer encoder layer, the new trajectory representation T is obtained rc , which encodes the information of the entire trajectory into the representation of each trajectory point.
[0086] S4: Based on the grid representation obtained in step S2 and the trajectory representation obtained in step S3, a combined model of a cross-attention mechanism and a gated recurrent unit is used to decode the missing trajectory points in the incomplete trajectory to be restored.
[0087] In the embodiment, step S4 specifically includes:
[0088] The present invention uses a gated recurrent unit (GRU) to restore the missing trajectory point sequence in an autoregressive manner. Specifically, the representation of the current incomplete trajectory is first linearly transformed to obtain a hidden state vector representing the entire trajectory, and the hidden state vector is used as the initial hidden state of the GRU network.
[0089] Considering that the influence of sampled trajectory points on different missing trajectory points is different, the present invention adaptively captures the influence of sampled trajectory points in the current incomplete trajectory on the missing trajectory points through the cross-attention mechanism, thereby obtaining "customized" global information. The specific formula is as follows:
[0090]
[0091]
[0092]
[0093] Among them, u ki Represents the sampling trajectory point p i For the missing trajectory point p k The attention score, a ki Indicates the use of softmax function for u ki The normalized result, W s and W t is the learnable weight matrix, v is the learnable weight vector, T represents the transpose operation, s k-1 represents the hidden state of the GRU output at the previous time step, Represents the sampling trajectory point p i The embedding representation of .
[0094] In addition, since the motion state of the missing trajectory point is usually similar to that of the previous trajectory point, and its motion state is usually similar to that of the neighboring trajectory points, the input x k It is expressed as:
[0095] x k =Δp k-1 ||h k-1 ||a k
[0096] Among them, Δp k-1 =(Δx k-1 ,Δy k-1 ) is the prediction result of the previous time step, h k-1 is the characterization vector of the grid cell where the previous missing trajectory point is located, a k It is the global information “customized” for the k-th trajectory point.
[0097] After getting the output s of GRU at the kth time step k After that, the linear layer is further applied to predict the relative position of the kth missing trajectory point, and the longitude and latitude coordinates of the kth missing trajectory point are obtained according to the absolute position of the k-1th missing trajectory point:
[0098] (lon k ,lat k )=(lon x-1 +Δx k ,lat k-1 +Δy k )
[0099] In the present invention, a generative adversarial network architecture is introduced, the model in steps S1-S4 is used as a generator, and the combined model of bidirectional GRU and multi-layer perceptron is used as a discriminator. Through adversarial training, the model learns a better representation of the trajectory point sequence.
[0100] In the embodiment, the optimization scheme specifically includes:
[0101] Considering that the vehicle's driving trajectory is usually consistent with motion consistency and smooth, in the process of model training, in addition to using the mean square error loss commonly used in existing solutions, the constraints on the trajectory in terms of morphology and motion state changes should also be considered. By introducing a generative adversarial network, the present invention can learn better sequence representations in adversarial training. Specifically, the model in steps S1-S4 is used as a generator, and MSE is used as the loss function for training optimization:
[0102]
[0103] Where m represents the number of missing trajectory points in the incomplete trajectory, y krepresents the true position of the missing trajectory point, represents the predicted position of the model. ||·|| 2 is the L2 norm, which represents the Euclidean distance between two locations.
[0104] The discriminator is a binary classifier used to distinguish between real samples and samples generated by the generator. The present invention designs a combined model of bidirectional GRU and multi-layer perceptron as the discriminator. After obtaining the restored trajectory through the generator, the motion features of each trajectory point are updated and input into the discriminator to obtain Similarly, the motion features of each trajectory point in the true complete trajectory are extracted and input into the discriminator to obtain Therefore, the loss function of the discriminator consists of the loss of generated samples and the loss of real samples:
[0105]
[0106] in, It represents the result obtained by extracting the motion feature Y of each trajectory point in the true complete trajectory and inputting it into the discriminator model. The result is a scalar value in the interval [0,1], which represents the probability that Y is a true sample; Indicates that after the current incomplete trajectory is restored through the generator, the motion characteristics of each trajectory point are updated to obtain The result obtained by inputting it into the discriminator is a scalar value in the interval [0,1], representing is the probability of being a true sample; Indicates expected value.
[0107] In order to verify the effectiveness of the present invention, real trajectory data is selected for recovery. In the experiment, m trajectory points are randomly deleted continuously from each trajectory to indicate an incomplete trajectory with continuous missing points, and the positions of the original trajectory points are taken as the true values of the missing trajectory points. The method of the present invention is compared and evaluated with the existing trajectory recovery methods, including DHTR and SimiDTR. Figure 2 The following is the trajectory recovery effect diagram of SimiDTR. Figure 3 The figure shows the effect diagram of trajectory recovery of the method of the present invention, where the green trajectory is the missing trajectory, the red trajectory is the true trajectory, and the blue trajectory is the trajectory recovery result. The method of the present invention can achieve a better recovery effect for the missing trajectory segment of the U-turn. In quantitative evaluation, the two evaluation indicators RMSE and NDTW are used to evaluate the similarity between the true trajectory and the recovered trajectory. The smaller the value of the two indicators, the better the effect. The comparative evaluation results are shown in Table 1. The experimental results show that the RMSE and NDTW distances between the missing trajectory restored by the method proposed in the present invention and the true trajectory are smaller, which proves the effectiveness of the present invention.
[0108] RMSE: The root mean square error between the true coordinates and the predicted coordinates of the missing trajectory points, with the distance unit being km.
[0109] NDTW: Normalized Dynamic Time Warping Distance between the true trajectory and the recovered trajectory. NDTW is an improved version of Dynamic Time Warping Distance (DTW), which divides the DTW distance between trajectories by the number of recovered trajectory points. The distance unit is km.
[0110] Given the current incomplete trajectory Figure 3 As shown in the green trajectory in the middle, as well as the historical incomplete trajectory, the geographic space area is first divided into grid units, and the historical trajectory behavior features and current trajectory motion features are extracted. Subsequently, a trajectory transfer graph is constructed based on the historical incomplete trajectory and the graph attention network is used to adaptively aggregate the features of adjacent grids to obtain a grid representation that integrates the information of neighboring trajectories. At the same time, the current incomplete trajectory is embedded and the Transformer encoder is used to model the global correlation of the current incomplete trajectory to obtain a representation of the current incomplete trajectory. Finally, a combined model of the cross-attention mechanism and the gated recurrent unit is used to restore the missing trajectory points in the current incomplete trajectory, and the restored missing trajectory points are connected with the sampled trajectory points to obtain Figure 3 Medium blue track.
[0111] Table 1 Comparison of the effects of different methods
[0112]
[0113] In summary, the present invention comprehensively adopts adversarial generative network architecture, graph attention network, gated recurrent unit, Transformer and other technologies to form a data recovery method for complex morphological trajectories, which can accurately restore missing trajectory segments, thereby providing a data basis for traffic research tasks based on trajectory data.
[0114] The protection content of the present invention is not limited to the above embodiments. Without departing from the spirit and scope of the present invention, changes and advantages that can be thought of by those skilled in the art are included in the present invention and are protected by the attached claims.
Claims
1. A data recovery method for complex morphological trajectories, It is characterized in that The following steps are involved: S1: Divide the geographic space area into grid units, and extract the trajectory behavior characteristics of each grid based on the historical incomplete trajectories in different grid units, and extract the motion characteristics at each trajectory point for the current incomplete trajectory to be restored; S2: Based on the grid features obtained in step S1, a trajectory transfer graph is constructed and the features of adjacent grids are adaptively aggregated using a graph attention network, thereby obtaining a grid representation that integrates neighboring trajectory information; the step S2 specifically includes: Step 2.
1. Construct a trajectory transition graph from historical trajectory data to represent the transition relationships between grid cells: Consider each grid cell as a node in the trajectory transition graph. Given a historical incomplete trajectory tr i ={p 0 , p 1 , …, p i , p j …, p n}, where 1 ≤ i < j ≤ n and j - i > 1, segment the historical incomplete trajectory into two or more complete sub-trajectories according to the number of breakpoints in the historical incomplete trajectory. Then, for each pair of adjacent trajectory points (p x , p x+1 ) in the complete sub-trajectory, construct an edge between the corresponding grid cells of p x and p x+1 . After processing all the historical incomplete trajectories, obtain the trajectory transition graph, denoted as TG; Step 2.2: Use the graph attention network to adaptively aggregate the information of adjacent nodes to obtain a grid representation that incorporates the information of neighboring trajectories: Considering that the graph attention network can recursively aggregate the information of adjacent nodes into the representation of the current node, the feature matrix of the grid unit is convolved using a 1×1 convolutional layer to obtain the initialized node feature matrix H 0 , and then use the graph attention network to model the influence of neighboring trajectories; the adjacent node pairs (g i , g j )The attention score at layer l+1 is calculated as follows: in, is the node representation of node i in layer l, pe i Represented as the sine and cosine position encoding of node i in the feature matrix G, and is a learnable weight matrix; a (l) is a learnable weight vector, T represents the transposition operation, ·||· represents the concatenation operation; N i represents all nodes adjacent to node i in the graph TG; σ is a nonlinear function; after five layers of graph attention layers, a new representation of the grid unit is obtained; S3: Based on the motion features obtained in step S1 and the grid representation obtained in step S2, the current incomplete trajectory is embedded and represented, and the global correlation of the current incomplete trajectory is modeled using a Transformer encoder to obtain a representation of the current incomplete trajectory; the step S3 specifically includes: Considering the spatiotemporal dependency between trajectory points of the same trajectory, a Transformer-based trajectory encoder is used to learn the motion pattern of the current incomplete trajectory. c , whose embedding is as follows: in, is the trajectory point p c The motion characteristics of h c is the trajectory point p c The characterization vector of the grid cell, pe c is the trajectory point p c The sine and cosine position encoding in the trajectory sequence, ·||· is the concatenation operation; the embedding representation of the current incomplete trajectory is composed of the embedding representation of each trajectory point, denoted as T c ; Then, T c After inputting the Transformer encoder layer, the new trajectory representation T is obtained rc , the Transformer encoder captures the relationship between each trajectory point in the sequence through the self-attention mechanism, and encodes the information of the entire trajectory into the representation of each trajectory point; S4: Based on the grid representation obtained in step S2 and the trajectory representation obtained in step S3, a combined model of a cross attention mechanism and a gated recurrent unit is used to decode the missing trajectory points in the incomplete trajectory to be restored. The step S4 specifically includes: The gated recurrent unit is used to restore the missing trajectory point sequence in an autoregressive manner: first, the representation of the current incomplete trajectory is linearly transformed to obtain the hidden state vector representing the entire trajectory, denoted as s 0 =W 3 T rc , where W 3 is a learnable weight matrix; the hidden state vector is used as the initial hidden state of the gated recurrent unit network; The cross-attention mechanism is used to adaptively capture the influence of the sampled trajectory points in the current incomplete trajectory on the missing trajectory points to obtain global information. The specific formula is as follows: Among them, u ki Represents the sampling trajectory point p i For the missing trajectory point p k The attention score, a ki Indicates the use of softmax function for u ki The normalized result, W s and W t is the learnable weight matrix, v is the learnable weight vector, T represents the transpose operation, s k-1 represents the hidden state of the gated recurrent unit output at the previous time step, Represents the embedded representation of the sampled trajectory point pi; The input x of the gated recurrent unit at the kth time step k It is expressed as: x k =Δp k-1 ||h k-1 ||a k , Among them, Δp k-1 =(Δx k-1 , Δy k-1 ) is the prediction result of the previous time step, h k-1 is the characterization vector of the grid cell where the previous missing trajectory point is located, a k is the global information of the kth trajectory point; After getting the output s of the gated recurrent unit at the kth time step k Finally, a linear layer is applied to predict the relative position of the kth missing track point, and the longitude and latitude coordinates of the kth missing track point are obtained according to the absolute position of the k-1th missing track point: (lon k ,years k )=(lon k-1 +Δx k ,years k-1 +Δy k )。 2. The data recovery method according to claim 1, It is characterized in that The step S1 specifically includes: Step 1.1, dividing the geographic space area into discrete and non-intersecting grid cells, and the side length of each grid cell is set to 25-100 meters; Step 1.2: Extract the features of each grid cell including trajectory point density, trajectory line segment density, and trajectory point set direction distribution according to the historical incomplete trajectory in the grid cells divided in step 1.1, and obtain a 10-dimensional feature vector f for each grid cell. grid and the grid feature matrix G of the entire geographic space; Step 1.3: For the incomplete trajectory to be restored, the motion feature f of each trajectory point is obtained by calculating the relative position between the current trajectory point and the previous trajectory point. move .
3. The data recovery method according to claim 2, It is characterized in that In step 1.2, the trajectory point density refers to the number of trajectory points in each grid cell; the trajectory segment density refers to the number of trajectory segments passing through each grid cell, and the trajectory segments connect two adjacent trajectory points; the trajectory point set distribution refers to the direction distribution of the trajectory point set in each grid cell, and the direction of the trajectory point refers to the angle between the line segment connecting the current trajectory point and the next trajectory point and the north direction. The direction of each trajectory point is mapped into 8 standardized equal-sized direction histograms.
4. The data recovery method according to claim 2, It is characterized in that In step 1.3, the motion feature f move Expressed as a two-dimensional feature vector, f move =[Δx,Δy]; Δx=P i .lon-p i-1 .lon,Δy=p i .lat-p i-1 .lat, Among them, p i .lon and p i-1 .lon represents the longitude of the current track point and the previous track point respectively, p i .lat and p i-1 .lat represents the latitude of the current track point and the previous track point respectively.
5. The data recovery method according to claim 1, It is characterized in that The data recovery method introduces a generative adversarial network architecture to further optimize the model: The model in steps S1-S4 is used as a generator, and the mean square error MSE is used as the loss function for training optimization: Where m represents the number of missing trajectory points in the incomplete trajectory, y k represents the true position of the missing trajectory point, represents the predicted position of the model; ||·|| 2 is the L2 norm, which represents the Euclidean distance between two locations; A combination model of bidirectional gated recurrent unit and multi-layer perceptron is designed as the discriminator; after obtaining the restored trajectory through the generator, the motion features of each trajectory point are updated and input into the discriminator to obtain Extract the motion features of each trajectory point in the real complete trajectory and input them into the discriminator to obtain The loss function of the discriminator consists of the loss of generated samples and the loss of real samples: in, It represents the result obtained by extracting the motion feature Y of each trajectory point in the true complete trajectory and inputting it into the discriminator model. The result is a scalar value in the interval [0,1], which represents the probability that Y is a true sample; Indicates that after the current incomplete trajectory is restored through the generator, the motion characteristics of each trajectory point are updated to obtain The result obtained by inputting it into the discriminator is a scalar value in the interval [0,1], representing is the probability of being a true sample; Indicates expected value.
