A grid and road cooperative trajectory generation method and system
By constructing fine-grained feature vectors and temporal grid image sequences, combined with a multi-layer Transformer encoder and a multi-adjacency graph attention mechanism, the problem of insufficient grid and road representation and alignment is solved, improving the accuracy and robustness of trajectory generation, especially the ability to discriminate between temporal and spatial evolution.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NAT UNIV OF DEFENSE TECH
- Filing Date
- 2026-01-19
- Publication Date
- 2026-06-02
Smart Images

Figure CN121542366B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of trajectory representation and trajectory similarity discrimination, and specifically to a trajectory generation method and system that combines grid and road. Background Technology
[0002] Trajectory similarity determination is an important problem in trajectory analysis and has been widely applied in many scenarios such as trajectory clustering, anomaly detection, path planning, traffic optimization, and trajectory matching.
[0003] GPS trajectories have two representation forms: grid trajectories and road trajectories. Deep learning-based trajectory similarity discrimination methods can be divided into grid-based methods, road-based methods, and methods that utilize both grid and road trajectories simultaneously. Grid-based methods, such as "Chang, Yanchuan, Qi, et al. Contrastive Trajectory Similarity Learning with Dual-Feature Attention[C] / / 2023 IEEE 39th International Conference on Data Engineering (ICDE). 2023.", typically extract regional semantics and spatial neighborhood features from grid trajectories. Road-based methods, such as "Jiang, Jiawei, Pan, et al. Self-supervised Trajectory Representation Learning with Temporal Regularities and Travel Semantics[C] / / 2023 IEEE 39th International Conference on Data Engineering (ICDE). 2023.", generally extract road network topology and road attribute features from road trajectories. These works often model movement patterns because vehicles can only travel along road segments, and recent road network representation learning has validated the effectiveness of this approach. The method based on both trajectories combines the characteristics of grid trajectories and road trajectories, resulting in a more comprehensive and richer feature extraction for trajectories.
[0004] However, the existing trajectory generation methods mentioned above still have the following drawbacks:
[0005] 1. Insufficient unified representation and alignment
[0006] Most methods use only one of the two representations, grid or road, or use both representations but lack a common representation space and effective alignment mechanism. This results in the information of the two forms being fragmented and difficult to mutually verify and complement each other. After fusion, the similarity measurement is easily affected by the form bias, and the ranking is unstable.
[0007] 2. Insufficient fine-grained and temporal modeling on the mesh side.
[0008] A grid cell is often approximated by a single point or a few representative points, lacking explicit modeling of the movement of multiple points within the cell, the direction and distance of entering and leaving the boundary, and the evolution across time slices; the time dimension often relies on weak positional encoding or simple aggregation, with insufficient sequence discrimination information, and easily confuses trajectories that are "similar in shape but have different transit directions or time rhythms".
[0009] 3. Limited perception of roadside structures and static weighting of attributes
[0010] Structural modeling is often limited to adjacent neighborhoods, resulting in a small receptive field and difficulty in capturing multi-level or long-range topological consistency. Attributes such as road type, orientation, and length are often statically weighted, failing to dynamically highlight key attributes as the scene changes. This leads to insufficient ability to discriminate global trends and key transitions, as well as weak cross-city generalization capabilities. Summary of the Invention
[0011] The technical problem to be solved by this invention is that the existing methods for generating trajectories in conjunction with grids and roads lack unified representation and alignment, have insufficient fine-grained and temporal modeling on the grid side, limited structural perception on the road side, and static weighting of attributes, which leads to inaccurate trajectories and poor robustness.
[0012] This invention solves the above-mentioned technical problems through the following technical means: a trajectory generation method for grid and road coordination, comprising:
[0013] S1. The aggregate coordinates are obtained by weighted fusion of all trajectory points within each grid cell traversed by the grid trajectory. Cross-cell boundary features are extracted using the previous and current grid cells to obtain the Euclidean distance and entry direction angle of the cross-cell boundary. Fine-grained feature vectors are constructed using the aggregate coordinates, Euclidean distance of the cross-cell boundary, and entry direction angle. The grid trajectory data is sliced at fixed time intervals to construct a temporal grid image sequence. Multiple 3D convolutions are stacked on the temporal grid image sequence. The output results are concatenated with the fine-grained feature vectors and temporal embedding and positional encoding are added. The resulting sequence is input into a multi-layer Transformer encoder to obtain the grid trajectory vector.
[0014] S2. Linearly map the original attributes of the road edges in the road network of the road trajectory as the original output features of three adjacency graphs. Stack multiple layers of graph attention networks on the three adjacency graphs to obtain the output of the last layer of graph attention network on each adjacency graph. Fuse the outputs of the last layer of graph attention network on the three adjacency graphs to obtain the multi-adjacency graph fusion feature. Inject minute-level and week-level time codes and location codes into the multi-adjacency graph fusion feature. Then perform multi-head attention calculation on the obtained sequence for three attributes: road type, azimuth angle and length to obtain the road trajectory vector.
[0015] S3. Using the road trajectory vector as the query vector and the grid trajectory vector as the key vector and value vector, we obtain the fused features. We then perform a linear mapping on the fused features to obtain the trajectory vector that combines the road and grid features.
[0016] Furthermore, the aggregated coordinates are obtained by weighted fusion of all trajectory points within each grid cell traversed by the grid trajectory, including:
[0017] Collect the set of all trajectory points within each grid cell traversed by the grid trajectory on the map. , For the first The x and y coordinates of all trajectory points within a grid cell are used as weights, based on either dwell time or inverse velocity ratio. Perform a weighted average to obtain the aggregated coordinates within the grid cell:
[0018] (1)
[0019] in, For the first Aggregate x-coordinates within each grid cell For the first Aggregate ordinate within each grid cell For the first The first grid cell within the [number] grid cell The x and y coordinates of each trajectory point.
[0020] Furthermore, the step of extracting cross-cell boundary features using the previous and current grid cells to obtain the Euclidean distance and entry direction angle of the cross-cell boundary, and constructing a fine-grained feature vector using aggregated coordinates, the Euclidean distance of the cross-cell boundary, and the entry direction angle, includes:
[0021] Let the x and y coordinates of the last trajectory point of the previous grid cell be... The x and y coordinates of the first trajectory point of the current grid cell are Then the Euclidean distance across the unit boundary is:
[0022] (2)
[0023] Entering direction angle (3)
[0024] in, for function;
[0025] Finally, fine-grained feature vectors are obtained. .
[0026] Furthermore, the step of slicing the grid trajectory data at fixed time intervals to construct a temporal grid image sequence, and stacking multiple layers of 3D convolutions on the temporal grid image sequence, includes:
[0027] S1.2.1 Slice the grid trajectory data at fixed time intervals to construct a time-series grid image sequence. ;
[0028] S1.2.2, in Multiple layers of 3D convolutions are stacked, and the joint features of grid cells and time slices are extracted layer by layer:
[0029]
[0030] (4)
[0031] in, As the first activation function, This represents the total number of layers in the 3D convolution. For the first 3D convolutional layers For the first The feature tensor obtained after 3D convolution; after The feature tensor is obtained after 3D convolution. .
[0032] Furthermore, the output result is concatenated with a fine-grained feature vector and temporal embedding and positional encoding are added. The resulting sequence is input into a multi-layer Transformer encoder to obtain a grid trajectory vector, including:
[0033] For each grid event in the grid trajectory From the feature tensor Retrieve the spatiotemporal dynamic semantic vector at the corresponding location and with fine-grained feature vectors By concatenating the components and performing a linear transformation, a fused representation is obtained:
[0034] (5)
[0035] in, Indicates the first The time slice corresponding to each grid cell Indicates the first Traffic intensity of each grid cell, grid events Indicates time Inner The number of times each grid cell is accessed; For feature dimension splicing, Represents a linear transformation, embedding time. With position encoding Adding it to the fusion representation yields a new fusion representation:
[0036] (6)
[0037] in, For the first A new fused representation corresponding to each of the m grid cells is used to construct a sequence. In the sequence Add first The token is then input into a multi-layer Transformer encoder to obtain the hidden representation:
[0038] (7)
[0039] The hidden representation is obtained by linearly mapping to a unified dimension and taking the first dimension. The token is represented as the final grid trajectory vector:
[0040] (8)
[0041] in, express token tag.
[0042] Furthermore, the original attributes of road edges in the road network of the road trajectory are linearly mapped as the original output features of three adjacency graphs, namely, a direction graph, a length graph, and a travel time graph. Multiple layers of graph attention networks are stacked on each of the three adjacency graphs to obtain the output of the last stacked layer of graph attention network for each adjacency graph. The outputs of the last stacked layer of graph attention networks on the three adjacency graphs are fused to obtain a multi-adjacency graph fusion feature. Minute-level and week-level time encoding and location encoding are injected into the multi-adjacency graph fusion feature, including:
[0043] The original features of the road trajectory are projected into a unified latent space through linear mapping:
[0044] (9)
[0045] in, As the first activation function, It is the initial weight matrix. It is a characteristic of the original directed graph structure of the road network. These are the original properties of the roadside; stacked on the three adjacency graphs respectively. Layered graph attention network:
[0046] (10)
[0047] in, For the second activation function, Indicates the first Adjacency graph, Indicates the first The original output features on the adjacency graph. Indicates the first Stacked adjacency graphs Features output by layered graph attention networks The graph attention network represents the first... The first adjacency graph Layer operation functions, Indicates the first The adjacency matrix corresponding to each type of adjacency relationship; Indicates the first Layered graph attention network;
[0048] In the The output of the attention network stacked on the last layer of the adjacency graph is denoted as
[0049] (11)
[0050] Finally, the multi-adjacency graph fusion feature is obtained through multi-branch fusion.
[0051]
[0052] It is the third activation function. Represents the fusion weight matrix;
[0053] Inject coarse-grained temporal location codes into each road segment, that is:
[0054] (12)
[0055] in, The first representing the road trajectory The daily minutes corresponding to the segment trajectory The first representing the road trajectory The number of days per week corresponding to the segment of the trajectory. The first characteristic representing the fusion feature of a multi-adjacency graph is... Segment trajectory characteristics, The first of the road trajectory Coarse-grained temporal location encoding corresponding to segment trajectories; It is the first of the road trajectory Location encoding of road segment trajectories; the sequence is obtained by combining the coarse-grained temporal location encodings of each road segment. , This represents the trajectory of the nth segment.
[0056] Furthermore, the obtained sequence undergoes multi-head attention calculation for three attributes: road type, azimuth angle, and length, to obtain a road trajectory vector, including:
[0057] S2.2.1 For the attributes of each road segment, first map them to a hidden vector:
[0058] (13)
[0059] in, , , The first of each road trajectory Road type of segment trajectory Azimuth With length The corresponding hidden vector, Indicates the first The vector corresponding to the type attribute of the road segment trajectory. Azimuth The weight matrix, For length The weight matrix for any class of attributes ,structure
[0060] (14)
[0061] in, These represent the road type attribute, azimuth attribute, and length attribute, respectively. Indicates the first Attention matrix corresponding to class attributes Indicates the first Attention bias matrix corresponding to class attributes Indicates the first The trajectory segment in the first Feature vectors under class attributes Indicates the feature dimension;
[0062] In the attention of the bulls, As an additive bias added to the score:
[0063] (15)
[0064] in, , , They are respectively The query vector, key vector, and value vector corresponding to the class attributes. for , , The corresponding learnable matrix, for The attention score corresponding to the class attribute is used to obtain the Transformer output guided by each class attribute.
[0065] (16)
[0066] This process occurs in the sequence. Add a second one to the very front token;
[0067] S2.2.2 After obtaining the structural feature encoding through multi-feature adaptive fusion, the weights are then gated. Fuse and project onto the output dimension:
[0068] , (17)
[0069] in, This is the road trajectory vector after multi-attribute fusion. This is the weighted road trajectory vector. for The weight, finally, By linearly mapping to a unified dimension, the second... The token is represented as the final road trajectory vector. :
[0070] (18).
[0071] Furthermore, S3 includes:
[0072] Using road trajectory vectors as query vectors The grid trajectory vector serves as the key vector. Sum value vector , obtain fusion features :
[0073]
[0074] (19)
[0075] in, for , , The corresponding learnable matrix, This represents a feedforward neural network. express function, By linearly mapping to a unified dimension, the second... The token is represented as a trajectory vector that ultimately integrates road and grid features. :
[0076] (20).
[0077] The present invention also provides a trajectory generation system that coordinates grids and roads, comprising:
[0078] The grid trajectory encoder uses weighted fusion of all trajectory points within each grid cell traversed by the grid trajectory to obtain aggregated coordinates. It extracts cross-cell boundary features using the previous and current grid cells to obtain the Euclidean distance and entry direction angle of the cross-cell boundary. It constructs a fine-grained feature vector using the aggregated coordinates, the Euclidean distance of the cross-cell boundary, and the entry direction angle. The grid trajectory data is sliced at fixed time intervals to construct a temporal grid image sequence. Multiple layers of 3D convolutions are stacked on the temporal grid image sequence. The output is concatenated with the fine-grained feature vector and temporal embedding and position encoding are added. The resulting sequence is input into a multi-layer Transformer encoder to obtain the grid trajectory vector.
[0079] The road trajectory encoder is used to linearly map the original attributes of road edges in the road network of the road trajectory as the original output features of three adjacency graphs. Multi-layer graph attention networks are stacked on the three adjacency graphs to obtain the output of the last stacked graph attention network on each adjacency graph. The outputs of the last stacked graph attention network on the three adjacency graphs are fused to obtain the multi-adjacency graph fusion feature. Minute-level and week-level time codes and location codes are injected into the multi-adjacency graph fusion feature. The resulting sequence is then subjected to multi-head attention calculation of three attributes: road type, azimuth angle and length, to obtain the road trajectory vector.
[0080] The dual-objective cross-modal collaborative learning module is used to obtain fused features by using road trajectory vectors as query vectors and grid trajectory vectors as key and value vectors. The fused features are then linearly mapped to obtain trajectory vectors that fuse road and grid features.
[0081] Furthermore, the aggregated coordinates are obtained by weighted fusion of all trajectory points within each grid cell traversed by the grid trajectory, including:
[0082] Collect the set of all trajectory points within each grid cell traversed by the grid trajectory on the map. , For the first The x and y coordinates of all trajectory points within a grid cell are used as weights, based on either dwell time or inverse velocity ratio. Perform a weighted average to obtain the aggregated coordinates within the grid cell:
[0083] (1)
[0084] in, For the first Aggregate x-coordinates within each grid cell For the first Aggregate ordinate within each grid cell For the first The first grid cell within the [number] grid cell The x and y coordinates of each trajectory point.
[0085] Furthermore, the step of extracting cross-cell boundary features using the previous and current grid cells to obtain the Euclidean distance and entry direction angle of the cross-cell boundary, and constructing a fine-grained feature vector using aggregated coordinates, the Euclidean distance of the cross-cell boundary, and the entry direction angle, includes:
[0086] Let the x and y coordinates of the last trajectory point of the previous grid cell be... The x and y coordinates of the first trajectory point of the current grid cell are Then the Euclidean distance across the unit boundary is:
[0087] (2)
[0088] Entering direction angle (3)
[0089] in, for function;
[0090] Finally, fine-grained feature vectors are obtained. .
[0091] Furthermore, the step of slicing the grid trajectory data at fixed time intervals to construct a temporal grid image sequence, and stacking multiple layers of 3D convolutions on the temporal grid image sequence, includes:
[0092] S1.2.1 Slice the grid trajectory data at fixed time intervals to construct a time-series grid image sequence. ;
[0093] S1.2.2, in Multiple layers of 3D convolutions are stacked, and the joint features of grid cells and time slices are extracted layer by layer:
[0094]
[0095] (4)
[0096] in, As the first activation function, This represents the total number of layers in the 3D convolution. For the first 3D convolutional layers For the first The feature tensor obtained after 3D convolution; after The feature tensor is obtained after 3D convolution. .
[0097] Furthermore, the output result is concatenated with a fine-grained feature vector and temporal embedding and positional encoding are added. The resulting sequence is input into a multi-layer Transformer encoder to obtain a grid trajectory vector, including:
[0098] For each grid event in the grid trajectory From the feature tensor Retrieve the spatiotemporal dynamic semantic vector at the corresponding location and with fine-grained feature vectors By concatenating the components and performing a linear transformation, a fused representation is obtained:
[0099] (5)
[0100] in, Indicates the first The time slice corresponding to each grid cell Indicates the first Traffic intensity of each grid cell, grid events Indicates time Inner The number of times each grid cell is accessed; For feature dimension splicing, Represents a linear transformation, embedding time. With position encoding Adding it to the fusion representation yields a new fusion representation:
[0101] (6)
[0102] in, For the first A new fused representation corresponding to each of the m grid cells is used to construct a sequence. In the sequence Add first The token is then input into a multi-layer Transformer encoder to obtain the hidden representation:
[0103] (7)
[0104] The hidden representation is obtained by linearly mapping to a unified dimension and taking the first dimension. The token is represented as the final grid trajectory vector:
[0105] (8)
[0106] in, express token tag.
[0107] Furthermore, the original attributes of road edges in the road network of the road trajectory are linearly mapped as the original output features of three adjacency graphs, namely, a direction graph, a length graph, and a travel time graph. Multiple layers of graph attention networks are stacked on each of the three adjacency graphs to obtain the output of the last stacked layer of graph attention network for each adjacency graph. The outputs of the last stacked layer of graph attention networks on the three adjacency graphs are fused to obtain a multi-adjacency graph fusion feature. Minute-level and week-level time encoding and location encoding are injected into the multi-adjacency graph fusion feature, including:
[0108] The original features of the road trajectory are projected into a unified latent space through linear mapping:
[0109] (9)
[0110] in, As the first activation function, It is the initial weight matrix. It is a characteristic of the original directed graph structure of the road network. These are the original properties of the roadside; stacked on the three adjacency graphs respectively. Layered graph attention network:
[0111] (10)
[0112] in, For the second activation function, Indicates the first Adjacency graph, Indicates the first The original output features on the adjacency graph. Indicates the first Stacked adjacency graphs Features output by layered graph attention networks The graph attention network represents the first... The first adjacency graph Layer operation functions, Indicates the first The adjacency matrix corresponding to each type of adjacency relationship; Indicates the first Layered graph attention network;
[0113] In the The output of the attention network stacked on the last layer of the adjacency graph is denoted as
[0114] (11)
[0115] Finally, the multi-adjacency graph fusion feature is obtained through multi-branch fusion.
[0116]
[0117] It is the third activation function. Represents the fusion weight matrix;
[0118] Inject coarse-grained temporal location codes into each road segment, that is:
[0119] (12)
[0120] in, The first representing the road trajectory The daily minutes corresponding to the segment trajectory The first representing the road trajectory The number of days per week corresponding to the segment of the trajectory. The first characteristic representing the fusion feature of a multi-adjacency graph is... Segment trajectory characteristics, The first of the road trajectory Coarse-grained temporal location encoding corresponding to segment trajectories; It is the first of the road trajectory Location encoding of road segment trajectories; the sequence is obtained by combining the coarse-grained temporal location encodings of each road segment. , This represents the trajectory of the nth segment.
[0121] Furthermore, the obtained sequence undergoes multi-head attention calculation for three attributes: road type, azimuth angle, and length, to obtain a road trajectory vector, including:
[0122] S2.2.1 For the attributes of each road segment, first map them to a hidden vector:
[0123] (13)
[0124] in, , , The first of each road trajectory Road type of segment trajectory Azimuth With length The corresponding hidden vector, Indicates the first The vector corresponding to the type attribute of the road segment trajectory. Azimuth The weight matrix, For length The weight matrix for any class of attributes ,structure
[0125] (14)
[0126] in, These represent the road type attribute, azimuth attribute, and length attribute, respectively. Indicates the first Attention matrix corresponding to class attributes Indicates the first Attention bias matrix corresponding to class attributes Indicates the first The trajectory segment in the first Feature vectors under class attributes Indicates the feature dimension;
[0127] In the attention of the bulls, As an additive bias added to the score:
[0128] (15)
[0129] in, , , They are respectively The query vector, key vector, and value vector corresponding to the class attributes. for , , The corresponding learnable matrix, for The attention score corresponding to the class attribute is used to obtain the Transformer output guided by each class attribute.
[0130] (16)
[0131] This process occurs in the sequence. Add a second one to the very front token;
[0132] S2.2.2 After obtaining the structural feature encoding through multi-feature adaptive fusion, the weights are then gated. Fuse and project onto the output dimension:
[0133] , (17)
[0134] in, This is the road trajectory vector after multi-attribute fusion. This is the weighted road trajectory vector. for The weight, finally, By linearly mapping to a unified dimension, the second... The token is represented as the final road trajectory vector. :
[0135] (18).
[0136] Furthermore, the dual-objective cross-modal collaborative learning module is also used for:
[0137] Using road trajectory vectors as query vectors The grid trajectory vector serves as the key vector. Sum value vector , obtain fusion features :
[0138]
[0139] (19)
[0140] in, for , , The corresponding learnable matrix, This represents a feedforward neural network. express function, By linearly mapping to a unified dimension, the second... The token is represented as a trajectory vector that ultimately integrates road and grid features. :
[0141] (20).
[0142] The advantages of this invention are:
[0143] (1) This invention uses road trajectory vectors as query vectors and grid trajectory vectors as key and value vectors to obtain fused features, enabling the same trajectory to be consistently represented in the same space on both the grid side and the road side, thus solving the problem of insufficient unified representation and alignment. Fine-grained feature vectors and temporal grid image sequences are constructed on the grid side, simultaneously enhancing fine-grained and temporal modeling capabilities, thus solving the problem of insufficient fine-grained and temporal modeling on the grid side. Three types of adjacency graphs are introduced on the road side to obtain topological information combining near and far elements. Simultaneously, an attention mechanism guided by three types of attributes is used to ensure that different attributes receive reasonable weights under different tasks and scenarios, solving the problems of limited structural perception on the road side and static equal weighting of attributes. Therefore, the overall scheme generates more accurate trajectories with stronger robustness.
[0144] (2) Compared to existing methods that represent grid cells using only a single point or rely solely on geometric shape for discrimination, this invention explicitly encodes transitional semantics such as the direction of entry and exit from grid cells, distance to the boundary, and traversal time, and performs weighted aggregation on multiple points within a cell. This preserves fine-grained entry and exit boundary clues, accurately distinguishes trajectories with "similar shapes but different boundary transitions," reduces misclassification and confusion, and improves the hit rate and sorting stability of the top-ranked trajectories. Compared to existing methods that primarily rely on static spatial distribution or weak temporal location encoding, the multi-image spatiotemporal modeling step of this invention constructs trajectories into a sequence that evolves both temporally and spatially, fully characterizing cross-temporal change patterns through spatiotemporal modeling. This distinguishes trajectories with "geometric similarities but different temporal sequences," significantly enhancing the ability to discriminate temporal rhythm and sequence, and reducing erroneous recalls caused by temporal mismatches.
[0145] (3) Compared to local structure methods that aggregate only on adjacent roads, the multi-hop graph structure learning process of this invention simultaneously models multi-order adjacency with one hop, two hops, and above, expanding the receptive field of the structure and capturing long-distance dependencies and global consistency. This avoids classifying trajectories with "similar local segments but different overall directions" as similar, improving global structure discrimination and cross-regional robustness. Compared to existing methods that equally weight attributes such as road type, orientation, and length, this invention adaptively adjusts the importance of each attribute according to the scenario, allowing the model to focus on the road semantics most relevant to the task. This improves semantic expressiveness and discriminability, especially enhancing the ability to distinguish the preceding path and reducing missorting of highly similar interference samples.
[0146] (4) The advantage of the combination of "boundary-aware multi-point aggregation + multi-image spatiotemporal modeling" on the grid side of the present invention is that it preserves the details of entering and leaving the boundary and motion at the unit level, and captures the cross-time evolution at the sequence level, and the two complement each other. Compared with the schemes that only do space or only do time, this combination simultaneously suppresses two types of misjudgments: "same shape but different direction" and "same shape but different time", making the grid side representation more delicate and more stable.
[0147] (5) The advantages of the roadside “multi-hop structure learning + attribute guidance” combination of the present invention are: the multi-level structure provides topological information that combines near and far distances, and the attribute guidance dynamically highlights key attributes in different cities and different traffic situations, forming a synergistic gain of structure and semantics. Compared with the scheme that relies solely on local structure or static attributes, this combination is more reliable in global direction recognition and key transfer node discrimination, and has stronger cross-city generalization.
[0148] (6) The advantage of the overall combination of bilateral and cross-modal collaboration in this invention is that when the grid side provides fine-grained spatiotemporal clues and the road side provides multi-scale structure and semantics, the similarity measurement in the unified representation space is more robust after cross-modal alignment and complementarity (such as masking reconstruction with grid to supplement roads). Compared with the scheme of simply splicing the two sources of information or using them independently, this collaborative combination can maintain a higher hit rate and a lower average ranking when noise, missing information and matching errors are present. Attached Figure Description
[0149] Figure 1 This is a flowchart of a trajectory generation method for grid and road coordination disclosed in Embodiment 1 of the present invention. Detailed Implementation
[0150] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0151] Example 1
[0152] like Figure 1 As shown, Embodiment 1 of the present invention provides a trajectory generation method for grid and road coordination, comprising the following steps:
[0153] S1. Setting up a grid trajectory encoder; To simultaneously capture fine-grained dynamic patterns and multi-scale spatiotemporal features in a grid trajectory, this invention designs a dynamic spatiotemporal grid trajectory encoding framework oriented towards fine-grained features. This encoding framework mainly consists of two parts: boundary-aware multi-point aggregation and a multi-image dynamic spatiotemporal convolutional network. The specific process is as follows:
[0154] S1.1, Boundary-Aware Multi-Point Aggregation
[0155] Existing grid-based trajectory representation methods typically retain only one anchor point (such as the first GPS point) in each grid cell, often ignoring the motion details of multiple points within that cell, leading to a loss of spatiotemporal information, especially when complex motion patterns such as stationary or low-speed movement occur. To address this, this invention proposes a boundary-aware multi-point spatiotemporal aggregation strategy. By weighted fusion of key anchor points, it simultaneously encodes fine-grained spatial position changes within a cell and boundary transition patterns across cells into the feature vector.
[0156] S1.1.1 Multi-point aggregation and normalization
[0157] For grid trajectory First, collect the set of all trajectory points within each grid cell traversed by the grid trajectory on the map. , For the first The x and y coordinates of all trajectory points within a grid cell are used as weights, based on either dwell time or inverse velocity ratio. Perform a weighted average to obtain the aggregated coordinates within the grid cell:
[0158] (1)
[0159] in, For the first Aggregate x-coordinates within each grid cell For the first Aggregate ordinate within each grid cell For the first The first grid cell within the [number] grid cell The x and y coordinates of each trajectory point.
[0160] S1.1.2, Cross-cell boundary feature extraction: Let the previous grid cell (the...) The x and y coordinates of the final trajectory point (of -1 grid cells) are The current grid cell (the first one) The x and y coordinates of the first trajectory point (of 1 grid cell) are: Then the Euclidean distance across the unit boundary is:
[0161] (2)
[0162] The azimuth angle is defined as a unitized angle relative to due east.
[0163] (3)
[0164] in, for function; return The directional angle, by adding And normalize to [0,1].
[0165] The final 4D fine-grained feature vector It records fine-grained grid features.
[0166] S1.2, Multi-Image Dynamic Spatiotemporal Convolutional Network
[0167] The motion of a trajectory is influenced not only by details within local units but also by the combined effects of a larger spatial layout and temporal dynamics. To model the dynamic evolution of the trajectory, this invention introduces a three-dimensional convolutional network, which performs convolutions in a time-height-width three-dimensional space, thereby simultaneously capturing local spatial structure and temporal dependencies. The specific process is as follows:
[0168] S1.2.1, Grid Image Construction
[0169] The grid trajectory data is sliced at fixed time intervals to construct a time-series grid image sequence. ,in, For the number of time slices, Divide the grid cells into sizes. There are three corresponding channels: the longitude of the grid cell center, the latitude of the center, and the traffic intensity (the number of times the grid cell is accessed by the trajectory within the time slice).
[0170] S1.2.2 Dynamic Spatiotemporal Coding
[0171] exist Multiple layers of 3D convolutions are stacked, and the joint features of grid cells and time slices are extracted layer by layer:
[0172]
[0173] (4)
[0174] in, As the first activation function, This represents the total number of layers in the 3D convolution. For the first 3D convolutional layers For the first The feature tensor obtained after 3D convolution; after The feature tensor is obtained after 3D convolution. It simultaneously encodes the spatial neighborhood and temporal dynamic relationship, and then maps it to... 3D feature space.
[0175] For each grid event in the grid trajectory From the feature tensor Retrieve the spatiotemporal dynamic semantic vector corresponding to the time slice position in the middle. and with fine-grained feature vectors By concatenating the components and performing a linear transformation, a fused representation is obtained:
[0176] (5)
[0177] in, Indicates the first The time slice corresponding to each grid cell Indicates the first Traffic intensity of each grid cell, grid events Indicates time Inner The number of times each grid cell is accessed; For feature dimension splicing, Represents a linear transformation, embedding time. With position encoding Adding it to the fusion representation yields a new fusion representation:
[0178] (6)
[0179] in, For the first A new fused representation corresponding to each of the m grid cells is used to construct a sequence. In the sequence Add first The token is then input into a multi-layer Transformer encoder to model long-range dependencies, resulting in the hidden representation:
[0180] (7)
[0181] Finally, the hidden representation is linearly mapped to a unified dimension, and the first dimension is taken. The token is represented as the final grid trajectory vector:
[0182] (8)
[0183] in, express token tag.
[0184] Time embedding in the above process This is used to encode the dynamic features of a trajectory in the time dimension, enabling the model to perceive temporal changes. Position encoding. This is used to identify the spatial relationships of grid cells, helping the model capture spatial structure. The new fusion representation consists of the original features, temporal embeddings, and positional encodings, fusing spatiotemporal information. The fused representation sequence, composed of new fused representations of all mesh elements, serves as input for subsequent spatiotemporal modeling. A multi-layer Transformer encoder is used to process the representation sequence. Feature extraction is performed to capture the complex spatiotemporal dependencies between different grid cells. The first [CLS] token is in the sequence. The special identifier added at the very beginning is used to aggregate information from the entire sequence in the Transformer, and its output vector is ultimately used as a global representation of the entire grid trajectory.
[0185] S2. Setting up a road trajectory encoder; To fully model the structural and semantic features of road trajectories, this invention designs a multi-scale road trajectory representation framework based on structure-semantic collaboration. This multi-scale road trajectory representation framework consists of two parts: multi-hop graph structural representation learning and multi-feature adaptive fusion guided by road attributes. The specific process is as follows:
[0186] S2.1 Learning Multi-hop Graph Structure Representation
[0187] Given road network ,in, It's a roadside gathering. It is the adjacency matrix of the road network edges. These are the original attributes of the roadside. Each roadside has its own original attribute. This includes maximum speed limit, average travel time, road length, road direction, in / out degree, and road type. First, the original features are projected onto a unified latent space using a linear mapping:
[0188] (9)
[0189] in, As the first activation function, This is the initial weight matrix, used to map the original attribute features of the roadside to the latent space. It is the original directed graph structure of the road network. Based on this, in order to capture local and global structural dependencies, three adjacency graphs are stacked respectively. Layered graph attention network:
[0190] (10)
[0191] in, For the second activation function, Indicates the first Adjacency graph, Indicates the first The original output features on the adjacency graph. Indicates the first Stacking the first adjacency graph on a type of adjacency graph (such as a direction graph, length graph, or travel time graph) Features output by layered graph attention networks The graph attention network represents the first... The first adjacency graph Layer operation functions are used to aggregate adjacent node information. Indicates the first An adjacency matrix corresponding to each adjacency relationship defines the connectivity between nodes; Indicates the first Layered graph attention network;
[0192] In the The output of the attention network stacked on the last layer of the adjacency graph is denoted as
[0193] (11)
[0194] Finally, the multi-adjacency graph fusion feature is obtained through multi-branch fusion.
[0195]
[0196] It is the third activation function. This represents the fusion weight matrix, used to weight and fuse features extracted from different types of adjacency graphs, resulting in... This is equivalent to a lookup table for road segment representation in structure-aware computing. It should be noted that... Activation functions are used for nonlinear transformations. In this embodiment, the ReLU activation function is typically chosen to enhance the model's nonlinear expressive power. The activation function is used for feature normalization and non-linear mapping after the output of each layer of the graph attention network. In this embodiment, LeakyReLU can be used to avoid gradient sparsity. The activation function, typically ReLU or tanh, is used for nonlinear mapping after feature fusion of multi-branch graphs.
[0197] Given a road trajectory , For the nth segment of the road trajectory, the road trajectory is mapped to a sequence of road segments. To further enhance the temporal semantics, coarse-grained time encoding (minute-level and week-level) is injected into each road segment, i.e.:
[0198] (12)
[0199] in, The first representing the road trajectory The daily minutes corresponding to the segment trajectory The first representing the road trajectory The number of days per week corresponding to the segment of the trajectory. The first characteristic representing the fusion feature of a multi-adjacency graph is... Segment trajectory characteristics, This is the coarse-grained temporal location encoding for the k1th segment of the road trajectory; It is the first of the road trajectory Location encoding of road segment trajectories. The sequence obtained by combining coarse-grained temporal and location codes for each road segment. This serves as input for subsequent attribute-guided modeling.
[0200] S2.2, Road Attribute-Guided Multi-Feature Adaptive Fusion
[0201] Although multi-hop graph structure encoding captures multi-scale topological information of the road network, it does not explicitly distinguish the importance of different road attributes in the task context. Therefore, this invention proposes a road attribute-guided attention fusion mechanism, using the road trajectory's first hop as the basis for the second hop. Road type of segment trajectory Azimuth With length Three core attributes serve as guiding signals to dynamically adjust the self-attention weights in the Transformer.
[0202] S2.2.1 Attention Mechanism Guided by Road Attributes
[0203] Specifically, for the attributes of each road segment, they are first mapped to hidden vectors:
[0204] (13)
[0205] in, , , The first of each road trajectory Road type of segment trajectory Azimuth With length The corresponding hidden vector, Indicates the first The vector corresponding to the type attribute of the road segment trajectory. Azimuth The weight matrix, For length The weight matrix for any class of attributes ,structure
[0206] (14)
[0207] in, These represent the road type attribute, azimuth attribute, and length attribute, respectively. Indicates the first The attention matrix corresponding to the class attribute records the attention distribution among different trajectory segments. Indicates the first The attention bias matrix corresponding to the class attribute is used to introduce additional semantic or positional information. Indicates the nth trajectory segment at the th position. Feature vectors under class attributes, i.e., attribute representations of individual segments. Indicates the feature dimension.
[0208] In the attention of the bulls, As an additive bias added to the score:
[0209] (15)
[0210] in, , , They are respectively The query vector, key vector, and value vector corresponding to the class attributes. for , , The corresponding learnable matrix, for The attention score corresponding to the class attribute is used to obtain the Transformer output guided by each class attribute.
[0211] (16)
[0212] To aggregate the information of the entire sequence in the Transformer, this process involves... Add a second one to the very front token.
[0213] S2.2.2 After obtaining the structural feature encoding through multi-feature adaptive fusion, the weights are then gated. Fuse and project onto the output dimension:
[0214] , (17)
[0215] in, This is the road trajectory vector after multi-attribute fusion. This is the weighted road trajectory vector. for The weights are then linearly mapped to a unified dimension, and the second weight is taken. The token is represented as the final road trajectory vector. :
[0216] (18)
[0217] S3, Dual-objective cross-modal collaborative learning
[0218] To fully utilize the complementary information of grid trajectory and road trajectory modalities, this invention employs a cross-attention mechanism to fuse the representations of the two modalities. The road trajectory vector is used as the query vector. The grid trajectory vector serves as the key vector. Sum value vector , obtain fusion features :
[0219]
[0220] (19)
[0221] in, for , , The corresponding learnable matrix, This represents a feedforward neural network. express Function, take the second The token is represented as a trajectory vector that ultimately integrates road and grid features. :
[0222] (20)
[0223] Regarding the training objective, this invention employs a dual-objective optimization strategy:
[0224] 1) Cross-modal contrastive learning loss The constraint mesh and the road representation are aligned on the same trajectory to ensure the rationality and consistency of the fusion.
[0225] 2) Cross-modal MLM loss : By using grid representation to assist in the reconstruction of occluded road trajectories, the complementarity and robustness of the representation are improved. The final loss function is:
[0226] (twenty one)
[0227] During training, the network parameters are continuously adjusted and the value of the loss function is calculated until the value of the loss function is minimized. At this point, training is stopped, the network parameters are fixed, and an optimized network model is obtained. The optimized network model is then used to fuse the grid trajectory and the road trajectory to generate the final trajectory.
[0228] Through the above technical solution, the grid trajectory vector generation process of this invention maps the same trajectory to a grid sequence according to time slices. First, multi-point weighted aggregation is performed within each grid cell, and transition semantics such as the direction of entering and leaving the cell and the distance to the boundary are explicitly encoded to form fine-grained cell features. Then, the entire trajectory is constructed into a "time × space" grid image, and the local spatial and cross-temporal dynamic patterns are extracted using three-dimensional spatiotemporal convolution. This is then combined with temporal embedding and fed into a sequence encoder to output a global vector representation on the grid side. This branch solves the problem of difficulty in distinguishing between "same shape but different direction, different time rhythms" while preserving details such as stops, turns, and cross-cell crossings.
[0229] The road trajectory vector generation process of this invention obtains a road segment sequence through map matching of the trajectory, constructs multi-level adjacencies (one-hop, two-hop, and above) on the global road network map, and learns multi-scale structural features through a graph attention layer to expand the receptive field. Furthermore, attributes such as road type, orientation, length, speed limit, average travel time, and in / out degree are mapped as guiding signals, serving as the basis for adaptive attention and gating fusion, enabling the model to dynamically emphasize key attributes in different scenarios. Combined with temporal embedding and a sequence encoder, a global vector representation of the road is obtained. This branch enhances the discriminative power of global direction and key transitions, as well as the cross-city generalization ability.
[0230] The dual-objective cross-modal collaborative learning process of this invention uses grid vectors and road vectors of the same trajectory as positive pairings. Through contrastive learning, the two are compressed into a unified representation space to obtain a stable and comparable similarity metric. Simultaneously, continuous segment masking is performed on the road sequence, and reconstruction is assisted by grid-side information, forcing the two information paths to complement each other and improving robustness to missing and matching errors. During inference, explicit interactive fusion is performed using cross-attention with roads as queries and grids as keys / values, outputting a unified trajectory vector for retrieving the most similar trajectory in the vector database (improving hit rate and reducing average ranking).
[0231] The overall solution employs unified representation and stable alignment to reduce morphological bias. Fine-grained spatiotemporal mapping and multi-hop structures jointly enhance discriminative power, resulting in improved hit rates for the top few positions, lower average ranking, and reduced ranking jitter. A mesh-based road-filling masking and reconstruction mechanism increases tolerance for missing segments and map matching errors; the multi-hop structure and attribute adaptation improve cross-city and cross-time period migration capabilities. A unified vector space facilitates the integration of efficient approximate nearest neighbor retrieval structures, enabling low-latency retrieval in large-scale trajectory databases while maintaining the aforementioned accuracy and robustness advantages.
[0232] Example 2
[0233] Based on Embodiment 1, Embodiment 2 of the present invention further provides a trajectory generation system that coordinates grids and roads, comprising:
[0234] The grid trajectory encoder uses weighted fusion of all trajectory points within each grid cell traversed by the grid trajectory to obtain aggregated coordinates. It extracts cross-cell boundary features using the previous and current grid cells to obtain the Euclidean distance and entry direction angle of the cross-cell boundary. It constructs a fine-grained feature vector using the aggregated coordinates, the Euclidean distance of the cross-cell boundary, and the entry direction angle. The grid trajectory data is sliced at fixed time intervals to construct a temporal grid image sequence. Multiple layers of 3D convolutions are stacked on the temporal grid image sequence. The output is concatenated with the fine-grained feature vector and temporal embedding and position encoding are added. The resulting sequence is input into a multi-layer Transformer encoder to obtain the grid trajectory vector.
[0235] The road trajectory encoder is used to linearly map the original attributes of road edges in the road network of the road trajectory as the original output features of three adjacency graphs. Multi-layer graph attention networks are stacked on the three adjacency graphs to obtain the output of the last stacked graph attention network on each adjacency graph. The outputs of the last stacked graph attention network on the three adjacency graphs are fused to obtain the multi-adjacency graph fusion feature. Minute-level and week-level time codes and location codes are injected into the multi-adjacency graph fusion feature. The resulting sequence is then subjected to multi-head attention calculation of three attributes: road type, azimuth angle and length, to obtain the road trajectory vector.
[0236] The dual-objective cross-modal collaborative learning module is used to obtain fused features by using road trajectory vectors as query vectors and grid trajectory vectors as key and value vectors. The fused features are then linearly mapped to obtain trajectory vectors that fuse road and grid features.
[0237] Specifically, the aggregated coordinates are obtained by weighted fusion of all trajectory points within each grid cell traversed by the grid trajectory, including:
[0238] Collect the set of all trajectory points within each grid cell traversed by the grid trajectory on the map. , For the first The x and y coordinates of all trajectory points within a grid cell are used as weights, based on either dwell time or inverse velocity ratio. Perform a weighted average to obtain the aggregated coordinates within the grid cell:
[0239] (1)
[0240] in, For the first Aggregate x-coordinates within each grid cell For the first Aggregate ordinate within each grid cell For the first The first grid cell within the [number] grid cell The x and y coordinates of each trajectory point.
[0241] More specifically, the step of extracting cross-cell boundary features using the previous and current grid cells to obtain the Euclidean distance and entry direction angle of the cross-cell boundary, and constructing a fine-grained feature vector using aggregated coordinates, the Euclidean distance of the cross-cell boundary, and the entry direction angle, includes:
[0242] Let the x and y coordinates of the last trajectory point of the previous grid cell be... The x and y coordinates of the first trajectory point of the current grid cell are Then the Euclidean distance across the unit boundary is:
[0243] (2)
[0244] Entering direction angle (3)
[0245] in, for function;
[0246] Finally, fine-grained feature vectors are obtained. .
[0247] More specifically, the step of slicing the grid trajectory data at fixed time intervals to construct a temporal grid image sequence, and stacking multiple layers of 3D convolutions on the temporal grid image sequence, includes:
[0248] S1.2.1 Slice the grid trajectory data at fixed time intervals to construct a time-series grid image sequence. ;
[0249] S1.2.2, in Multiple layers of 3D convolutions are stacked, and the joint features of grid cells and time slices are extracted layer by layer:
[0250]
[0251] (4)
[0252] in, As the first activation function, This represents the total number of layers in the 3D convolution. For the first 3D convolutional layers For the first The feature tensor obtained after 3D convolution; after The feature tensor is obtained after 3D convolution. .
[0253] More specifically, the output result is concatenated with a fine-grained feature vector and temporal embedding and positional encoding are added. The resulting sequence is input into a multi-layer Transformer encoder to obtain a grid trajectory vector, including:
[0254] For each grid event in the grid trajectory From the feature tensor Retrieve the spatiotemporal dynamic semantic vector at the corresponding location and with fine-grained feature vectors By concatenating the components and performing a linear transformation, a fused representation is obtained:
[0255] (5)
[0256] in, Indicates the first The time slice corresponding to each grid cell Indicates the first Traffic intensity of each grid cell, grid events Indicates time Inner The number of times each grid cell is accessed; For feature dimension splicing, Represents a linear transformation, embedding time. With position encoding Adding it to the fusion representation yields a new fusion representation:
[0257] (6)
[0258] in, For the first A new fused representation corresponding to each of the m grid cells is used to construct a sequence. In the sequence Add first The token is then input into a multi-layer Transformer encoder to obtain the hidden representation:
[0259] (7)
[0260] The hidden representation is obtained by linearly mapping to a unified dimension and taking the first dimension. The token is represented as the final grid trajectory vector:
[0261] (8)
[0262] in, express token tag.
[0263] More specifically, the original attributes of road edges in the road network of the road trajectory are linearly mapped as the original output features of three adjacency graphs, namely, a direction graph, a length graph, and a travel time graph. Multiple layers of graph attention networks are stacked on each of the three adjacency graphs to obtain the output of the last stacked layer of graph attention network for each adjacency graph. The outputs of the last stacked layer of graph attention networks on the three adjacency graphs are fused to obtain a multi-adjacency graph fusion feature. Minute-level and week-level time encoding and location encoding are injected into the multi-adjacency graph fusion feature, including:
[0264] The original features of the road trajectory are projected into a unified latent space through linear mapping:
[0265] (9)
[0266] in, As the first activation function, It is the initial weight matrix. It is a characteristic of the original directed graph structure of the road network. These are the original properties of the roadside; stacked on the three adjacency graphs respectively. Layered graph attention network:
[0267] (10)
[0268] in, For the second activation function, Indicates the first Adjacency graph, Indicates the first The original output features on the adjacency graph. Indicates the first Stacked adjacency graphs Features output by layered graph attention networks The graph attention network represents the first... The first adjacency graph Layer operation functions, Indicates the first The adjacency matrix corresponding to each type of adjacency relationship; Indicates the first Layered graph attention network;
[0269] In the The output of the attention network stacked on the last layer of the adjacency graph is denoted as
[0270] (11)
[0271] Finally, the multi-adjacency graph fusion feature is obtained through multi-branch fusion.
[0272]
[0273] It is the third activation function. Represents the fusion weight matrix;
[0274] Inject coarse-grained temporal location codes into each road segment, that is:
[0275] (12)
[0276] in, The first representing the road trajectory The daily minutes corresponding to the segment trajectory The first representing the road trajectory The number of days per week corresponding to the segment of the trajectory. The first characteristic representing the fusion feature of a multi-adjacency graph is... Segment trajectory characteristics, The first of the road trajectory Coarse-grained temporal location encoding corresponding to segment trajectories; It is the first of the road trajectory Location encoding of road segment trajectories; the sequence is obtained by combining the coarse-grained temporal location encodings of each road segment. , This represents the trajectory of the nth segment.
[0277] More specifically, the obtained sequence is then subjected to multi-head attention calculations for three attributes: road type, azimuth angle, and length, to obtain a road trajectory vector, including:
[0278] S2.2.1 For the attributes of each road segment, first map them to a hidden vector:
[0279] (13)
[0280] in, , , The first of each road trajectory Road type of segment trajectory Azimuth With length The corresponding hidden vector, Indicates the first The vector corresponding to the type attribute of the road segment trajectory. Azimuth The weight matrix, For length The weight matrix for any class of attributes ,structure
[0281] (14)
[0282] in, These represent the road type attribute, azimuth attribute, and length attribute, respectively. Indicates the first Attention matrix corresponding to class attributes Indicates the first Attention bias matrix corresponding to class attributes Indicates the first The trajectory segment in the first Feature vectors under class attributes Indicates the feature dimension;
[0283] In the attention of the bulls, As an additive bias added to the score:
[0284] (15)
[0285] in, , , They are respectively The query vector, key vector, and value vector corresponding to the class attributes. for , , The corresponding learnable matrix, for The attention score corresponding to the class attribute is used to obtain the Transformer output guided by each class attribute.
[0286] (16)
[0287] This process occurs in the sequence. Add a second one to the very front token;
[0288] S2.2.2 After obtaining the structural feature encoding through multi-feature adaptive fusion, the weights are then gated. Fuse and project onto the output dimension:
[0289] , (17)
[0290] in, This is the road trajectory vector after multi-attribute fusion. This is the weighted road trajectory vector. for The weight, finally, By linearly mapping to a unified dimension, the second... The token is represented as the final road trajectory vector. :
[0291] (18).
[0292] More specifically, the dual-objective cross-modal collaborative learning module is also used for:
[0293] Using road trajectory vectors as query vectors The grid trajectory vector serves as the key vector. Sum value vector , obtain fusion features :
[0294]
[0295] (19)
[0296] in, for , , The corresponding learnable matrix, This represents a feedforward neural network. express function, By linearly mapping to a unified dimension, the second... The token is represented as a trajectory vector that ultimately integrates road and grid features. :
[0297] (20).
[0298] The above embodiments are only used to illustrate the technical solutions of the present invention, and are not intended to limit it. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A trajectory generation method that coordinates grid and road, characterized in that, include: S1. The aggregate coordinates are obtained by weighted fusion of all trajectory points within each grid cell traversed by the grid trajectory. Cross-cell boundary features are extracted using the previous and current grid cells to obtain the Euclidean distance and entry direction angle of the cross-cell boundary. Fine-grained feature vectors are constructed using the aggregate coordinates, Euclidean distance of the cross-cell boundary, and entry direction angle. The grid trajectory data is sliced at fixed time intervals to construct a temporal grid image sequence. Multiple 3D convolutions are stacked on the temporal grid image sequence. The output results are concatenated with the fine-grained feature vectors and temporal embedding and positional encoding are added. The resulting sequence is input into a multi-layer Transformer encoder to obtain the grid trajectory vector. S2. The original attributes of road edges in the road network of the road trajectory are linearly mapped to serve as the original output features of three adjacency graphs. Multiple layers of graph attention networks are stacked on each of the three adjacency graphs to obtain the output of the last stacked graph attention network for each adjacency graph. The outputs of the last stacked graph attention networks on the three adjacency graphs are fused to obtain a multi-adjacency graph fusion feature. Minute-level and week-level time codes and location codes are injected into the multi-adjacency graph fusion feature. The resulting sequence is then subjected to multi-head attention calculations for three attributes: road type, azimuth, and length, to obtain the road trajectory vector. S2 includes: The original features of the road trajectory are projected into a unified latent space through linear mapping: (9) in, As the first activation function, It is the initial weight matrix. It is a characteristic of the original directed graph structure of the road network. These are the original properties of the roadside; stacked on the three adjacency graphs respectively. Layered graph attention network: (10) in, For the second activation function, Indicates the first Adjacency graph, Indicates the first The original output features on the adjacency graph. Indicates the first Stacked adjacency graphs Features output by layered graph attention networks The graph attention network represents the first... The first adjacency graph Layer operation functions, Indicates the first The adjacency matrix corresponding to each type of adjacency relationship; Indicates the first Layered graph attention network; In the The output of the attention network stacked on the last layer of the adjacency graph is denoted as (11) Finally, the multi-adjacency graph fusion feature is obtained through multi-branch fusion. It is the third activation function. Represents the fusion weight matrix; Inject coarse-grained temporal location codes into each road segment, that is: (12) in, The first representing the road trajectory The daily minutes corresponding to the segment trajectory The first representing the road trajectory The number of days per week corresponding to the segment of the trajectory. The first characteristic representing the fusion feature of a multi-adjacency graph is... Segment trajectory characteristics, The first of the road trajectory Coarse-grained temporal location encoding corresponding to segment trajectories; It is the first of the road trajectory Location encoding of road segment trajectories; the sequence is obtained by combining the coarse-grained temporal location encodings of each road segment. , Represents the trajectory of the nth segment; The obtained sequence is then subjected to multi-head attention calculations for three attributes: road type, azimuth angle, and length, to obtain a road trajectory vector, including: S2.2.1 For the attributes of each road segment, first map them to a hidden vector: (13) in, , , The first of each road trajectory Road type of segment trajectory Azimuth With length The corresponding hidden vector, Indicates the first The vector corresponding to the type attribute of the road segment trajectory. Azimuth The weight matrix, For length The weight matrix for any class of attributes ,structure (14) in, These represent the road type attribute, azimuth attribute, and length attribute, respectively. Indicates the first Attention matrix corresponding to class attributes Indicates the first Attention bias matrix corresponding to class attributes Indicates the first The trajectory segment in the first Feature vectors under class attributes Indicates the feature dimension; In the attention of the bulls, As an additive bias added to the score: (15) in, , , They are respectively The query vector, key vector, and value vector corresponding to the class attributes. for , , The corresponding learnable matrix, for The attention score corresponding to the class attribute is used to obtain the Transformer output guided by each class attribute. (16) This process occurs in the sequence. Add a second one to the very front token; S2.2.2 After obtaining the structural feature encoding through multi-feature adaptive fusion, the weights are then gated. Fuse and project onto the output dimension: , (17) in, This is the road trajectory vector after multi-attribute fusion. This is the weighted road trajectory vector. for The weight, finally, By linearly mapping to a unified dimension, the second... The token is represented as the final road trajectory vector. : (18); S3. Using the road trajectory vector as the query vector and the grid trajectory vector as the key vector and value vector, we obtain the fused features. We then perform a linear mapping on the fused features to obtain the trajectory vector that combines the road and grid features.
2. The trajectory generation method for grid and road coordination according to claim 1, characterized in that, The aggregated coordinates are obtained by weighted fusion of all trajectory points within each grid cell traversed by the grid trajectory, including: Collect the set of all trajectory points within each grid cell traversed by the grid trajectory on the map. , For the first The x and y coordinates of all trajectory points within a grid cell are used as weights, based on either dwell time or inverse velocity ratio. Perform a weighted average to obtain the aggregated coordinates within the grid cell: (1) in, For the first Aggregate x-coordinates within each grid cell For the first Aggregate ordinate within each grid cell For the first The first grid cell within the [number] grid cell The x and y coordinates of each trajectory point.
3. The trajectory generation method for grid and road coordination according to claim 2, characterized in that, The method involves extracting cross-cell boundary features using the previous and current grid cells to obtain the Euclidean distance and entry direction angle of the cross-cell boundary. A fine-grained feature vector is then constructed using aggregated coordinates, the Euclidean distance across the cell boundary, and the entry direction angle. This includes: Let the x and y coordinates of the last trajectory point of the previous grid cell be... The x and y coordinates of the first trajectory point of the current grid cell are Then the Euclidean distance across the unit boundary is: (2) Entering direction angle (3) in, for function; Finally, fine-grained feature vectors are obtained. .
4. The trajectory generation method for grid and road coordination according to claim 3, characterized in that, The step of slicing the grid trajectory data at fixed time intervals to construct a temporal grid image sequence, and stacking multiple layers of 3D convolutions on the temporal grid image sequence, includes: S1.2.1 Slice the grid trajectory data at fixed time intervals to construct a time-series grid image sequence. ; S1.2.2, in Multiple layers of 3D convolutions are stacked, and the joint features of grid cells and time slices are extracted layer by layer: (4) in, As the first activation function, This represents the total number of layers in the 3D convolution. For the first 3D convolutional layers For the first The feature tensor obtained after 3D convolution; after The feature tensor is obtained after 3D convolution. .
5. The trajectory generation method for grid and road coordination according to claim 4, characterized in that, The output result is concatenated with a fine-grained feature vector and subjected to temporal embedding and positional encoding. The resulting sequence is input into a multi-layer Transformer encoder to obtain a grid trajectory vector, including: For each grid event in the grid trajectory From the feature tensor Retrieve the spatiotemporal dynamic semantic vector at the corresponding location and with fine-grained feature vectors By concatenating the components and performing a linear transformation, a fused representation is obtained: (5) in, Indicates the first The time slice corresponding to each grid cell Indicates the first Traffic intensity of each grid cell, grid events Indicates time Inner The number of times each grid cell is accessed; For feature dimension splicing, Represents a linear transformation, embedding time. With position encoding Adding it to the fusion representation yields a new fusion representation: (6) in, For the first A new fused representation corresponding to each of the m grid cells is used to construct a sequence. In the sequence Add first The token is then input into a multi-layer Transformer encoder to obtain the hidden representation: (7) The hidden representation is obtained by linearly mapping to a unified dimension and taking the first dimension. The token is represented as the final grid trajectory vector: (8) in, express token tag.
6. The trajectory generation method for grid and road coordination according to claim 1, characterized in that, S3 includes: Using road trajectory vectors as query vectors The grid trajectory vector serves as the key vector. Sum value vector , obtain fusion features : (19) in, for , , The corresponding learnable matrix, This represents a feedforward neural network. express function, By linearly mapping to a unified dimension, the second... The token is represented as a trajectory vector that ultimately integrates road and grid features. : (20)。 7. A system for implementing the trajectory generation method for grid and road coordination according to any one of claims 1-6, characterized in that, include: The grid trajectory encoder uses weighted fusion of all trajectory points within each grid cell traversed by the grid trajectory to obtain aggregated coordinates. It extracts cross-cell boundary features using the previous and current grid cells to obtain the Euclidean distance and entry direction angle of the cross-cell boundary. It constructs a fine-grained feature vector using the aggregated coordinates, the Euclidean distance of the cross-cell boundary, and the entry direction angle. The grid trajectory data is sliced at fixed time intervals to construct a temporal grid image sequence. Multiple layers of 3D convolutions are stacked on the temporal grid image sequence. The output is concatenated with the fine-grained feature vector and temporal embedding and position encoding are added. The resulting sequence is input into a multi-layer Transformer encoder to obtain the grid trajectory vector. The road trajectory encoder is used to linearly map the original attributes of road edges in the road network of the road trajectory as the original output features of three adjacency graphs. Multi-layer graph attention networks are stacked on the three adjacency graphs to obtain the output of the last stacked graph attention network on each adjacency graph. The outputs of the last stacked graph attention network on the three adjacency graphs are fused to obtain the multi-adjacency graph fusion feature. Minute-level and week-level time codes and location codes are injected into the multi-adjacency graph fusion feature. The resulting sequence is then subjected to multi-head attention calculation of three attributes: road type, azimuth angle and length, to obtain the road trajectory vector. The dual-objective cross-modal collaborative learning module is used to obtain fused features by using road trajectory vectors as query vectors and grid trajectory vectors as key and value vectors. The fused features are then linearly mapped to obtain trajectory vectors that fuse road and grid features.
Citation Information
Patent Citations
Strip mine road network generation method based on two-way map convolutional network
CN115204304A
Road network topological graph generation method and device, electronic equipment and medium
CN119784871A