An Approach to Ship Behavior Prediction Based on AIS and RNN Optimization Model

AIS (Automatic Identification System) is a mandatory navigational equipment on board according to SOLAS (Safety of Life at Sea) convention. It is an automatic tracking system that uses VHF (Very High Frequency) transponders on ships and is used by VTS (Vessel Traffic Services) for monitor vessel movements. Existing AIS data has some principle defects due to radio propagation. This paper provides an approach to predict ship behavior with AIS data. In order to solve the problem that traditional ship behavior prediction needs to establish complex ship motion model, a new ship behavior prediction method based on LSTM (Long Short-Term Memory, LSTM) neural network model of machine learning is proposed. LSTM is the optimization model of RNN (Recurrent Neural Networks). Unlike standard feedback neural networks, LSTM has feedback connections. It can not only process single data points, but also entire sequences of data. These prominent features just match the characteristics of AIS data. The LSTM neural network prediction model is established and the shore is used. Based on the real data of AIS (Automatic Identification System) which ships engaged in the waters of South China Sea, the time series of ship behavior characteristics are extracted to train the model and validate the data. The training data is grouped by MMSI (Maritime Mobile Service Identity) and ensure the equal interval requirements of the ship's navigation behavior sequence data. This paper presents 4 figures with the parameter course, speed, position and the loss curve of LSTM training and testing. The results show that the model has a high accuracy and avoids the complicated process of ship motion modeling. The predicted results can improve the supervision of VTS (Vessel Traffic Services) and play a high practical application value in early warning of ship collision, SAR (Search and Rescue) operation and safety-related issues.


Introduction
With the rapid development of worldwide economy, the amount of maritime traffic in many important waterways are becoming increasingly bigger as well as the flow of many important waterways are getting increasingly higher and the waterways are much busier than before. For VTS supervision, real-time and accurate acquisition of ship behavior state is an essential support for better coordination of navigation vessels within the channel and management of navigable waterways. However, due to various reasons such as unsatisfactory AIS data update and improper operation of AIS, the shore-based AIS equipment may not receive AIS data in time, or the data which AIS received may be incomplete or inaccurate. For the sake of making up for the deficiency that the AIS data receiving is not in time or accurate, new technical methods are necessary to be introduced for ship behavior prediction to offset the defects of the existing system. BP neural network is adopted for the prediction of the ship's track. The speed and heading are used as the input of BP neural network, and the longitude and latitude difference are used as the output as well. The difference of the latitude and longitude of the ship is small, thus the error of the prediction is of high precision and a good ship's track is predicted. However, the dynamic characteristics of the ship such as course and speed are not predicted [1]. In reference [2], Kalman filtering algorithm is used to estimate the ship's AIS trajectory. The AIS observation node data of ship is adopted for estimating the system by the least squares methods, and the trajectory is smoothed and predicted. Also, the ship is correctly obtained. Compared with the traditional trajectory estimation and ship positioning, the accuracy of ship position prediction is improved [2]. Reference [3] is further extended based on the research content of reference [1], which establishes the prediction model of ship behavior based on BP neural network, also gives the prediction of ship's course and speed on the basis of the existing track predictions, realizes the multidimensional prediction of ship behavior characteristics, and the shore-based AIS data is used for verification.
Compared with the maritime field, there are more types of methods for aircraft track prediction in the aviation field. In addition to the above, there are also machine learning methods such as clustering methods, functional regression methods, radial basis neural networks, random forests, etc. Introducing machine learning algorithms into the prediction of ship behavior is also a new idea for ship behavior prediction. The LSTM model belongs to the RNN recurrent neural network in machine learning which has shown great potential in data prediction. Reference [4] uses LSTM to predict ship attitude including ship pitching, rolling, etc. In reference [5], LSTM combined with Kalman filter is used to predict the arrival time of the bus. The results show that the prediction effect of LSTM on time series data is better with faster prediction speed, which is sufficient for the requirements of accuracy and real-time in practical work, and can be used to predict ship behavior. The ship behavior at each moment is related to the navigation behavior of the ship at some previous time. The time series data of the ship behavior is constructed with AIS data. The LSTM (Long Short-Term Memory, LSTM) neural network model is trained with the time sequence data in order to achieve the purpose of ship behavior prediction.

