Ship Short-Term Trajectory Prediction Based on RNN

In the application of ship supervision, ship collision avoidance, maritime search and rescue, the trajectory prediction of the target ship is a key issue. Given the ship navigation trajectory is easily affected by wind and waves, in order to improve the accuracy and efficiency of prediction, a ship short-term trajectory prediction method combining with Automatic Identification System (AIS) data and deep learning is proposed. Based on the preprocessing of AIS data, a recurrent neural network (RNN) model is constructed to achieve the accurate prediction of ship position information is realized. Through the real ship AIS trajectory data experiment, the results show that the method is practical and effective. Compared with the traditional backpropagation (BP) neural network processing method, it has certain advantages in prediction accuracy.


Introduction
With the development of the global economy, maritime traffic has grown rapidly. More and more ships are sailing at sea, which makes the accidents occur frequently. Therefore, it is necessary to find out the abnormal conditions of the ship in time in order to prevent the accidents. The prediction of ship track is the prerequisite of discovering the abnormal navigation behavior of the ship. However, it is difficult to predict the movement trend of surrounding targets due to the dynamic traffic conditions and environmental conditions. Different from land transportation, ships sail in the ocean, and there is no fixed road for navigation. Therefore, how to improve the accuracy of the target ship trajectory prediction is a key problem.
At present, there have been kinds of research on ship trajectory prediction at home and abroad. Li et al. [1] established a mathematical model of ship motion in the inertial coordinate system, combined with GPS positioning and navigation system, to analyze and predict the trajectory parameters of the next position of the ship; To ship state estimation and navigation trajectory prediction for single-ship, Perera et al. [2] proposed an extended Kalman filter algorithm to estimate the state of the ship and further predict the trajectory of the ship; Qiao et al. [3] proposed a trajectory prediction algorithm based on hidden Markov model (HMM) and adopt the trajectory division algorithm based on density to improve the prediction efficiency. Deng et al. [4] used discrete wavelet transform combined with gray prediction algorithm and nonlinear programming method to model and predict ship trajectory. Mazzarella et al. [5] used historical ship trajectory data to propose a Bayesian trajectory prediction algorithm based on particle filtering. The algorithm was assisted by traffic route knowledge to improve the quality of ship position prediction. Xu et al. [6] used latitude and longitude difference, heading difference, and speed difference as features, and proposed a three-layer model based on BP neural network to predict ship trajectory. This model has the advantages of accuracy and generality.  [7] proposed a prediction method combining AIS information and BP neural network, using the AIS information of the ship at each moment as a feature to predict the ship's next position, course, speed and other information. In a word, the above studies all adopt traditional statistical models or simple BP neural networks. Most of them need to combine complex kinematics models to construct kinematic equations, which require high-quality data, and most of them can only be applied to ideal conditions.
In this paper, the ship position (longitude, latitude) elements are extracted from AIS data to construct the ship trajectory sequence data. The realization of ship navigation dynamic prediction model based on RNN network is studied. The RNN network prediction model is trained and tested by using the ship real trajectory sequence data. Compared to BP neural network model, and the experimental results are discussed and summarized.

Ship Trajectory Model
In 2002, the International Maritime Organization required that merchant ships on international routes over 300 gross tonnages must be equipped with an AIS transceiver. The AIS messages contain the dynamic information (such as position, speed, course), static information (such as ship name, ship length, ship width) and voyage-related information (such as destination, estimated time of arrival) [8]. The broadcast frequency of the AIS message is 2s-30s, so it has important practical significance for effectively using huge AIS data to predict ship trajectories and achieve the purpose of avoiding ship collisions.
This paper selects the ship position information in the AIS dynamic message to study the ship trajectory prediction problem. Suppose the trajectory point at the time i t is

RNN Model
RNN is a hot topic in neural network research in recent years and is composed of input layer, hidden layer and output layer like the traditional neural network. The input of the hidden layer includes the output of the hidden layer at the previous moment, so that the output of the hidden layer can reflect historical information to a certain extent, and this information flows through the next neuron together with new information to affect the final output. A typical RNN structure diagram is shown in figure 1. The context layer ( 1l u ...u ) provides a temporary memory to the network, allowing it to "remember" previous hidden layer states. A diagram for a one-unit RNN is shown in figure 2. From bottom to top: input state, hidden state, output state. U, V, W are the weights of the network. The compressed diagram on the left and the unfold version of it on the right.
When a ship sails on the ocean, its speed and course are affected by the destination, geographical conditions, the handling habits of the crew, and the performance of the ship. From the perspective of the time dimension, the ship's position can be regarded as a time series. The ship's position in the future will have a certain relationship with historical data. The choice of the next location is often close to the previous location and has a certain time sequence. From this point of view, the RNN model is very suitable for the prediction of the ship's position, that is, the ship's position at the next moment can be predicted based on the historical ship trajectory.

