A freight vehicle flow prediction method based on GPS trajectory data
By constructing a regional transfer map based on GPS trajectory data and a spatiotemporal coding network, freight vehicle traffic prediction is achieved. This solves the problem of insufficient robustness of spatial dependencies and temporal patterns in existing technologies, and achieves more accurate and stable prediction results.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- DALIAN UNIV OF TECH
- Filing Date
- 2026-06-15
- Publication Date
- 2026-07-17
AI Technical Summary
Existing technologies struggle to accurately characterize spatial dependencies and build robust models to complex temporal patterns and noise in freight vehicle traffic forecasting, leading to unstable forecast results.
By acquiring GPS trajectory data of freight vehicles, unsupervised clustering is performed to divide spatial regions, constructing a regional transition map, performing time series decomposition, and using a spatiotemporal coding network to extract features. Combined with the regional transition map, regularization training is performed to form a freight vehicle traffic prediction model.
It improves the accuracy and robustness of freight vehicle traffic forecasting, is suitable for freight scenarios with limited data sources, reflects the functional connectivity between regions, takes into account both short-term fluctuations and long-term trend information, and alleviates the overfitting problem.
Smart Images

Figure CN122416738A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of traffic flow prediction technology, and in particular to a method for predicting freight vehicle traffic flow based on GPS trajectory data. Background Technology
[0002] With the rapid development of the Internet of Things (IoT) and positioning technologies, the acquisition of large-scale vehicle trajectory data has become increasingly convenient, providing an important data foundation for urban computing and intelligent transportation system research. Among numerous application scenarios, urban traffic flow prediction is of great significance for optimizing road resource allocation, alleviating traffic congestion, and refining urban management. In recent years, models based on graph convolutional networks, graph attention networks, and transformer structures have demonstrated superior performance in passenger traffic flow prediction tasks such as taxi and ride-hailing services.
[0003] However, in the field of traffic flow forecasting, the problem of freight truck traffic forecasting, which is closely related to urban economic operation, still lacks in-depth research. Compared with passenger vehicles, freight vehicles operate under fundamentally different patterns. Their travel behavior is typically driven by specific economic activities such as logistics distribution, port collection and distribution, and industrial supply chains, rather than the randomness of individual travel demands. This difference results in freight traffic exhibiting significantly different characteristics in its spatiotemporal distribution, including:
[0004] (1) Strong purposefulness, that is, the origin and destination of vehicles are highly correlated with logistics hubs; (2) Significant spatial heterogeneity, with traffic mainly concentrated in limited freight corridors and extremely uneven distribution; (3) It has a weaker periodicity, and its changes are more affected by the production cycle and the rhythm of business activities than by the typical daily commute cycle.
[0005] Therefore, directly applying general prediction models designed for passenger transport scenarios often fails to achieve ideal results, as their implicit assumptions based on spatial homogeneity, strong periodicity, and geographical proximity deviate from the actual operating patterns of freight transport systems.
[0006] Currently, traffic flow prediction methods based on GPS trajectory data face key challenges at both the spatial and temporal modeling levels, particularly in freight scenarios. In terms of spatial modeling, accurately depicting the spatial dependencies between regions is one of the core issues in traffic flow prediction. Existing methods typically rely on predefined graph structures to construct spatial relationships, including: (1) Construct an adjacency matrix based on the road network topology; (2) Construct a similarity matrix based on the geographical distance between regions; (3) Construct a spatial relationship matrix based on the spatial adjacency relationship of the regular grid (such as "queen adjacency").
[0007] However, the above methods all have certain limitations: the road network topology is not entirely equivalent to the actual vehicle flow path, and it is difficult to extract it accurately directly from GPS data; the modeling assumption based on distance attenuation ignores the attraction effect between functional areas, for example, traffic flow from residential areas is more likely to flow to commercial areas rather than other adjacent residential areas; the modeling method based on grid adjacency is too simplistic and cannot capture long-distance transportation links across regions (such as long-distance connections formed by highways or elevated roads). For freight traffic, its flow depends more on the functional connections formed by the logistics network than on simple geographical proximity, so traditional spatial modeling methods are difficult to effectively characterize its true dependency structure.
[0008] In temporal modeling, traffic flow sequences typically contain complex components such as trend terms, periodic terms, and noise. To improve modeling capabilities, some methods have proposed decoupling and fusion paradigms in recent years, modeling time series separately by decomposing them into low-frequency trend components and high-frequency fluctuation components to alleviate distribution offset problems. Typical implementations include discrete wavelet transform, Fourier transform, and data-driven adaptive decomposition methods. However, in freight scenarios, the temporal dynamics of different regions exhibit significant differences: some regions are affected by the irregularity of loading and unloading operations and scheduling, resulting in strong suddenness and non-Gaussian noise interference; while other regions show relatively stable and somewhat regular change patterns. This cross-regional heterogeneity significantly increases the difficulty of unifying temporal modeling strategies. In this case, directly applying traditional decoupling methods can easily lead to high-frequency components being dominated by noise, causing the model to learn ineffective or even harmful patterns, thus affecting the stability and robustness of prediction results.
[0009] Therefore, how to effectively characterize the spatial dependencies that conform to the characteristics of freight traffic and construct a prediction model that is robust to complex time patterns and noise, relying solely on GPS trajectory data, remains a key technical problem that urgently needs to be solved. Summary of the Invention
[0010] To address the aforementioned technical problems, this invention provides a method for predicting freight vehicle traffic flow based on GPS trajectory data. The invention acquires and preprocesses GPS trajectory data of freight vehicles within a target area. Unsupervised clustering is then performed based on a set of GPS coordinates within a preset time interval to divide the continuous geographic space into spatial regions, forming a regional traffic flow time series. For the same vehicle, regional migration relationships between adjacent GPS records are statistically analyzed to construct a regional transfer map. The regional traffic flow time series is decomposed into an original sequence branch and a low-frequency trend branch. Input embedding, temporal embedding, and spatial embedding are performed on both branches, and spatiotemporal dependency features are extracted using a spatiotemporal coding network. The spatiotemporally encoded features of the two branches are then time-aligned and fused across branches to obtain the freight vehicle traffic flow prediction result. During model training, the regional transfer map is used to impose structural constraints on the spatial embedding. This invention improves the accuracy and robustness of freight vehicle traffic flow prediction.
[0011] The technical means employed in this invention are as follows: A method for predicting freight vehicle traffic flow based on GPS trajectory data includes: acquiring GPS trajectory data of freight vehicles within a target area, and preprocessing the GPS trajectory data according to vehicle identifiers and timestamps; performing unsupervised clustering based on a set of GPS coordinates within a preset time interval to divide the continuous geographic space into K spatial regions, and mapping each GPS record to a corresponding regional label based on the clustering results, aggregating the GPS records within each spatial region to form a regional traffic flow time series; statistically analyzing the regional migration relationships between adjacent GPS records for the same vehicle in chronological order, constructing a regional transfer matrix, and obtaining a regional transfer map representing the functional connectivity relationships between regions based on the regional transfer matrix; and processing the regional traffic flow data. The traffic flow time series is decomposed into an original sequence branch and a low-frequency trend branch. Input embedding, temporal embedding, and spatial embedding are then performed on the original sequence branch and the low-frequency trend branch, respectively. The embedding results are input into a spatiotemporal coding network to extract time-dependent and spatial-dependent features. A freight vehicle traffic prediction model is constructed, and the time-dependent and spatial-dependent features are time-aligned and fused across branches to obtain the freight vehicle traffic prediction results for each spatial region within a preset future time span. The spatial embedding is regularized using the region transition map, and the freight vehicle traffic prediction model is trained based on real traffic data to obtain the trained freight vehicle traffic prediction model, thus enabling the prediction of freight vehicle traffic.
[0012] Furthermore, each GPS record in the GPS trajectory data Represented as:
[0013] in, Indicates the vehicle identifier. Indicates longitude and latitude coordinate, Represents a timestamp. This indicates auxiliary attribute information; when the geographical coverage of the target area meets the preset planar approximation conditions, clustering is performed directly on the latitude and longitude coordinates; otherwise, clustering is performed after performing a projection transformation on the latitude and longitude coordinates.
[0014] Furthermore, the unsupervised clustering employs the K-means clustering method, which divides the GPS coordinate set into clusters by minimizing the sum of squared Euclidean distances between the GPS coordinates and their respective cluster centers. A number of non-overlapping spatial regions; the objective function of the K-means clustering is expressed as:
[0015] in, Represents GPS coordinates, Indicates the first Cluster centers of each region Representing coordinates The corresponding clustering assignment results The L2 norm is used to represent the region labels of GPS records. Based on the region labels, the GPS records in each spatial region are statistically aggregated to form the traffic time series corresponding to each spatial region.
[0016] Furthermore, the construction of the region transition matrix includes: GPS records for the same vehicle are arranged in ascending order of timestamps. When the time interval between two adjacent GPS records is no greater than a preset threshold and the area label changes, the transfer counts for the corresponding starting and target areas are accumulated. The transfer count matrix is row-normalized to obtain a first-order transfer matrix. The first-order transfer matrix is then subjected to first- to n-order powers and averaged to obtain a multi-step transfer matrix. The step transition matrix is expressed as:
[0017] in, Denotes the first-order transition matrix. Indicates the first Step transition matrix, Indicates the number of transition steps. This represents the upper limit of the transition order; by averaging the transition matrices of different orders, the multi-step transition matrix is obtained. :
[0018] The multi-step transition matrix is symmetricized to obtain a region transition map. The region transition map is then... Represented as:
[0019] in express The transpose of .
[0020] Furthermore, the time series of the regional traffic flow is decomposed into time series components, specifically including: Discrete wavelet transform or low-pass wavelet filtering with upsampling is used to extract low-frequency trend components from the regional flow time series as the low-frequency trend branch; the low-frequency trend components are then... Represented as:
[0021] in, This represents the original regional flow time series. Indicates a low-pass filter. This represents the upsampling operator; the undecomposed regional flow time series is retained as the original sequence branch.
[0022] Furthermore, the step of performing input embedding, temporal embedding, and spatial embedding on the original sequence branch and the low-frequency trend branch respectively specifically includes: By performing linear projections on the original sequence branch and the low-frequency trend branch respectively, the input embedding is obtained, which is represented as follows:
[0023] in, Represents the input sequence. Represents the features after linear projection. This represents the input projection weight matrix. Represents the bias vector, and , Indicates the input feature dimension. Represents the feature dimension after linear projection; For each time step in the input window Construct time embeddings, which include time embeddings within a day and date embeddings within a week, as follows:
[0024]
[0025]
[0026] in, Indicates time step The corresponding time of day is embedded. This represents the time of day embedded in the table, and , Indicates time step A time index for the day; Indicates time step The corresponding date embedding within a week, The table represents the embedded dates of the week, and , Indicates time step Date index within a week; Indicates time step Time embedding, Indicates the time embedding dimension. Indicates a splicing operation; For each spatial region, a learnable region embedding is constructed, which is represented as:
[0027] in, Indicates the first Region embedding of a spatial region Represents the region embedding matrix, and , Indicates the number of spatial regions. Represents the spatial embedding dimension; For each pair of time steps and spatial regions The input features after linear projection, the temporal embedding, and the spatial embedding are concatenated to obtain the input representation of the spatiotemporal coding network:
[0028] The hidden representation dimension satisfies:
[0029] in, Indicates time step First The input representation corresponding to each spatial region Indicates time step First Linear projection characteristics corresponding to each spatial region The hidden dimension is indicated; the embedding operation is the same for the original sequence branch and the low-frequency trend branch, which share the same set of spatiotemporal embeddings.
[0030] Furthermore, the spatiotemporal coding network uses gated causal convolution for temporal modeling of the original sequence branches, and the input representation of the original sequence branches after input embedding, temporal embedding, and spatial embedding is denoted as:
[0031] in, The input representation of the original sequence branch. Indicates the length of the input time step. Indicates the number of spatial regions. This indicates the dimension of hidden features within the spatiotemporal coding network; Two parallel causal convolutional transformations are applied to the input representation along the time dimension to generate candidate temporal features and a gated signal, respectively, as follows:
[0032]
[0033] in, Indicates candidate time features, Indicates a gating signal. Represents the convolutional branch of candidate features. Indicates a gated convolution branch; The candidate time features are residually concatenated with the input representation to obtain the enhanced candidate time features:
[0034] in, This represents the candidate temporal features after reinforcement via residual connections; Enhanced candidate temporal features after activation function processing Element-wise multiplication with the gated signal transformed by the Sigmoid function is performed to obtain the temporal characteristics of the original sequence branches. , represented as:
[0035] in, This represents the temporal characteristics of the original sequence branches after time modeling. This represents the linear rectified activation function with leakage slope. This represents the Sigmoid function. This indicates element-wise multiplication.
[0036] Furthermore, the spatiotemporal coding network employs a causal Transformer with gated attention for temporal modeling of the low-frequency trend branch, and the input representation of the low-frequency trend branch after input embedding, temporal embedding, and spatial embedding is denoted as:
[0037] in, The input representation indicates the low-frequency trend branch. Indicates the length of the input time step. Indicates the number of spatial regions. This indicates the dimension of hidden features within the spatiotemporal coding network; The query vector, key vector, and value vector are generated from the low-frequency trend branch input, and are represented as follows:
[0038]
[0039]
[0040] in, Represents the query vector. Represents the key vector. Represents a value vector. , and These represent the query projection matrix, key projection matrix, and value projection matrix, respectively. , This represents the feature dimension corresponding to a single attention head; In causal mask The scaling dot product attention under constraints is expressed as:
[0041] in, This represents the scaled dot product attention operator. Represents a causal mask matrix, and when hour, This ensures that the current time step only focuses on information from the current time step and time steps prior to it. This indicates a normalization operation; The low-frequency trend branch input is used to generate a gating signal:
[0042] in, Indicates a gating signal. This represents the Sigmoid activation function. Let represent the gated projection matrix, and ; The scaled dot product attention is multiplied element-wise with the gated signal, and then projected to obtain the gated temporal attention output:
[0043] in, This represents the gated attention operator. This indicates element-wise multiplication. This represents the output feature projection matrix, and h represents the number of attention heads; By performing a residual connection between the gated-time attention output and the low-frequency trend branch input, we obtain the attention-enhanced features:
[0044] in, This represents the characteristics of low-frequency trend branches after gated attention enhancement; The attention enhancement features are input into a position-wise feedforward network, which is represented as follows:
[0045] in, This represents a position-by-position feedforward network. Indicates input variables, and These represent the weight matrices of the first and second layers of the feedforward network, respectively. and These represent the corresponding bias vectors, and , , Indicates the dimension of the hidden layer in the feedforward network; The time characteristics of low-frequency trend branches obtained through residual connections are expressed as follows:
[0046] in, This represents the time characteristics of the low-frequency trend branch after time modeling.
[0047] Furthermore, the extraction of time-dependent and spatial-dependent features specifically includes: For both the original sequence branch and the low-frequency trend branch, a spatial Transformer with gated attention is executed along the spatial dimension at each fixed time step to extract the spatial dependencies between regions. The features of any branch after time modeling are denoted as:
[0048] in, This represents the branching features after time modeling. This indicates a branch in the original sequence or a low-frequency trend branch. Indicates the length of the input time step. Indicates the number of spatial regions. This indicates the dimension of hidden features within the spatiotemporal coding network; For each fixed-time index The spatial query vector, spatial key vector, and spatial value vector are generated from the branch features, and are respectively represented as follows:
[0049]
[0050]
[0051] in, Represents a spatial query vector. Represents a spatial key vector. Represents a spatial value vector. , and These represent the spatial query projection matrix, the spatial key projection matrix, and the spatial value projection matrix, respectively. Calculate the scaled dot product spatial attention based on the spatial query vector, spatial key vector, and spatial value vector:
[0052] in, This represents the scaled dot product spatial attention operator. This represents the feature dimension corresponding to a single attention head; Generate a gating signal based on the spatial input:
[0053] in, Indicates a space-gated signal. This represents the Sigmoid activation function. Represents the spatial gated projection matrix, and ; The scaled dot product spatial attention output is multiplied element-wise with the spatially gated signal, and then projected to obtain the spatially gated attention output:
[0054] in, This represents a spatially gated attention operator. This indicates element-wise multiplication. This represents the spatial output projection matrix, and , Indicates the number of heads of attention; Spatial augmentation features are obtained through residual connections and position-by-position feedforward networks:
[0055]
[0056] in, This indicates the features enhanced by spatial gating attention. This represents the branching features after spatial modeling. This represents a position-by-position feedforward network; High-order spatiotemporal features are obtained step by step by stacking multiple layers of spatiotemporal coding units:
[0057] in, Indicates the first The output of the layer spatiotemporal coding unit, Indicates the first The input of the layer spatiotemporal coding unit, This represents the initial embedded input representation. Indicates the number of stacking layers of spatiotemporal coding units; Furthermore, the freight vehicle traffic prediction model utilizes convolution to align the temporal dimension of the time-dependent feature and the spatial-dependent feature with the prediction span. Using the alignment features of the original sequence branches as the query vector, and the alignment features of the low-frequency trend branches as the key and value vectors, cross-branch attention fusion is performed to obtain the fused features; the fused features are represented as:
[0058] in, This represents the characteristics of the original signal branch after time alignment. Represents the query vector. Represents the key vector. Represents a value vector. This represents the attention fusion operator; The fused features are linearly projected to obtain the main prediction result, and the aligned features of the low-frequency trend branch are linearly projected to obtain the auxiliary prediction result. The regularization includes calculating the cosine similarity matrix between the embeddings of each spatial region; the elements of the cosine similarity matrix are represented as:
[0059] in, Indicates the first The spatial region and the first Cosine similarity between spatial regions and They represent the first The spatial region and the first Region embedding of a spatial region express The transpose of , and They represent and The second norm; The cosine similarity matrix is multiplied by the Hadamard product with the region transition map to obtain a positive structuring term that characterizes high transition probability region pairs; a binary mask matrix is constructed based on elements in the region transition map that are less than a preset threshold, and the cosine similarity matrix is multiplied by the Hadamard product with the binary mask matrix to obtain a negative structuring term that characterizes weakly connected region pairs. A joint objective function is constructed based on the main prediction loss, the low-frequency auxiliary prediction loss, the positive structured term, and the negative structured term. The joint objective function is expressed as follows:
[0060] in, Indicates the main predicted loss. This indicates the low-frequency auxiliary prediction loss. The structural constraint loss is represented; after the number of training rounds exceeds a preset threshold, the structural constraint is turned off, and the training of the freight vehicle traffic prediction model is completed.
[0061] Compared with the prior art, the present invention has the following advantages: This invention can achieve regional division and regional relationship modeling solely based on GPS trajectory data, without relying on prior knowledge of external road topology, making it suitable for freight scenarios where data sources are limited.
[0062] This invention uses an adaptive spatial region division method instead of a fixed grid division method, which can better fit the non-uniform spatial distribution characteristics of freight vehicle activities.
[0063] This invention constructs a regional transfer map based on real trajectories, which can reflect the functional connectivity between regions and is more suitable for freight traffic modeling than simple geographical proximity.
[0064] This invention employs a dual-branch modeling mechanism, consisting of a branch for the original sequence and a branch for the low-frequency trend, to balance short-term fluctuations with long-term trends, thereby improving the predictive model's adaptability to complex non-stationary time series.
[0065] This invention introduces spatial embedding regularization based on region transition graphs during model training, which helps improve the stability and interpretability of spatial representation and alleviate overfitting and representation collapse problems. Attached Figure Description
[0066] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0067] Figure 1 This is a flowchart of the freight vehicle traffic prediction method based on GPS trajectory data in this invention.
[0068] Figure 2 This is a schematic diagram of the region division results in an embodiment of the present invention.
[0069] Figure 3 This is a schematic diagram of the dual-branch spatiotemporal prediction model structure in an embodiment of the present invention. Detailed Implementation
[0070] It should be noted that, unless otherwise specified, the embodiments and features described in the present invention can be combined with each other. The present invention will now be described in detail with reference to the accompanying drawings and embodiments.
[0071] 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 with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. The following description of at least one exemplary embodiment is merely illustrative and is in no way intended to limit the present invention or its application or use. 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.
[0072] It should be noted that the terminology used herein is for the purpose of describing particular embodiments only and is not intended to limit the scope of exemplary embodiments according to the invention. As used herein, the singular form is intended to include the plural form as well, unless the context clearly indicates otherwise. Furthermore, it should be understood that when the terms "comprising" and / or "including" are used in this specification, they indicate the presence of features, steps, operations, devices, components, and / or combinations thereof.
[0073] Unless otherwise specifically stated, the relative arrangement, numerical expressions, and values of the components and steps described in these embodiments do not limit the scope of the invention. It should also be understood that, for ease of description, the dimensions of the various parts shown in the drawings are not drawn to actual scale. Techniques, methods, and devices known to those skilled in the art may not be discussed in detail, but where appropriate, such techniques, methods, and devices should be considered part of the specification. In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limitations. Therefore, other examples of exemplary embodiments may have different values. It should be noted that similar reference numerals and letters in the following figures denote similar items; therefore, once an item is defined in one figure, it need not be further discussed in subsequent figures.
[0074] like Figure 1 As shown, this invention provides a method for predicting freight vehicle traffic flow based on GPS trajectory data, including: acquiring GPS trajectory data of freight vehicles within a target area, and preprocessing the GPS trajectory data according to vehicle identifiers and timestamps; in a preferred embodiment of this invention, each GPS record in the GPS trajectory data is... Represented as:
[0075] in, Indicates the vehicle identifier. Indicates longitude and latitude coordinate, Represents a timestamp. This represents auxiliary attribute information, including but not limited to vehicle speed, direction, or status indicators. For target areas with relatively limited geographical coverage, latitude and longitude can be approximated as planar coordinates for subsequent clustering. For scenarios with large cross-regional areas or high latitudes, coordinate projection transformation can be performed first, followed by subsequent processing. When the geographical coverage of the target area meets the preset planar approximation conditions, clustering is performed directly on the latitude and longitude coordinates; otherwise, a projection transformation is performed on the latitude and longitude coordinates before clustering.
[0076] Unsupervised clustering is performed based on a set of GPS coordinates within a preset time interval to divide the continuous geographic space into K spatial regions. Based on the clustering results, each GPS record is mapped to a corresponding regional label. GPS records within each spatial region are then aggregated to form a regional traffic time series. In a preferred embodiment of this invention, GPS records from a complete week or other preset statistical periods can be selected for spatial region modeling, and this data is kept separate from subsequent training and testing sets to avoid data leakage. Let the set of GPS coordinates extracted in the preprocessing stage be... ,in , This represents a preset time interval. Unsupervised clustering uses the K-means clustering method, which divides the GPS coordinate set into groups by minimizing the sum of squared Euclidean distances between GPS coordinates and their respective cluster centers. K-means clustering consists of three non-overlapping spatial regions; the objective function of K-means clustering is expressed as:
[0077] in, Represents GPS coordinates, Indicates the first Cluster centers of each region Representing coordinates The corresponding clustering assignment results The L2 norm is used to represent the region. Cluster centers are used to assign region labels to GPS records, and GPS records within each spatial region are statistically aggregated based on these region labels to form a traffic time series corresponding to each spatial region. After obtaining K spatial regions, the remaining GPS records are mapped to their corresponding spatial regions, and the number of vehicles, vehicle passage times, or other traffic statistics within each region are aggregated at a preset time granularity to form a regional traffic time series. Figure 2 The diagram illustrates the results of the region partitioning. Different colored regions or non-adjacent regions in the diagram represent different clusters.
[0078] GPS data points are divided into regions, and the data in each region is aggregated as input to the backbone model. Then, the regional information is used to further construct a regional transition map, which is used as a regularization constraint in the model training process.
[0079] To analyze the regional migration relationships between adjacent GPS records of the same vehicle in chronological order, a regional transfer matrix is constructed, and a regional transfer map representing the functional connectivity between regions is obtained based on the regional transfer matrix. Specifically, as a preferred embodiment of this invention, the construction of the regional transfer matrix includes: arranging the GPS records of the same vehicle in ascending order of timestamps; accumulating the transfer counts of the corresponding starting and target regions when the time interval between two adjacent GPS records is not greater than a preset threshold and the region label changes; normalizing the transfer count matrix row-wise to obtain a first-order transfer matrix; performing first- to nth-order power operations on the first-order transfer matrix and averaging them to obtain a multi-step transfer matrix; and then... The step transition matrix is expressed as:
[0080] in, Denotes the first-order transition matrix. Indicates the first Step transition matrix, Indicates the number of transition steps. This represents the upper limit of the transition order; by averaging the transition matrices of different orders, the multi-step transition matrix is obtained. :
[0081] The multi-step transition matrix is symmetricized to obtain a regional transition map. This regional transition map can simultaneously reflect both direct and indirect migration relationships between regions, making subsequent spatial representation learning more consistent with the actual flow patterns of freight vehicles. The regional transition map... Represented as:
[0082] in, express The transpose of .
[0083] The regional traffic flow time series is decomposed into an original sequence branch and a low-frequency trend branch. Specifically, in a preferred embodiment of this invention, the decomposition of the regional traffic flow time series includes: considering that freight traffic flow series typically contain long-term trends, short-term disturbances, and random noise simultaneously, this embodiment preferably uses a combination of low-pass wavelet filtering and upsampling to extract the low-frequency trend component. Using low-pass wavelet filtering and upsampling, the low-frequency trend component is extracted from the regional traffic flow time series as the low-frequency trend branch; the low-frequency trend component... Represented as:
[0084] in, This represents the original regional flow time series. Indicates a low-pass filter. Indicates the upsampling operator; original time series The low-frequency trend component is extracted from the original sequence branch. This serves as input to the subsequent model as a low-frequency trend branch. In this way, short-term variation information in the original sequence is preserved, while long-term trend reference information is explicitly provided to the model.
[0085] In this implementation, the discrete wavelet transform is implemented using a Symlet wavelet of order 2, namely sym2. Sym2 belongs to the Symlet wavelet family and is an approximately symmetrical improvement of the Daubechies wavelet. It has tight support and good time-frequency localization characteristics. Its approximate symmetry helps to reduce phase distortion, so it is suitable for trend extraction in traffic flow signals.
[0086] Input embedding, temporal embedding, and spatial embedding are performed on the original sequence branch and the low-frequency trend branch respectively, and the embedding results are input into a spatiotemporal coding network to extract temporal and spatial dependency features. Specifically, in a preferred embodiment of this invention, input embedding, temporal embedding, and spatial embedding are performed on the original sequence branch and the low-frequency trend branch respectively, including: By performing linear projections on the original sequence branch and the low-frequency trend branch respectively, the input embedding is obtained, which is represented as follows:
[0087] in, Represents the input sequence. Represents the features after linear projection. This represents the input projection weight matrix. Represents the bias vector, and , Indicates the input feature dimension. Represents the feature dimension after linear projection; For each time step in the input window Construct time embeddings, which include time embeddings within a day and date embeddings within a week, represented as follows:
[0088]
[0089]
[0090] in, Indicates time step The corresponding time of day is embedded. This represents the time of day embedded in the table, and , Indicates time step A time index for the day; Indicates time step The corresponding date embedding within a week, The table represents the embedded dates of the week, and , Indicates time step Date index within a week; Indicates time step Time embedding, Indicates the time embedding dimension. Indicates a splicing operation; For each spatial region, a learnable region embedding is constructed, which is represented as:
[0091] in, Indicates the first Region embedding of a spatial region Represents the region embedding matrix, and , Indicates the number of spatial regions. Represents the spatial embedding dimension; For each pair of time steps and spatial regions The input features after linear projection, the temporal embedding, and the spatial embedding are concatenated to obtain the input representation of the spatiotemporal coding network:
[0092] The hidden representation dimension satisfies:
[0093] in, Indicates time step First The input representation corresponding to each spatial region Indicates time step First Linear projection characteristics corresponding to each spatial region This indicates the hidden representation dimension; temporal embeddings are shared by all spatial regions at the same time step to characterize global temporal patterns independent of specific regional locations, while spatial embeddings are shared across different time steps within the same spatial region to express the region's stable semantic attributes. The above embedding method is identical for both the original sequence branch and the low-frequency trend branch, with both branches sharing the same set of temporal and spatial embedding parameters.
[0094] In a specific implementation, as a preferred embodiment of the present invention, the spatiotemporal coding network uses gated causal convolution for temporal modeling of the original sequence branches, and the input representation of the original sequence branches after input embedding, temporal embedding and spatial embedding is denoted as:
[0095] in, The input representation of the original sequence branch. Indicates the length of the input time step. Indicates the number of spatial regions. This indicates the dimension of hidden features within the spatiotemporal coding network; Two parallel causal convolutional transformations are applied to the input representation along the time dimension to generate candidate temporal features and a gated signal, respectively, as follows:
[0096]
[0097] in, Indicates candidate time features, Indicates a gating signal. Represents the convolutional branch of candidate features. This represents a gated convolutional branch; the two causal convolutional branches use the same kernel size and dilation strategy, and adjust the time steps through causal padding and truncation. The output does not depend on information from future time steps, thus satisfying the causal constraints in time prediction tasks.
[0098] The candidate temporal features are residually concatenated with the input representation to obtain the enhanced candidate temporal features:
[0099] in, This represents the candidate temporal features after reinforcement via residual connections; Enhanced candidate temporal features after activation function processing Element-wise multiplication with the gated signal transformed by the Sigmoid function is performed to obtain the temporal characteristics of the original sequence branches. , represented as:
[0100] in, This represents the temporal characteristics of the original sequence branches after time modeling. This represents the linear rectified activation function with leakage slope. This represents the Sigmoid function. This indicates element-wise multiplication.
[0101] The gated signal after Sigmoid function transformation can be regarded as an input-correlated time filter, which is used to dynamically control the information flow intensity of each time step and each feature channel to suppress noise or invalid time patterns and enhance the short-term dynamic feature representation in the freight vehicle flow sequence.
[0102] In a specific implementation, as a preferred embodiment of the present invention, the spatiotemporal coding network uses a causal Transformer with gated attention for time modeling of the low-frequency trend branch. The input representation of the low-frequency trend branch after input embedding, temporal embedding, and spatial embedding is denoted as:
[0103] in, The input representation indicates the low-frequency trend branch. Indicates the length of the input time step. Indicates the number of spatial regions. This indicates the dimension of hidden features within the spatiotemporal coding network; The query vector, key vector, and value vector are generated from the low-frequency trend branch input, and are represented as follows:
[0104]
[0105]
[0106] in, Represents the query vector. Represents the key vector. Represents a value vector. , and These represent the query projection matrix, key projection matrix, and value projection matrix, respectively. , This represents the feature dimension corresponding to a single attention head; In causal mask The scaling dot product attention under constraints is expressed as:
[0107] in, This represents the scaled dot product attention operator. Represents a causal mask matrix, and when hour, This ensures that the current time step only focuses on information from the current time step and time steps prior to it. This indicates a normalization operation; Generate a gated signal using a low-frequency trend branch input:
[0108] in, Indicates a gating signal. This represents the Sigmoid activation function. Let represent the gated projection matrix, and ; The scaled dot product attention is multiplied element-wise with the gated signal and projected to obtain the gated temporal attention output:
[0109] in, This represents the gated attention operator. This indicates element-wise multiplication. This represents the output feature projection matrix, and h represents the number of attention heads; the gating mechanism can dynamically filter irrelevant contextual information based on the input content, thereby enhancing the representation ability related to low-frequency long-term trends.
[0110] By performing a residual connection between the gated-time attention output and the low-frequency trend branch input, we obtain the attention-enhanced features:
[0111] in, This represents the characteristics of low-frequency trend branches after gated attention enhancement; The attention-enhancing features are input into a position-wise feedforward network, which is represented as follows:
[0112] in, This represents a position-by-position feedforward network. Indicates input variables, and These represent the weight matrices of the first and second layers of the feedforward network, respectively. and These represent the corresponding bias vectors, and , , Indicates the dimension of the hidden layer in the feedforward network; The time characteristics of low-frequency trend branches obtained through residual connections are expressed as follows:
[0113] in, This represents the temporal characteristics of the low-frequency trend branch after time modeling. The gating signal is used to dynamically filter the attention aggregation results to enhance contextual information relevant to long-term trends and suppress irrelevant information.
[0114] In a specific implementation, as a preferred embodiment of the present invention, extracting time-dependent features and spatial-dependent features specifically includes: performing a spatial Transformer with gated attention along the spatial dimension on the original sequence branch and the low-frequency trend branch at each fixed time step, such as... Figure 3 As shown, spatial dependencies between regions are extracted, and any branch feature after time modeling is denoted as:
[0115] in, This represents the branching features after time modeling. This indicates a branch in the original sequence or a low-frequency trend branch. Indicates the length of the input time step. Indicates the number of spatial regions. This indicates the dimension of hidden features within the spatiotemporal coding network; For each fixed-time index The spatial query vector, spatial key vector, and spatial value vector are generated from the branch features, and are represented as follows:
[0116]
[0117]
[0118] in, Represents a spatial query vector. Represents a spatial key vector. Represents a spatial value vector. , and These represent the spatial query projection matrix, the spatial key projection matrix, and the spatial value projection matrix, respectively. Calculate the scaled dot product spatial attention based on the spatial query vector, spatial key vector, and spatial value vector:
[0119] in, This represents the scaled dot product spatial attention operator. This represents the feature dimension corresponding to a single attention head; Generate a gating signal based on the spatial input:
[0120] in, Indicates a space-gated signal. This represents the Sigmoid activation function. Represents the spatial gated projection matrix, and ; The scaled dot product spatial attention output is multiplied element-wise with the spatially gated signal, and then projected to obtain the spatially gated attention output:
[0121] in, This represents a spatially gated attention operator. This indicates element-wise multiplication. This represents the spatial output projection matrix, and , This indicates the number of attention heads; through this gating mechanism, the interaction information between regions can be dynamically filtered according to the input content, thereby enhancing the ability to model spatial dependencies between key regions.
[0122] Spatial augmentation features are obtained through residual connections and position-by-position feedforward networks:
[0123]
[0124] in, This indicates the features enhanced by spatial gating attention. This represents the branching features after spatial modeling. This represents a position-by-position feedforward network; High-order spatiotemporal features are obtained step by step by stacking multiple layers of spatiotemporal coding units:
[0125] in, Indicates the first The output of the layer spatiotemporal coding unit, Indicates the first The input of the layer spatiotemporal coding unit, This represents the initial embedded input representation. This indicates the number of stacked layers of the spatiotemporal coding units; the final layer output is used for subsequent temporal alignment and cross-branch fusion processing. Spatial gating signals are used to dynamically filter inter-regional interaction information to enhance key regional dependencies and suppress irrelevant spatial associations.
[0126] A freight vehicle traffic prediction model is constructed, and time-dependent and spatial-dependent features are aligned and fused across branches to obtain the freight vehicle traffic prediction results for each spatial region within a preset time span. The spatial embedding is regularized using a region transition map, and the freight vehicle traffic prediction model is trained based on real traffic data to obtain the trained model, thus enabling freight vehicle traffic prediction. Specifically, in a preferred embodiment, the freight vehicle traffic prediction model uses 1×1 convolutions to align the time dimension of both time-dependent and spatial-dependent features with the prediction span. Cross-branch attention fusion is performed using the alignment features of the original sequence branches as the query vector and the alignment features of the low-frequency trend branches as the key and value vectors to obtain the fused features. The fused features are represented as follows:
[0127] in, This represents the characteristics of the original signal branch after time alignment. Represents the query vector. Represents the key vector. Represents a value vector. This represents the attention fusion operator; a linear projection is performed on the fused features to obtain the main prediction results for each spatial region within a preset time span in the future; at the same time, a linear projection can also be performed separately on the low-frequency trend branch to obtain auxiliary prediction results.
[0128] The main prediction result is obtained by linearly projecting the fused features, and the auxiliary prediction result is obtained by linearly projecting the aligned features of the low-frequency trend branch. Regularization involves calculating the cosine similarity matrix between the embeddings of each spatial region; the elements of the cosine similarity matrix are represented as:
[0129] in, Indicates the first The spatial region and the first Cosine similarity between spatial regions and They represent the first The spatial region and the first Region embedding of a spatial region express The transpose of , and They represent and The second norm; Performing the Hadamard product between the cosine similarity matrix and the region transition map yields a positive structuring term used to characterize pairs of regions with high transition probabilities:
[0130] in, Indicates a positive structured term. This represents the cosine similarity matrix formed by the embeddings of each spatial region. Represents a regional transfer map. It represents the Hadamardi (or Hadama) stack.
[0131] Construct a binary mask matrix based on elements in the region transition map that are less than a preset threshold:
[0132] in, Represents a binary mask matrix The Middle Line 1 Column elements, This represents the preset threshold. The cosine similarity matrix and the binary mask matrix are then subjected to a Hadamard product.
[0133] Performing the Hadamard product between the cosine similarity matrix and the binary mask matrix yields a negative structuring term used to characterize weakly connected region pairs:
[0134] in, This indicates a negative structured term.
[0135] A joint objective function is constructed based on the main prediction loss, low-frequency auxiliary prediction loss, positive structured term, and negative structured term. The joint objective function is expressed as follows:
[0136] in, Indicates the main predicted loss. This indicates the low-frequency auxiliary prediction loss. This represents the structural constraint loss; after the number of training rounds exceeds a preset threshold, the structural constraints are turned off, and the training of the freight vehicle traffic prediction model is completed.
[0137] Regional traffic statistics can be the number of vehicles entering the region, the number of vehicles leaving the region, the number of vehicles staying in the region, or a combination thereof within a unit of time. The preset time granularity can be set to 5 minutes, 10 minutes, 15 minutes, or other time intervals according to specific business scenarios. The number of clustered regions K, the multi-step transition order n, the time interval threshold, and the number of model layers can all be adjusted according to the data scale, regional coverage, and prediction accuracy requirements.
[0138] Example The model in this invention is trained using the Adam optimizer with a learning rate of 0.002 and a batch size of 64. The feature dimension is set to... =24, time embedding dimension set to =40, region embedding dimension set to =32. Both the temporal and spatial Transformers employ a multi-head attention mechanism, with the number of attention heads set to 32. =32. The gated causal temporal convolution module contains two convolutional layers with a kernel size of 2, and the spatiotemporal encoder consists of two stacked layers. In this embodiment, the regularization term coefficients... and All can be set to 100. All experiments can be performed on a single NVIDIA RTX 4090 GPU, and unless otherwise stated, the above hyperparameter settings are kept consistent across all experimental groups.
[0139] The method of this invention was validated on a GPS dataset of freight trucks in a certain city, using a setting of predicting the next 12 time steps from the input of 12 time steps. On the test set, the method of this invention achieved the following prediction results: mean absolute error (MAE) of 4.98, root mean square error (RMSE) of 6.99, and mean absolute percentage error (MAPE) of 12.82%. These results demonstrate that the method of this invention can achieve superior prediction performance in freight vehicle traffic prediction tasks.
[0140] The method of the present invention can also be executed by an electronic device, which includes a processor and a memory. The memory stores a computer program, and when the processor executes the computer program, it implements the steps of the freight vehicle traffic flow prediction method based on GPS trajectory data described above. The computer program can also be stored in a computer-readable storage medium.
[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; 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 or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for predicting freight vehicle traffic flow based on GPS trajectory data, characterized in that, include: Obtain GPS trajectory data of freight vehicles within the target area, and preprocess the GPS trajectory data according to vehicle identification and timestamp; Unsupervised clustering is performed based on the GPS coordinate set within a preset time interval to divide the continuous geographic space into K spatial regions. Based on the clustering results, each GPS record is mapped to the corresponding regional label. The GPS records in each spatial region are aggregated to form a regional traffic time series. For the same vehicle, the regional migration relationship between adjacent GPS records is statistically analyzed in chronological order, a regional transfer matrix is constructed, and a regional transfer map representing the functional connectivity relationship between regions is obtained based on the regional transfer matrix; The time series of the regional traffic flow is decomposed into a time series branch to obtain the original series branch and the low-frequency trend branch; The original sequence branch and the low-frequency trend branch are respectively embedded by input, time and space, and the embedding results are input into the spatiotemporal coding network to extract time-dependent features and spatial-dependent features. A freight vehicle traffic prediction model is constructed, and the time-dependent features and spatial-dependent features are time-aligned and cross-branch fused to obtain the freight vehicle traffic prediction results for each spatial region within a future preset time span. The spatial embedding is regularized using the region transition map, and the freight vehicle traffic prediction model is trained based on real traffic data to obtain the trained freight vehicle traffic prediction model, thereby realizing the prediction of freight vehicle traffic.
2. The freight vehicle traffic flow prediction method based on GPS trajectory data according to claim 1, characterized in that, Each GPS record in the GPS trajectory data Represented as: in, Indicates the vehicle identifier. Indicates longitude and latitude coordinate, Represents a timestamp. This indicates auxiliary attribute information; when the geographical coverage of the target area meets the preset planar approximation conditions, clustering is performed directly on the latitude and longitude coordinates; otherwise, clustering is performed after performing a projection transformation on the latitude and longitude coordinates.
3. The freight vehicle traffic flow prediction method based on GPS trajectory data according to claim 1, characterized in that, The unsupervised clustering employs the K-means clustering method, which divides the GPS coordinate set into groups by minimizing the sum of squared Euclidean distances between GPS coordinates and their respective cluster centers. A number of non-overlapping spatial regions; the objective function of the K-means clustering is expressed as: in, Represents GPS coordinates, Indicates the first Cluster centers of each region Representing coordinates The corresponding clustering assignment results The L2 norm is used to represent the region labels of GPS records. Based on the region labels, the GPS records in each spatial region are statistically aggregated to form the traffic time series corresponding to each spatial region.
4. The freight vehicle traffic flow prediction method based on GPS trajectory data according to claim 1, characterized in that, The construction of the region transition matrix includes: GPS records for the same vehicle are arranged in ascending order of timestamps. When the time interval between two adjacent GPS records is no greater than a preset threshold and the area label changes, the transfer counts for the corresponding starting and target areas are accumulated. The transfer count matrix is row-normalized to obtain a first-order transfer matrix. The first-order transfer matrix is then subjected to first- to n-order powers and averaged to obtain a multi-step transfer matrix. The step transition matrix is expressed as: in, Denotes the first-order transition matrix. Indicates the first Step transition matrix, Indicates the number of transition steps. This represents the upper limit of the transition order; by averaging the transition matrices of different orders, the multi-step transition matrix is obtained. : The multi-step transition matrix is symmetricized to obtain a region transition map. The region transition map is then... Represented as: in express The transpose of .
5. The freight vehicle traffic flow prediction method based on GPS trajectory data according to claim 1, characterized in that, The time series of the regional flow is decomposed into time series components, specifically including: Discrete wavelet transform or low-pass wavelet filtering with upsampling is used to extract low-frequency trend components from the regional flow time series as the low-frequency trend branch; the low-frequency trend components are then... Represented as: in, This represents the original regional flow time series. Indicates a low-pass filter. This represents the upsampling operator; the undecomposed regional flow time series is retained as the original sequence branch.
6. The freight vehicle traffic flow prediction method based on GPS trajectory data according to claim 1, characterized in that, The specific steps of performing input embedding, temporal embedding, and spatial embedding on the original sequence branch and the low-frequency trend branch respectively include: By performing linear projections on the original sequence branch and the low-frequency trend branch respectively, the input embedding is obtained, which is represented as follows: in, Represents the input sequence. Represents the features after linear projection. This represents the input projection weight matrix. Represents the bias vector, and , Indicates the input feature dimension. Represents the feature dimension after linear projection; For each time step in the input window Construct time embeddings, which include time embeddings within a day and date embeddings within a week, as follows: in, Indicates time step The corresponding time of day is embedded. This represents the time of day embedded in the table, and , Indicates time step A time index for the day; Indicates time step The corresponding date embedding within a week, The table represents the embedded dates of the week, and , Indicates time step Date index within a week; Indicates time step Time embedding, Indicates the time embedding dimension. Indicates a splicing operation; For each spatial region, a learnable region embedding is constructed, which is represented as: in, Indicates the first Region embedding of a spatial region Represents the region embedding matrix, and , Indicates the number of spatial regions. Represents the spatial embedding dimension; For each pair of time steps and spatial regions The input features after linear projection, the temporal embedding, and the spatial embedding are concatenated to obtain the input representation of the spatiotemporal coding network: The hidden representation dimension satisfies: in, Indicates time step First The input representation corresponding to each spatial region Indicates time step First Linear projection characteristics corresponding to each spatial region The hidden dimension is indicated; the embedding operation is the same for the original sequence branch and the low-frequency trend branch, which share the same set of spatiotemporal embeddings.
7. The freight vehicle traffic flow prediction method based on GPS trajectory data according to claim 1, characterized in that, The spatiotemporal coding network uses gated causal convolution to perform temporal modeling for the original sequence branches. The input representation of the original sequence branch after input embedding, temporal embedding, and spatial embedding is denoted as: in, The input representation of the original sequence branch. Indicates the length of the input time step. Indicates the number of spatial regions. This indicates the dimension of hidden features within the spatiotemporal coding network; Two parallel causal convolutional transformations are applied to the input representation along the time dimension to generate candidate temporal features and a gated signal, respectively, as follows: in, Indicates candidate time features, Indicates a gating signal. Represents the convolutional branch of candidate features. Indicates a gated convolution branch; The candidate time features are residually concatenated with the input representation to obtain the enhanced candidate time features: in, This represents the candidate temporal features after reinforcement via residual connections; Enhanced candidate temporal features after activation function processing Element-wise multiplication with the gated signal transformed by the Sigmoid function is performed to obtain the temporal characteristics of the original sequence branches. , is represented as: in, This represents the temporal characteristics of the original sequence branches after time modeling. This represents the linear rectified activation function with leakage slope. This represents the Sigmoid function. This indicates element-wise multiplication.
8. The freight vehicle traffic flow prediction method based on GPS trajectory data according to claim 1, characterized in that, The spatiotemporal coding network uses a causal Transformer with gated attention to perform temporal modeling for the low-frequency trend branch. The input representation of the low-frequency trend branch after input embedding, temporal embedding, and spatial embedding is denoted as: in, The input representation indicates the low-frequency trend branch. Indicates the length of the input time step. Indicates the number of spatial regions. This indicates the dimension of hidden features within the spatiotemporal coding network; The query vector, key vector, and value vector are generated from the low-frequency trend branch input, and are represented as follows: in, Represents the query vector. Represents the key vector. Represents a value vector. , and These represent the query projection matrix, key projection matrix, and value projection matrix, respectively. , This represents the feature dimension corresponding to a single attention head; In causal mask The scaling dot product attention under constraints is expressed as: in, This represents the scaled dot product attention operator. Represents a causal mask matrix, and when hour, This ensures that the current time step only focuses on information from the current time step and time steps prior to it. This indicates a normalization operation; The low-frequency trend branch input is used to generate a gating signal: in, Indicates a gating signal. This represents the Sigmoid activation function. Let represent the gated projection matrix, and ; The scaled dot product attention is multiplied element-wise with the gated signal, and then projected to obtain the gated temporal attention output: in, This represents the gated attention operator. This indicates element-wise multiplication. This represents the output feature projection matrix, and h represents the number of attention heads; By performing a residual connection between the gated-time attention output and the low-frequency trend branch input, we obtain the attention-enhanced features: in, This represents the characteristics of low-frequency trend branches after gated attention enhancement; The attention enhancement features are input into a position-wise feedforward network, which is represented as follows: in, This represents a position-by-position feedforward network. Indicates input variables, and These represent the weight matrices of the first and second layers of the feedforward network, respectively. and These represent the corresponding bias vectors, and , , Indicates the dimension of the hidden layer in the feedforward network; The time characteristics of low-frequency trend branches obtained through residual connections are expressed as follows: in, This represents the time characteristics of the low-frequency trend branch after time modeling.
9. The freight vehicle traffic flow prediction method based on GPS trajectory data according to claim 1, characterized in that, The extraction of time-dependent and spatial-dependent features specifically includes: For both the original sequence branch and the low-frequency trend branch, a spatial Transformer with gated attention is executed along the spatial dimension at each fixed time step to extract the spatial dependencies between regions. The features of any branch after time modeling are denoted as: in, This represents the branching features after time modeling. This indicates a branch in the original sequence or a low-frequency trend branch. Indicates the length of the input time step. Indicates the number of spatial regions. This indicates the dimension of hidden features within the spatiotemporal coding network; For each fixed-time index The spatial query vector, spatial key vector, and spatial value vector are generated from the branch features, and are respectively represented as follows: in, Represents a spatial query vector. Represents a spatial key vector. Represents a spatial value vector. , and These represent the spatial query projection matrix, the spatial key projection matrix, and the spatial value projection matrix, respectively. Calculate the scaled dot product spatial attention based on the spatial query vector, spatial key vector, and spatial value vector: in, This represents the scaled dot product spatial attention operator. This represents the feature dimension corresponding to a single attention head; Generate a gating signal based on the spatial input: in, Indicates a space-gated signal. This represents the Sigmoid activation function. Represents the spatial gated projection matrix, and ; The scaled dot product spatial attention output is multiplied element-wise with the spatially gated signal, and then projected to obtain the spatially gated attention output: in, This represents a spatially gated attention operator. This indicates element-wise multiplication. This represents the spatial output projection matrix, and , Indicates the number of heads of attention; Spatial augmentation features are obtained through residual connections and position-by-position feedforward networks: in, This indicates the features enhanced by spatial gating attention. This represents the branching features after spatial modeling. This represents a position-by-position feedforward network; High-order spatiotemporal features are obtained step by step by stacking multiple layers of spatiotemporal coding units: in, Indicates the first The output of the layer spatiotemporal coding unit, Indicates the first The input of the layer spatiotemporal coding unit, This represents the initial embedded input representation. This indicates the number of stacking layers of the spatiotemporal coding units.
10. The freight vehicle traffic flow prediction method based on GPS trajectory data according to claim 1, characterized in that, The freight vehicle traffic prediction model uses convolution to align the time dimension and prediction span of the time-dependent and spatial-dependent features, respectively. Cross-branch attention fusion is performed using the alignment features of the original sequence branches as the query vector and the alignment features of the low-frequency trend branches as the key vector and value vector to obtain the fused features; The fusion feature is represented as: in, This represents the characteristics of the original signal branch after time alignment. Represents the query vector. Represents the key vector. Represents a value vector. This represents the attention fusion operator; The fused features are linearly projected to obtain the main prediction result, and the aligned features of the low-frequency trend branch are linearly projected to obtain the auxiliary prediction result. The regularization includes calculating the cosine similarity matrix between the embeddings of each spatial region; the elements of the cosine similarity matrix are represented as: in, Indicates the first The spatial region and the first Cosine similarity between spatial regions and They represent the first The spatial region and the first Region embedding of a spatial region express The transpose of , and They represent and The second norm; The cosine similarity matrix is multiplied by the Hadamard product with the region transition map to obtain a positive structuring term that characterizes high transition probability region pairs; a binary mask matrix is constructed based on elements in the region transition map that are less than a preset threshold, and the cosine similarity matrix is multiplied by the Hadamard product with the binary mask matrix to obtain a negative structuring term that characterizes weakly connected region pairs. A joint objective function is constructed based on the main prediction loss, the low-frequency auxiliary prediction loss, the positive structured term, and the negative structured term. The joint objective function is expressed as follows: in, Indicates the main predicted loss. This indicates the low-frequency auxiliary prediction loss. The structural constraint loss is represented; after the number of training rounds exceeds a preset threshold, the structural constraint is turned off, and the training of the freight vehicle traffic prediction model is completed.