Ship Behavior Model Based-on AIS Data
The Automatic Identification System (AIS) is an important part of modern ship navigation equipment. Chapter V of the SOLAS Convention requires that all ships of 300 gross tonnage and upwards engaged on international voyages and cargo ship of 500 gross tonnages and upwards not engaged on international voyages and passenger ships irrespective of size shall be fitted with an Automatic Identification System (AIS). AIS uses the ship's global unique coding system, the MMSI code, as a means of identification. Each ship is given a globally unique MMSI code from the beginning of construction to the disintegration of the ship.
The types of information sent by AIS devices include static information, dynamic information, voyage-related information, and safety-related information. Static information includes: MMSI, IMO number, call sign, ship name, ship's length and width, ship's type and other information; dynamic information including ship's position, Universal Time Coordinated (UTC), Course Over Ground (COG), Speed Over Ground (SOG), heading, navigational status (if there is mooring, anchoring, loss of control, etc.).
The main concern of the ship's navigation behavior is the specific dynamic of the ship. Therefore, the MMSI in the static information of the AIS data is used as the unique identification code of the ship, and then the dynamic information corresponding to the MMSI is taken as the constituent field of the ship's navigation behavior. Specifically, it includes five fields: {UTC, Latitude, Longitude, COG, SOG}, which are time, latitude, longitude, heading, and speed.
With the processing of the continuous AIS, several ships' navigation behavior records corresponding to the specified MMSI can be obtained, which is the AIS time series data, can be used for the next step of prediction.

LSTM Algorithm Model
LSTM (Long Short-Term Memory) is a long-short term memory network. It is a recursive neural network suitable for processing and predicting important events with relatively long intervals and delays in time series. LSTM has a variety of applications in the technology field. LSTM was proposed by Hochreiter & Schmidhuber (1997) and has recently been improved and promoted by Alex Graves. In many cases, LSTM has achieved considerable success and also has been widely used.
The LSTM model structure contains a set of interconnected recursive subnetworks, namely memory blocks. Each network block contains one or more autocorrelation memory cells and three proliferative units: an input gate, an output gate, and a forget gate, which respectively correspond to the writing, reading, and resetting of the previous state of the sequence data. Figure 2 shows an LSTM memory module containing a single cell. The three gates are non-linear summary units that aggregate all the excitation inside and outside the block and control the excitation of the cells through the multiplication node (the small black circle in the figure). The excitation function of the forget gate is usually a logarithmic logic curve, so the gate excitation takes a value between 0 (door closed) and 1 (door open). The excitation function of the cell input gate and output gate is usually a hyperbolic tangent function and a logic function.

Set
as the weights of the LSTM model cell to the cell j, n, φ, ω corresponds to input gate, forget gate and output gate respectively. I, H, and K are the numbers of the input layer, the hidden layer, and the output layer, respectively, and C is used to indicate the number of memory cells.
For the action value of LSTM forwards transmission and the input gate are affected by the hidden layer output value at the previous moment and the state value of all memory cells at the previous moment, under the time sequence {t|t=1, 2, 3,… T}, the input of the memory cell n is 1 1 In the above formula: is the input of the cell i with respect to the time sequence data; is the nonlinear mapping of the cell h, usually expressed by the unit excitation function . ; is the state of the memory cell c; the initial condition =0, the residual ij δ =0.
In the LSTM model memory block, except for the sequence data calculation inside the unit itself, only the output at the moment before the forget gate is transmitted to the unit. The forget gate is used to control the state of the memory cell at the previous moment, and its output is The input and status of the memory cell are respectively express as The input and output of the input gate are respectively express as The corresponding nonlinear mapping in equations (1), (2), and (5) is ( ) where k is taken as n, φ, ω. The cell output corresponding to equation (3) is controlled by the output gate, and this output is also used as the input of the entire memory module at the next moment, in the form of ( ) The Output layer is usually a softmax function or a logistic function. To facilitate the description of the residual back-transfer, first use the chain rule to define the auxiliary variable.
Where L is the loss function.
The residuals act successively with memory cells, forget gates and input gates; After the residual is first transmitted to the completion, the residual is directly used to obtain the partial derivative of the weight, there is After obtaining the local gradient, the Delta rule is used to re-adjust the weights of each layer. Finally, the iterative step of the repeated gradient descent method reduces the cost function and determines the LSTM neural network model. In this paper, in the process of training, the network is continuously trained for the formula (1-13) to minimize the loss function, so that the weight is continuously updated to obtain a complete network model.

