1. Introduction
“A country with strong transportation, parallel by land and water.” As one of the comprehensive transportation modes, waterway transportation undertakes nearly 90% of the world’s bulk trade freight volume. Due to its characteristics of low cost and large volume, the activity of the waterway transportation industry is regarded as a barometer of world and regional economic recovery. [
1]. With the rapid development of China’s shipping industry, the number of ships in the oceans, especially inland rivers, has increased dramatically, leading to an increasing trend of ship traffic accidents. Therefore, in ports or waters with high traffic density and complex conditions, improving the safety of ship navigation is a key issue [
2,
3]. Vessel Traffic Service (VTS) [
4,
5] can accurately and effectively monitor and predict the real-time trajectory of ships, which provides a technical support for the early warning of marine traffic accidents. In order to improve the safety of ship navigation in inland river environments, it is necessary to provide real-time trajectory prediction and risk warning functions for the ship’s intelligent navigation system. However, the inland river environment is complex and changeable, and traffic accidents are prone to occur, especially in crowded docks and bridge areas. Consequently, it is difficult to predict the trajectory of ships [
6].
In recent years, domestic and foreign scholars have proposed a series of ship trajectory prediction models. Anderson [
7] takes time as the independent variable, obtains the measured value of the trajectory in discrete time, and regards the trajectory as a one-dimensional Gaussian process. A prior continuous time is defined by a nonlinear time-varying stochastic differential equation driven by white noise. By obtaining the joint prior density and covariance matrix of the observed and the predicted value, the posterior distribution of the predicted value is calculated, and the smoothing trajectory is predicted by combining with dynamics. This method is computationally intensive, and its accuracy gradually decreases over time. Jiang [
8] proposed the polynomial Kalman filter method to fit the ship trajectory. This method implements trajectory prediction in a recursive manner, which occupies less memory space in the calculation process and can achieve short-term prediction. However, the assumptions of initial state and ideal conditions of the model have a greater impact on the prediction results. Literature [
9] divides the specified sea area into grids, calculates the grid state with the ship’s position, speed, and direction as the key factors, and uses the K-order Markov chain to establish a state transition matrix for prediction; however, the utilization rate of historical track information is poor when calculating the grid state at each moment. Zhang [
10] proposed a spatial clustering method based on hierarchical density clustering, adopting the DBSCAN model to cluster and denoise the original AIS trajectories to achieve the purpose of predicting ship trajectories. Rong [
11] proposed a new probabilistic trajectory prediction model, which described the uncertainty of the future position of the ship trajectory through a continuous probability distribution and has high prediction accuracy.
With the continuous in-depth research of artificial neural networks (ANN) [
12,
13], the ship trajectory prediction model based on ANN is becoming more and more popular and is widely used in the field of ship navigation [
14,
15,
16]. Literature [
17] uses the back-propagation (BP) neural network model to train and predict ship trajectory with longitude, latitude, and speed information in the AIS data, but the BP neural network has a weak ability to deal with nonlinear problems, and only in the case of a short track are the prediction results more accurate. Literature [
18] uses a support vector machine (SVM) to establish a ship trajectory prediction model and adopts speed over ground (SOG), course over ground (COG), longitude (LON), latitude (LAT), and time stamp as the input sample features, which improves the prediction efficiency and accuracy to a certain extent; however, SVM has shortcomings such as weak generalization ability and ease of falling into local extreme values. Brian [
19] proposed a dual linear auto-encoder method to predict the future trajectories of selected ships. The auto-encoder consists of two modules, encoding and decoding, which can extract hidden features of AIS data, and the model can predict the trajectory of multiple ships. However, in the process of trajectory features extraction, useless data features cannot be effectively filtered, so the prediction effect of the model is poor. Mao [
20] proposed a method for predicting ship trajectory based on an extreme learning machine (ELM). As a single-hidden-layer feed-forward neural network model, the ELM does not require weights and biases of the iterative network and has a high calculation speed. However, the number of hidden-layer nodes in the ELM model is difficult to determine, which affects the generalization performance of the network.
Recurrent neural networks (RNNs) have been extensively developed due to their powerful ability to process sequence information and predictable time information. Hochreater et al. [
21] improved the RNN unit structure and proposed a long short-term memory network (LSTM) model, which solved the problems of gradient disappearance, gradient explosion, and insufficient information memory ability by designing the “gate” structure, and LSTM networks can effectively use long-distance timing information [
22]. LSTM networks have been successfully applied in speech recognition [
23], text processing [
24], and other fields, yet there are some defects key hyperparameters, such as the number of hidden-layer neurons, learning rate, etc., which are difficult to determine [
25]. Because the number of hidden-layer neurons plays a decisive role in the fitting ability of the model, the learning rate directly affects the convergence speed and calculation time of the model and the topology of the model is controlled directly by the LSTM network structure parameters. Therefore, the prediction performance of the model established by different hyperparameters is quite different, and how to select the appropriate parameters is very important for the establishment of the model. At present, the hyperparameters of the network model are often selected based on the experience of the researchers and the results of multiple experiments. The randomness is relatively large, which affects the prediction performance of the model to a certain extent.
In order to predict the ship trajectory quickly and accurately, this paper adopts the LSTM network model [
26,
27,
28] as the technical basis to establish an inland river ship trajectory prediction model. Considering that the key hyperparameters of the current LSTM model are difficult to determine, such as the number of hidden-layer neurons, learning rate, etc., the genetic algorithm (GA) is proposed to optimize the key hyperparameters of LSTM networks. The model takes LOG, LAT, SOG, and COG as the input features and the future position of the ship as the target output. The LSTM neural network model optimized by the GA (GA-LSTM) is used to predict the ship trajectory. The experimental results show that, compared with the current classical LSTM and SVM, the algorithm proposed in this paper can predict the ship trajectory more quickly and accurately to a certain extent.
The remainder of this paper is organized as follows.
Section 2 describes the ship trajectory prediction model.
Section 3 describes the theoretical background of the LSTM, GA and GA-LSTM models. Moreover,
Section 4 mainly contains experiments and analysis. Finally,
Section 5 concludes the paper.
2. Ship Trajectory Prediction Model
An automatic identification system (AIS) can provide real-time ship trajectory data for detecting the navigation status of ships. Nowadays, it is widely used in ship collision avoidance, maritime monitoring, ship traffic flow forecasting, and maritime accident investigation mechanisms [
29]. When a ship is sailing, it mainly relies on the AIS data from the target ship to obtain its navigation behavior, so as to make timely and accurate collision avoidance decisions in complex encounters. In actual navigation, the navigation behavior of a ship is mainly reflected in the changes of characteristic variables such as ship position, SOG, and COG [
30]. It is assumed that the navigation behavior of a ship at time
can be characterized as:
where
,
,
, and
are respectively LON, LAT, SOG, and COG of the ship at time
.
Generally speaking, the navigation behavior of the ship at the next moment is the result of the current behavior and historical behavior. Therefore, in order to improve the accuracy of the model, the navigation behavior of the ship at the past three moments,
,
, and
, is taken as the input of the model and the LON and LAT of the ship at the next moment as the output of the model, namely:
This is the functional relationship between and : where is the nonlinear transformation function.
Therefore, for ship trajectory prediction, with some samples of AIS data as the training data set , obtaining the best estimate of the nonlinear transformation between the input sample and the target output sample is a problem. This paper selects the GA-LSTM model to fit the nonlinear transformation function , the GA-LSTM model is constructed with training data, and then the test data are input into the GA-LSTM model, and finally the real-time prediction of the ship trajectory is carried out.
3. LSTM Network Optimized by GA
3.1. LSTM Network Model
The LSTM neural network solves the problem of gradient disappearance and the explosion of traditional recursive neural networks linked by network units in a chain way, which can effectively improve the learning time. In dealing with the prediction of time series and nonlinear mapping problems, the LSTM model with memory ability shows strong advantages [
22]. A structure called a memory cell is added to LSTM to memorize past information, and three gate structures, input gate, output gate, and forget gate, are added to control the transmission of historical information [
31].
The structure of the LSTM neural network is shown in
Figure 1. Supposing that the network input is
and the hidden-layer state is
, at time t, the calculations of each unit and gate are shown in Equations (3)–(8):
In Formulas (3)–(8), , , and are the calculations of input gate, forget gate, and output gate, respectively; among them, the input gate is mainly used to determine how much input information at the current moment is retained to the unit state at the current moment; the forget gate is mainly used to determine how much information of the unit state from the previous moment is retained in the current cell state ; the output gate is mainly used to determine how much output the current cell state has. is the final output of the network, is the current input unit state; is the current moment unit state; , , , and are the weight matrices of the three gates and unit states; , , , and are respectively the bias of each gate and unit state; and are transfer functions; represents the vector inner product; and the symbol represents element-wise multiplication.
3.2. Genetic Algorithm
The GA is usually a biological scientific algorithm that simulates Darwin’s theory of biological evolution by a computer, proposed by J. Holland [
32] in 1975. In the genetic evolution of populations in the GA, it is found that chromosomes are used as the main carrier of population inheritance, and with the help of a variety of random operations— gene selection, gene crossover, and gene mutation—a new solution set population is constantly evolving. According to the value of individual fitness and the selection function, the optimal population individual can be selected, which is the optimal solution of the optimization problem in the GA.
In this paper, the GA is used to optimize the key hyperparameters of the LSTM network and the powerful global random search ability of the GA is adopted to obtain the optimal combination of the number of neurons and the learning rate in the LSTM network. The basic idea is as follows:
The number of hidden-layer neurons and the learning rate in the LSTM network are taken as the initialization objects of the GA, and chromosome coding is carried out in the form of real-number coding. The interval range of hidden-layer neurons is set to [2, 40], and the interval range of the learning rate is set to [0.001–0.1].
- (2)
Fitness function
The fitness function is applied to determine which individuals in the population can perform next-generation genetic operations. According to differing individual fitness, the “survival of the fittest” is used for screening individuals. The selection-of-fitness function directly affects the performance of the optimized network by the GA and then affects the performance of prediction. This paper mainly constructs the fitness function based on the overall fit between the estimated value and the true value of the ship navigation position. In order to make the network parameters obtained by the GA more suitable for the LSTM model and improve the generalization ability of the model, the AIS data are divided into training samples and test samples. The training samples are utilized for LSTM network training. After reaching the limit of the number of iterations, the training sample output value and test sample output value of the LSTM network are obtained. Then the individual fitness function is defined as:
where
and
are the predicted value of the training sample and the predicted value of the test sample, respectively, and
and
are the actual value. The error of the test sample directly reflects the prediction effect of the model; therefore, the fitness function
includes not only the fitting error of the training sample but also the verification error of the test sample. In the experiment, the error of the training sample and the error of the test sample are given the same weight, which is 0.5, and the sum of the two multiplied with the weight is used as the fitness function of the model.
- (3)
Selection operator, crossover operator, and mutation operator
The selection operator selects individuals with better adaptability as parents in the current population and passes genetic information to the offspring. Here, the tournament selection algorithm is used as the GA selection strategy. This selection strategy has the characteristics of efficient algorithm execution rate and easy implementation, and its algorithm complexity is much lower than other selection strategies and is easy to parallelize. It is not easy to fall into the local optimal individual during the selection process and does not require sorting the fitness values of all individuals. The crossover operator takes the shuffle crossover algorithm. Before the crossover, the
function is used to perform the shuffle operation in the parent, and then when the random number generated between 0 and 1 is less than the given crossover rate, the crossover transformation is performed. In the mutation operator, when the random number generated between 0 and 1 is less than the given mutation rate, the mutation operation is performed. The rule of variation about the number of hidden-layer neurons and learning rate is shown in Equation (10):
where
is the number of hidden-layer neurons in a population and
is the learning rate.
3.3. GA-LSTM Model
In this paper, the GA and LSTM neural network models are combined to construct a ship trajectory prediction model based on GA-LSTM. Firstly, the GA is adopted to optimize the hyperparameters of the LSTM network, and then the best combination of learning rate and the number of hidden-layer neurons is obtained to further improve the nonlinear mapping ability of the model; in addition, the GA-LSTM model constructed by the optimal parameter combination is used as the nonlinear transformation function between the input sample and output sample; on this basis, the nonlinear transformation function is applied to obtain the position information of the ship at the next moment. The specific operation process of the model is as follows:
- (1)
Selecting training data set.
In order to obtain the best-fitting effect of the function
, the input data of the GA-LSTM model are composed of the navigation information of the ship at the past three moments, which are represented by the vector
, and the target output is represented by the vector
. As shown in Formula (11):
- (2)
Optimizing LSTM network parameters with the GA.
a. Taking the learning rate and the number of hidden-layer units of LSTM model as the optimization objects, and then performing the initialization of the population and the chromosome encoding and decoding operations.
b. Calculating the fitness value of each individual in the initial population.
c. Performing selection, crossover, and mutation operations on chromosomes.
d. Decoding chromosomes and calculating the fitness of individuals in the population. The smaller the fitness value in this algorithm, the more the individual should be retained; otherwise, the individual should be eliminated.
e. If the genetic termination conditions are not met, it will return to Step c. If the genetic termination conditions are met, the optimal parameters calculated by the GA are taken as the final parameters of the LSTM network model.
- (3)
Training the GA-LSTM model.
Inputting and into the GA-LSTM network of the optimal parameter combination, the output of the GA-LSTM network model is the position of the ship at the next moment. The difference between the target output and the predicted output of the model is represented by the error , which is . The GA-LSTM model minimizes the fitting error according to the mean square error and finally obtains the best-fitting function between the input samples and the output samples.
- (4)
Predicting ship trajectory.
The experimental data are sent to the GA-LSTM model, and then the ship navigation position at the next moment is calculated by using the best-fitting function .
The ship trajectory prediction model framework is shown in
Figure 2. The framework is mainly composed of three parts: data preprocessing, model analysis, and error analysis. Data preprocessing is an essential part of GA-LSTM model, and the data after preprocessing can improve the overall performance of the model to a certain extent. For model analysis, the GA is introduced into the selection of network hyperparameters based on the LSTM network model, which reduces the influence of artificial determination to some extent. For error analysis, visualization and index evaluation are used to further verify the feasibility and performance of the proposed method.
5. Conclusions
In the background of world economic globalization, shipping has become one of the most important modes of transportation in international trade. The number, types, and new routes of ships continue to increase. Although the shipping trade shows a thriving atmosphere, it also makes the channel congested and the load increases, which affects the safety of ship navigation and seriously threatens the life and property safety of ship personnel. From the analysis of the ship accident investigation organization, it can be seen that human error is the main cause of marine and inland river accidents. The key to the safe navigation of ships lies in the perception of the surrounding navigation environment during the navigation process and the effective use of varied information for correct analysis and decision making. As a common navigation environment perception means, AIS has some deficiencies in the process of receiving and sending ship information, which restricts the maneuvering behavior of the ship. Knowing how to use the AIS information to accurately predict the trajectories of their own ship and the target ship in a specific time is vital for a ship driver to make a correct evaluation and decision.
In order to improve the prediction accuracy and calculation efficiency when predicting the future position of the ship in a specific period, this paper introduces the LSTM network and the GA optimization algorithm to the future position prediction of the ship and proposes a new method based on GA-LSTM to predict the course and position of inland ships. Considering the disadvantages of AIS equipment in the process of receiving and sending ship information, firstly, the collected real-time AIS data are preprocessed and the cubic spline interpolation method is adopted to interpolate data for the data loss of individual ships. Then, RNNs have powerful time-series processing capabilities, and are able to use historical information to accurately predict future state, building the ship trajectory prediction model based on the LSTM network model, and utilizing the GA optimizes the hyperparameters of the LSTM network. The GA-LSTM prediction model can minimize the impact of hyperparameter factors on the accuracy of ship trajectory prediction. In this paper, two typical ship trajectories in the Wuhan section of the Yangtze River are selected for prediction experiments and compared with the classic SVM method and the LSTM method. The experimental results show that the GA-LSTM model proposed in this paper has higher prediction accuracy and prediction speed; this model not only performs well in predicting the trajectory of the ship sailing in a straight line but also has a strong advantage in trajectory prediction when the ship starts to maneuver or maneuvers at a large angle. On the basis of high computing efficiency, it can predict ship trajectory in real time and accurately provide effective guarantee measures for the safe navigation of ships, and it has better generalization ability.
This model solves the problems of low prediction accuracy and complex calculation of ship trajectory prediction to a certain extent and has good practical application value in the intelligent navigation of inland river ships. The GA-LSTM model is similar to other time-series models, and the effect of ship trajectory prediction with long-term information is not ideal. On the basis of ensuring the prediction accuracy and speed, if the accuracy of long-distance ship position prediction can be improved, it will provide great help for ship collision avoidance and other maneuvering processes. Even though the model in this paper is based on a recursive network model, the calculation cost is relatively high in long-distance ship position prediction, and it is not practical in the collision avoidance maneuvering of unmanned ships. How to predict the ship’s position without losing prediction accuracy and efficiency and how to decrease the computational cost as well will be carried out in further work.