## 1. Introduction

For a ship to avoid collision, it must predict the behaviors of other ships in order to estimate the collision risk. High-precision real-time prediction of ships’ navigational behaviors can effectively increase the reliability of collision avoidance decisions and decrease the risk of collisions.

Navigation behavior prediction algorithms can be divided into two categories: offline and online prediction. Numerous offline prediction algorithms are employed in the fields of trajectory estimation and data restoration. In offline prediction, trajectory data are input to a fixed formula or trained model. These algorithms are insufficiently flexible for adaptation to actual predicted data; they also lack timeliness and high efficiency.

Examples of offline prediction studies include work by Han et al. [

1] on the prediction of a ship’s trajectory by establishing a state-switching model; they proposed a conflict-free four-dimensional aircraft prediction method based on hybrid system theory. For predicting ship positions, Xu et al. [

2] trained a three-layer back-propagation (BP) neural network to accept the ship’s direction and speed as inputs and yield differences in the latitude and longitude as output. Xu et al. [

3] used a Kalman filter to modify automatic identification system (AIS) data and least-squares estimation to determine the system state. Liu et al. [

4] first used a discrete wavelet transform to preprocess the ship’s trajectory and then applied grey systems theory to predict the ship’s navigation position. Zhen et al. [

5] constructed a three-layer BP neural network in which AIS data from the previous three points were used as the input and the fourth point was given as the output to predict the navigation behavior of the ship. Zhao et al. [

6] used an improved Kalman filter algorithm to predict ship trajectories. Tong et al. [

7] examined the law of curved navigation and the reliability of ship trajectories and proposed a geographic information system (GIS)-based prediction method for the AIS data of island navigation. Kim and Hong [

8] used a nonlinear Kalman filter in a curved-motion interactive multimodel (IMM) algorithm to track vehicles. Mehrotra and Mahapatra [

9] applied a four-state Kalman filter and “jerk” model to track predictions via motion models in a three-dimensional (3D) space. Vaidehi et al. [

10] used an ordinary Kalman filter with neural network elements and an auxiliary Kalman filtering scheme to track highly maneuverable multi-targets. Gan et al. [

11] grouped historical trajectories by the k-means algorithm and then used artificial neural network (ANN) models to predict ship trajectories. Cai and Zhang [

12] constructed an offline model using a hybrid particle swarm optimization evolutionary algorithm (PSO-EA) for time series prediction.

Previous online prediction algorithms could not learn or retain the experience of prior data repairs. Examples of online prediction studies include a ship trajectory prediction model based on Gaussian process regression, proposed by Mao et al. [

13], in which a 24 min ship trajectory was simulated and predicted by extrapolating from the ship’s existing data. Perera et al. [

14] analyzed and tracked multiple ship conditions, combined ship trajectory detection with shipping state estimation, and simulated ship trajectories. Berker et al. [

15] applied a two-dimensional (2D) obstacle motion-tracking module to a dynamometer tracking algorithm to improve data quality for navigation purposes. Stubberud and Kramer [

16] used a neural-extension Kalman filter to dynamically predict a target state online, thus improving the state estimation capability of existing models. Sang et al. [

17] built a prediction model by using change of speed (COS), rate of turn (ROT), speed over ground (SOG), and course over ground (COG) to develop the closest point of approaching (CPA) searching method. Nagai and Watanabe [

18] proposed a ship-position prediction model for a path following the ship’s performance on a curved path. Borkowski [

19] presented an algorithm of ship-movement trajectory prediction, which considered measurements of the ship’s current position from a number of doubled autonomous devices through data fusion. Zissis et al. [

20] employed machine learning and specifically ANNs as tools to add predictive capability to vessel traffic-monitoring information systems (VTMISs). Yin et al. [

21] proposed an online sequential extreme learning machine (OS-ELM)-based gray prediction approach for online ship roll prediction. Zhang et al. [

22] predicted ship maneuvering in regular waves. Based on a two-time scale model, the total ship motion can be divided into low-frequency maneuvering motion and high-frequency wave-induced motion. Breda [

23], in the simulator, created critical vessel traffic scenarios and predicted maneuvering margins of the vessel, indicating the predicted boundaries of safe operation.