Ship Behavior Prediction Experiments and Results
Taking AIS data of the ship engaged in the South China Sea waters as the experimental data, the data grouping is carried out based on the MMSI code to test the ship's navigation behavior. The AIS data of the ship with a speed of 3~14 knots are selected. The AIS launch interval of the ship at this speed section is 10s, so as to ensure the equal interval requirements of the ship's navigation behavior sequence data.
This paper develops LSTM ship behavior prediction software based on windows platform and python language. The ship behavior sequence data {S(t-2), S(t-1), S(t)} at the time of {t-2, t-1, t} is used as the input of the LSTM network model, and taking the ship behavior sequence data S(t+1) at time t+1 as the output.
First, build a training data set, with serial data {S(t-103), S(t-102)…… S(t-1) for 103 consecutive moments as the input of training LSTM, the sequence data {S(t-100), S(t-99)... S(t)}, which is 100 times longer than the input data, is used as the output of the training LSTM, and the third-party Numpy library of python can be used to achieve converting the data into a training data set and then normalize the data set.
Where raw x is the original data value, min( ) X is the minimum value of the original data value, max( ) X is the most n large value of the original data value, and raw x is the normalized data value. raw x is only a numerical value and does not contain any dimension.
The continuous (T-33 to T-1) 323 ship behavior sequences {S(t-33), S(t-32)... S(t-1)} are used as the initial input of the test data to predict the corresponding The ship's navigation behavior (S(t-30), S(t-29)... S(t)} at the time of (T-30 to T), the comparison between the predicted value and the true value obtained is shown in the following figures:     Figure 3 shows the comparison between the predicted value of the course and the true value. It is thus clear that the predicted value of the course is basically consistent with the true value, and maintains a good predictive ability when the change of course large as well; Figure 4 shows the comparison between the predicted value of the velocity and the true value. The curve is basically the same as the error is no more than 0.2kt; Figure 5 is the comparison between the predicted value of the position and the true value. It can be seen that the continuous ship's curve is almost completely coincident, and the error is basically below 0.01°. Figure 6 shows the loss curve of LSTM training and testing. The final results are all around 0.05, and a good fitting result is obtained. The mean square error of the predicted and actual values obtained by the calculation is 0.05, which further verifies the accuracy of the prediction results.

Conclusion
According to the characteristics of ship behavior in actual navigation, the ship behavior prediction method based on LSTM model is adopted. The Actual AIS data in South China Sea for experimental training and verification is engaged.
Using the comparison between the actual value and the predicted value of the ship's navigation behavior data, it is verified that the LSTM can effectively make the AIS time sequence data of the navigation behavior characteristics of the ship, such as the ship's position, speed and heading. At the same time, it avoids the establishment of complex ship motion models and provides new ideas for ship behavior prediction.
Compared with the traditional method, the ship behavior data predicted by the LSTM model has the advantages of high precision, good adaptability and fast prediction speed. This method gets the rid of the limitations of human supervision in navigation behavior prediction, and has higher application value in practical work. The proposed method could potentially be applied as the predictive foundation for various intelligent systems, including intelligent collision avoidance, search and rescue operation, vessel route planning, operational efficiency estimation, and anomaly detection systems.
In the next work, the LSTM network needs to be further optimized to get better prediction results using more real data and take more parameter to estimate the results of the training and improve the model to predict the ship's movements.