GPS track representation method and device based on double-view encoder, and storage medium

By constructing a GPS trajectory representation method of a dual-view encoder, the sequence of interest is directly processed, and combining structure and timing view, the error problem introduced by trajectory alignment in the existing method is solved, and efficient and accurate trajectory representation is achieved.

CN120371930APending Publication Date: 2025-07-25UNIV OF ELECTRONICS SCI & TECH OF CHINA
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510443011.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-09
Publication Date
2025-07-25

AI Technical Summary

Technical Problem

The existing GPS trajectory representation method needs to align the trajectory length in advance, resulting in noise interference and errors, and fail to effectively utilize the structural characteristics between trajectories.

Method used

A GPS trajectory representation method based on a dual-view encoder is constructed, and a sequence of points of interest is generated through K-means clustering, combining structure and timing view encoder, using graph attention and self-attention mechanisms to optimize the trajectory representation vector.

Benefits of technology

The need to align the trajectory lengths improves the accuracy and efficiency of trajectory representation, enhances the generalization ability of the model, and significantly improves the accuracy of trajectory relationships.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120371930A_ABST
    Figure CN120371930A_ABST
Patent Text Reader

Abstract

The invention relates to the field of GPS track data processing, and provides a GPS track representation method and device based on a double-view encoder and a storage medium. The method aims at solving the problem that errors are caused by the fact that an existing track representing method needs to align the track length in advance. Defining a data structure of a GPS track, and performing preprocessing to obtain a POI sequence; constructing a double-view track encoder, representing a POI sequence from two views of a structure and a time sequence, and performing double-view fusion to obtain a final track representation vector; the method comprises the following steps of: constructing a structure view StraucView, regarding a POI as a node and a POI sequence as a hyperedge, constructing a hypergraph, aggregating information through a graph attention mechanism, and generating a vector with a unified dimension; a time sequence view SeqView is implemented, probability distribution of a POI sequence is calculated as a prompt vector, the prompt vector is spliced with original features and then input into a GRU model, and vectors with unified dimensions are generated; and implementing a double-view fusion mechanism, and fusing the representation vectors of the two views through a self-attention mechanism to obtain a final trajectory representation vector.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of GPS trajectory data processing, and in particular, to a GPS trajectory representation method, device, and storage medium based on a dual-view encoder. Background Art

[0002] With the popularization of GPS technology, GPS trajectory data has important application values in fields such as traffic analysis and urban planning. Due to the varying lengths of trajectory data, existing methods usually need to align variable-length trajectories to a unified length before performing vector representation. Such preprocessing not only increases the computational complexity but also introduces noise due to padding or truncation operations, resulting in inaccurate representation of the relationships between trajectories. For example, existing technologies usually directly process the aligned trajectory sequences using recurrent neural networks, but the length alignment process will destroy the spatio-temporal distribution characteristics of the original trajectories.

[0003] Specifically, there are two types of operations for existing trajectory representation methods after obtaining the representation vectors by pre-aligning the trajectory lengths: one is to intercept the vector of the original trajectory length from the model output as the final representation, and the other is to directly use the aligned vector output by the model. Both of these methods need to force the alignment of the trajectory lengths through padding or sampling in the preprocessing stage, resulting in the introduction of redundant information (such as invalid padding points or repeated sampling points). Such redundant information will interfere with the extraction of the true features of the trajectories by the model, causing deviations in the calculation of the similarity between trajectories, and ultimately resulting in significant errors in the representation of the relationships between trajectories. In addition, existing methods mostly focus on the temporal feature modeling of single trajectories and fail to effectively mine the spatial structure associations of co-occurring points of interest (POIs) between trajectories, further restricting the accuracy of the representation model. Therefore, there is an urgent need for a trajectory representation method that does not require length alignment and can fuse spatio-temporal dual-view features to improve the accuracy and efficiency of traffic data analysis. Summary of the Invention

[0004] The purpose of the present invention is to solve the problems that existing GPS trajectory representation methods introduce errors due to the need to align trajectory lengths in advance and fail to fully utilize the structural characteristics between trajectories. By constructing structural and temporal dual-view encoders to directly fuse the POI sequence features, high-precision trajectory representation vectors can be generated without aligning the trajectories.

[0005] The present invention solves the problem that existing trajectory representation methods introduce errors due to the need to align trajectory lengths in advance through a GPS trajectory representation method that does not require advance alignment of trajectory lengths. The GPS trajectories are preprocessed into point-of-interest sequences, a dual-view trajectory encoder is constructed, the point-of-interest sequences are directly represented from the structural and temporal views without pre-aligning the trajectory lengths, and then dual-view fusion is performed to obtain the final trajectory representation vectors. The model is trained based on a weighted InfoNCE loss function to optimize the trajectory representation vectors. Thus, the effect of accurately representing the relationships between trajectories is achieved.

[0006] To achieve the above object, the present invention adopts the following technical means:

[0007] A GPS trajectory representation method based on a dual-view encoder, comprising the following steps:

[0008] Step 1, GPS trajectory data preprocessing, using the K-means clustering algorithm to cluster all trajectory points in the area to generate an interest point POI set; for each trajectory sequence, take the average of the longitude and latitude of the trajectory points in the POIs it passes through, and convert the trajectory sequence into a POI sequence;

