Ship traffic flow prediction method based on improved space-time diagram attention neural network
By using an improved spatiotemporal graph attention neural network, which combines graph attention and temporal pattern attention mechanisms, the problem of existing technologies being unable to capture the complexity of maritime traffic networks has been solved, and more efficient ship traffic flow prediction has been achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- CHINA UNIV OF GEOSCIENCES (WUHAN)
- Filing Date
- 2023-05-06
- Publication Date
- 2026-04-21
AI Technical Summary
Existing methods for predicting ship traffic flow lack consideration of global spatial information, especially the irregularity and complexity of maritime traffic networks, resulting in low model efficiency.
An improved spatiotemporal graph attention neural network is adopted, which combines graph attention neural network and temporal pattern attention mechanism to replace the fully connected network of gated recurrent network. The model is constructed by adjacency matrix and feature matrix to capture the spatiotemporal features of ship traffic flow, and one-dimensional convolutional depth is used to mine the intrinsic relationship of time series of multiple port areas.
It improves the model's ability to model spatiotemporal dependencies, enhances the comprehensive consideration of the complex characteristics of maritime transportation networks, and improves prediction accuracy and generalization performance.
Smart Images

Figure CN116612664B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of waterway traffic flow prediction methods, and specifically relates to a ship traffic flow prediction method based on an improved spatiotemporal graph attention neural network. Background Technology
[0002] Most current popular methods for predicting ship traffic flow focus on single sea areas or cross-sections, lacking consideration of global spatial information. While many researchers have improved models based on CNNs to extract spatial features from ship traffic flow data, CNNs are typically used to process regular Euclidean data, such as images and grid data, while maritime road networks are non-Euclidean data, exhibiting irregularity and complexity. Therefore, using CNNs cannot effectively capture the spatial features of maritime traffic flow and is inefficient. To address this challenge, this invention proposes a ship traffic flow prediction model based on an improved spatiotemporal graph attention neural network. Based on the significant correlations exhibited by ship traffic flow data in both time and space, a graph attention neural network is introduced to improve the gated recurrent network, identifying the spatiotemporal correlations between ship traffic flows in multiple port areas. Furthermore, a time pattern attention mechanism (TPA) is incorporated to deeply mine the intrinsic connections between time series from multiple port areas. This method overcomes the shortcomings of existing technologies, comprehensively considers the complex spatiotemporal characteristics of maritime road networks, and improves the model's ability to model spatiotemporal dependencies. Summary of the Invention
[0003] The technical problem to be solved by the present invention is to provide a method for predicting ship traffic flow based on an improved spatiotemporal graph attention neural network.
[0004] The technical solution of the present invention to solve the above-mentioned technical problems is as follows:
[0005] The ship traffic flow prediction method based on an improved spatiotemporal graph attention neural network includes the following steps:
[0006] Step 1: Extract navigation data from the Automatic Identification System (AIS) data to obtain the ship traffic flow entering and leaving each port area at each time point within a certain period;
[0007] Step 2: Use the average value of the ship traffic flow data in the same time period before and after a certain moment to fill in the missing ship traffic flow data at that moment, and normalize all ship traffic flow data.
[0008] Step 3: Construct the adjacency matrix A and the feature matrix X. Assuming there are N port areas, represent the water transport network as G = (V N ,E,A),V NLet E represent the set of N nodes; E is the set of edges connecting the nodes; and A is the adjacency matrix, representing the connection status of each node.
[0009] A feature matrix X is constructed based on the historical ship traffic flow of each port area according to statistics:
[0010]
[0011] In the formula, This represents the ship traffic flow in port area i at time t, where m represents the time data dimension.
[0012] Step 4: Input the adjacency matrix A and feature matrix X into the prediction model based on the improved spatiotemporal graph attention neural network. The prediction model includes a spatiotemporal feature module, an attention mechanism module, and a fully connected layer module. The spatiotemporal feature module introduces a graph attention neural network (GAT) to replace the fully connected network in the gated recurrent network (GRU). By combining the adjacency matrix A, it learns the historical traffic flow data sequence {x1, x2, ..., x...}. t This method captures the spatiotemporal features of ship traffic flow data and outputs a spatiotemporal feature tensor {h1,h2,…,h}. t}, where x1 is the first column of the feature matrix X, and h1 is the spatiotemporal feature tensor corresponding to x1; the temporal pattern attention mechanism module is used to process and obtain the spatiotemporal feature tensor {h1, h2, ..., h1} at each time step using the spatiotemporal feature module. t Let {h1,h2,…,h} t-1} and h t These are the key and query in the time-mode attention mechanism, respectively. One-dimensional convolution is used to deeply mine the intrinsic relationships between multiple port time series, yielding the output h of the attention mechanism module. t ′;
[0013] h t The input is a fully connected layer module, which outputs the predicted ship traffic flow Y for each time step within a future time period n. n×N Y n×N =σ(W O ·h t ′)+b O In the formula: W O Let b be an n×N weight matrix. O Let be an n×N bias matrix, and σ be the tanh activation function;
[0014] Step 5: Based on the predicted and actual ship traffic flow, calculate the loss value using the loss function. Repeat Step 4 to train the prediction model based on the improved spatiotemporal graph attention neural network, adjust the model parameters, and train the model until the loss function is minimized. The model training is then complete, and the final ship traffic flow prediction model is obtained.
[0015] Step 6: Use the final ship traffic flow prediction model to predict future ship traffic flow.
[0016] Furthermore, the specific process of step 1 is as follows: First, the AIS data is cleaned and navigation vessel data is extracted by setting a speed threshold; then, based on the vessel identification number and update time, the discrete point data provided by AIS is converted into continuous track lines, and the intersection algorithm is used to determine whether each vessel track intersects with the defined port area boundary within a set time range; finally, the port entry / exit attribute is determined based on whether the vessel's previous track point before passing the port area boundary is within the port area. If so, the corresponding vessel data is stored in the corresponding port entry / exit database, and the vessel traffic flow in and out of the port area is calculated by considering the vessel conversion factor.
[0017] Furthermore, in step 3, A = Q N×N +I N×N , among which, I N×N Let Q be an identity matrix with N rows and N columns. N×N From element Q ij Composition, where i∈{0,1,…,N}, j∈{0,1,…,N};
[0018]
[0019] In the formula, σ and ∈ are hyperparameters, and d ij Q represents the Euclidean distance between two ports. ij It represents the connection between port area i and port area j.
[0020] Furthermore, in step 4, the formula for calculating the spatiotemporal feature tensor of the spatiotemporal feature module is as follows:
[0021] z t =σ(A[h t-1 ,x t ]·W z +b z )
[0022]
[0023] In the formula, z t r t These are the values of the update gate and reset gate of the cell element in the GAT-GRU spatiotemporal feature module at time t. To calculate h t Intermediate variables generated during the process, W z W r , and b z b r b h They are calculating z t r t , The weight and bias parameters of GAT are given by A, where A is the adjacency matrix and σ is the sigmoid activation function.
[0024] Furthermore, in step 5, the L2 norm training loss function MAELoss(f(x;θ),y) is calculated using the following formula:
[0025] MAELoss(f(x;θ),y)=(f(x;θ)-y) 2
[0026] Where x represents the input sample, θ represents the parameters required by the model, f(x; θ) represents the predicted value of the model when the input sample is x and the model parameters are θ, and y represents the actual value corresponding to x.
[0027] The beneficial effects of this invention are as follows: (1) When calculating the values of the reset gate, update gate, and hidden state, this invention uses a graph attention neural network (GAT) instead of a gated recurrent network (GRU) to aggregate the spatial information contained in all port traffic flow data. Compared with the temporal graph convolutional network (T-GCN) model, this invention has the ability to simultaneously mine temporal and spatial correlations. In addition, GAT can dynamically learn the relationships between nodes to process sparse graph structure data, and has a better global information capture capability. (2) This invention introduces a temporal pattern attention mechanism (TPA) for dynamic adjustment, which can help the model focus on processing important time steps and realize the extraction of the intrinsic connections between multiple port areas. Moreover, TPA also uses one-dimensional convolution operations, which can better process the local features of the time series, thereby effectively capturing the changes and trends in the time series and improving the generalization performance and prediction accuracy of the model.
[0028] Attached illustrations
[0029] Figure 1 This is a schematic diagram of the method flow of the present invention;
[0030] Figure 2 A logic diagram for extracting ship traffic flow data;
[0031] Figure 3 Structure diagram of the improved spatiotemporal graph attention neural network prediction model;
[0032] Figure 4This is a schematic diagram illustrating the working principle of the GAT-GRU memory unit.
[0033] Figure 5 This is a diagram illustrating the prediction results. Detailed Implementation
[0034] The principles and features of the present invention are described below with reference to the accompanying drawings. The examples given are only for explaining the present invention and are not intended to limit the scope of the present invention.
[0035] like Figure 1 As shown, the specific implementation steps of the ship traffic flow prediction method based on the improved spatiotemporal graph attention neural network are as follows:
[0036] Step 1: AIS Data Cleaning and Vessel Traffic Flow Extraction. First, AIS data is cleaned and navigation vessel data is extracted by setting a speed threshold. Then, based on the vessel identification number (MMSI) and update time (lasttime), the discrete point data provided by AIS is converted into continuous tracks. An intersection algorithm is used to sequentially determine whether each vessel track intersects with the defined port area boundary within a set time range. Finally, based on whether the vessel's previous track point before passing the port area boundary was within the port area, its entry / exit attribute is determined. Vessel data meeting the above conditions are stored in the corresponding entry / exit database, and vessel traffic flow in and out of the port area is calculated considering vessel conversion factors. The specific process is as follows: Figure 2 As shown;
[0037] Step 2: Data Preprocessing. First, the missing values at a given time are filled using the average of data from the same time period before and after a specific moment. Then, Min-Max normalization is used to eliminate the influence of units on the prediction results. (Original sample x) original The transformation formula for X′ obtained through Min-Max normalization is as follows:
[0038]
[0039] Step 3: Construct the adjacency matrix and the feature matrix.
[0040] First, assuming the number of port areas under study is N, the water transport network can be represented as G = (V N ,E,A N×N V N Let A be a set of N nodes, E be the set of edges connecting the nodes, and A be the set of edges connecting the nodes. N×N It is an adjacency matrix, representing the connectivity of each node. This invention constructs the adjacency matrix A based on the distances between port areas and sets certain parameters. N×N To represent the spatial topology of the waterway network, the calculation formula is as follows:
[0041]
[0042] A N×N =Q N×N +I N×N
[0043] In the formula, σ and ∈ are hyperparameters, set to 6e-6 and 0.5 respectively, and d ij Q represents the Euclidean distance between two ports. ij This represents the connection relationship between vertices i and j. After adding self-connections, the resulting adjacency matrix A is formed. N×N This solves the self-propagation problem. The elements in matrix A can only take two values: 0 and 1. 1 indicates that the two nodes are connected or self-connected, while 0 indicates that the two nodes are not connected.
[0044] Secondly, a feature matrix is constructed based on the historical vessel traffic flow statistics for each port area, with each port area occupying one row. Furthermore, the port area indices in the feature matrix must match the port area indices in the constructed adjacency matrix. The constructed spatial feature matrix is represented as follows:
[0045]
[0046] In the formula, the eigenvector X represents the traffic state at consecutive time steps. Let represent the feature vector of the i-th node at time step t, m represent the data dimension, and N represent the number of traffic nodes. The ultimate goal is to learn the mapping function F(·), where the input is the feature vector of the past m time steps, and the output is the feature vector of the predicted N port areas for the next n time steps. This is represented as follows:
[0047] Y n×N =F(X) m×N ,G)
[0048] Step 4: As Figure 3 As shown, a ship traffic flow prediction method is based on an improved spatiotemporal graph attention neural network model. Specifically, it includes the following steps:
[0049] S41, construct a prediction model based on an improved spatiotemporal graph attention neural network. The model consists of three parts: a spatiotemporal feature block (GAT-GRU Block), an attention mechanism block (TPA Block), and fully connected layers (FC), as follows: Figure 3 As shown, the feature matrix X and the adjacency matrix A are used as inputs.
[0050] Specifically, for the GAT-GRU module, GAT is introduced to replace the fully connected network of GRU, and historical traffic flow data sequences {x1,x2,…,x} are learned. tThis is used to capture the spatiotemporal features in ship traffic flow data, and finally outputs the spatiotemporal feature tensor {h1,h2,…,h}. t}
[0051] Figure 4 x in i h represents the input data of the GAT-GRU memory cell at the i-th time step. i z represents the hidden state output by the GAT-GRU memory cell at the i-th time step. t r t These are the values of the update gate and reset gate for the GAT-GRU cell at time step t, respectively. To calculate h t Intermediate variables generated during the process, W z W r , and b z b r , They are calculating z t r t , The weight and bias parameters of GAT are given by A, which is the constructed adjacency matrix, and σ is the Sigmoid activation function.
[0052] z t =σ(A[h t-1 ,x t ]·W z +b z )
[0053] r t =σ(A[h t-1 ,x t ]·W r +b r )
[0054]
[0055]
[0056] Then, the hidden state h at each time step is obtained using the GAT-GRU process described in the previous section. i The hidden features of the time series {h1,h2,…,h} are obtained. t Let {h1,h2,…,h} t-1} and h t These represent the key and query in the Time Pattern Attention (TPA) mechanism, respectively. One-dimensional convolution processing (Conv1d) is used to deeply mine the intrinsic relationships between multiple port time series, thereby improving the model's ability to model temporal dependencies, and obtaining the output h′ of the TPA model. t .
[0057] Finally, h′ t As input to the fully connected (FC) layer, the final output is the prediction result Y of the N port areas for the next n time steps. n×N .
[0058]
[0059] In the formula: W O b is the weight parameter. O Let σ be the bias parameter and σ be the tanh activation function.
[0060] S42, the improved spatiotemporal graph attention neural network model is trained using the training set, and the model's fitting effect is evaluated and adjusted using the validation set. The loss function is trained using the L2 norm to obtain the final improved spatiotemporal graph attention neural network model. The calculation formula is as follows:
[0061] MAELoss(f(x;θ),y)=(f(x;θ)-y) 2
[0062] Where x represents the input sample of the deep learning model, θ represents the parameters required by the model, f(x; θ) represents the predicted value of the model when the input sample is x and the model parameters are θ, and y represents the actual value corresponding to x.
[0063] The model sets the number of iterations and batch size to 150 and 50 respectively, with a learning rate of 3e-4. The RAdam optimizer is used for internal parameter tuning, and the input time window is set to 24, with the output variable being a single time step. Then, the number of heads in the GAT multi-head attention mechanism is set to 8, the number of neurons per layer in the GRU is set to 64 and 128, the kernel size of the TPA is set to (1, 24), the number of filters is 4, and sigmoid is chosen as the activation function. A dropout layer is added between the hidden and output layers to prevent overfitting. Finally, during model training, if the validation set loss value does not decrease after more than 30 epochs, training is stopped using earlystop to avoid overfitting. When the model converges, training is stopped, the model parameters are saved, and the final ship traffic flow prediction model parameters are obtained.
[0064] S43 inputs the test set and adjacency matrix into the trained ship traffic flow prediction model and outputs the ship traffic flow for each port area in the future time period.
[0065] Experimental results
[0066] This invention was tested on a dataset from Ningbo-Zhoushan Port. The prediction results on the test set are as follows: Figure 5As shown. Its mean absolute error (MAE), root mean square error (RMSE), explained variance, and coefficient of determination (R²) are presented. 2 The values are 1.4618, 1.9516, 0.9422, and 0.9420, respectively.
[0067] like Figure 5 Experimental results show that the prediction method based on the improved spatiotemporal graph attention neural network proposed in this invention can more accurately capture the potential spatial and temporal correlations in ship traffic flow, and achieve better prediction capabilities in solving the problem of ship traffic flow prediction in multiple port areas.
[0068] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A method for predicting ship traffic flow based on an improved spatiotemporal graph attention neural network, characterized in that, Includes the following steps: Step 1: Data Extraction; Extract navigation data from the Automatic Identification System (AIS) data to obtain the ship traffic flow entering and leaving each port area at each time point within a certain period; Step 2: Data preprocessing; The missing values of the ship traffic flow data at a certain moment are filled by using the average value of the ship traffic flow data in the same time period before and after a certain moment, and the ship traffic flow data are normalized. Step 3: Construct the adjacency matrix A and the feature matrix X; assuming the number of port areas is N, represent the water transport network as G = (V N ,E,A), where V N Let E represent a set of N nodes, E be the set of edges connecting the nodes, and A be the adjacency matrix, which represents the connection status of each node. A feature matrix X is constructed based on the historical ship traffic flow of each port area according to statistics: In the formula, This represents the ship traffic flow in port area i at time t, where m represents the time data dimension. Step 4: Input the adjacency matrix A and the feature matrix X into the prediction model based on the improved spatiotemporal graph attention neural network. The prediction model based on the improved spatiotemporal graph attention neural network includes a spatiotemporal feature module, an attention mechanism module, and a fully connected layer module. The spatiotemporal feature module introduces a graph attention neural network to replace the fully connected network in the gated recurrent network. By combining the adjacency matrix A, it learns the historical traffic flow data sequence {x1, x2, ..., x...}. t This method captures the spatiotemporal features of ship traffic flow data and outputs a spatiotemporal feature tensor {h1,h2,…,h}. t }, where x1 is the first column of the feature matrix X, and h1 is the spatiotemporal feature tensor corresponding to x1; the attention mechanism module is used to process the spatiotemporal feature module to obtain the spatiotemporal feature tensor {h1, h2, ..., h} at each time step. t Let {h1,h2,…,h} t-1 } and h t These are the key and query in the time-pattern attention mechanism, respectively. One-dimensional convolutional depthwise mining is used to uncover the intrinsic relationships between multiple port time series, yielding the output h of the time-pattern attention mechanism module. t ′; h′ t The input is a fully connected layer module, which outputs the predicted ship traffic flow Y for each time step n in the future. n×N Y n×N =σ(W O ·h t ′)+b O In the formula: W O Let b be an n×N weight matrix. O Let be an n×N bias matrix, and σ be the tanh activation function; Step 5: Based on the predicted and actual ship traffic flow, calculate the loss value using the loss function. Repeat Step 4 to train the prediction model based on the improved spatiotemporal graph attention neural network, adjust the model parameters, and train the model until the loss function is minimized. The model training is then complete, and the final ship traffic flow prediction model is obtained. Step 6: Use the final ship traffic flow prediction model to predict future ship traffic flow.
2. The ship traffic flow prediction method based on an improved spatiotemporal graph attention neural network according to claim 1, characterized in that, The specific process of step 1 is as follows: First, the AIS data is cleaned and navigation vessel data is extracted by setting a speed threshold; then, the discrete point data provided by AIS is converted into continuous tracks according to the vessel identification number and update time, and the intersection algorithm is used to determine whether each vessel track intersects with the defined port area boundary within a set time range; finally, the port entry / exit attribute is determined based on whether the vessel's previous track point before passing the port area boundary is within the port area. If so, the vessel data of the corresponding vessel is stored in the corresponding port entry / exit database, and the vessel traffic flow in and out of the port area is calculated by considering the vessel conversion factor.
3. The ship traffic flow prediction method based on an improved spatiotemporal graph attention neural network according to claim 1, characterized in that, In step 3, A = Q N×N +I N×N , among which, I N×N Let Q be an identity matrix with N rows and N columns. N×N From element Q ij Composition, where i∈{0,1,…,N}, j∈{0,1,…,N}; In the formula, σ and ∈ are hyperparameters, and d ij Q represents the Euclidean distance between two ports. ij It represents the connection between port area i and port area j.
4. The ship traffic flow prediction method based on an improved spatiotemporal graph attention neural network according to claim 1, characterized in that, In step 4, the formula for calculating the spatiotemporal feature tensor of the spatiotemporal feature module is as follows: z t =σ(A[h t-1 ,x t ]·W z +b z ) r t =σ(A[h t-1 ,x t ]·W r +b r ) In the formula, z t r t These are the values of the update gate and reset gate of the cell element in the GAT-GRU spatiotemporal feature module at time t. To calculate h t Intermediate variables generated during the process, W z W r , and b z b r , They are calculating z t r t , The weight and bias parameters of GAT are given by A, where A is the adjacency matrix and σ is the Sigmoid activation function.
5. The ship traffic flow prediction method based on an improved spatiotemporal graph attention neural network according to claim 1, characterized in that, In step 5, the L2 norm training loss function MAELoss(f(x;θ),y) is calculated using the following formula: MAELoss(f(x;θ),y)=(f(x;θ)-y) 2 Where x represents the input sample, θ represents the parameters required by the model, f(x; θ) represents the predicted value of the model when the input sample is x and the model parameters are θ, and y represents the actual value corresponding to x.
Citation Information
Patent Citations
AIS data-based channel traffic flow prediction method
CN114373299A