A traffic speed prediction method and system based on whale optimization spatiotemporal graph neural network
Patent Information
- Application Number
- CN202611227774.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-13
- Publication Date
- 2026-10-30
AI Technical Summary
[0003]然而智慧交通系统的运行产生了大量的交通流数据,这些交通流数据多以时序序列形式存在且具有空间上的分布,如果仅仅依靠传统的统计学方法,很难捕捉到各个路网节点之间交通速度的关系
相对于传统交通速度预测模型,本发明通过动态计算路网节点间的权重值突破了对固定拓扑结构的依赖,同时采用门控时间卷积与图卷积相结合的方式,实现时空特征融合,能有效捕捉交通流的时间演化与空间关联特性,在长时序预测中显著提升预测精度并减少误差累积,为交通管理提供更可靠的支撑。
Smart Images

Figure CN123012987A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent transportation technology, and more specifically to a traffic speed prediction method and system based on a whale-optimized spatiotemporal graph neural network. Background Technology
[0002] Against the backdrop of the rapid development of modern intelligent transportation, traffic speed prediction, as a core supporting technology, plays an irreplaceable and important role in improving road network operation efficiency, optimizing traffic signal control strategies, and assisting autonomous vehicle path planning.
[0003] However, the operation of intelligent transportation systems generates a large amount of traffic flow data, which is mostly in the form of time-series data and has a spatial distribution. Relying solely on traditional statistical methods makes it difficult to capture the relationship between traffic speeds at various road network nodes. The development of deep learning has provided a new approach to solving this problem, offering strong technical support for traffic speed prediction.
[0004] Therefore, how to propose a traffic speed prediction method and system based on whale-optimized spatiotemporal graph neural network to improve the accuracy of traffic speed prediction and the generalization performance of the model is a problem that urgently needs to be solved by those skilled in the art. Summary of the Invention
[0005] In view of this, the present invention provides a traffic speed prediction method and system based on a whale-optimized spatiotemporal graph neural network, which effectively integrates spatiotemporal features and performs hyperparameter optimization to improve the accuracy of traffic speed prediction and the generalization performance of the model.
[0006] To achieve the above objectives, the present invention adopts the following technical solution: On one hand, this invention discloses a traffic speed prediction method based on a whale-optimized spatiotemporal graph neural network, comprising the following steps: Historical traffic speed time series data of road network nodes and directed distance data between road network nodes are obtained, and the traffic speed time series data is preprocessed by normalization. Time series samples are constructed based on the preprocessed traffic speed time series data, and a distance adjacency matrix is generated based on the directed distance data; a training set, a validation set, and a test set are constructed based on the time series samples and the distance adjacency matrix. The training set is input into the spatiotemporal graph neural network for training, and traffic flow temporal evolution features and road network spatial dependence features are extracted and fused. During training, the prediction error index is calculated using the validation set, and the hyperparameters of the spatiotemporal graph neural network are iteratively optimized using the whale optimization algorithm to obtain the optimal parameters. The test set is input into a spatiotemporal graph neural network with optimal parameters, and the network outputs the traffic speed prediction results for future time periods at road network nodes.
[0007] Preferably, the traffic speed time series data is preprocessed using Z-score normalization.
[0008] Preferably, the time series sample is constructed based on the preprocessed traffic speed time series data using the sliding window slicing method. The Gaussian kernel distance weighting function is used to calculate the association weights between road network nodes. And set weight thresholds Sparse pruning of the distance-adjacency matrix is performed using the following formula:
[0009] In the formula, For nodes and nodes The shortest path distance between them The scale parameter is used to control the range of distance attenuation.
[0010] Preferably, the spatiotemporal graph neural network is composed of multiple cascaded spatiotemporal fusion blocks. Each spatiotemporal fusion block processes the input data sequentially as follows: First, the traffic flow temporal evolution features of each road network node are extracted by gated temporal convolution. Then, the spatial dependency features of the nodes under the road network topology are modeled by graph convolution operation. Subsequently, the temporal evolution features and spatial dependency features are synergistically fused by nonlinear activation and channel transformation. Finally, the fully connected output layer maps the fused high-order spatiotemporal representation into speed prediction values for several future time steps.
[0011] Preferably, after each training batch is completed, the mean absolute percentage error is calculated using the validation set to evaluate the fitting effect of the current spatiotemporal graph neural network, and the hyperparameters of the spatiotemporal graph neural network are optimized using the whale optimization algorithm. Repeat the above training, evaluation and optimization process until the preset maximum number of iterations is reached, and use the final optimized hyperparameters as the optimal parameters.
[0012] On the other hand, the present invention also discloses a traffic speed prediction system based on a whale-optimized spatiotemporal graph neural network, comprising: The data processing module is used to acquire historical traffic speed time series data of road network nodes and directed distance data between road network nodes, and to perform normalization preprocessing on the traffic speed time series data. The dataset construction module is used to construct time series samples based on preprocessed traffic speed time series data, generate a distance adjacency matrix based on the directed distance data, and construct training, validation and test sets based on the time series samples and the distance adjacency matrix. The network training module is used to input the training set into the spatiotemporal graph neural network for training, and to extract and fuse traffic flow temporal evolution features and road network spatial dependence features. The hyperparameter tuning module is optimized to calculate the prediction error index using the validation set during training. The whale optimization algorithm is used to iteratively optimize the hyperparameters of the spatiotemporal graph neural network to obtain the optimal parameters. The speed prediction output module is used to input the test set into a spatiotemporal graph neural network with optimal parameters and output the traffic speed prediction results of road network nodes in the future time period.
[0013] As can be seen from the above technical solution, the present invention discloses a traffic speed prediction method and system based on a whale-optimized spatiotemporal graph neural network, which has the following advantages compared with the prior art: Compared to traditional traffic speed prediction models, this invention breaks through the dependence on fixed topology by dynamically calculating the weight values between road network nodes. At the same time, it adopts a combination of gated temporal convolution and graph convolution to achieve spatiotemporal feature fusion, which can effectively capture the temporal evolution and spatial correlation characteristics of traffic flow. In long-term prediction, it significantly improves prediction accuracy and reduces error accumulation, providing more reliable support for traffic management.
[0014] Compared to the traditional parameter setting method that relies on experience and manual debugging, this invention introduces the whale optimization algorithm to achieve automatic hyperparameter optimization, which solves the defects of low efficiency and easy getting trapped in local optima by manual parameter tuning, greatly improves the model training efficiency, and enhances the generalization and robustness of the model in different urban road network scenarios, making it easier to deploy and apply in actual engineering. Attached Figure Description
[0015] 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 only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0016] Figure 1 The method flowchart provided by the present invention. Detailed Implementation
[0017] 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. 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.
[0018] On one hand, this invention discloses a traffic speed prediction method based on a whale-optimized spatiotemporal graph neural network, as shown in Title 1, which includes the following steps: S1. Obtain historical traffic speed time series data of road network nodes and directed distance data between road network nodes, and perform normalization preprocessing on the traffic speed time series data. Traffic speed time-series data are preprocessed using Z-score normalization, as shown in the following formula:
[0019] In the formula, The normalized value. The original data, The mean of the dataset. is the standard deviation of the dataset.
[0020] S2. Construct time series samples based on preprocessed traffic speed time series data, and generate a distance adjacency matrix based on directed distance data; construct training set, validation set and test set based on time series samples and distance adjacency matrix.
[0021] In this embodiment, the speed data at each intersection with a 5-minute granularity is sliced using a sliding window to generate historical input sequences and corresponding future output sequences, which constitute the time-related speed sequence samples required for model training.
[0022] Based on road network topology information, intersections are abstracted as vertices of a graph. An adjacency weight matrix is constructed using the directed distance data of the nodes, serving as the edges of the graph. This matrix, based on the actual road distances between nodes, undergoes Gaussian kernel mapping and sparsity threshold pruning to form a sparse matrix reflecting the strength of spatial associations. Specifically, the Gaussian kernel distance weight function is used to calculate the association weights between road network nodes. And set weight thresholds Sparse pruning of the distance-adjacency matrix is performed using the following formula:
[0023] In the formula, For nodes and nodes The shortest path distance between them The scale parameter is used to control the range of distance attenuation.
[0024] In this embodiment, the training set, validation set, and test set are obtained by dividing the time series samples according to the time sequence and a preset ratio, and the distance adjacency matrix is shared by the training set, validation set, and test set.
[0025] S3. Input the training set into the spatiotemporal graph neural network for training, and extract and fuse traffic flow temporal evolution features and road network spatial dependence features.
[0026] The spatiotemporal graph neural network is composed of multiple spatiotemporal fusion blocks cascaded together.
[0027] Each spatiotemporal fusion block processes the input data sequentially as follows: First, the traffic flow temporal evolution features of each road network node are extracted through gated temporal convolution. Then, the spatial dependency features of the nodes under the road network topology are modeled through graph convolution operation. Subsequently, the temporal evolution features and spatial dependency features are synergistically fused through nonlinear activation and channel transformation. Finally, the fully connected output layer maps the fused high-order spatiotemporal representation into speed prediction values for several future time steps.
[0028] S4. During the training process, the prediction error index is calculated using the validation set, and the hyperparameters of the spatiotemporal graph neural network are iteratively optimized using the whale optimization algorithm to obtain the optimal parameters.
[0029] Initialize the training configuration. Set initial hyperparameters such as learning rate, batch size, and maximum number of training epochs, and introduce a batch marking mechanism to track training progress. Before the start of each training batch, reset the accumulated loss value and gradient state to ensure the accuracy of gradient calculation and parameter updates.
[0030] In each training round, the whale optimization algorithm first randomly initializes multiple whale individuals (candidate solutions) within a pre-defined hyperparameter search space, with each individual corresponding to a complete set of hyperparameter combinations.
[0031] In each iteration of the training round, the algorithm adjusts the control coefficient vector. The value determines whether to enter the global exploration phase or the local development phase. When the algorithm enters the global exploration phase, each individual randomly selects a hyperparameter combination represented by another whale individual (candidate solution) in the population (a subset of candidate solutions in the current iteration) as a reference direction, and performs large-scale random perturbations in the vicinity of this reference combination, thereby exploring unexplored hyperparameter regions to avoid local optimum traps; when At that time, the algorithm enters the partial development stage. When entering the local development strategy one, a shrinking, small-amplitude perturbation search is performed near the current optimal hyperparameter combination. The second local development strategy involves a fine-tuning process along a spiral path around the current optimal combination. This spiral motion causes the hyperparameters to change with different step sizes, facilitating detailed tuning within the optimal region. In each training iteration, the mean absolute percentage error is calculated using the validation set to evaluate the fitting performance of the current spatiotemporal graph neural network. If the performance of a new combination is better than the current global optimum, it is replaced.
[0032] Throughout the process, as the number of iterations increases, the parameters controlling the balance between exploration and development gradually decrease linearly from their initial values, allowing the algorithm to gradually transition from a wide-range search to a local fine-grained search until the preset maximum number of iterations is reached. Finally, the algorithm outputs the set of hyperparameters that has the best performance on the validation set.
[0033] The search strategy formula and parameters of the whale optimization algorithm are explained below: Convergence factor:
[0034] Coefficient vector:
[0035] Coefficient vector:
[0036] Global Exploration:
[0037] Local development strategy one:
[0038] Partial Development Strategy Two:
[0039] In the formula, This represents the current iteration number. The maximum number of iterations, for Random vectors within an interval For the hyperparameter combination of candidate solutions, This represents the current globally optimal combination of hyperparameters. For randomly selected hyperparameter combinations, Helical shape constant (usually taken as 1). Let p be a random number within the interval [-1, 1]. The random number within the interval determines which local development strategy to adopt.
[0040] Mean absolute percentage error The calculation formula is as follows:
[0041] in For the sample size, For the true value, These are predicted values.
[0042] S5. Input the test set into the spatiotemporal graph neural network with optimal parameters, and output the traffic speed prediction results of the road network nodes in the future time period.
[0043] On the other hand, the present invention also discloses a traffic speed prediction system based on a whale-optimized spatiotemporal graph neural network, comprising: The data processing module is used to acquire historical traffic speed time series data of road network nodes and directed distance data between road network nodes, and to perform normalization preprocessing on the traffic speed time series data. The dataset construction module is used to construct time series samples based on preprocessed traffic speed time series data and generate a distance adjacency matrix based on directed distance data; and to construct training, validation, and test sets based on the time series samples and the distance adjacency matrix. The network training module is used to input the training set into the spatiotemporal graph neural network for training, and to extract and fuse traffic flow temporal evolution features and road network spatial dependence features. The hyperparameter tuning module is optimized to calculate the prediction error index using the validation set during training. The whale optimization algorithm is used to iteratively optimize the hyperparameters of the spatiotemporal graph neural network to obtain the optimal parameters. The speed prediction output module is used to input the test set into a spatiotemporal graph neural network with optimal parameters and output the traffic speed prediction results for future time periods of road network nodes.
[0044] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to the method section.
[0045] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A traffic speed prediction method based on a whale-optimized spatiotemporal graph neural network, characterized in that, Includes the following steps: Historical traffic speed time series data of road network nodes and directed distance data between road network nodes are obtained, and the traffic speed time series data is preprocessed by normalization. Time series samples are constructed based on the preprocessed traffic speed time series data, and a distance adjacency matrix is generated based on the directed distance data. A training set, a validation set, and a test set are constructed based on time series samples and a distance adjacency matrix; The training set is input into the spatiotemporal graph neural network for training, and traffic flow temporal evolution features and road network spatial dependence features are extracted and fused. During training, the prediction error index is calculated using the validation set, and the hyperparameters of the spatiotemporal graph neural network are iteratively optimized using the whale optimization algorithm to obtain the optimal parameters. The test set is input into a spatiotemporal graph neural network with optimal parameters, and the network outputs the traffic speed prediction results for future time periods at road network nodes.
2. The traffic speed prediction method based on a whale-optimized spatiotemporal graph neural network according to claim 1, characterized in that, The traffic speed time series data were normalized and preprocessed using Z-score normalization.
3. The traffic speed prediction method based on a whale-optimized spatiotemporal graph neural network according to claim 1, characterized in that, The time series samples are constructed based on the preprocessed traffic speed time series data using a sliding window slicing method. The Gaussian kernel distance weighting function is used to calculate the association weights between road network nodes. And set weight thresholds Sparse pruning of the distance-adjacency matrix is performed using the following formula: In the formula, For nodes and nodes The shortest path distance between them The scale parameter is used to control the range of distance attenuation.
4. The traffic speed prediction method based on a whale-optimized spatiotemporal graph neural network according to claim 1, characterized in that, The spatiotemporal graph neural network is composed of multiple cascaded spatiotemporal fusion blocks. Each spatiotemporal fusion block processes the input data sequentially as follows: First, the traffic flow temporal evolution features of each road network node are extracted by gated temporal convolution. Then, the spatial dependency features of the nodes under the road network topology are modeled by graph convolution operation. Subsequently, the temporal evolution features and spatial dependency features are synergistically fused by nonlinear activation and channel transformation. Finally, the fully connected output layer maps the fused high-order spatiotemporal representation into speed prediction values for several future time steps.
5. The traffic speed prediction method based on a whale-optimized spatiotemporal graph neural network according to claim 1, characterized in that, After each training batch is completed, the mean absolute percentage error is calculated using the validation set to evaluate the fitting effect of the current spatiotemporal graph neural network, and the hyperparameters of the spatiotemporal graph neural network are optimized using the whale optimization algorithm. Repeat the above training, evaluation and optimization process until the preset maximum number of iterations is reached, and use the final optimized hyperparameters as the optimal parameters.
6. A traffic speed prediction system based on a whale-optimized spatiotemporal graph neural network, characterized in that, include: The data processing module is used to acquire historical traffic speed time series data of road network nodes and directed distance data between road network nodes, and to perform normalization preprocessing on the traffic speed time series data. The dataset construction module is used to construct time series samples based on preprocessed traffic speed time series data and generate a distance adjacency matrix based on the directed distance data; A training set, a validation set, and a test set are constructed based on time series samples and a distance adjacency matrix; The network training module is used to input the training set into the spatiotemporal graph neural network for training, and to extract and fuse traffic flow temporal evolution features and road network spatial dependence features. The hyperparameter tuning module is optimized to calculate the prediction error index using the validation set during training. The whale optimization algorithm is used to iteratively optimize the hyperparameters of the spatiotemporal graph neural network to obtain the optimal parameters. The speed prediction output module is used to input the test set into a spatiotemporal graph neural network with optimal parameters and output the traffic speed prediction results of road network nodes in the future time period.
