# Research on Multi-Port Ship Traffic Prediction Method Based on Spatiotemporal Graph Neural Networks
## 2 Methods
### Spatiotemporal Blocks  
In the context of multi-port traffic flow prediction, we consider each individual port as a distinct node and employ a data-driven methodology to establish edge relationships between ports, thereby constructing the port network based on historical data. The collection of nodes and edges represents the graph structure of the multi-port network.  
The previous study [30] presented in this paper demonstrated that existing spatiotemporal graph models do not exhibit significant advantages over traditional time series prediction models when applied to multi-port traffic flow prediction. The spatial exploration capability of the spatiotemporal graph network was found to be underutilized. We propose two potential explanations for these experimental results. Firstly, the multi-port network structure in this scenario may inadequately represent the connectivity and spatial relationships between ports. Secondly, there may exist an inherent imbalance between the temporal and spatial features, with the roles of time and space varying across different datasets. To address the first conjecture, we optimize the existing data-driven method for the construction of the multi-port network structure. Additionally, we conduct theoretical research based on the second conjecture and make targeted improvements to the existing spatiotemporal graph framework.  
Firstly, this paper summarizes the existing general framework of spatiotemporal graphs, as shown in Figure 1. The combination of the temporal layer and the spatial layer is referred to as a \"spatiotemporal block.\" In the spatiotemporal block, the temporal layer captures the temporal patterns of historical traffic flow data for each port, while the spatial layer handles the relationships among port nodes across different time dimensions. The sequential arrangement of multiple spatiotemporal blocks forms a deep spatiotemporal graph neural network model.  
From a holistic perspective, the framework directly utilizes the output of the temporal layer as the input for the subsequent spatial layer, and the output of the spatial layer becomes the input for the next temporal layer. After several iterations of these spatiotemporal  
Figure 1: General framework of spatiotemporal graph model.  
blocks, the predicted results are generated through the output layer. There is no specific handling between the temporal and spatial layers in this architecture. The advantage of this approach lies in its ability to fully preserve the features processed by the temporal and spatial layers. However, it overlooks the potential master-slave relationship between the temporal and spatial layers.  
Inspired by [31], this paper employs a gating mechanism to determine the propagation and forgetting of information, in order to simulate the imbalance between time and space. As shown in Figure 2, the model first duplicates the input tensor into two identical copies. One copy is processed through the temporal layer and then passed through a _tanh_ activation function for output. The other copy is processed through the spatial layer and mapped to the range of 0 to 1 using a _sigmoid_ function, treating it as a filtering net for spatial information. Finally, the two parts of the output are combined using element-wise multiplication (Hadamard product). In other words, this structure treats the spatial hidden features as a filter, using spatial features to filter important temporal features, which are then outputted in the form of temporal features to enter the next hidden layer. This structure enhances the model's sensitivity to temporal flow data while reducing the influence of the graph structure on feature information. It can effectively simulate the imbalance between time and space.  
In summary, the spatiotemporal graph framework used in this paper is illustrated in Figure 3.  
Figure 3: Overall framework of the Gated Attention Graph WaveNet model.  
Figure 2: Structure of a spatiotemporal block.