# Research on Offshore Vessel Trajectory Prediction Based on PSO-CNN-RGRU-Attention
## 2 Related Works
### PSO-CNN-RGRU-Attention Trajectory Prediction Model  
Particle Swarm Optimization (PSO) is a type of swarm intelligence optimization algorithm in the field of artificial intelligence. The PSO algorithm initially initializes a group of particles in the solution space. Each particle has three attributes: velocity, position, and fitness value, with each particle representing a potential optimal solution to an extremum optimization problem. Velocity indicates the speed of the particle's movement, position represents the direction of movement, and the fitness value is calculated by the fitness function. The Mean Square Error (\(MSE\)) between the predicted values and the true values is calculated using Equation (8), where \(y_{i}\) represents the true value of the sample, \(\hat{y}_{i}\) represents the predicted value of the sample, and \(N\) represents the number of samples in the sequence. In this paper, the fitness function is given by Equation (9), which records the fitness value, the individual extremum \(\mathrm{P_{best}}\), and the global extremum \(\mathrm{G_{best}}\) positions.  
\[MSE=\frac{1}{N}\sum_{i=1}^{N}\left(y_{i}-\hat{y}_{i}\right)^{2} \tag{8}\]  
\[Fit(x)=min(MSE) \tag{9}\]  
Based on the analysis of the performance of CNN, residual modules, attention mechanisms, and GRU, a new model is proposed that integrates CNN residual modules, attention mechanisms, and GRU. For the input AIS data, the model first uses CNN layers for preliminary feature extraction. In this process, the output of the first convolutional layer is added to the output of the second convolutional layer via a residual connection. This helps alleviate the vanishing gradient problem and simplifies network training. Next, an attention mechanism is introduced, enabling the model to dynamically focus on the important parts of the sequence. By using the attention mechanism, the model can adjust the weights based on the importance of each time step in the sequence, thereby highlighting critical information. Finally, the data with attention weights are fed into the GRU layer, which further models the sequential data and outputs the representation of the sequence. The output is passed through a fully connected layer to generate the final prediction result. The PSO optimization algorithm is used to optimize the learning rate and the number of  
Figure 4: Weighted Sum of the Output Values from Attention Aggregation.  
neurons in the model, yielding the best hyperparameters. The structure of the model is shown in Figure 5.  
The PSO-CNN-RGRU-Attention regression problem is essentially a task of ship trajectory prediction. Generally, a ship's navigation state follows a certain pattern over a period of time. The navigation states at past and current moments significantly influence the navigation state at the next moment. Therefore, by inputting the ship's navigation information at both past and current times, the model can output the future trajectory data in terms of longitude and latitude. The network is trained using real ship trajectory samples to establish a corresponding mapping relationship between the input and output, enabling the prediction of the ship's future trajectory.