A recurrent neural network (RNN) is a deep learning technology designed to deal with time series data [

24]. RNNs can achieve high precision for machine learning tasks with time series attribute data. For example, in 2015, Google substantially improved speech recognition in Android phones and other devices by using RNNs. Apple’s iPhone also uses an RNN framework in Siri. Microsoft uses RNNs for speech recognition, virtual-dialogue image generation, and programming code. RNNs have been applied in a wide range of research areas, including translation, document abstraction, speech recognition, image recognition, disease prediction, click-through rate prediction, stock forecasting, synthetic music, and e-commerce fraud detection. In an RNN, feedback is provided from the output variable to the input [

25,

26]. The feedback variable contains a time delay network. However, training an RNN is complex and convergence cannot be guaranteed. AIS data regarding a ship’s trajectory are given as a time series. In an RNN, increasing the data length may induce a gradient error, or a gradient explosive may occur when error parameters are back-propagated. The gradient explosion phenomenon does not meet the training objectives, and a typical RNN does not provide satisfactory results. Therefore, in a bidirectional RNN structure [

27], based on the traditional RNN concept, forward and backward propagation are used to effectively update the weights, thereby increasing the contextual relevance and prediction precision. Instead of a hidden-layer unit, the bidirectional RNN uses a long short-term memory (LSTM) unit. The LSTM unit effectively filters key features, performs selective memory, and solves the problem of RNN processing for long-time data. The LSTM algorithm was proposed by Sak [

28] to establish long-term correlations between input values. By replacing the hidden-layer network in an RNN with an LSTM unit [

29,

30], the problem of gradient dispersion is solved and a new storage unit is created to selectively forget or remember a given operation. In this study, we developed a bidirectional LSTM RNN (BI-LSTM-RNN) combining historical experience and real-time adjustment flexibility that can be utilized to predict the navigation behavior of an unmanned ship during collision avoidance measures against a manned ship. This approach can support a human operator’s better understanding of complex conditions at sea and enhance decision-making to avoid danger.

## 4. Results

Four points from the AIS data were used to form a training sample. The first data point was fixed, and the second, third, and fourth points were intercepted at intervals of three to five points. This selection disrupted the personality association between the data and increased the sensitivity of the data to time parameters. The problems of gradient explosion and gradient disappearance were solved through batch training. The trained network model was highly versatile and directly usable; it did not require retraining for specific areas. The BI-LSTM-RNN network continued to learn online and adjusted the network in the actual application scenario. By using three historical data points at a time, six future ship position points could be predicted. Furthermore, by adjusting the network parameters according to the continuously generated ship data, six new future ship position points could be predicted (

Figure 12).

The data from Tianjin Port for January–October were used as the training group to train the neural network parameters. The error was stable at approximately 90 m. The training error is displayed in

Figure 13.

Previously published trajectory prediction algorithms had two major disadvantages: (1) The prediction algorithms mostly included multiple input points and eigenvalues, but only one output point, thus limiting their prediction capacity and consequently restricting their applicability and accessibility in navigation. In this study, the BI-LSTM-RNN structure used three historical ship position data points, and six points could be continuously predicted. Thereafter, the prediction accuracy gradually decreased. (2) Conventional prediction algorithms possess limited versatility, are based on a fixed mathematical model, and are only valid for learning the training data of a ship in advance. Conventional algorithms cannot be adaptively changed, and precise prediction and judgment of the targeted object are impossible, thus the versatility is weak. The BI-LSTM-RNN can be applied to improve versatility by retaining the navigational habits of ships included in AIS big data and using the forget operation on the individual cases of single-ship data. The object is forecasted online, and the characteristics of the current ship can be memorized for a short period of time. Thus, the navigation behavior of a ship can be precisely predicted.

Trajectory prediction involves grasping the movement of the ship and obtaining reliable collision avoidance decisions in advance. The trajectory prediction algorithm requires accuracy and timeliness. Greater consistency with reality improves the user’s likelihood of obtaining the correct conclusion. The time available for making collision avoidance decisions is very limited. Therefore, obtaining the prediction result quickly is necessary. To prove the superiority of the proposed prediction algorithm, AIS data from Tianjin Port from November to December, which included 7,530,103 data points, were used as the verification group. The data were not intercepted when the network was being trained, and all the data were directly taken as input for the navigation behavior of the ship. The ship used the BI-LSTM-RNN, BI-RNN, and LSTM-RNN to compare prediction errors.

Figure 14 displays a comparison of the convergence effects of the three algorithms.

It can be clearly seen from

Figure 14 that the neural network predicts the behavior of the ship. When predicted for a period of time, the data of a single ship in the verification dataset are limited, and the data after verification are replaced with the data of the other ship to continue the prediction and verification. Although the prediction accuracy deteriorates suddenly, it always converges in a short time and stabilizes. The convergence velocity, oscillation amplitude, and prediction accuracy of the BI-LSTM-RNN are superior to those of the LSTM-RNN and bidirectional RNN. The experimental results indicate that the BI-LSTM-RNN is trained to predict the position of a single ship in a short time, as illustrated in

Figure 15 and

Figure 16.

It can be seen from

Figure 16 that although each conversion of the new ship data image will cause the rebound phenomenon to occur, it can quickly converge and stabilize in a short time. After about 15 batches of training, the predictive performance of the BI-LSTM-RNN appeared to be stable. The reliability of the navigation behavior prediction was 10 m or less within the accuracy of GPS positioning. The BI-LSTM-RNN was then applied as a prediction module.