Preprocessing of AIS Data
The original AIS data contains a lot of wrong data [11], which limits the application of AIS data. Therefore, it is necessary to clean the original AIS data to eliminate outliers. The original AIS data 3 stream is arranged according to the receiving time of the AIS message. The preprocessing of the cleaned data is to separate the original AIS data stream into ship trajectories. The specific process is divided into two steps: (1) Maritime mobile service identification (MMSI) is the unique identification of the ship, so the MMSI is used to separate the ship trajectory of different ships.
(2) In dense navigation waters, network communication will be blocked. AIS can't reserve or intercept idle time slots, which will lead to the delay of sending AIS information. Therefore, the original trajectory data need to be separated by timestamp information to obtain continuous ship trajectory data.

RNN Model Training
The min-max normalization method is used to normalize the data and is defined in Eq.1.  In order to accelerate the convergence speed of RNN without affecting its prediction accuracy, the variable learning rate algorithm is selected, with the maximum iteration number is 100, the maximum learning rate is 0.5 and the minimum learning rate is 0.002.
In this paper, the adaptive learning rate optimization algorithm Adam is used to updating the network parameters. Root Mean Square Error (RMSE) is used to evaluate the ship trajectory prediction model, and the RMSE formula is defined in equation (2).
where i x represents the true value, x is the prediction value and n is the number of samples.

Experiment and Analysis
Based on the Windows platform, this paper uses Pytorch to develop a Python language version of the RNN model for ship navigation trajectory prediction. The data used in this article comes from a real ship (MMSI=413409000) in the waters of Laotieshan. The length and width of the ship are 164 meters and 25 meters, respectively. Ship AIS data with a speed of 0~14kn is selected and the ship AIS transmission time interval is required to be 10s, in order to ensure the equal time interval of the ship dynamic time-series data. The 6 ship dynamic position data at t-5, t-4, t-3, t-2, t-1 and t are input and the ship position data at t+1 is output. In the experiment, 70% of the data is used for training and the remaining 30% is used to test the prediction accuracy of the model. It has been proved that a three-layer BP neural network can fit any nonlinear function, so this model chooses BP neural network with hidden layers of 1.
The graph of loss function iteration is the curve of loss function changing with iteration numbers when different models train samples. From figure 3, it can be seen that the loss value keeps decreasing as the number of iterations increases. The RNN model has outstanding performance. Not only does the RNN model converge the fastest, but the final loss function value reaches 0.00002. It can be seen from figure 4 that the prediction results of the RNN and BP models maintain the same trend as the real longitude curve. The longitude prediction of the RNN model fits the real longitude curve better. Figure 5 shows that the RNN model converges the fastest and can stabilize faster during the training process. The final loss function value is also smaller, tending to zero. Figure  6 shows the latitude prediction results of the RNN and BP models, which clearly express the superiority of the RNN model prediction, while the BP model is far away from the true latitude curve. Therefore, the whole trajectory predicted by the RNN model has a better fit with the true trajectory. This can also be seen from the RMSE in table 1. In terms of longitude or latitude prediction, the prediction accuracy of RNN is higher than that of BP.

Conclusion
According to the characteristics of actual ship AIS data, the ship navigation trajectory is extracted from real ship AIS data, and the RNN network is trained and verified. The predicted value is compared with the real value. The experiment shows that the RNN network can effectively and accurately predict the ship navigation trajectory while avoiding the establishment of complex ship motion models, which provides new ideas for ship navigation dynamics prediction. After comparing the prediction results with the traditional BP neural network, it is concluded that the RNN network has the advantages of small error, high accuracy, and strong robustness. In the next work, it is necessary to combine possible application scenarios, such as collision avoidance, grounding warning, etc., to further adjust and optimize the RNN network in order to obtain better prediction results and applications.