Travel trajectory data generation method and device, medium and equipment
By training the generator and discriminator through generative adversarial networks, and comprehensively considering geographical, temporal and category factors, more realistic and deceptive travel trajectory data is generated, which solves the problem of unrealistic travel trajectory data generation in existing technologies and improves the privacy protection effect.
Patent Information
- Application Number
- CN202510817909.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-18
- Publication Date
- 2025-10-03
AI Technical Summary
When generating travel trajectory data, existing technologies ignore factors other than geographic information, resulting in a large gap between the generated travel trajectory data and the real data, lack of deceptiveness, and inability to effectively protect user privacy.
A generative adversarial network is used to construct real travel trajectory data containing geographic coordinates, time, and travel trajectory category attributes. The generator and discriminator are trained to perform repeated games. The generator generates more deceptive synthetic trajectory data by minimizing the spatial, temporal and category similarity gaps between noise and real trajectory data.
The generated travel trajectory data is more authentic in multiple dimensions and difficult to distinguish by the discriminator, which improves the privacy protection capability and enhances the deceptiveness and usability of the data.
Smart Images

Figure CN120745708A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information security technology, and in particular to a method, device, medium and equipment for generating travel trajectory data. Background Art
[0002] With the rise and rapid development of the mobile internet, location-based services (LBS) have emerged. They provide services to users by obtaining mobile terminal user information (such as geographic coordinates) through external positioning methods such as GPS. To ensure high-quality service, private user travel trajectory data is widely used. However, this comes with the serious risk of privacy leakage. Balancing service quality optimization with user privacy protection has attracted much attention. This problem can be solved by generating fake travel trajectories to anonymize real data.
[0003] In the prior art, Chinese patent CN 110223515 B discloses a vehicle trajectory generation method, which includes: preprocessing trajectory data and map data; generating a road segment trajectory generation model and a trip trajectory generation model; and loading the road segment trajectory generation model and the trip trajectory generation model to obtain trajectory data.
[0004] However, the above method only relies on geographic information to generate travel trajectories, ignoring other factors that affect the travel trajectory. It may cause the loss of other important features of the generated travel trajectory, resulting in a large gap between the generated travel trajectory data and the real travel trajectory data, which is not deceptive and will reduce the ability to protect the real data. Summary of the Invention
[0005] Based on this, it is necessary to provide a method, device, medium and equipment for generating travel trajectory data to address the above technical problems.
[0006] This manual adopts the following technical solutions:
[0007] This specification provides a method for generating travel trajectory data, including:
[0008] Construct a dataset based on real travel trajectory data containing geographic coordinates, time and travel trajectory category attributes;
[0009] Build a generative adversarial network and train it based on the dataset:
[0010] The real travel trajectory data and random noise are input into the generator in the generative adversarial network. The generator converts the random noise into synthetic trajectory data based on the real travel trajectory data.
[0011] Input the real travel trajectory data and the synthetic trajectory data into the discriminator in the generative adversarial network, and output the probability value of the input real travel trajectory data and the synthetic trajectory data being real data;
[0012] The probability value of the synthetic trajectory data being real data is fed back to the generator. The generator minimizes the gap between the spatial similarity, temporal similarity, and category similarity between the random noise and the real travel trajectory data to maximize the probability value of the synthetic trajectory data being judged as real data by the discriminator.
[0013] Through repeated game between the generator and the discriminator, the probability value of the discriminator outputting the synthetic trajectory data as real data is maximized to obtain a trained generative adversarial network;
[0014] Use the generator in the trained generative adversarial network to generate new travel trajectory data.
[0015] Furthermore, the real travel trajectory data based on the geographical coordinates, time and travel trajectory category attributes specifically includes:
[0016] Taking spatial attributes, time attributes, and travel trajectory category attributes as travel trajectory points, obtain travel trajectory data including a plurality of travel trajectory points, and encode the travel trajectory data:
[0017] For geographic coordinates, all longitudes and latitudes are normalized using the centroid of all travel trajectory data in the dataset to obtain the deviation between the longitude and latitude and the centroid;
[0018] Use a one-hot encoder to encode the Day attribute in the time attribute into a 7-bit binary vector, and encode the Hour attribute in the time attribute into a 24-bit binary vector;
[0019] Use a one-hot encoder to encode the travel trajectory category attribute into a 10-bit binary vector;
[0020] All attributes of the encoded travel trajectory data are stored in a multi-dimensional matrix, where the first dimension of the multi-dimensional matrix represents the index of each travel trajectory.
[0021] Furthermore, the generative adversarial network includes a generator and a discriminator; the generative adversarial network includes a generator and a discriminator; the generator and the discriminator both include a bidirectional GRU layer with an attention mechanism, and the bidirectional GRU layer with an attention mechanism is used to capture the long-term dependency relationship between multiple travel trajectory points in the travel trajectory data;
[0022] The generator uses a bidirectional GRU layer with an attention mechanism to capture long-term dependencies in the real travel trajectory data to generate synthetic travel trajectory data that is more similar to the real travel trajectory data.
[0023] The discriminator obtains the long-term dependencies of the discriminator input data through a bidirectional GRU layer with an attention mechanism to improve the ability to distinguish between real and generated data.
[0024] Furthermore, the generator includes a generator input layer, a generator embedding layer, a generator feature fusion layer, a generator modeling layer and a generator output layer;
[0025] The generator input layer is used to receive travel trajectory data, noise vector, and mask information;
[0026] The generator embedding layer uses a multi-layer perceptron (MLP) to embed the output of the generator input layer, including:
[0027] Create an empty embedding list embeddings, traverse the key list of the multidimensional matrix, and define an embedding layer for each attribute;
[0028] The generator feature fusion layer is used to splice the output of the generator embedding layer, including:
[0029] Concatenate the output of the generator embedding layer along the third dimension and convert the concatenated tensor into a list where each element corresponds to a time step of the original.
[0030] Input the concatenated tensor into a fully connected layer dense, and convert the output of the fully connected layer into a tensor through the Lambda function;
[0031] Concatenate the elements in the list along the time step to get the output tensor emb_traj;
[0032] The generator modeling layer is used to generate track data, including:
[0033] Define a single GRU layer gru_cell constructed using GRU;
[0034] Use the Bidirectional wrapper to wrap the single GRU layer gru_cell into a bidirectional GRU layer bidirectional_gru;
[0035] Apply the attention mechanism to the bidirectional GRU layer bidirectional_gru, calculate the attention weights, and apply the attention weights to the output of the bidirectional GRU layer bidirectional_gru;
[0036] The generator output layer is used to process through the time distribution layer to produce the required synthetic travel trajectory, including:
[0037] For spatial attribute data, the output layer uses a dense layer with the activation function tanh to map the generated coordinates to the appropriate range;
[0038] For other attribute data, the output layer uses a dense layer with activation function softmax to convert the generated attribute values into probability distribution.
[0039] Furthermore, the discriminator includes a discriminator input layer, a discriminator embedding layer, a discriminator feature fusion layer, a discriminator modeling layer and a discriminator output layer;
[0040] The discriminator input layer is used to receive the travel trajectory data generated by the generator or the real travel trajectory data;
[0041] The discriminator embedding layer uses a multi-layer perceptron (MLP) to embed the output of the discriminator input layer, including:
[0042] Create an empty embedding list embeddings, traverse the key list of the multidimensional matrix, and define an embedding layer for each attribute;
[0043] The discriminator feature fusion layer is used to splice the output of the discriminator embedding layer, including:
[0044] Concatenate the output of the discriminator embedding layer along the third dimension and convert the concatenated tensor into a list where each element corresponds to an original time step.
[0045] Input the concatenated tensor into a fully connected layer dense, and convert the output of the fully connected layer into a tensor through the Lambda function;
[0046] Concatenate the elements in the list along the time step to get the output tensor emb_traj;
[0047] The discriminator modeling layer is used to model the temporal dynamics and long-term dependencies in the travel trajectory data, including:
[0048] Define a single GRU layer gru_cell built based on GRU;
[0049] Use expand_dims to expand the dimension of the single GRU layer gru_cell to (None, 1, 100), and convert the output of the single GRU layer gru_cell from a 2D tensor to a 3D tensor as the input of the bidirectional GRU layer bidirectional_gru layer;
[0050] Use the Bidirectional wrapper to wrap the single GRU layer gru_cell into a bidirectional GRU layer bidirectional_gru layer;
[0051] Apply the attention mechanism to the bidirectional GRU layer bidirectional_gru layer, calculate the attention weights, and apply the attention weights to the output of the bidirectional GRU layer bidirectional_gru;
[0052] The discriminator output layer is used to map the hidden state of the discriminator modeling layer to a probability value between 0 and 1 using a sigmoid activation function.
[0053] Furthermore, the step of training the generative adversarial network also includes minimizing the cross-entropy loss function of the discriminator in the generative adversarial network, where the cross-entropy loss function is used to measure the difference between the predicted probability distribution of the discriminator and the true label probability distribution.
[0054] This specification provides a travel trajectory data generation device, including:
[0055] A data acquisition module, used to construct a dataset based on real travel trajectory data containing geographic coordinates, time, and travel trajectory category attributes;
[0056] The model building module is used to build a generative adversarial network and train the generative adversarial network based on the dataset:
[0057] The real travel trajectory data and random noise are input into the generator in the generative adversarial network. The generator converts the random noise into synthetic trajectory data based on the real travel trajectory data.
[0058] Input the real travel trajectory data and the synthetic trajectory data into the discriminator in the generative adversarial network, and output the probability value of the input real travel trajectory data and the synthetic trajectory data being real data;
[0059] The probability value of the synthetic trajectory data being real data is fed back to the generator. The generator minimizes the gap between the spatial similarity, temporal similarity, and category similarity between the random noise and the real travel trajectory data to maximize the probability value of the synthetic trajectory data being judged as real data by the discriminator.
[0060] Through repeated game between the generator and the discriminator, the probability value of the discriminator outputting the synthetic trajectory data as real data is maximized to obtain a trained generative adversarial network;
[0061] The data generation module is used to generate new travel trajectory data using the generator in the trained generative adversarial network.
[0062] This specification provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned travel trajectory data generation method is implemented.
[0063] This specification provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, the above-mentioned method for generating travel trajectory data is implemented.
[0064] At least one of the above technical solutions adopted in this specification can achieve the following beneficial effects:
[0065] The present invention trains a generative adversarial network through repeated games between a generator and a discriminator. During the game, the generator reduces the gap in spatial similarity, temporal similarity, and category similarity between random noise and real travel trajectory data to increase the probability that the discriminator will identify the output synthetic trajectory data as real data, thereby maximizing the probability that the discriminator will identify the output synthetic trajectory data as real data. That is, the synthetic trajectory data output by the generator is difficult for the discriminator to distinguish from the real travel trajectory data.
[0066] This training method forces the generator to learn the spatial and temporal features of real travel trajectory data, as well as the categorical features of different categories of real travel trajectory data. This multi-dimensional feature learning enables the trained generator to generate travel trajectory data that is more realistic in multiple dimensions, making the generated travel trajectory data more deceptive and better able to protect real data. BRIEF DESCRIPTION OF THE DRAWINGS
[0067] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0068] Figure 1 A flowchart of a method for generating travel trajectory data provided in this specification;
[0069] Figure 2 A framework diagram of a method for generating travel trajectory data provided in this manual
[0070] Figure 3 This is a schematic diagram of a travel trajectory data generating device provided in this specification;
[0071] Figure 4 A schematic diagram of a computer device for implementing a method for generating travel trajectory data provided in this specification. DETAILED DESCRIPTION
[0072] To make the purpose, technical solutions, and advantages of this specification more clear, the technical solutions of this application will be clearly and completely described below in conjunction with the specific embodiments of this specification and the corresponding drawings. Obviously, the embodiments described are only part of the embodiments of this application, not all of them. Based on the embodiments in this specification, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0073] Common methods for protecting travel trajectory privacy include fake travel trajectories, travel trajectory generalization, travel trajectory suppression, differential privacy, and deep learning. The first four methods all have privacy-preserving capabilities and their own unique characteristics, but they also have corresponding limitations. They all primarily obfuscate travel trajectory locations or add more uncertainty to protect privacy, significantly reducing the usability of travel trajectories. There is still a lack of a good balance between privacy protection and usability in the temporal and spatial dimensions. Existing methods also focus on the spatial dimension of travel trajectories, paying less attention to the time and event themes of travel trajectories. These two features also play a crucial role in identifying travel trajectory users. Once the data is leaked, attackers can use these two pieces of information to match travel trajectory users, resulting in serious travel trajectory privacy leaks.
[0074] Deep learning models have powerful data modeling capabilities and can learn and capture complex spatiotemporal dependencies from large-scale travel trajectory data. Through deep learning models, travel trajectory data can be more accurately modeled and predicted, extracting key information hidden in the data. In addition, combined with the GAN structure, the generator and discriminator are trained together, which can significantly improve the quality of synthetic travel trajectories. Rao et al. proposed an LSTM-TrajGAN method to generate privacy-protected synthetic travel trajectory data using a long short-term memory network (LSTM). Similarly, Zhang et al. proposed a publishing mechanism based on LSTM-GAN, LGAN-DP, which also uses LSTM and GAN to generate synthetic travel trajectories and uses differential privacy to process the results of travel trajectory data publishing, thereby improving data privacy. Zhao et al. proposed a temporal graph convolutional network (T-GCN) that combines a graph convolutional network (GCN) and a gated recurrent unit (GRU) to build a deep neural network model that can adapt to more complex temporal and spatial dependencies. Compared with LSTM, it achieved certain optimizations. Jin et al. applied the T-GCN model to the field of travel trajectory privacy protection, performed spatiotemporal predictions on travel trajectories, and obtained Laplace noise based on the predicted privacy matrix.
[0075] Methods that rely solely on time tags and travel trajectory starting points to generate travel trajectories may ignore many other important factors that affect travel trajectory formation and behavior. Such simplified models may cause the generated travel trajectories to lack authenticity and accuracy because they fail to capture many common behavioral patterns and travel trajectory characteristics in the real world. Individual behavior in the real world is influenced by many factors, including individual preferences, social influences, environmental factors, etc. Ignoring these factors may cause the generated travel trajectories to lack diversity and authenticity because they fail to simulate various behavioral patterns and behavioral preferences in the real world. Therefore, in order to generate more realistic and accurate travel trajectory data, it is necessary to comprehensively consider multiple factors such as time, space, behavior, and environment, and adopt more complex and comprehensive models to generate travel trajectories to ensure that the generated travel trajectories have high authenticity and accuracy, thereby improving their ability to protect real data and practicality.
[0076] Based on this, an embodiment of the present application provides a method for generating and protecting travel trajectories based on a generative adversarial network (GAN). The method aims to balance the relationship between service quality optimization and user privacy protection, and to evaluate the performance of synthetic travel trajectories in terms of feature preservation and privacy protection in multiple dimensions. The method includes: S1, the travel trajectory publisher encodes travel trajectory data (including geographic coordinates, date and time, user ID, and travel trajectory ID) and converts the original travel trajectory data into a specific format; S2, the travel trajectory publisher uses a GAN to input the real travel trajectory and random noise into a travel trajectory generator to generate a synthetic travel trajectory; S3, the synthetic travel trajectory output by the travel trajectory generator and the real travel trajectory are input into a travel trajectory discriminator, and the travel trajectory discriminator outputs a probability value of the travel trajectory being real; S4, through repeated game play between the travel trajectory generator and the travel trajectory discriminator, high-quality travel trajectory data is synthesized; S5, the travel trajectory publisher uses travel trajectory-user matching and mutual information to evaluate the privacy protection effect of the travel trajectory generated by the model; and uses Hausdorff distance, Jaccard index, mean squared error, and mean absolute error to evaluate the spatiotemporal characteristics of the travel trajectory generated by the model.
[0077] The following describes in detail the technical solutions provided by various embodiments of the present application in conjunction with the accompanying drawings.
[0078] Figure 1 and Figure 2 The flow chart and framework diagram of the method for generating travel trajectory data include the following steps:
[0079] S1: Construct a dataset based on real travel trajectory data containing geographic coordinates, time, and travel trajectory category attributes. The travel trajectory publisher encodes the travel trajectory data (including geographic coordinates, date and time, category, user ID, and travel trajectory ID) and converts the original travel trajectory data into a specific format. The travel trajectory data contains geographic coordinates, time, and travel trajectory category attributes. Specifically, it includes:
[0080] S11: The travel trajectory publisher introduces a travel trajectory encoding model when encoding the travel trajectory data and encodes the travel trajectory points. S11 includes the following steps (S1) to (2).
[0081] Step (1), the trajectory point coding uses the centroid of all the trajectories in the dataset to normalize all the longitudes and latitudes for the location attribute, and obtains the deviation between the longitude and latitude and the centroid: Δlat i ,Δlon i .
[0082] Step (2) of the travel trajectory point encoding uses a one-hot encoder for time attributes and categorical attributes, converting categorical variables into a form that is easily usable by machine learning algorithms. The attributes are encoded into high-dimensional binary vectors based on their vocabulary. The "Day" attribute in the time attribute is encoded as a 7-bit binary vector, the "Hour" attribute is encoded as a 24-bit binary vector, and the "Category" attribute in the categorical attribute is encoded as a 10-bit binary vector. The user ID and travel trajectory ID are not encoded and are used to indicate the user and the travel trajectory to which the point belongs.
[0083] S12: The travel trajectory publisher stores all attributes of the travel trajectory in a multi-dimensional matrix, where the first dimension of the multi-dimensional matrix represents the index of each travel trajectory.
[0084] Since the length of each travel trajectory data (that is, the number of travel trajectory points) is a variable, the travel trajectory publisher uses travel trajectory padding technology to ensure that the length of all travel trajectories is consistent with the longest travel trajectory. In this way, data of the same size can be used for batch processing and applied to the training of deep learning models, speeding up the training process.
[0085] S2: Build a generative adversarial network and train it based on the dataset. The publisher of the travel trajectory uses the generative adversarial network to input the real travel trajectory and random noise into the travel trajectory generator. The generator converts the random noise into synthetic trajectory data based on the real travel trajectory data. Specifically, it includes:
[0086] S21: The input layer of the travel trajectory generator is used to receive the travel trajectory data and the noise vector. The noise vector is used to introduce randomness into the data.
[0087] S22: The embedding layer of the travel trajectory generator uses a multi-layer perceptron (MLP) to embed the input data. S22 includes the following steps (1) to (4).
[0088] In step (1), create an empty embedding list embeddings, then traverse the key list of input features (the type of data information contained in each travel trajectory), define an embedding layer for each feature, and select different processing methods based on the given key value.
[0089] In step (2), if the key is longitude and latitude, create an input layer with a shape of (self.max_length, self.vocab_size[key]) and use the Lambda function to split the input tensor into a list along axis 1 to process the longitude and latitude features of each time step. Create an MLP layer that contains a fully connected layer with 64 neurons and uses the ReLU activation function. Input each split tensor into the MLP layer separately to obtain a list of results after MLP processing. Use the Lambda function to stack the processed result list back into a tensor to serve as the input of the network.
[0090] In step (3), if the key is not latitude and longitude, similar steps are taken as above, but the number of neurons in the Dense layer is set to the vocabulary size corresponding to the specific attribute.
[0091] In step (4), the processed results are stacked again through the Lambda layer to form the final embedding representation e.
[0092] In S23: the travel trajectory generator concatenates the output of the embedding layer in the feature fusion layer. S23 includes the following steps (1) to (3).
[0093] Step (1) concatenates the output of the previous embedding layer along the third dimension (axis = 2, in a tensor, dimensions are usually numbered starting from 0. For example, a two-dimensional tensor has two dimensions, which can be represented by 0 and 1 respectively. In a three-dimensional tensor, in addition to rows and columns, there is an additional dimension, usually called the depth dimension or the third dimension.) and converts the concatenated tensor into a list, where each element in the list corresponds to an original time step.
[0094] In step (2), the concatenated tensor is input into a dense fully connected layer, and the output of the fully connected layer is converted into a tensor through the Lambda function.
[0095] Step (3) concatenates the elements in the list along the time step to obtain the output tensor emb_traj.
[0096] In S24, the travel trajectory generator generates continuous and consistent location travel trajectory data using the feature fusion data through the modeling layer. S24 includes the following steps (1) to (3).
[0097] Step (1) defines a single GRU layer gru_cell constructed using GRU, where the model parameters specify that the dimension of the GRU cell is 100, the activation function is relu, the length of the input tensor, the layer returns the complete sequence output, and the regularizer is l1.
[0098] The Gated Recurrent Unit (GRU) is a special recurrent neural network (RNN) unit that introduces a gating mechanism to mitigate the vanishing gradient problem encountered by traditional RNNs when processing long sequences of data. In a GRU, the gating mechanism helps the model learn when to update internal state and when to retain the old state. A single-item GRU layer (gru_cell) refers to a basic GRU network layer. This is a unidirectional GRU, meaning that when processing a sequence, it only considers the output of the previous time step and ignores information from subsequent time steps. Defining such a GRU layer requires specifying several key model parameters. For example, the GRU cell dimension is set to 100, meaning that the output of each GRU cell is a 100-dimensional vector. ReLU is also selected as the activation function, as its nonlinear properties help the network better learn and process complex relationships in the data. The length of the input tensor refers to the length of each input sequence. Furthermore, the GRU layer is configured to return a complete sequence output, meaning that for each time step in the input sequence, the GRU layer will have a corresponding output, thus preserving the integrity of the sequence data. To prevent model overfitting (i.e., preventing the model from performing too well on the training data and underperforming on new, unseen data), L1 regularization was introduced. L1 regularization is implemented by penalizing the absolute value of the model weights, which encourages the model to use more sparse weights, thereby simplifying the model's complexity and improving its generalization ability.
[0099] Step (2) uses the Bidirectional wrapper to wrap gru_cell into a bidirectional GRU layer bidirectional_gru.
[0100] The Bidirectional wrapper is a function provided by Keras (TensorFlow's high-level API) that is used to convert a unidirectional recurrent neural network layer (such as a GRU layer) into a bidirectional layer. The purpose of this wrapper is to enable the model to simultaneously consider forward and backward information in the sequence data. The bidirectional GRU layer (bidirectional_gru) consists of two independent GRU layers that run in parallel. One GRU layer processes the forward direction of the input sequence (from beginning to end), while the other GRU layer processes the reverse direction of the input sequence (from end to beginning). In this way, the output of each time step is a combination of information in both directions, providing the model with more comprehensive contextual information. Ultimately, the outputs of the two GRU layers are merged to form a richer sequence representation. By combining forward and backward sequence information, the bidirectional GRU layer can provide more accurate and comprehensive sequence analysis.
[0101] In step (3), the Attention layer is applied to bidirectional_gru, the attention weight is calculated, and the attention weight is applied to the output of bidirection_gru; the generator obtains the long-term dependency of several travel trajectory points in the real travel trajectory data through the bidirectional GRU layer with the attention mechanism, so as to generate synthetic travel trajectory data that is more similar to the real travel trajectory data.
[0102] The attention mechanism allows the model to focus on the most important parts of a sequence when processing sequential data. This mechanism recognizes that each time step in the sequence may contribute differently to the output, so it can assign different weights to each time step, allowing the model to pay more attention to those parts that are more important to the current task. When the attention mechanism is applied, the model automatically learns how to calculate the attention weights. These weights are determined based on the outputs of the forward and backward GRU layers, and the model uses these outputs to judge the importance of each time step to the entire sequence. Once the attention weights are calculated, they are applied to the output of the bidirectional GRU layer, which means that the weights adjust the output of each time step of the bidirectional GRU layer, causing the model to pay more attention to those time steps determined by the attention mechanism to be important. In this way, the attention mechanism can help the model generate more accurate location and travel trajectory data because it can adjust the weight of each time step based on the dynamic characteristics of the sequence, thereby better capturing the key information in the sequence data.
[0103] In S25: the travel trajectory generator processes the output of the modeling layer through the time distribution layer to generate the required synthetic travel trajectory. S25 includes the following steps (1) to (2).
[0104] In step (1), for the latitude and longitude data (lat_lon), the output layer uses a dense layer with the activation function tanh to map the generated coordinates to the appropriate range.
[0105] In step (2), for other attribute data, the output layer uses a dense layer with activation function softmax to convert the generated attribute values into probability distribution.
[0106] S3: The synthetic travel trajectory and the real travel trajectory output by the travel trajectory generator are input into the travel trajectory discriminator. The travel trajectory discriminator discriminates the input data and outputs the probability value of the input real travel trajectory data and synthetic travel trajectory data being real data. Specifically including:
[0107] S31: The input layer of the travel trajectory discriminator is used to receive travel trajectory data.
[0108] S32: The embedding layer of the trajectory discriminator uses a multi-layer perceptron (MLP) to embed the input data. S32 includes the following steps (1) to (4).
[0109] Step (1) creates an empty embedding list embeddings, then traverses the key list of the input features, defines an embedding layer for each feature, and selects different processing methods based on the given key value.
[0110] In step (2), if the key is longitude and latitude, an input layer i is created, and then the input is unpacked (unstacked) through the Lambda layer so that each time step can be processed in the time dimension. Next, an MLP layer d with 64 neurons, using the relu activation function and He initialization is defined through the Dense layer, and then this layer is applied to the input of each time step.
[0111] In step (3), if the key is not latitude and longitude, similar steps are taken as above, but the number of neurons in the Dense layer is set to the vocabulary size corresponding to the specific attribute.
[0112] In step (4), the processed results are stacked again through the Lambda layer to form the final embedding representation e.
[0113] S33: The trajectory discriminator concatenates the outputs of the embedding layer in the feature fusion layer. S33 includes the following steps (1) to (3).
[0114] Step (1) concatenates the output of the previous embedding layer along the third dimension (axis = 2), and converts the concatenated tensor into a list, where each element in the list corresponds to an original time step.
[0115] In step (2), the concatenated tensor is input into a dense fully connected layer, and the output of the fully connected layer is converted into a tensor through the Lambda function.
[0116] Step (3) concatenates the elements in the list along the time step to obtain the output tensor emb_traj.
[0117] S34: The travel trajectory discriminator models the temporal dynamics and long-term dependencies in the travel trajectory data. S34 includes the following steps (1) to (3).
[0118] In step (1), a single-item GRU layer gru_cell is defined using GRU, where the model parameters specify that the dimension of the GRU unit is 100, the activation function is relu, and the regularizer is l1.
[0119] In step (2), expand_dims is used to expand the dimension of gru_cell to (None, 1, 100), and the output of gru_cell is converted from a 2D tensor to a 3D tensor as the input of the bidirectional_gru layer.
[0120] Step (3), use the Bidirectional wrapper to wrap gru_cell into a bidirectional GRU layer bidirectional_gru.
[0121] In step (4), the Attention layer is applied to bidirectional_gru, the attention weight is calculated, and the attention weight is applied to the output of bidirection_gru. The discriminator obtains the long-term dependency of several travel trajectory points in the discriminator input data through the bidirectional GRU layer with the attention mechanism, so as to improve the ability to distinguish between real and generated data.
[0122] S35: The travel trajectory discriminator passes the output of the modeling layer through the sigmoid activation function to map the hidden state of the modeling layer to a probability value between 0 and 1.
[0123] S4: Feedback the probability value of the synthesized trajectory data being real data to the generator. The generator reduces the gap in spatial similarity, temporal similarity, and category similarity between random noise and real travel trajectory data to increase the probability value of the output synthesized trajectory data being judged by the discriminator as real data. After repeated game play between the travel trajectory generator and the travel trajectory discriminator, the probability value of the synthesized trajectory data output by the discriminator as real data is maximized, and the generator in the trained generative adversarial network is used to synthesize high-quality travel trajectory data. Specifically, it includes:
[0124] S41: The travel trajectory generator passes the synthesized travel trajectory as input to the travel trajectory discriminator.
[0125] S42: The travel trajectory discriminator uses the synthetic travel trajectory to evaluate the possibility that the synthetic travel trajectory is the true travel trajectory.
[0126] S43: Construct the model loss function, compare the similarity loss of the model data in the spatial, temporal and classification dimensions, and use this loss function to train the model. Iterative training updates the parameters and weights of the generator to improve the generator's ability to synthesize travel trajectories and the quality of travel trajectory data. The model loss function TrajLoss in S43 is defined as follows:
[0127] TrajLoss(y r ,y p ,t r ,t s )=αL BCE (y r ,y p )+βL s (t r ,t s )+γL t (t r ,t s )+cL c (t r ,t s )
[0128] Among them, y r 、y p Represent the true value label and the discriminator's prediction results for the trajectory, t r , t s Represent the real trajectory and the corresponding synthetic trajectory, L BCE Denotes the binary cross entropy loss function L s , L t , L c They represent the spatial similarity loss, temporal similarity loss, and category similarity loss between the real trajectory and the synthesized trajectory respectively. α, β, γ, and c correspond to the weights of the losses, and different weights can be assigned in different situations.
[0129] Spatial similarity refers to the degree of geographic proximity between the generated travel trajectory and the real travel trajectory. This includes the latitude and longitude of the travel trajectory points, the shape of the travel trajectory, the distance and direction of travel, and so on. By minimizing the spatial similarity loss, the generator can learn the spatial characteristics of the real travel trajectory, thereby generating travel trajectories that are more geographically realistic.
[0130] Temporal similarity refers to the degree to which the generated travel trajectory resembles the real travel trajectory in terms of temporal distribution. This includes factors such as the sampling time, dwell time, and movement speed of the travel trajectory points. By minimizing the temporal similarity loss, the generator can learn the temporal characteristics of the real travel trajectory, thereby generating a more temporally realistic travel trajectory.
[0131] Category similarity refers to the degree to which the generated trip trajectories are similar to the real trip trajectories in terms of category characteristics. This includes the category label of the trip trajectory (such as work, leisure, commuting, etc.), the user's movement pattern, and the semantic information of the trip trajectory. By minimizing the category similarity loss, the generator can learn the characteristics of trip trajectories of different categories, thereby generating trip trajectories that are more realistic in terms of category.
[0132] This training method forces the generator to comprehensively consider multi-dimensional features such as space, time, and category when generating travel trajectories, thereby generating more statistically realistic and comprehensive travel trajectory data. This helps to narrow the gap between generated data and real data, and improve the authenticity of the generated travel trajectories. The trained generator can generate travel trajectory data that is authentic in multiple dimensions, making the generated travel trajectories more deceptive and difficult to identify as fake data. This helps to use generated travel trajectory data instead of real data in scenarios where the privacy of real data needs to be protected, such as data publishing and data sharing.
[0133] For the loss function, the GAN function uses the binary cross entropy function BCE to handle binary classification problems. The loss is calculated by comparing the probability of the model output with the logarithmic probability of the true label. The L2 loss function (also known as the mean square error) calculates the average square difference between the predicted value and the true value. It has a good effect in measuring the spatial similarity of travel trajectories. The SCE loss function is used for multi-classification problems, where each sample can belong to one of multiple categories and is more suitable for L t and L c situation.
[0134] S5: The publisher of the travel trajectory uses travel trajectory-user matching and mutual information to evaluate the privacy protection effect of the travel trajectory generated by the model; and uses Hausdorff distance, Jaccard index, mean square error, and mean absolute error to evaluate the spatiotemporal characteristics of the travel trajectory generated by the model. Specifically, it includes:
[0135] S51: The publisher of the travel trajectory uses the travel trajectory-user matching index to evaluate the privacy protection effect of the travel trajectory generated by the model. S51 includes the following steps (1) to (3).
[0136] In step (1), MARC (Multi-aspect Travel Trajectory Classifier) is used to perform the TUL task on the test data and the synthetic data of the model, and the labels of the corresponding users are found by analyzing the various features of the travel trajectory.
[0137] In step (2), ACC@K is used to show the probability of correctly estimating the correct travel trajectory label among the K most likely labels.
[0138]
[0139] The T test is the set of travel trajectories in the test, and L is the set of K labels with the highest prediction probability of travel trajectory T.
[0140] In step (3), the average precision and recall of all classes of the model are evaluated using Macro-F1, Macro-P, and Macro-R.
[0141] Macro-P (macro precision): How many of the positive examples predicted by the model are real?
[0142]
[0143] Macro-R (macro recall): How many of all positive examples are successfully found by the model.
[0144]
[0145] Macro-F1: The harmonic mean of Macro-P and Macro-R, which takes into account both the precision and recall of the model. The calculation formula of the simple harmonic mean is known:
[0146]
[0147] Then the calculation formula of Macro-F1 is:
[0148]
[0149] S52: The publisher of the travel trajectory uses the mutual information indicator to evaluate the privacy protection effect of the travel trajectory generated by the model. Operation S52 includes the following steps (1) to (2).
[0150] In step (1), DBSCAN clustering is used to cluster the data, and the degree of clustering refinement is controlled by adjusting the EPSILON parameter and the MIN_SAMPLES parameter.
[0151] In step (2), the mutual_info_score function is used, with the cluster labels of the original and synthesized travel trajectories as parameters to obtain the mutual information value of the travel trajectories.
[0152] In sub-operation S53 , the travel trajectory publisher uses Hausdorff distance to evaluate the privacy protection effect of the travel trajectory generated by the model.
[0153] S53: Use the Hausdorff distance calculation formula to measure the similarity or difference between the two point sets of the real travel trajectory dataset A and the synthetic travel trajectory dataset B.
[0154] Its mathematical expression formula is as follows:
[0155] dH(A,B)=max(max(d(a,B)),max(d(b,A)))
[0156] Among them, d(a,B) represents the distance from point a to the nearest point in point set B, and d(b,A) represents the distance from point b to the nearest point in point set A.
[0157] S54: The publisher of the travel trajectory uses the Jaccard index to evaluate the privacy protection effect of the travel trajectory generated by the model. S54 includes the following steps (1) to (2):
[0158] Step (1): Calculate the convex hull of the original travel trajectory and the convex hull of the synthetic travel trajectory.
[0159] In step (2), the Jaccard index calculation formula is used to calculate the intersection and union between the convex hull of the original travel trajectory and the convex hull of the synthetic travel trajectory, and the Jaccard index is obtained by calculating the ratio between the intersection and the union.
[0160] Its mathematical expression is as follows:
[0161] J(A,B)=|A∩B| / |A∪B|
[0162] Among them, A represents the convex hull of the original travel trajectory, B represents the convex hull of the synthetic travel trajectory, |A∩B| represents the intersection of A and B, and |A∪B| represents the union of A and B.
[0163] S55: The publisher of the travel trajectory uses mean square error to evaluate the privacy protection effect of the travel trajectory generated by the model.
[0164] S55 uses the mean square error calculation formula to calculate the error of corresponding points between the predicted travel trajectory and the actual travel trajectory, adds the squares of the error values, and takes the average to obtain the mean square error.
[0165] Its mathematical expression is as follows:
[0166] MSE=(1 / n)*Σ(y_pred-y_true)^2
[0167] Where MSE represents the mean square error, n represents the number of data points, y_pred represents a data point in the predicted travel trajectory, and y_true represents the corresponding data point in the true travel trajectory.
[0168] S56: The publisher of the travel trajectory uses the mean absolute error to evaluate the privacy protection effect of the travel trajectory generated by the model.
[0169] S56 uses the mean absolute error calculation formula to calculate the error of corresponding points between the predicted travel trajectory and the actual travel trajectory, then adds the absolute value of each error value and takes the average to obtain the mean absolute error.
[0170] Its mathematical expression is as follows:
[0171] MAE=(1 / n)*Σ|y_pred-y_true|
[0172] Where MAE represents the mean absolute error, n represents the number of data points, y_pred represents a data point in the predicted travel trajectory, and y_true represents the corresponding data point in the true travel trajectory.
[0173] The above is a method for generating travel trajectory data provided by one or more embodiments of this specification. Based on the same idea, this specification also provides a corresponding travel trajectory data generating device, such as Figure 3 Shown, including:
[0174] The data acquisition module is used to construct a dataset based on real travel trajectory data containing geographic coordinates, time and travel trajectory category attributes.
[0175] The model building module is used to build a generative adversarial network and train the generative adversarial network based on the dataset:
[0176] The real travel trajectory data and random noise are input into the generator in the generative adversarial network. The generator converts the random noise into synthetic trajectory data based on the real travel trajectory data.
[0177] Input the real travel trajectory data and the synthetic trajectory data into the discriminator in the generative adversarial network, and output the probability value of the input real travel trajectory data and the synthetic trajectory data being real data;
[0178] The probability value of the synthetic trajectory data being real data is fed back to the generator. The generator reduces the gap between the spatial similarity, temporal similarity, and category similarity between the random noise and the real travel trajectory data to increase the probability value of the output synthetic trajectory data being judged by the discriminator as real data.
[0179] Through repeated games between the generator and the discriminator, the probability value of the discriminator outputting the synthetic trajectory data as real data is maximized to obtain a trained generative adversarial network.
[0180] The data generation module is used to generate new travel trajectory data using the generator in the trained generative adversarial network.
[0181] For the specific definition of the travel trajectory data generation device, please refer to the definition of the travel trajectory data generation method above, and will not be repeated here. The various modules in the above-mentioned travel trajectory data generation device can be implemented in whole or in part by software, hardware, or a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory of the computer device in software form, so that the processor can call and execute the corresponding operations of the above modules.
[0182] This specification also provides a computer-readable storage medium, which stores a computer program that can be used to execute the above Figure 1 Provided travel trajectory data generation method.
[0183] This manual also provides Figure 4 The structural diagram of the computer equipment shown in FIG. Figure 4 As shown in the figure, at the hardware level, the computer device includes a processor, an internal bus, a network interface, a memory, and a non-volatile memory. Of course, it may also include other hardware required for the business. The processor reads the corresponding computer program from the non-volatile memory into the memory and then runs it to achieve the above Figure 1 Provided travel trajectory data generation method.
[0184] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0185] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
Claims
1. A method for generating travel trajectory data, characterized in that: include: Construct a dataset based on real travel trajectory data containing geographic coordinates, time and travel trajectory category attributes; Construct a generative adversarial network consisting of a generator and a discriminator, and train the generative adversarial network based on the dataset: The real travel trajectory data and random noise are input into the generator, and the generator converts the random noise into synthetic trajectory data based on the real travel trajectory data; Input the real travel trajectory data and the synthetic trajectory data into the discriminator, and output the probability value of the real travel trajectory data and the synthetic trajectory data being the real data; The probability value of the synthetic trajectory data being real data is fed back to the generator. The generator minimizes the gap between the spatial similarity, temporal similarity, and category similarity between the random noise and the real travel trajectory data to maximize the probability value of the synthetic trajectory data being judged as real data by the discriminator. Through repeated game between the generator and the discriminator, the probability value of the discriminator outputting the synthetic trajectory data as real data is maximized to obtain a trained generative adversarial network; Use the generator in the trained generative adversarial network to generate new travel trajectory data.
2. The method for generating travel trajectory data according to claim 1, wherein: The real travel trajectory data including geographic coordinates, time and travel trajectory category attributes specifically includes: Acquiring travel trajectory data including a plurality of travel trajectory points, and encoding the travel trajectory data, wherein the travel trajectory points include spatial attributes, temporal attributes, and travel trajectory category attributes; For the geographic coordinates in the spatial attributes, all longitudes and latitudes are normalized using the centroid of all travel trajectory data in the dataset to obtain the deviation between the longitude and latitude and the centroid; Use a one-hot encoder to encode the Day attribute in the time attribute into a 7-bit binary vector, and encode the Hour attribute in the time attribute into a 24-bit binary vector; Use a one-hot encoder to encode the travel trajectory category attribute into a 10-bit binary vector; All attributes of the encoded travel trajectory data are stored in a multi-dimensional matrix, where the first dimension of the multi-dimensional matrix represents the index of each travel trajectory.
3. The method for generating travel trajectory data according to claim 2, wherein: The generative adversarial network includes a generator and a discriminator; both the generator and the discriminator include a bidirectional GRU layer with an attention mechanism, and the bidirectional GRU layer with an attention mechanism is used to capture the long-term dependencies between multiple travel trajectory points in the travel trajectory data; The generator uses a bidirectional GRU layer with an attention mechanism to capture long-term dependencies in the real travel trajectory data to generate synthetic travel trajectory data that is more similar to the real travel trajectory data. The discriminator obtains the long-term dependencies of the discriminator input data through a bidirectional GRU layer with an attention mechanism to improve the ability to distinguish between real and generated data.
4. The method for generating travel trajectory data according to claim 3, wherein: The generator includes a generator input layer, a generator embedding layer, a generator feature fusion layer, a generator modeling layer and a generator output layer; The generator input layer is used to receive travel trajectory data, noise vector, and mask information; The generator embedding layer uses a multi-layer perceptron (MLP) to embed the output of the generator input layer, including: Create an empty embedding list embeddings, traverse the key list of the multidimensional matrix, and define an embedding layer for each attribute; The generator feature fusion layer is used to splice the output of the generator embedding layer, including: Concatenate the output of the generator embedding layer along the third dimension and convert the concatenated tensor into a list where each element corresponds to a time step of the original. Input the concatenated tensor into a fully connected layer dense, and convert the output of the fully connected layer into a tensor through the Lambda function; Concatenate the elements in the list along the time step to get the output tensor emb_traj; The generator modeling layer is used to generate trajectory data, including: Define a single GRU layer gru_cell constructed using GRU; Use the Bidirectional wrapper to wrap the single GRU layer gru_cell into a bidirectional GRU layer bidirectional_gru; Apply the attention mechanism to the bidirectional GRU layer bidirectional_gru, calculate the attention weights, and apply the attention weights to the output of the bidirectional GRU layer bidirectional_gru; The generator output layer is used to output the synthetic travel trajectory, including: For spatial attribute data, the output layer uses a dense layer with the activation function tanh to map the generated coordinates to the appropriate range; For other attribute data, the output layer uses a dense layer with activation function softmax to convert the generated attribute values into probability distribution.
5. The method for generating travel trajectory data according to claim 3, wherein: The discriminator includes a discriminator input layer, a discriminator embedding layer, a discriminator feature fusion layer, a discriminator modeling layer and a discriminator output layer; The discriminator input layer is used to receive the travel trajectory data generated by the generator or the real travel trajectory data; The discriminator embedding layer uses a multi-layer perceptron (MLP) to embed the output of the discriminator input layer, including: Create an empty embedding list embeddings, traverse the key list of the multidimensional matrix, and define an embedding layer for each attribute; The discriminator feature fusion layer is used to splice the output of the discriminator embedding layer, including: Concatenate the output of the discriminator embedding layer along the third dimension and convert the concatenated tensor into a list where each element corresponds to an original time step. Input the concatenated tensor into a fully connected layer dense, and convert the output of the fully connected layer into a tensor through the Lambda function; Concatenate the elements in the list along the time step to get the output tensor emb_traj; The discriminator modeling layer is used to model the temporal dynamics and long-term dependencies in the travel trajectory data, including: Define a single GRU layer gru_cell built based on GRU; Use expand_dims to expand the dimension of the single GRU layer gru_cell to (None, 1, 100), and convert the output of the single GRU layer gru_cell from a 2D tensor to a 3D tensor as the input of the bidirectional GRU layer bidirectional_gru layer; Use the Bidirectional wrapper to wrap the single GRU layer gru_cell into a bidirectional GRU layer bidirectional_gru layer; Apply the attention mechanism to the bidirectional GRU layer bidirectional_gru layer, calculate the attention weights, and apply the attention weights to the output of the bidirectional GRU layer bidirectional_gru; The discriminator output layer is used to map the hidden state of the discriminator modeling layer to a probability value between 0 and 1 using a sigmoid activation function.
6. The method for generating travel trajectory data according to claim 1, wherein: The step of training the generative adversarial network also includes minimizing a cross-entropy loss function of a discriminator in the generative adversarial network, where the cross-entropy loss function is used to measure the difference between the predicted probability distribution output by the discriminator and the true label probability distribution.
7. A travel trajectory data generating device, characterized in that: include: A data acquisition module, used to construct a dataset based on real travel trajectory data containing geographic coordinates, time, and travel trajectory category attributes; The model building module is used to build a generative adversarial network and train the generative adversarial network based on the dataset: The real travel trajectory data and random noise are input into the generator in the generative adversarial network. The generator converts the random noise into synthetic trajectory data based on the real travel trajectory data. Input the real travel trajectory data and the synthetic trajectory data into the discriminator in the generative adversarial network, and output the probability value of the input real travel trajectory data and the synthetic trajectory data being real data; The probability value of the synthetic trajectory data being real data is fed back to the generator. The generator minimizes the gap between the spatial similarity, temporal similarity, and category similarity between the random noise and the real travel trajectory data to maximize the probability value of the synthetic trajectory data being judged as real data by the discriminator. Through repeated game between the generator and the discriminator, the probability value of the discriminator outputting the synthetic trajectory data as real data is maximized to obtain a trained generative adversarial network; The data generation module is used to generate new travel trajectory data using the generator in the trained generative adversarial network.
8. A computer-readable storage medium, characterized in that The storage medium stores a computer program, and when the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.
9. A computer device, characterized in that: The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the method according to any one of claims 1 to 6 is implemented.
Citation Information
Patent Citations
A method for generating vehicle trajectories
CN110223515B