[0009] Step 2, construct a dual-view trajectory encoder, represent the POI sequence generated in Step 1 from two views of structure and time series, and then perform dual-view fusion to obtain the final trajectory representation vector;

[0010] Step 3, implement the structure view StrucView, regard the POI as a node and the POI sequence as a hyperedge, construct a hypergraph and aggregate information through the graph attention mechanism to generate a vector H of a unified dimension struc ;

[0011] Step 4, implement the time series view SeqView, calculate the probability distribution of the POI sequence as a prompt vector, splice it with the original features and input it into the gated recurrent unit GRU model to generate a vector H of a unified dimension seq ;

[0012] Step 5, implement the dual-view fusion mechanism, and fuse the representation vectors of the two views generated in Step 3 and Step 4 through the self-attention mechanism to obtain the final trajectory representation vector.

[0013] In the above technical solution, Step 1 includes the following steps:

[0014] Step 1.1: Define the trajectory as TR = {p1, p2, …, p i , …, p l}, where p i is a binary tuple p i = (long, lat), representing a GPS data point of the trajectory, where long represents longitude and lat represents latitude;

[0015] Step 1.2: For all trajectory points}p1, p2, …, p l} in the area, use the K-means clustering algorithm for clustering to generate an interest point set POI =}POI1, POI2, …, POI k};

[0016] Step 1.3: For the trajectory sequence TR i , pass the POIs it passes throughk The longitude and latitude of the inner trajectory points are averaged to obtain the trajectory sequence TR; at the point of interest Original features:

[0017]

[0018] where M k is the number of trajectory points of TR i within long j and lat j are the longitude and latitude of the j-th trajectory point respectively, and k is the number of the POI;

[0019] Step 1.4: Convert the trajectory sequence TR i into a POI sequence where indicates that the i-th trajectory passes through the POI numbered j.

[0020] In the above technical solution, Step 3 includes the following steps:

[0021] Step 3.1: Construct a hypergraph, regard all the points of interest in the area as nodes in the hypergraph, regard the POI sequence as hyperedges in the hypergraph, and the hyperedges connect the points of interest passed in the sequence;

[0022] Step 3.2: Extract node features. For each point of interest POI k , calculate the average of the longitude and latitude of all its trajectory points as the node feature:

[0023]

[0024] where N k is the number of trajectory points belonging to POI k long i and lat i are the longitude and latitude of the i-th trajectory point respectively;

[0025] Step 3.3: Apply the graph attention mechanism to the nodes and hyperedges in the hypergraph, specifically:

[0026] For each hyperedge E, calculate the weighted sum of the node representations it connects as the initial representation of the hyperedge:

[0027]

[0028] where α E,k is the attention weight of the hyperedge E to the node POI k ;

[0029] For each node POI k, calculate the weighted sum of all hyperedge representations it participates in as the node's update table:

[0030]

[0031] where ε k is the set of hyperedges containing the node POI k , β k,E is the attention weight of the node POI k to the hyperedge E;

[0032] Step 3.4: For each hyperedge E, calculate the average of the updated representations of the nodes it connects to generate the final representation H of the hyperedge E , that is:

[0033]

[0034] where H struc is the representation vector output by the structural view, V E is the set of nodes connected by the hyperedge E, |V E | is the number of nodes.

[0035] In the above technical solution, step 4 includes the following steps:

[0036] Step 4.1: Construct a prompt vector, calculate according to the POI sequence obtained in step 1.4, specifically:

[0037] For the point of interest i in the POI sequence POI calculate the number of trajectory points c i of the corresponding trajectory TR passing through the point of interest j , and calculate the probability distribution of POI i passing through each point of interest according to the total number of trajectory points C of this trajectory:

[0038]

[0039] where get the prompt vector Hhint = [Pr(POI1), Pr(POI2), …, Pr(POIn)];

[0040] Step 4.2: Concatenate the prompt vector H hint with the feature vector of the POI sequence calculated in step 1.3 to form a new feature vector:

[0041]

[0042] where [;] represents the vector concatenation operation;

[0043] Step 4.3: Feed the concatenated feature vector F concat into the gated recurrent unit (GRU) model to generate a representation vector of a unified dimension:

[0044] H seq = GRU(F concat )

[0045] where H seq is the representation vector output by the temporal view.

[0046] In the above technical solution, Step 5 includes the following steps:

[0047] Step 5.1: Concatenate the structural view representation vector H struc obtained in Step 3 and the temporal view representation vector H seq obtained in Step 4 into a matrix H:

[0048] H = [H struc ; H seq

[0049] where [;] represents the vector concatenation operation, and d is the feature dimension;

[0050] Step 5.2: Apply a linear transformation to each column of the matrix H to calculate the self-attention weights:

[0051]

[0052] where Linear(H) calculates the weight vector through a linear layer;

[0053] Step 5.3: Use the self-attention weights W to perform a weighted sum on the matrix H to obtain the final trajectory representation vector:

[0054]

[0055] where H final is the final trajectory representation vector.

[0056] In the above technical solution, Step 6 is further included, which trains the model based on the weighted InfoNCE loss function to optimize the trajectory representation vector. Step 6 includes the following steps:

[0057] Step 6.1: Calculate the predicted Euclidean distance matrix D pred , specifically:

[0058] According to the final trajectory representation vector obtained in Step 5.3, where N is the number of samples and d is the feature dimension, calculate the Euclidean distance between each pair of samples:

[0059] D​pred [i, j] = ‖H i - H j ||²

[0060] where H i and H j are trajectory representation vectors, and it is the predicted Euclidean distance matrix;

[0061] Step 6.2: Normalize the true distance matrix D true as the soft contrast weight w i,j :

[0062]

[0063] where τ is the temperature coefficient, controlling the smoothness of the distribution;

[0064] Step 6.3: Construct a weighted contrastive loss function based on InfoNCE, specifically:

[0065] Construct the loss function by minimizing the difference between the predicted distance and the true distance:

[0066]

[0067] where the numerator represents the similarity weight of the positive samples, and the denominator represents the sum of the similarity weights of all negative samples. By optimizing this loss function, similar trajectories are close in the feature space, and dissimilar trajectories are far apart.

[0068] The present invention provides a GPS trajectory representation device based on a dual-view encoder, including:

[0069] A data preprocessing module, which is used to cluster all trajectory points in the area using the K-means clustering algorithm to generate a set of points of interest (POI); for each trajectory sequence, the average value of the longitude and latitude of the trajectory points in the POIs it passes through is taken, and the trajectory sequence is converted into a POI sequence;

[0070] A dual-view trajectory encoder construction module, which is used to represent the POI sequence generated by the data preprocessing module from two views of structure and time series, and then perform dual-view fusion to obtain the final trajectory representation vector;

[0071] A structure view implementation module, which is used to regard the POI as a node and the POI sequence as a hyperedge, construct a hypergraph and aggregate information through a graph attention mechanism to generate a vector H of a unified dimension struc ;

[0072] The timing view implementation module is used to calculate the probability distribution of the POI sequence as a prompt vector, which is concatenated with the original features and then input into the gated recurrent unit (GRU) model to generate a vector H with a unified dimension. seq ;

[0073] The dual-view fusion mechanism implementation module is used to fuse the representation vectors of the two views generated by the structure view implementation module and the timing view implementation module through the self-attention mechanism to obtain the final trajectory representation vector.

[0074] The present invention also provides a storage medium. When a processor executes a program in the storage medium, the described GPS trajectory representation method based on a dual-view encoder is implemented.

[0075] Since the present invention adopts the above technical solutions, the following beneficial effects are achieved:

[0076] Trajectory representation is a common task for analyzing urban traffic using urban vehicle GPS data. Existing trajectory representation methods have two types of operations after obtaining the representation vector by pre-aligning the trajectory lengths. One is to take the vector of the original trajectory length from the representation vector obtained by the model as the final representation, and the other is to directly use the representation vector obtained by the model as the final representation vector. Both methods add redundant information to the trajectory during preprocessing, which will lead to errors in the representation of the relationship between the final trajectories. Different from the existing methods, the present invention does not need to align the trajectory lengths in advance and directly represents the trajectory sequence, which not only avoids introducing redundant information into the trajectory but also improves the data preprocessing efficiency. In the present invention, the trajectory sequence is first processed into a point of interest (POI) sequence, which retains the key features of the trajectory. Then, the trajectory is represented from both structural and timing perspectives through a dual-view encoder, which can capture the features of the trajectory more comprehensively, thereby accurately representing the relationship between the trajectories. In addition, the dual-view fusion mechanism combines the self-attention mechanism, which can effectively integrate the structural and timing information, enhance the generalization ability of the model, and make it perform more stably in different scenarios. Finally, the model is trained through a weighted InfoNCE loss function, which further optimizes the trajectory representation vector, making similar trajectories close in the feature space and dissimilar trajectories far away. This significantly improves the accuracy and effectiveness of the trajectory representation. Description of the Drawings

[0077] Figure 1 It is a block diagram of a GPS trajectory representation method based on a dual-view encoder provided for the implementation of the present invention. Detailed Embodiments

[0078] The following will give a detailed description of the embodiments of the present invention. Although the present invention will be described and explained in conjunction with some specific embodiments, it should be noted that the present invention is not limited to these embodiments only. On the contrary, any modifications or equivalent replacements made to the present invention should be covered within the scope of the claims of the present invention.

[0079] In addition, for a better illustration of the present invention, numerous specific details are given in the following specific embodiments. Those skilled in the art will understand that the present invention can also be implemented without these specific details.

[0080] To achieve the above object, the present invention adopts the following technical means:

[0081] A GPS trajectory representation method based on a dual-view encoder, comprising the following steps:

[0082] Step 1, GPS trajectory data preprocessing: Use the K-means clustering algorithm to cluster all trajectory points in the area to generate an interest point POI set; for each trajectory sequence, take the average of the longitude and latitude of the trajectory points in the POIs it passes through, and convert the trajectory sequence into a POI sequence;

[0083] Step 2, construct a dual-view trajectory encoder: Represent the POI sequence generated in Step 1 from two views, namely the structure and the time series, and then perform dual-view fusion to obtain the final trajectory representation vector;

[0084] Step 3, implement the structure view StrucView: Regard the POI as a node and the POI sequence as a hyperedge, construct a hypergraph and aggregate information through a graph attention mechanism to generate a vector H with a unified dimension struc ;

[0085] Step 4, implement the time series view SeqView: Calculate the probability distribution of the POI sequence as a cue vector, concatenate it with the original features and input them into a gated recurrent unit GRU model to generate a vector H with a unified dimension seq ;

[0086] Step 5, implement the dual-view fusion mechanism: Through a self-attention mechanism, fuse the representation vectors of the two views generated in Step 3 and Step 4 to obtain the final trajectory representation vector.

[0087] In the above technical solution, Step 1 includes the following steps:

[0088] Step 1.1: Define the trajectory as TR = {p1, P2, …, p i , …, p l}, where p i is a binary tuple p i=(long, lat), representing a GPS data point of a trajectory, where long represents longitude and lat represents latitude;

[0089] Step 1.2: For all the trajectory points {p1, p2,..., p l} within the region, use the K-means clustering algorithm for clustering to generate a set of points of interest POI = {POI1, P0I2,..., POI k};

[0090] Step 1.3: For the trajectory sequence TR i , take the average of the longitudes and latitudes of the trajectory points passing through the point of interest POI k to obtain the original features of the trajectory sequence TR i at the point of interest :

[0091]

[0092] where M k is the number of trajectory points of TR i within , long j and lat j are the longitude and latitude of the j-th trajectory point respectively, and k is the number of the POI;

[0093] Step 1.4: Convert the trajectory sequence TR j into a POI sequence where indicates that the i-th trajectory passes through the point of interest numbered j.

[0094] In the above technical solution, Step 3 includes the following steps:

[0095] Step 3.1: Construct a hypergraph, regard all the points of interest within the region as nodes in the hypergraph, regard the POI sequence as hyperedges in the hypergraph, and the hyperedges connect the points of interest passed through in the sequence;

[0096] Step 3.2: Extract node features. For each point of interest POI k , calculate the average of the longitudes and latitudes of all its trajectory points as the node feature:

[0097]

[0098] where N k is the number of trajectory points belonging to POI k , long i and lat i are the longitude and latitude of the i-th trajectory point respectively;

[0099] Step 3.3: Apply the graph attention mechanism to the nodes and hyperedges in the hypergraph, specifically:

[0100] For each hyperedge E, calculate the weighted sum of the node representations it connects as the initial representation of the hyperedge:

[0101]

[0102] where α E,k is the attention weight of hyperedge E to node POI k ;

[0103] For each node POI k , calculate the weighted sum of all hyperedge representations it participates in as the updated representation of the node:

[0104]

[0105] where ε k is the set of hyperedges containing node POI k , β k,E is the attention weight of node POI k to hyperedge E;

[0106] Step 3.4: For each hyperedge E, calculate the average of the updated representations of the nodes it connects to generate the final representation H F of the hyperedge, that is:

[0107]

[0108] where H struc is the representation vector output by the structure view, V E is the set of nodes connected by hyperedge E, and |V E | is the number of nodes.

[0109] In the above technical solution, step 4 includes the following steps:

[0110] Step 4.1: Construct a prompt vector and calculate it according to the POI sequence obtained in step 1.4, specifically:

[0111] For the points of interest i in the POI sequence POI calculate the number of track points c i corresponding to the trajectory TR passing through the point of interest j , and calculate the probability distribution of POI i passing through each point of interest according to the total number of track points C of this trajectory:

[0112]

[0113] where Obtain the hint vector H hint = [Pr(POI1), Pr(POI2), …, Pr(POI n )];

[0114] Step 4.2: Concatenate the hint vector H hint with the feature vector of the POI sequence calculated in Step 1.3 to form a new feature vector:

[0115]

[0116] where [;] represents the vector concatenation operation;

[0117] Step 4.3: Feed the concatenated feature vector F concat into the gated recurrent unit (GRU) model to generate a representation vector of a unified dimension:

[0118] H seq = GRU(F concat )

[0119] where H seq is the representation vector output in the temporal view.

[0120] In the above technical solution, Step 5 includes the following steps:

[0121] Step 5.1: Concatenate the structure view representation vector H struc obtained in Step 3 and the temporal view representation vector H seq obtained in Step 4 into a matrix H:

[0122] H = [H struc ; H seq

[0123] where [;] represents the vector concatenation operation, d is the feature dimension;

[0124] Step 5.2: Apply a linear transformation to each column of the matrix H to calculate the self-attention weights:

[0125]

[0126] where Linear(H) calculates the weight vector through a linear layer;

[0127] Step 5.3: Use the self-attention weights W to perform weighted summation on the matrix H to obtain the final trajectory representation vector:

[0128]

[0129] where H final ​Is the final trajectory representation vector.

[0130] In the above technical solution, it further includes step 6 of training the model based on the weighted InfoNCE loss function to optimize the trajectory representation vector. Step 6 includes the following steps:

[0131] Step 6.1: Calculate the predicted Euclidean distance matrix D pred , specifically:

[0132] According to the final trajectory representation vector obtained in step 5.3 where N is the number of samples and d is the feature dimension, calculate the Euclidean distance between each pair of samples:

[0133] D pred [i, j] = ||H i -H j ||2

[0134] where H i and H j are trajectory representation vectors, is the predicted Euclidean distance matrix;

[0135] Step 6.2: Normalize the true distance matrix D true as the soft contrast weight w i,j :

[0136]

[0137] where τ is the temperature coefficient that controls the smoothness of the distribution;

[0138] Step 6.3: Construct a weighted contrast loss function based on InfoNCE, specifically:

[0139] Construct the loss function by minimizing the difference between the predicted distance and the true distance:

[0140]

[0141] where the numerator represents the similarity weight of the positive samples, and the denominator represents the sum of the similarity weights of all negative samples. By optimizing this loss function, similar trajectories are brought closer in the feature space, and dissimilar trajectories are moved farther apart.

[0142] The present invention provides a GPS trajectory representation device based on a dual-view encoder, including:

[0143] A data preprocessing module for clustering all trajectory points in the area using the K-means clustering algorithm to generate an interest point POI set; for each trajectory sequence, take the average of the longitude and latitude of the trajectory points in the POIs it passes through, and convert the trajectory sequence into a POI sequence;

[0144] A dual-view trajectory encoder construction module, which is used to represent the POI sequence generated by the data preprocessing module from two views of structure and time series, and then perform dual-view fusion to obtain the final trajectory representation vector;

[0145] A structure view implementation module, which is used to regard the POI as a node and the POI sequence as a hyperedge, construct a hypergraph and aggregate information through a graph attention mechanism to generate a vector H with a unified dimension struc ;

[0146] A time series view implementation module, which is used to calculate the probability distribution of the POI sequence as a prompt vector, splice it with the original features and input it into a gated recurrent unit GRU model to generate a vector H with a unified dimension seq ;

[0147] A dual-view fusion mechanism implementation module, which is used to fuse the representation vectors of the two views generated by the structure view implementation module and the time series view implementation module through a self-attention mechanism to obtain the final trajectory representation vector.

[0148] The present invention also provides a storage medium. When a processor executes a program in the storage medium, it implements the described GPS trajectory representation method based on a dual-view encoder.

[0149] Embodiment 1

[0150] In this embodiment, the publicly available taxi GPS trajectory dataset GeoLife is taken as an example to demonstrate the complete implementation process of the method of the present invention. This dataset contains 17,621 trajectories, each of which consists of multiple GPS points, and each point contains longitude and latitude information.

[0151] As Figure 1 shown, in an embodiment of the present invention, a GPS trajectory representation method based on a dual-view encoder is provided, including:

[0152] Step 1. GPS trajectory data preprocessing: Use the K-means clustering algorithm to cluster all trajectory points in the area to generate an interest point POI set; for each trajectory sequence, take the average of the longitude and latitude of the trajectory points in the POIs it passes through, and convert the trajectory sequence into a POI sequence. Specifically, this step is as follows:

[0153] Step 1.1: Define the trajectory data structure, and define a single trajectory as:

[0154] TR = {p1, p2,…, P i ,…, p l}

[0155] where p i=(long, lat) represents the longitude and latitude of the i-th GPS point. For example, if a certain trajectory contains 200 GPS points, then l = 200.

[0156] Step 1.2: Set the clustering parameter k = 1000 (adjusted according to the area size. In this embodiment, taking the area within the Fifth Ring Road in Beijing as an example, for all GPS points in the area, use the K-means clustering algorithm for clustering, input the longitude and latitude data of all trajectory points, output 1000 clustering categories, and define each category as an interest point to generate an interest point set POI = {POI1, POI2, ……, POI 1000}.

[0157] Step 1.3: For the trajectory sequence TR i , take the average of the longitudes and latitudes of the trajectory points passing through the interest point POI k to obtain the original features of the trajectory sequence TR i at the interest point :

[0158]

[0159] Where M k is the number of trajectory points of TR i within , long j and lat j are the longitude and latitude of the j-th trajectory point respectively, and k is the number of the POI. For example, for the trajectory sequence TR1, the trajectory points passing through the interest point POI 20 are {p4, p5, p6, p7}, then the feature of TR1 at POI 20 is the average of the longitudes and latitudes of these four points {p4, p5, p6, p7}.

[0160] Step 1.4: Convert the trajectory sequence TR i into a POI sequence Where represents that the i-th trajectory passes through the interest point numbered j. For example, the trajectory sequence TR1 can be converted into

[0161] Step 2: Construct a dual-view trajectory encoder to represent the POI sequence generated in Step 1 from the structural and temporal views, and then perform dual-view fusion to obtain the final trajectory representation vector.

[0162] Step 3: Implement the structural view StrucView, regard the POI as nodes and the POI sequence as hyperedges, construct a hypergraph and aggregate information through the graph attention mechanism to generate a vector H with a unified dimension strucFor example, the feature dimension of the POI node is (1000, 2). Implement the structure view StrucView encoding to obtain H struc with a dimension of (17621, 128). This step is specifically as follows:

[0163] Step 3.1: Construct a hypergraph. Consider all the points of interest in the area as nodes in the hypergraph, and consider the POI sequence as a hyperedge in the hypergraph. The hyperedge connects the points of interest passed through in the sequence;

[0164] Step 3.2: Extract node features. For each point of interest POI k , calculate the average of the longitudes and latitudes of all its trajectory points as the node feature:

[0165]

[0166] where N k is the number of trajectory points belonging to POI k , long i and lat i are the longitude and latitude of the i-th trajectory point respectively;

[0167] Step 3.3: Apply the graph attention mechanism to the nodes and hyperedges in the hypergraph. Specifically:

[0168] For each hyperedge E, calculate the weighted sum of the node representations it connects as the initial representation of the hyperedge:

[0169]

[0170] where α E,k is the attention weight of the hyperedge E to the node POI k ;

[0171] For each node POI k , calculate the weighted sum of all the hyperedge representations it participates in as the updated representation of the node:

[0172]

[0173] where ε k is the set of hyperedges containing the node POI k , β k,E is the attention weight of the node POI k to the hyperedge E;

[0174] Step 3.4: For each hyperedge E, calculate the average of the updated node representations it connects to generate the final representation H E of the hyperedge, that is:

[0175]

[0176] Among them, H struc is the representation vector output for the structure view, V E is the set of nodes connected by the hyperedge E, |V E | is the number of nodes.

[0177] Step 4: Implement the timing view SeqView, calculate the probability distribution of the POI sequence as the hint vector, and input it into the gated recurrent unit GRU model after splicing with the original features to generate a vector H with a unified dimension seq . For example, the number of POIs in a POI sequence is 24 (the specific number depends on the specific length of the POI sequence). The original feature dimension of this POI sequence is (1, 24, 3). After splicing the constructed hint vector with the original features, the feature dimension of this POI sequence is (1, 24, 4). Input 17,621 unequal-length POI sequences into the gated recurrent unit GRU model in sequence to obtain H seq with a dimension of (17,621, 128). This step is specifically as follows:

[0178] Step 4.1: Construct the hint vector, calculate according to the POI sequence obtained in Step 1.4, specifically:

[0179] For the point of interest i in the POI sequence POI calculate the number of track points c i of the corresponding track TR passing through the point of interest j , and calculate the probability distribution of POI i passing through each point of interest according to the total number of track points C of this track:

[0180]

[0181] Among them obtain the hint vector H hint = [Pr(PoI1), Pr(POI2), …, Pr(POI n )];

[0182] Step 4.2: Splice the hint vector H hint with the feature vector of the POI sequence calculated in Step 1.3 to form a new feature vector:

[0183]

[0184] where [;] represents the vector splicing operation;

[0185] Step 4.3: Input the spliced feature vector F concatFeed it into the recurrent gate unit (GRU) model to generate a representation vector of a unified dimension:

[0186] H seq = GRU(F concat )

[0187] where H seq is the representation vector output by the temporal view.

[0188] Step 5: Implement a dual-view fusion mechanism. Through the self-attention mechanism, fuse the representation vectors of the two views generated in Step 3 and Step 4 to obtain the final trajectory representation vector. For example, the dimension of H struc generated in Step 3 is (17621, 128), and the dimension of H seq generated in Step 4 is (17621, 128). After implementing the dual-view fusion mechanism, the dimension of the final trajectory representation vector is (17621, 128). This step is specifically as follows:

[0189] Step 5.1: Concatenate the structural view representation vector H struc obtained in Step 3 and the temporal view representation vector H seq obtained in Step 4 into a matrix H:

[0190] H = [H struc ; H seq

[0191] where [;] represents the vector concatenation operation, d is the feature dimension;

[0192] Step 5.2: Apply a linear transformation to each column of matrix H to calculate the self-attention weights:

[0193]

[0194] where Linear(H) calculates the weight vector through a linear layer;

[0195] Step 5.3: Use the self-attention weights W to perform a weighted sum on matrix H to obtain the final trajectory representation vector:

[0196]

[0197] where H final is the final trajectory representation vector.

[0198] In the above technical solution, it further includes Step 6. Train the model based on the weighted InfoNCE loss function to optimize the trajectory representation vector. Step 6 includes the following steps:

[0199] Step 6.1: Calculate the predicted Euclidean distance matrix D pred , specifically as follows:​

[0200] The final representation vector of the trajectory obtained according to step 5.3 where N is the number of samples and d is the feature dimension, and the Euclidean distance between each pair of samples is calculated as follows:

[0201] D pred [i, j] = ||H i - H j ||²

[0202] where H i and H j are the trajectory representation vectors, and it is the predicted Euclidean distance matrix. For example, the dimension of D pred is (17621, 17621).

[0203] Step 6.2: Normalize the true distance matrix D true as the soft contrast weight w i,j :

[0204]

[0205] where τ is the temperature coefficient that controls the smoothness of the distribution.

[0206] Step 6.3: Construct a weighted contrastive loss function based on InfoNCE, specifically:

[0207] Construct the loss function by minimizing the difference between the predicted distance and the true distance:

[0208]

[0209] where the numerator represents the similarity weight of the positive samples, and the denominator represents the sum of the similarity weights of all negative samples. By optimizing this loss function, similar trajectories are made closer in the feature space, and dissimilar trajectories are made farther apart. For example, the loss value in the first round of training is 7.93, the loss value in the second round of training is 7.77, and the loss value in the third round of training is 7.73, and the loss is continuously decreasing.

[0210] In summary, the present invention has the following characteristics:

[0211] 1. Avoid the error introduced by trajectory length alignment and improve the representation accuracy

[0212] Traditional methods need to align variable-length trajectories to a fixed length, resulting in redundancy or truncation and damaging the spatial relationships of trajectories. The present invention directly processes POI sequences through a dual-view encoder without preprocessing alignment, eliminating the resulting information loss and errors. The Structure View (StrucView) models the spatial associations between POIs using a hypergraph, and the Sequence View (SeqView) enhances the dynamic features of the sequence through probabilistic hint vectors. Both support variable-length inputs and retain the integrity of the original trajectories, thus significantly improving the representation accuracy.

[0213] 2. Multi-view feature fusion enhances the trajectory relationship modeling ability

[0214] The complex spatial interactions between POIs are captured through the hypergraph attention mechanism (Structure View), and the dynamic changes in movement patterns are captured by combining GRU temporal modeling (Sequence View). The complementary features of the dual views cover the spatial-temporal dual attributes of the trajectories. Further, the self-attention fusion mechanism dynamically weights the view contributions to adaptively strengthen the key features, enabling the final representation vector to more comprehensively represent the similarities and differences between trajectories.

[0215] 3. Introduce soft-weight contrastive learning to optimize the representation space distribution

[0216] Based on the weighted InfoNCE loss function, soft contrast weights are generated using the true distance matrix to guide the model to distinguish samples with different similarities. Compared with traditional binary contrastive learning, this method smoothly optimizes the clustering of similar trajectories and the separation of dissimilar trajectories through probabilistic weights, enhancing the discriminability of the feature space and making the representation vector have stronger generalization ability in downstream tasks such as traffic analysis and recommendation systems.

[0217] 4. Improve data processing efficiency and model scalability

[0218] The original trajectory points are abstracted into POI sequences through K-means clustering to reduce data complexity; the dual-view encoder processes the structural and temporal features in parallel to reduce computational redundancy. In addition, the design of the hypergraph construction and GRU model takes scalability into account and can adapt to large-scale trajectory data and diverse POI distribution scenarios, providing an efficient and robust trajectory representation basis for urban computing applications.

[0219] In summary, through the innovative dual-view coding architecture and fusion mechanism, the present invention overcomes the limitations of existing methods that rely on trajectory alignment, achieving significant improvements in trajectory representation accuracy, feature richness, and model efficiency, providing reliable technical support for intelligent applications based on GPS data.

Claims

1. A GPS trajectory representation method based on a dual-view encoder, characterized in that, It includes the following steps: Step 1: GPS trajectory data preprocessing. Use the K-means clustering algorithm to cluster all trajectory points in the area to generate an interest point (POI) set. For each trajectory sequence, take the average of the longitudes and latitudes of the trajectory points in the POIs it passes through, and convert the trajectory sequence into a POI sequence; Step 2: Construct a dual-view trajectory encoder to represent the POI sequence generated in Step 1 from both structural and temporal views, and then perform dual-view fusion to obtain the final trajectory representation vector; Step 3: Implement the structure view StrucView, treat the POI as a node, the POI sequence as a hyperedge, construct a hypergraph, and aggregate information through the graph attention mechanism to generate a vector H with a unified dimension strruc ; Step 4: Implement the timing view SeqView, calculate the probability distribution of the POI sequence as the hint vector, splice it with the original features and input them into the gated recurrent unit (GRU) model to generate a vector H with a unified dimension seq ; Step 5: Implement the dual-view fusion mechanism. Through the self-attention mechanism, fuse the representation vectors of the two views generated in Step 3 and Step 4 to obtain the final trajectory representation vector.

2. The method for representing GPS trajectories based on a dual-view encoder according to claim 1, wherein, Step 1 includes the following steps: Step 1.1: Define the trajectory as TR = {p1, p2, …, p i , …, p l}, where p i is a binary tuple, p i = (long, lat), representing a GPS data point of the trajectory, where long represents longitude and lat represents latitude; Step 1.2: For all trajectory points {p1, p2,..., p l} within the region, use the K-means clustering algorithm for clustering to generate a set of points of interest POI = {POI1, P012,..., POI k}; Step 1.3: For the trajectory sequence TR i , take the average of the longitudes and latitudes of the trajectory points within it passing through the point of interest POI k to obtain the trajectory sequence TR i The original features at the point of interest are as follows: where M k is the number of trajectory points within TR i in , long j and lat j are the longitude and latitude of the j-th trajectory point respectively, and k is the POI number; Step 1.4: Convert the trajectory sequence TR i into a POI sequence where indicates that the i-th trajectory passes through the POI numbered j.

3. A GPS trajectory representation method based on a dual-view encoder according to claim 1, wherein Step 3 includes the following steps: Step 3.1: Construct a hypergraph. Consider all the interest points in the area as nodes in the hypergraph, and consider the POI sequence as a hyperedge in the hypergraph. The hyperedge connects the interest points passed through in the sequence; Step 3.2: Extract node features. For each point of interest (POI) k calculate the average of the longitudes and latitudes of all trajectory points as the node feature: where N k is the number of trajectory points belonging to the POI k , long i and lat i are the longitude and latitude of the i-th trajectory point respectively; Step 3.3: Apply the graph attention mechanism to the nodes and hyperedges in the hypergraph. Specifically: For each hyperedge E, calculate the weighted sum of the representations of the nodes it connects as the initial representation of the hyperedge: where α E,k is the attention weight of the hyperedge E to the node POI k ; For each node POI k , calculate the weighted sum of all the hyperedges it participates in as the updated representation of the node: where ε k is the hyperedge set containing the node POI k , and β k,E is the attention weight of the node POI k to the hyperedge E; Step 3.4: For each hyperedge E, calculate the average of the updated representations of the nodes it connects to generate the final representation H of the hyperedge E , that is: Among them, H struc is the representation vector output for the structural view, V E is the set of nodes connected by the hyperedge E, |V E | is the number of nodes.

4. A GPS trajectory representation method based on a dual-view encoder according to claim 1, characterized in that Step 4 includes the following steps: Step 4.1: Construct a prompt vector, which is calculated according to the POI sequence obtained in Step 1.

4. Specifically: For the POI sequence POI i in the points of interest calculate the corresponding trajectory TR i passing through the points of interest the number of trajectory points c j , and calculate POI according to the total number of trajectory points C of this trajectory i the probability distribution of passing through each point of interest: Among them Obtain the hint vector H hint = [Pr(POI1), Pr(POI2), …, Pr(POI n )]; Step 4.2: Combine the prompt vector H hint with the feature vector of the POI sequence calculated in Step 1.3 to form a new feature vector: where [;] represents the vector concatenation operation; Step 4.3: Feed the concatenated feature vector F concat into the gated recurrent unit (GRU) model to generate a representation vector with a unified dimension: H seq = GRU(F concat ) Among them, H seq is the representation vector output by the timing view.

5. A GPS trajectory representation method based on a dual-view encoder according to claim 1, characterized in that Step 5 includes the following steps: Step 5.1: Concatenate the structural view representation vector H struc obtained in Step 3 seq and the temporal view representation vector H obtained in Step 4 into a matrix H: H = [H struc ; H seq ​ where [;] represents the vector concatenation operation, d is the feature dimension; Step 5.2: Apply a linear transformation to each column of the matrix H to calculate the self-attention weights: where Linear(H) calculates the weight vector through a linear layer; Step 5.3: Use the self-attention weights W to perform a weighted sum on the matrix H to obtain the final trajectory representation vector: Among which H fina1 is the final trajectory representation vector.

6. A GPS trajectory representation method based on a dual-view encoder according to claim 1, wherein, It also includes Step 6. Train the model based on the weighted InfoNCE loss function to optimize the trajectory representation vector. Step 6 includes the following steps: Step 6.1: Calculate the predicted Euclidean distance matrix D pred , specifically: The final representation vector of the trajectory obtained according to Step 5.3 where N is the number of samples and d is the feature dimension, and calculate the Euclidean distance between each pair of samples: D pred [i, j] = ‖H i -H j ||² Among which H i and H j are trajectory representation vectors, is the predicted Euclidean distance matrix; Step 6.2: Normalize the true distance matrix D true As the soft contrast weight w i,j : where τ is the temperature coefficient, which controls the smoothness of the distribution; Step 6.3: Construct a weighted contrastive loss function based on InfoNCE. Specifically: Construct a loss function By minimizing the difference between the predicted distance and the true distance: where the numerator represents the similarity weight of the positive sample, and the denominator represents the sum of the similarity weights of all negative samples. By optimizing this loss function, similar trajectories are close in the feature space, and dissimilar trajectories are far apart.

7. A GPS trajectory representation device based on a dual-view encoder, characterized in that, It includes: A data preprocessing module for using the K-means clustering algorithm to cluster all trajectory points in the area to generate an interest point (POI) set; For each trajectory sequence, take the average of the longitudes and latitudes of the trajectory points in the POIs it passes through, and convert the trajectory sequence into a POI sequence; A dual-view trajectory encoder construction module for representing the POI sequence generated by the data preprocessing module from both structural and temporal views, and then performing dual-view fusion to obtain the final trajectory representation vector; The structural view implementation module is used to regard POIs as nodes, POI sequences as hyperedges, construct a hypergraph and aggregate information through the graph attention mechanism to generate a vector H of a unified dimension struc ; The time series view implementation module is used to calculate the probability distribution of the POI sequence as a hint vector, which is concatenated with the original features and then input into the gated recurrent unit (GRU) model to generate a vector H with a unified dimension seq ; A dual-view fusion mechanism implementation module for fusing the representation vectors of the two views generated by the structural view implementation module and the temporal view implementation module through the self-attention mechanism to obtain the final trajectory representation vector.

8. A storage medium, characterized in that, When the processor executes the program in the storage medium, it implements the method as described in any one of claims 1-6.

Citation Information

Cited By

  • Task-adaptive trajectory representation learning method

    CN122241265A