Ship Trajectory Prediction: An Integrated Approach Using ConvLSTM-Based Sequence-to-Sequence Model

: Maritime transportation is one of the major contributors to the development of the global economy. To ensure its safety and reduce the occurrence of a maritime accident, intelligent maritime monitoring and ship behavior identiﬁcation have been drawing much attention from industry and academia, among which, the accurate prediction of ship trajectory is one of the key questions. This paper proposed a trajectory prediction model integrating the Convolutional LSTM (ConvLSTM) and Sequence to Sequence (Seq2Seq) models to facilitate simultaneous extraction of temporal and spatial features of ship trajectories, thereby enhancing the accuracy of prediction. Firstly, the trajectories are preprocessed using kinematic-based anomaly removal and Hierarchical Density-Based Spatial Clustering of Applications with Noise (HDBSCAN) to improve the data quality for the training process of trajectory prediction. Secondly, the ConvLSTM-based Seq2seq model is designed to extract temporal and spatial features of the ship trajectory and improve the performance of long-time prediction. Finally, by using real AIS data, the proposed model is compared with the Seq2Seq and Bidirectional LSTM based on attention mechanism (Bi-Attention-LSTM) models to verify its effectiveness. The experimental results demonstrate that the proposed model achieves excellent performance in predicting turning trajectories, good predictive accuracy on straight line motions, and greater improvement in prediction accuracy compared to the other two benchmark models. Overall, the proposed model represents a promising contribution to improving ship trajectory prediction accuracy and may enhance the safety and quality of ship navigation in complex and volatile marine environments.


Introduction
With the growth of international trade, maritime transportation has become one of the most critical trade transportation modes.However, in the waterways where the navigation environment is complex and high traffic density occurs, the behavior of ships tended to be complicated and poses an increasing risk of maritime accidents.Navigation safety is one of the challenges faced by smart ship applications [1].To prevent and manage potential risks, it is essential to employ intelligent ship management and monitoring strategies that enable reliable identification of ship behavior and intentions in specific areas, within which the accurate prediction of ship behavior and trajectories have been drawing much attention from both academia and industry.
At present, various scholars have carried out research work on ship trajectory prediction.Rong et al. [2] proposed a probabilistic trajectory prediction model, which decomposed ship motion prediction into two directions, horizontal and vertical, and calculated position probabilities along these two directions.There are also studies, e.g., [3], which applied machine learning technique to infer commonalities of related trajectory segments.Subsequently, the trajectory associated with that pattern was predicted.Yang et al. [4] combined Density-Based Spatial Clustering of Applications with Noise (DBSCAN) and Long Short-Term Memory (LSTM) models for trajectory prediction.In general, the research on ship trajectory prediction based on AIS data could be divided into methods based on statistics and methods based on Neural Networks and Deep Learning.
The ship trajectory prediction method based on statistics constructs the mathematical model of the trajectory through the historical data of the ship.According to the literature following this approach, the major statistic methods for trajectory prediction are as follows: Kalman filter [5,6], hidden Markov model [7,8], Bayesian network [9,10], Gaussian process [2], and Gaussian mixture model [11].Most of the ship trajectory prediction methods based on statistics have the advantages of simplicity, unbiasedness, and fast calculation, such as Kalman filter and GMM models.However, in non-linear mid-to-long-term scenarios, statistical-based forecasting methods no longer have good applicability, and there is a problem of low forecasting accuracy.For example, the Kalman filter has linear characteristics and cannot achieve the optimal estimation effect in non-linear scenarios.On the other hand, HMM can only utilize contextual information by building a high-level model.Therefore, it is necessary to find more suitable prediction methods for non-linear scenarios.
The emergence of deep learning (DL) provides a promising solution to precisely address this problem.From the research framework of trajectory prediction based on neural networks and deep learning, trajectory prediction research involves three major procedures: Data Processing, Model Structure design, and Model Optimization.
In terms of data processing, data filtering can use machine learning methods such as clustering and filtering to process ship trajectory data to obtain training data sets.For example, Suo et al. [12] used the DBSCAN algorithm to cluster trajectories to construct a training dataset for ship trajectory prediction.Some scholars have carried out more detailed research on the basis of dividing the data into four datasets: straight line, turning, acceleration, and deceleration; Gao et al. [13] used cubic spline interpolation and median filtering to process AIS data to eliminate the measurement error and time interval inconsistency of AIS data.These machine-learning-based practices help to build reliable datasets for deep learning models and improve the prediction accuracy of the models.In addition, semantic representation is also used to divide ship trajectories.Semantic representation of ship behavior using autoencoding and other methods, e.g., [14], have been used in the construction of training data sets.From the work aforementioned, one can see that constructing a trajectory set with rich and significant ship behavior characteristics is a necessary basis for ship trajectory prediction.
In terms of model structure design, Zhang et al. [15] used recurrent neural networks, a variant of LSTM networks, to model ship trajectories.And Suo et al. [12] used GRU for modeling.Although ship trajectory points all have behavioral characteristics, trajectory points such as turning, acceleration, and deceleration have a greater impact on subsequent trajectory behavior than ordinary straight-line points.Sekhon and Fleming [16] used spatial attention and temporal attention to optimize the model on the LSTM model so that the model could consider the influence of historical trajectory space and time on the future trajectory.In [17], a ship trajectory prediction model based on a multi-head attention mechanism and bidirectional gated recurrent unit (MHA-Bi-GRU) was proposed.In addition, due to the need to maintain a large distance between ships, many researchers believe that the behavior of other ships will also affect the prediction of ship behavior.Liu et al. [18] used the ship traffic conflict situation model generated by dynamic AIS data and social force concept to embed it into the LSTM network.
In order to obtain the good performance of different models, some researchers have combined the models for trajectory prediction research.In [19], a method of combining GRU with AM by a multi-scale convolutional neural network (MSCNN) and performing parallel collection with an autoregressive (AR) model is proposed.Abebe et al. [20] decomposed the AIS data into linear and nonlinear by using the moving average filter (MA) and applied ARIMA and LSTM to model the ship trajectory, respectively.To enhance the accuracy of long-term trajectory prediction, Forti et al. [21] employed a sequence-to-sequence neural network underpinned by a long short-term memory (LSTM) encoder-decoder framework to model the temporal dependencies in longer ship trajectory sequences.In [22], Wang proposed a generative adversarial network with an attention module and an interaction module, which could simultaneously infer the future trajectories of all ships in the same area.Considering the advantages of the attention mechanism and the Seq2Seq model, [23] used the Transformer model to build a ship trajectory prediction model, which consisted of self-attention to form a codec, making the model more efficient and accurate.
With the development of the graph convolutional neural network, Liu et al. [24] proposed a trajectory prediction framework based on spatio-temporal, multi-graph convolutional networks.The graphs used in the framework included the time to the nearest point and the size of surrounding ships according to the social force model.
The optimization of models can be categorized into parameter optimization and output optimization.Parameter optimization refers to the tuning of neural network hyperparameters through heuristic algorithms and other techniques [25].In [26], a Genetic Algorithm (GA) was used to optimize the hyper-parameters of the trajectory prediction framework LSTM.Model output optimization uses other models to optimize the output results of the neural network model to obtain a more accurate and realistic ship prediction trajectory.Ref. [27] cascades the data-driven predictor through the Kalman filter and the motion estimation model and uses the output of the data-driven predictor as the input of the filter to optimize the predicted trajectory.In [28], model predictive control is used to modify the output of the trajectory prediction model to ensure that the predicted trajectory satisfies the kinematic constraints.
While many machine learning methods have been used in the data processing part, researchers have found that the conventional ship trajectory processing methods are insufficient in integrating trajectory characteristics for ship trajectories in densely navigated waters.At the same time, due to the significant temporal relationship in the context of trajectory sequences, most studies focus more on extracting temporal features of ship trajectories while ignoring the spatial connections between trajectory points.Although some researchers have introduced graph convolution methods from roads to extract the spatial features of ship trajectories, the application of graph convolutional networks to ship trajectory prediction is not without challenges.One such difficulty is the inherent difficulty in modeling ship trajectories with graph networks as road networks possess well-defined nodes and edges, unlike the complex spatial features of ship trajectories.
All in all, extracting the spatio-temporal features of ship trajectories to obtain more accurate trajectories is of great significance for the identification of ship navigation intention and, therefore, improving the intelligent supervision of ships.The purpose of this study is to propose an accurate prediction method for ship trajectory in complex waters based on the spatio-temporal characteristics of ship trajectory.Compared with previous work, this paper uses different data repair and cluster analysis methods and tries to use a ConvLSTM unit to simultaneously extract temporal and spatial features of ship trajectories, rather than a spatial attention mechanism or graph neural network.The contribution of this work is as follows: 1.After data processing steps such as kinematics-based anomaly detection and Hierarchical Density-Based Spatial Clustering of Applications with Noise (HDBSCAN), ship trajectory clusters with stronger correlations are obtained.It helps to improve the accuracy of trajectory prediction; 2. Expand the ship trajectory into a graph-like format and use the Seq2Seq model based on ConvLSTM to model the ship trajectory so that the model can extract the temporal and spatial characteristics of the trajectory.
The rest of the paper is organized as follows: Section 2 introduces the basic principles of related methods and models; Section 3 introduces data preparation and model details; Section 4 uses real-world trajectory data as a case to experiment with the model; Section 5 discusses the results of the proposed model; Section 6 summarizes and discusses the main innovations of this study and suggests possible directions for further research.

Overall Design
The purpose of this study was to propose an accurate prediction method for ship trajectory in complex waters based on the spatio-temporal characteristics of ship trajectory.To achieve this goal, the following two components need to be conducted: (1) Data preprocessing: First, the historical AIS data were extracted and preprocessed to remove the outliers from the trajectory data, using a trajectory anomaly detection method based on kinematic interpolation, to ensure the accuracy of the trajectory data; Second, the Douglas-Peucker (DP) compression algorithm was used to compress the outlier-removed trajectories without losing the characteristics.Then, the HDBSCAN method was used to perform the cluster analysis on the compressed trajectory data, and the trajectory data were effectively classified according to the characteristics to facilitate the subsequent feature extraction and learning of the model.Finally, the classified trajectory data are interpolated at equal intervals using the cubic spline interpolation method to obtain trajectory data with the same time interval.( 2 This section describes the model used in this method in detail, and the overall framework flow of the model is shown in Figure 1.
discusses the results of the proposed model; Section 6 summarizes and discusses the main innovations of this study and suggests possible directions for further research.

Overall Design
The purpose of this study was to propose an accurate prediction method for ship trajectory in complex waters based on the spatio-temporal characteristics of ship trajectory.To achieve this goal, the following two components need to be conducted: (1) Data preprocessing: First, the historical AIS data were extracted and preprocessed to remove the outliers from the trajectory data, using a trajectory anomaly detection method based on kinematic interpolation, to ensure the accuracy of the trajectory data; Second, the Douglas-Peucker (DP) compression algorithm was used to compress the outlier-removed trajectories without losing the characteristics.Then, the HDBSCAN method was used to perform the cluster analysis on the compressed trajectory data, and the trajectory data were effectively classified according to the characteristics to facilitate the subsequent feature extraction and learning of the model.Finally, the classified trajectory data are interpolated at equal intervals using the cubic spline interpolation method to obtain trajectory data with the same time interval.(2) Ship trajectory prediction based on sequence-to-sequence model and ConvLSTM: On the basis of the data preprocessing, the ConvLSTM network was applied to extract the features of the trajectory data from two aspects of time and space to improve the feature extraction ability of the model.Combining the ConvLSTM network and the Seq2Seq model, a sequence-to-sequence ship trajectory prediction model with stronger spatiotemporal feature extraction and reconstruction capabilities was established.The preprocessed data were used to train the model, and a ship trajectory prediction method with the advantage of trajectory spatiotemporal feature extraction ability was obtained.This section describes the model used in this method in detail, and the overall framework flow of the model is shown in Figure 1.

Abnormal Data Removal
Due to the fact that the original ship AIS data could contain various outliers, which would greatly affect the applicability of AIS data in trajectory prediction tasks, this study adopted a trajectory anomaly detection method that comprehensively utilized ship kinematics information in AIS data to remove the potential abnormal data points.This method could identify both position anomalies and velocity anomalies and showed better performance than traditional methods that only considered the problem from the perspective of position [29].The trajectory anomaly detection method based on kinematics information could effectively remove the outliers of trajectory data and provide basic support for trajectory classification and model feature extraction.The trajectory anomaly detection method based on kinematics information processed trajectory data in three steps: (1) Kinematics estimation model of AIS data.(2) Anomaly detection of AIS data based on error clustering.
(3) Iteration based on loop detection with termination condition.

HDBSCAN for Trajectory Clustering
Cluster analysis of trajectory data can preliminarily identify and classify different motion behaviors of ships.It is helpful for the neural network model to extract and learn features of similar ship trajectories.In this study, a density clustering method based on HDBSCAN was used to cluster the trajectory data.This method could not only identify the noisy data but also cluster ship trajectories with different densities.It was more efficient in identifying ship-intensive waters, especially complex confluence waters [30].Although density-based methods could cluster trajectories of arbitrary shape, classical density-based algorithms are poor at clustering data clusters with different density distributions in the detection density space.By introducing the hierarchical clustering structure of the data, HDBSCAN based on DBSCAN has the ε (ε is used to judge whether other points are in the neighborhood of the current point) value of the stable function.The calculation process of the HDBSCAN algorithm could be described as: (1) Build a minimum spanning tree based on a similarity measure.(2) Build a hierarchical cluster structure.(3) Compression Clustering Hierarchy Based on Minimal Clusters.(4) Classification using spanning trees.

Cubic Spline Interpolation
The Cubic spline interpolation method is commonly used in space-time trajectory synchronization.When the space-time trajectory of the ship was missing, the cubic spline interpolation method had a good repair and synchronization effect.Normally, due to various factors, the time interval between the trajectory points of AIS data was usually inconsistent, and the trajectory data could be interpolated to obtain ship trajectory data at equal intervals as required, which helped to extract the temporal features of different ship trajectories.In this study, a cubic spline interpolation method was used to interpolate the trajectory data.The cubic spline function was defined as follows: Set on the interpolation interval [a, b], given n + 1 interpolation nodes is called the cubic spline interpolation function of f (x).

ConvLSTM-AI Network
In this study, the ConvLSTM network is used for feature extraction of trajectory data.ConvLSTM can not only establish a temporal relationship similar to LSTM but also have the ability to extract spatial features similar to CNN.The original purpose of this model is to solve the problem of precipitation forecasting.The problem of precipitation forecasting is usually regarded as a time-series problem, but a simple LSTM cannot use spatial data features through pictures.Ship trajectory prediction is also a prediction problem of a set of time-space sequences, and neither time nor space sequences only can fully represent the characteristics of ship trajectory data.Therefore, ConvLSTM is introduced to solve this problem.
ConvLSTM is a variant of LSTM.The difference between it and LSTM is that it uses convolution calculations instead of weight calculations, which is to say that a convolution operation process is added to each gate of the LSTM unit so that feature extraction can be performed through convolution operations in multidimensional data [31].In the ConvLSTM model, all of its inputs X and gates i t , f t , and o t are 3D tensors, where the last two dimensions represent the spatial dimensions (rows and columns).The key equations of ConvLSTM model are shown in Equations ( 1)-( 5), and the calculation of the convolution operation is shown in Figure 2.
In this study, the ConvLSTM network is used for feature extraction of trajectory data.ConvLSTM can not only establish a temporal relationship similar to LSTM but also have the ability to extract spatial features similar to CNN.The original purpose of this model is to solve the problem of precipitation forecasting.The problem of precipitation forecasting is usually regarded as a time-series problem, but a simple LSTM cannot use spatial data features through pictures.Ship trajectory prediction is also a prediction problem of a set of time-space sequences, and neither time nor space sequences only can fully represent the characteristics of ship trajectory data.Therefore, ConvLSTM is introduced to solve this problem.
ConvLSTM is a variant of LSTM.The difference between it and LSTM is that it uses convolution calculations instead of weight calculations, which is to say that a convolution operation process is added to each gate of the LSTM unit so that feature extraction can be performed through convolution operations in multidimensional data [31].In the ConvLSTM model, all of its inputs  1)-( 5), and the calculation of the convolution operation is shown in Figure 2.
( ) tanh( ) tanh( )   In all the above formulas: i t is the state retention probability of the output gate; σ is the Sigmoid activation function; tanh is the Hyperbolic Tangent (tanh) activation function; x t is the input at time t; • is the Hadamard product; * is the convolution operator; f t is the state retention probability of the forgetting gate; C t is the unit state at time t; o t is the output probability of the output gate at time t; H t is the output of the hidden layer at time

Ship Trajectory
The ship trajectory sequence is generally represented as a space-time sequence, which consists of multiple tuples such as spatial coordinates and timestamps.A space-time sequence can be formally expressed as: Among them, Tra (j) (j = 1 • • • N), N is the total number of ship trajectories, Tra (j) representing the j-th sub-trajectory; i indicating the i-th timestamp of the j-th sub-trajectory; and x i (j) , y i (j) indicates the j-th sub-trajectory.The longitude and latitude of the ship at the moment.

Trajectory Data Preprocessing
This step is mainly to preprocess the trajectory data obtained from AIS and screen out trajectory clusters with the same characteristics.The first step is to eliminate abnormal data.
(1) Trajectory anomaly detection method based on kinematics information to process trajectory data.
(1.1) Estimate the data points of the ship's trajectory according to the kinematic characteristics of the ship's speed and heading.(1.2) A modified k-means method is used to identify the details of the anomalies estimated by the AIS kinematics.(1.3)All outliers in the trajectory data are detected by repeating the motion estimation and error clustering process, and the clustering performance is evaluated with the silhouette coefficient as the termination condition.
(2) Mercator transformation, using the Mercator projection to transform the latitude and longitude of the spherical coordinates into Mercator projection coordinates.(3) Trim the trajectory using a threshold.By analyzing the AIS data with abnormal points removed, the following three phenomena can be found in the trajectory data.For example, although the time difference between two trajectory points of a ship is relatively large, they are considered as one trajectory.A ship with a short trajectory is not meaningful for research.A ship's Speed Over Ground (SOG) and Course Over Ground (COG) exhibit different values than normal trajectories.In order to remove this effect, the time threshold, trajectory points threshold, and SOG and COG thresholds are used to differentiate these data.A ship trajectory is segmented into discrete voyages when the temporal gap between consecutive data points surpasses a predefined threshold.For trajectories containing data points less than the preset threshold, they will be considered noise and removed from the data set.A preliminary trajectory data cleaning is also conducted by removing the data points with abnormal SOG and COG.
The second is HDBSCAN clustering: (1) Compressed data.Based on the Douglas-Peucker compression algorithm, the trajectory can be compressed without losing shape features.The algorithm compresses the curve graphics from the overall point of view and determines the final point sequence to be retained by finding the key points of each segment in the curve.This algorithm is based on connecting a straight line between the first and last points of each trajectory and then calculating the distance between all points and the straight line.The maximum distance value d max is then identified.If d max is less than the tolerance value d, all intermediate points on the curve are discarded.On the other hand, if d max is greater than or equal to d, the coordinate point corresponding to d max is kept.The curve is then divided into two parts at this point, and the same process is repeated for each part.(2) HDBSCNA clustering trajectory.The algorithm has two input parameters: min cluster size and min samples.The former represents the minimum size of the cluster and is the core parameter of HDBSCAN.The larger this parameter is, the fewer species will be clustered in the final cluster, and points less than this will be considered as 'noise'.The latter is min samples, which defines the number of samples a point has in its neighborhood.
To determine the values of the two parameters of the clustering algorithm, a comprehensive evaluation method that combines the Silhouette Coefficient (SC) and Davies-Bouldin index (DBI) is used to evaluate the clustering performance.This evaluation method involves calculating the clustering performance for different parameter values and selecting the parameter value that corresponds to the clustering result with the best performance.For details on setting the parameters of HDBSCAN and DP algorithm to specific values, please refer to Section 4.1.
The last is cubic spline interpolation.The cubic spline interpolation function can obtain the cubic spline interpolation of the time-longitude trajectory and the time-latitude trajectory, respectively, and the ship's navigation trajectory can be obtained by combining the above two cubic spline curves.Cubic spline interpolation can effectively provide equidistant data by interpolating trajectory data.

Trajectory Prediction
The conventional LSTM method has better performance on the prediction of time series data than that of spatial data.The data of the LSTM model is usually represented by two dimensions: one represents the stack of time steps, and the other represents the characteristics of the current time step.To overcome the shortcomings of LSTM in processing spatial information, ConvLSTM was developed.For the data at each moment, ConvLSTM replaces the fully connected operation of each gate in LSTM with a convolution operation, i.e., matrix multiplication becomes a convolution calculation.Based on previous experiments, this paper replaces the activation function of the input information (default tanh) and current hidden state output (default tanh) in the ConvLSTM model with Rectified Linear Unit (ReLU) to achieve better results.At the same time, this approach has been verified in RNN [32].The unit structure of ConvLSTM with ReLU activation function is shown in Figure 3.
ered as 'noise'.The la5er is min samples, which defines the number of samples a point has in its neighborhood.To determine the values of the two parameters of the clustering algorithm, a comprehensive evaluation method that combines the Silhoue5e Coefficient (SC) and Davies-Bouldin index (DBI) is used to evaluate the clustering performance.This evaluation method involves calculating the clustering performance for different parameter values and selecting the parameter value that corresponds to the clustering result with the best performance.For details on se5ing the parameters of HDBSCAN and DP algorithm to specific values, please refer to Section 4.1.
The last is cubic spline interpolation.The cubic spline interpolation function can obtain the cubic spline interpolation of the time-longitude trajectory and the time-latitude trajectory, respectively, and the ship's navigation trajectory can be obtained by combining the above two cubic spline curves.Cubic spline interpolation can effectively provide equidistant data by interpolating trajectory data.

Trajectory Prediction
The conventional LSTM method has be5er performance on the prediction of time series data than that of spatial data.The data of the LSTM model is usually represented by two dimensions: one represents the stack of time steps, and the other represents the characteristics of the current time step.To overcome the shortcomings of LSTM in processing spatial information, ConvLSTM was developed.For the data at each moment, ConvLSTM replaces the fully connected operation of each gate in LSTM with a convolution operation, i.e., matrix multiplication becomes a convolution calculation.Based on previous experiments, this paper replaces the activation function of the input information (default tanh) and current hidden state output (default tanh) in the ConvLSTM model with Rectified Linear Unit (ReLU) to achieve be5er results.At the same time, this approach has been verified in RNN [32].The unit structure of ConvLSTM with ReLU activation function is shown in Figure 3.The asterisk '*' in the figure indicates convolution calculation, and the others are the same as in Section 2.3.In this way, it captures the underlying spatial features by performing convolution operations in multidimensional data, allowing ConvLSTM to make predictions from the current input and the past states of local neighbors.This approach enables ConvLSTM not only to establish a temporal relationship similar to LSTM but also to have a spatial feature extraction capability similar to CNN.Experiments have proved that ConvLSTM has a better effect than LSTM in acquiring spatio-temporal relationships [31].
The ConvLSTM model in this research consists of a ConvLSTM-based encoder layer, a decoder layer, and a separate convolutional layer, respectively.The structure of the model is shown in Figure 4.
dictions from the current input and the past states of local neighbors.This approach enables ConvLSTM not only to establish a temporal relationship similar to LSTM but also to have a spatial feature extraction capability similar to CNN.Experiments have proved that ConvLSTM has a better effect than LSTM in acquiring spatio-temporal relationships [31].
The ConvLSTM model in this research consists of a ConvLSTM-based encoder layer, a decoder layer, and a separate convolutional layer, respectively.The structure of the model is shown in Figure 4.As shown in Figure 4, for each input sample original trajectory sequence, the data format conversion is performed first, and the longitude and latitude of the ship trajectory are, respectively, used as the characteristics of the two dimensions.Thus, the latitude and longitude of the ship trajectory become a point in the two-dimensional grid, which has a spatial relationship.The specific form is shown in Figure 5.  , , t  x x x ⋯ with a number of t, and, at the same time, t also represents the length of the input trajectory sequence.Then, the trajectory As shown in Figure 4, for each input sample original trajectory sequence, the data format conversion is performed first, and the longitude and latitude of the ship trajectory are, respectively, used as the characteristics of the two dimensions.Thus, the latitude and longitude of the ship trajectory become a point in the two-dimensional grid, which has a spatial relationship.The specific form is shown in Figure 5.
bles ConvLSTM not only to establish a temporal relationship similar to LSTM but also to have a spatial feature extraction capability similar to CNN.Experiments have proved that ConvLSTM has a better effect than LSTM in acquiring spatio-temporal relationships [31].
The ConvLSTM model in this research consists of a ConvLSTM-based encoder layer, a decoder layer, and a separate convolutional layer, respectively.The structure of the model is shown in Figure 4.As shown in Figure 4, for each input sample original trajectory sequence, the data format conversion is performed first, and the longitude and latitude of the ship trajectory are, respectively, used as the characteristics of the two dimensions.Thus, the latitude and longitude of the ship trajectory become a point in the two-dimensional grid, which has a spatial relationship.The specific form is shown in Figure 5.  , , t  x x x ⋯ with a number of t, and, at the same time, t also represents the length of the input trajectory sequence.Then, the trajectory Then, generate a trajectory sequence {x 1 , x 2 , • • • , x t } with a number of t, and, at the same time, t also represents the length of the input trajectory sequence.Then, the trajectory sequence is used as the input of the encoder layer, and the ConvLSTM network encodes the trajectory sequence in a many-to-many form.For the ConvLSTM unit, the longitude and latitude of the trajectory are no longer regarded as two features in one dimension, but as the values corresponding to the two dimensions.Therefore, the encoding of the trajectory sequence has both the temporal relationship of the input sequence and the spatial feature relationship of the input sequence.The encoder layer exports the encoding result and hidden feature matrix h at the same time.The decoded layer outputs the decoding sequence, which is then passed through a convolutional layer to produce the predicted trajectory sequence.In the training phase, the decoder layer also uses the input sequence for decoding auxiliary training to help the network model learn quickly.In the prediction stage, the decoder uses the output of the previous time step of the ConvLSTM unit as its decoding aid.Finally, the predicted trajectory sequence is converted into a trajectory sequence, and the output is a predicted trajectory sequence y t+1 , y t+2 , • • • , y t+q with a number of q.

Evaluation Function
In this paper, Root Mean Square Error (RMSE) is used to evaluate the overall performance of the model, and the Mean Distance Error (MDE) between the predicted data and the real AIS data are used to evaluate the prediction results.The specific calculation method is as follows: Among them, P is the total data volume of AIS, Y i is the predicted value of the network model, and y i is the expected output value.Lat i is the predicted value of the latitude of the network model, and lat i is the expected output value of the latitude.Log i is the longitude prediction value of the network model, and log i is the longitude expected output value.These predicted values and expected output values are the longitude and latitude values under the Mercator transformation.

Case Study
In this section, a case study on trajectory prediction of the proposed ConvLSTM-based Seq2Seq ship trajectory prediction model was carried out to verify the effectiveness of the method.The data utilized in this study were real historical data.The case study area was within the following boundaries: Latitude: 31.08 • N to 31.00 • N; Longitude: 122.0 • E to 122.4 • E. In order to prove the effectiveness of the proposed prediction model and avoid the influence of AIS data on ships with special nature of work, this case excluded the AIS data of small working boats, pilot boats, and fishing boats.The details of the case study are shown in Table 1, and the initial ship trajectories in the study waters are shown in Figure 6.

AIS Data Preprocessing
According to the geographical information and the set boundaries of the study area, this article selected the AIS data on 1 May 2019, and used the trajectory data elimination method in Section 3.2 to obtain 280 ship trajectory sets.First, the initial AIS data are read, and trajectory estimation points are generated according to the kinematic characteristics of the ship.Then, position and velocity errors between estimated points and trajectory data are analyzed.After that, the kinematic-based anomaly detection proposed by Guo et al. [29] is used to identify the error data.And, by repeating the above steps, abnormality detection is realized.The trajectory data after removing abnormal data are shown in Figure 7.

Ship type
Cargo ship

AIS Data Preprocessing
According to the geographical information and the set boundaries of the study area, this article selected the AIS data on 1 May 2019, and used the trajectory data elimination method in Section 3.2 to obtain 280 ship trajectory sets.First, the initial AIS data are read, and trajectory estimation points are generated according to the kinematic characteristics of the ship.Then, position and velocity errors between estimated points and trajectory data are analyzed.After that, the kinematic-based anomaly detection proposed by Guo et al. [29] is used to identify the error data.And, by repeating the above steps, abnormality detection is realized.The trajectory data after removing abnormal data are shown in Figure 7.After applying trajectory anomaly detection, as seen in Figure 7, the anomalies in the original data that deviate from the expected kinematic characteristics of the ship are removed.This step ensures that the remaining trajectories accurately represent the ship's true trajectory.
Due to the large number of trajectories, this article uses the DP algorithm to reduce the amount of ship trajectory data to accelerate the clustering process, and 100 m was utilized as the threshold of each trajectory to maintain the shape characteristics of the trajectory.The trajectory data were then clustered by the HDBSCAN algorithm.For its two parameters, this article used an adaptive method (Loop to find the optimal value) to receive the optimal values of min cluster size = 9 and min samples = 8.Finally, this article used cubic spline interpolation to complete the space between trajectory data and performed 20 s equidistant interpolation.An example of the interpolation effect is shown in Figure 8.After applying trajectory anomaly detection, as seen in Figure 7, the anomalies in the original data that deviate from the expected kinematic characteristics of the ship are removed.This step ensures that the remaining trajectories accurately represent the ship's true trajectory.
Due to the large number of trajectories, this article uses the DP algorithm to reduce the amount of ship trajectory data to accelerate the clustering process, and 100 m was utilized as the threshold of each trajectory to maintain the shape characteristics of the trajectory.The trajectory data were then clustered by the HDBSCAN algorithm.For its two parameters, this article used an adaptive method (Loop to find the optimal value) to receive the optimal values of min cluster size = 9 and min samples = 8.Finally, this article used cubic spline interpolation to complete the space between trajectory data and performed 20 s equidistant interpolation.An example of the interpolation effect is shown in Figure 8.As shown in Figure 8, the cubic spline interpolation method demonstrates excellent performance in interpolating the trajectories of ships with large, curved sections, as well as general ship trajectories.The resulting interpolated ship trajectories are generally smooth and accurately represent the ship's actual movement.
After performing several data preprocessing operations, this article obtained a total of 184 ship trajectories.These trajectories were then organized into six distinct clusters, as shown in Figure 9.As shown in Figure 8, the cubic spline interpolation method demonstrates excellent performance in interpolating the trajectories of ships with large, curved sections, as well as general ship trajectories.The resulting interpolated ship trajectories are generally smooth and accurately represent the ship's actual movement.
After performing several data preprocessing operations, this article obtained a total of 184 ship trajectories.These trajectories were then organized into six distinct clusters, as shown in Figure 9.
As shown in Figure 8, the cubic spline interpolation method demonstrates excellent performance in interpolating the trajectories of ships with large, curved sections, as well as general ship trajectories.The resulting interpolated ship trajectories are generally smooth and accurately represent the ship's actual movement.
After performing several data preprocessing operations, this article obtained a total of 184 ship trajectories.These trajectories were then organized into six distinct clusters, as shown in Figure 9.As exhibited in Figure 9, after a series of preprocessing operations, the trajectory data within the selected area were clustered into six groups.In comparison to Figure 7, some trajectory data without clear characteristics were excluded as noise, whereas small missing pieces of ship trajectory data were interpolated to create a continuous trajectory.The trajectory exhibited in Figure was partitioned into three distinct datasets according to the characteristics of the clusters.The first dataset consisted of black and red trajectory clusters, which exhibited numerous curved segments.The second dataset included the yellow and blue trajectory clusters, which had a relatively significant single curved segment.The final dataset contained the green and pink trajectory clusters, which were relatively straight in comparison to the other clusters.
In order to make model training more efficient and accurate, the min-max normalization method was used to normalize the data, and the min-max normalization was given by the following formula: In the formula:  As exhibited in Figure 9, after a series of preprocessing operations, the trajectory data within the selected area were clustered into six groups.In comparison to Figure 7, some trajectory data without clear characteristics were excluded as noise, whereas small missing pieces of ship trajectory data were interpolated to create a continuous trajectory.The trajectory exhibited in Figure 9 was partitioned into three distinct datasets according to the characteristics of the clusters.The first dataset consisted of black and red trajectory clusters, which exhibited numerous curved segments.The second dataset included the yellow and blue trajectory clusters, which had a relatively significant single curved segment.The final dataset contained the green and pink trajectory clusters, which were relatively straight in comparison to the other clusters.
In order to make model training more efficient and accurate, the min-max normalization method was used to normalize the data, and the min-max normalization was given by the following formula: In the formula: 1 ≤ i ≤ n, max{z max } is the maximum value of the sample data, min{z min } is the minimum value of the sample data, and the converted data are all within [0,1].
Then, the training sample is divided by the sliding window method.For a trajectory, the trajectory points Tra i , Tra i+1 • • • , Tra p−1 , Tra p of the first p consecutive time steps is used as the input sample, and the trajectory points of the subsequent q consecutive time steps are used as the predicted trajectory Tra p+1 , • • • , Tra q−1 , Tra q .This experiment will predict the trajectory data of the ship in the next 10, 15, and 20 min.

Trajectory Prediction
This study involves two different testing methods on three datasets, each serving a different purpose.The data set is divided into a training set and a test set according to the ratio of 8:2, and a trajectory is randomly extracted from the test set as the target trajectory.Firstly, the performance of the model is tested on the trajectory with clear maneuvering behavior and the long straight trajectory to verify its validity.For this purpose, Dataset 2 and Dataset 3 were selected, and a target prediction length of 20 min was chosen.Secondly, the ability of the model to monitor ship behavior was examined by analyzing its performance on trajectories that indicated different characteristics for an extended period of time.To achieve this, Dataset 1 was selected, and a target forecast length of 60 min for this trajectory was chosen.This approach allowed for a comprehensive analysis of the model's predictive capabilities across the three different datasets.
The operating system used in this experiment was Windows 10, the programming software was Pycharm, and the deep learning framework was tensorflow v2.3.0.In this experiment, the training model structure consisted of ConvLSTM layers with 64 output units and a 1 × 2 convolutional nuclear unit.The Convolutional layer had one output unit with a 1 × 2 convolutional nuclear unit.The setting of the convolution kernel was to perform convolution operations on the latitude and longitude data.The model was trained using the ADAM optimizer with a learning rate of 0.001 and a training loss function of Mean Squared Error.A batch size of 36 was used.During the prediction stage, the model predicted the trajectory in the form of accumulated errors, whereby all input data, except for the first historical data input, were predicted data from the model's previous output.
To assess the influence of input and output lengths on the model, the input and output were set to p and q = 5, 10, 15, 20, and 25 with a total input and output length, respectively.Each model length was consistent with other settings, except for the epoch.To reduce randomness and improve the accuracy of experiment, the RMSE and MDE of each model were averaged over five experiments, and the maximum and minimum RMSE and MDE were recorded for each group.Prediction results for different input and output lengths were tabulated in Tables 2-4, and prediction result icons were illustrated in Figures 10-12.Regarding Figures 10 and 12, both the trajectories at p = 20, q = 20 and the original trajectories closely resemble the trend and length.In Figure 10, there is noticeable bending in all five trajectories, with the trajectories at p = 25 and q = 25 exhibiting a soft reverse trend, and each trajectory demonstrating a gentler cornering trend towards the middle of the turn.In Figure 11, the five trajectories are significantly longer than the original trajectory, and the trajectories corresponding to p = 5, q = 5; p = 10, q = 10; and p = 15, q = 15 appear to be jittering and not smooth enough.When p = 20, q = 20 and p = 25, q = 25, the trajectory jitter is alleviated and smoother.As illustrated in Figure 12, the trajectory at p = 25, q = 25 closely resembles the trend and length of the original trajectory, with the distance between the mark points remaining relatively consistent.Conversely, the trajectory at p = 15, q = 15 exhibits a shorter length than the original trajectory, and the trend differs the most from the raw trajectory.The remaining trajectories are all longer than the raw trajectory, and the distance between points is larger than that in the original trajectory.As demonstrated by Tables 2-4, the length of the input and output parameters in the model affects its performance.For both Dataset 2 and Dataset 3, the models with p = 20 and q = 20 have the smallest average RMSE and MDE values, whereas p = 15 and q = 15 lead to the highest values of both metrics.Specifically, when predicting a 20 min trajectory, the average RMSE and MDE values for Dataset 2 are 148.71and 180.84, respectively, with p = 20 and q = 20, whereas the corresponding numbers for p = 15 and q = 15 are 249.13 and 338.81.When p = 20 and q = 20, the average MDE was 106.54 for a 10 min trajectory but increased to 180.84 for a 20 min trajectory, representing a 69.74% increase in MDE within the 10 min of trajectory prediction.Regarding Figures 10 and 12, both the trajectories at p = 20, q = 20 and the original trajectories closely resemble the trend and length.In Figure 10, there is noticeable bending in all five trajectories, with the trajectories at p = 25 and q = 25 exhibiting a soft reverse trend, and each trajectory demonstrating a gentler cornering trend towards the middle of the turn.In Figure 11, the five trajectories are significantly longer than the original trajectory, and the trajectories corresponding to p = 5, q = 5; p = 10, q = 10; and p = 15, q = 15 appear to be ji5ering and not smooth enough.When p = 20, q = 20 and p = 25, q = 25, the trajectory ji5er is alleviated and smoother.Similar trends can be observed for Dataset 3, where the average RMSE and MDE values with p = 20, q = 20 for 20 min trajectory prediction are 174.51 and 229.19, respectively, whereas they are 318.17 and 398.91 when p = 15 and q = 15.Additionally, when p = 20 and q = 20, the average MDE was 155.76 for a 10 min trajectory and increased to 229.19 for a 20 min trajectory, indicating a 45.96% increase in MDE for the 10 min of trajectory prediction.
According to Table 4 for Dataset 1, models with p = 25 and q = 25 have the lowest average RMSE and average MDE, whereas those with p = 15 and q = 15 have the highest.For example, when predicting a trajectory of 60 min, the model with p = 25 and q = 25 has an average RMSE of 222.23 and an average MDE of 281.75, whereas the model with p = 15 and q = 15 has an average RMSE of 758.16 and an average MDE of 969.62, indicating better performance for the former model.Moreover, when p = 25 and q = 25, the average MDE was 115.61 for a 10 min trajectory, 123.13 for a 20 min trajectory, and 281.75 for a 60 min trajectory.Within the 10 min of prediction, the average MDE increased by 6.50%, and it increased by 143.77% within an extra 50 min of prediction.

Model Performance Comparison
To validate the proposed method, this paper compares some other prediction methods.The use of the dataset is consistent with Section 4.2.Please be noted that the results of the comparison are based on the parameter settings of each method that obtains the best performance on trajectory prediction; therefore, the parameter settings for each method may not be consistent under each testing scenario.The comparing methods are as follows: The experimental parameters of the three models are shown in Table 5.
For the performance of the three models on dataset 2 (Figure 13), the trajectory generated by the ConvLSTM-Seq2Seq (ours) model closely resembles the original trajectory (blue trajectory), with the two almost overlapping.The trajectory of LSTM-Seq2Seq delivers comparable outcomes.For the performance of the models on Dataset 3 (Figure 14), the trajectory of LSTM-Seq2Seq outperforms the others by being the closest to the original trajectory, followed by the trajectory of our model.The performance of the Bi-LSTM model is much worse than those of the other two.As depicted in Figure 15, the trajectory of our model (orange trajectory) is the most similar to the trend and length among the three models and exhibits a similar trend as the original ship trajectory.Although the trajectory of Bi-LSTM (red trajectory) also shows high similarity to the real ship trajectory, its second half is not as close as that of our model's trajectory, which indicates the performance on long time prediction of our model is better.The trajectory of LSTM-Seq2Seq (green trajectory) is the most different from other results and exceeds the length of results of our model and Bi-LSTM model trajectories.To recap, the trajectory of our model is the most effective when compared with the original trajectory across all three figures.The trajectory of LSTM-Seq2Seq provides the second-best performance, whereas the trajectory of Bi-LSTM performs the worst.And, in each picture, the initial position of the trajectory of Bi-LSTM has shifted.For the performance of the three models on dataset 2 (Figure 13), the trajectory generated by the ConvLSTM-Seq2Seq (ours) model closely resembles the original trajectory (blue trajectory), with the two almost overlapping.The trajectory of LSTM-Seq2Seq delivers comparable outcomes.For the performance of the models on Dataset 3 (Figure 14), the trajectory of LSTM-Seq2Seq outperforms the others by being the closest to the original trajectory, followed by the trajectory of our model.The performance of the Bi-LSTM model is much worse than those of the other two.As depicted in Figure 15, the trajectory of our model (orange trajectory) is the most similar to the trend and length among the three models and exhibits a similar trend as the original ship trajectory.Although the trajectory of Bi-LSTM (red trajectory) also shows high similarity to the real ship trajectory, its second half is not as close as that of our model's trajectory, which indicates the performance on long time prediction of our model is be5er.The trajectory of LSTM-Seq2Seq (green trajectory) is the most different from other results and exceeds the length of results of our model and Bi-LSTM model trajectories.To recap, the trajectory of our model is the most effective when compared with the original trajectory across all three figures.The trajectory of LSTM-Seq2Seq provides the second-best performance, whereas the trajectory of Bi-LSTM performs the worst.And, in each picture, the initial position of the trajectory of Bi-LSTM has shifted.Table 6 shows the results for 20 min trajectory predictions using Dataset 2. From the figure, one can see that the ConvLSTM-based Seq2seq proposed in this paper has the lowest average RMSE and MDE among the three models, which is followed by the LSTM-Seq2Seq model, and the Bi-LSTM (Attention) model has the worst performance.In the meantime, with the increment of the prediction time, the performance of all models started to deteriorate and show higher prediction errors, whereas our model still maintains the best performance.From the analysis, our model has an evident advantage on prediction of curved trajectories.As for the prediction on straight trajectories, the model with the lowest errors is LSTM-Seq2Seq, followed by the ConvLSTM-Seq2Seq model, and the Bi-LSTM (Attention) model has the worst performance.This could be explained by the LSTM-Seq2seq having an advantage when learning the short-term characteristics of the data series.The detailed analysis could be referred to Section 6.As for the trajectory with continuous and small changes (Table 6), the results reveal the results for 60 min trajectory predictions using Dataset 1.The model with the lowest errors is ConvLSTM-Seq2Seq, followed by the Bi-LSTM (Attention) model, whereas the LSTM-Seq2Seq model performs the worst.Overall, the ConvLSTM-Seq2Seq model outperforms other models for predicting trajectory in Dataset 1.  Table 6 shows the results for 20 min trajectory predictions using Dataset 2. From the figure, one can see that the ConvLSTM-based Seq2seq proposed in this paper has the lowest average RMSE and MDE among the three models, which is followed by the LSTM-Seq2Seq model, and the Bi-LSTM (A5ention) model has the worst performance.In the meantime, with the increment of the prediction time, the performance of all models started to deteriorate and show higher prediction errors, whereas our model still maintains the best performance.From the analysis, our model has an evident advantage on prediction of curved trajectories.As for the prediction on straight trajectories, the model with the lowest errors is LSTM-Seq2Seq, followed by the ConvLSTM-Seq2Seq model, and the Bi-LSTM (A5ention) model has the worst performance.This could be explained by the LSTM-Seq2seq having an advantage when learning the short-term characteristics of the  Table 6 shows the results for 20 min trajectory predictions using Dataset 2. From the figure, one can see that the ConvLSTM-based Seq2seq proposed in this paper has the lowest average RMSE and MDE among the three models, which is followed by the LSTM-Seq2Seq model, and the Bi-LSTM (A5ention) model has the worst performance.In the meantime, with the increment of the prediction time, the performance of all models started to deteriorate and show higher prediction errors, whereas our model still maintains the best performance.From the analysis, our model has an evident advantage on prediction of curved trajectories.As for the prediction on straight trajectories, the model with the lowest errors is LSTM-Seq2Seq, followed by the ConvLSTM-Seq2Seq model, and the Bi-LSTM (A5ention) model has the worst performance.This could be explained by the LSTM-Seq2seq having an advantage when learning the short-term characteristics of the

Discussion
Ship trajectory prediction plays a very important role in regional ship intelligent collision avoidance and supervision, as it could facilitate the identification and prediction of ship intentions in the region.This paper proposes a ship trajectory prediction model ConvLSTM-based Seq2Seq.Compared with other models in the experiment, the effectiveness of our proposed model is verified.In data preprocessing, our preprocessing method divides trajectory clusters into six clusters, each with unique characteristics.
Experiments were conducted across different datasets, input and output lengths, and prediction lengths.The results revealed that the optimal parameters for the ConvLSTM-Seq2Seq model were p = 25 and q = 25 on Dataset 1, and p = 20 and q = 20 on Datasets 2 and 3, under which conditions this model achieved the best performance.Our observations of Figures 10-12 and Tables 2-4 demonstrate that the accuracy of our model's predictions is significantly influenced by different input and output lengths.Interestingly, in all three datasets, the models with p = 15 and q = 15 exhibited the greatest errors, indicating that as p and q lengths increase, prediction errors initially increase and then decrease slightly, with p = 15 and q = 15 representing a peak in prediction errors.Furthermore, due to the cumulative effect of errors, as the length of the prediction time increases, the prediction error of the model also continues to increase.This is evident from the data records corresponding to the trajectory in Figure 15 and the trajectory in Table 6.In Figure 15, the three trajectories initially closely follow the original trajectory.However, as the length of the forecast time increases, they deviate to varying degrees from the original trajectory, with the trajectory of LSTM-Seq2Seq being longer and the trajectory of Bi-LSTM and our model being slightly shorter.Additionally, as indicated in Table 6, the model error increases by 143.71%, 259.03%, and 413.45% within a time range of 50 min.These findings highlight the fact that prediction errors increase with the increase in predictive length.Therefore, by selecting appropriate input and output lengths and increasing the form of the forecasting step, the error can be reduced within the selected time range, and cumulative error can be minimized.The convLSTM-Seq2Seq model exhibits excellent performance when the input and output length is either 20 or 25.
The ConvLSTM-Seq2Seq model exhibits the best performance out of the three models, particularly on the training sets with Dataset 1 and Dataset 2. Although its performance is slightly weaker than the LSTM-Seq2Seq model on Dataset 3, it still produces good results.This superiority may be attributed to the convolutional structure of the ConvLSTM unit, which extracts further information on the relationship between the longitude and latitude of the trajectory data, thereby increasing its accuracy and significantly improving its predictive ability for trajectories with long-time trajectories compared to the other two models.On the other hand, the Bi-LSTM (Attention) model performs poorly among the three models, possibly because it uses a many-to-one prediction approach that outputs the trajectory data of the next time step, leading to multiple accumulated errors that increase its errors.However, in Dataset 3, the LSTM-Seq2Seq model exhibits higher prediction error, almost five times that of the ConvLSTM-Seq2Seq model, whereas the Bi-LSTM (Attention) model's error is three times that of the ConvLSTM-Seq2Seq model.One of the reasons could be that in the Dataset 3 training set, each small training set has significantly different features, making it difficult for the LSTM-Seq2Seq model to learn these characteristics effectively.In contrast, the attention mechanism of the Bi-LSTM (Attention) model enables it to learn more features from the Dataset 3 training set.Although the ConvLSTM-Seq2Seq model does not have an attention mechanism, its stronger feature extraction ability allows it to learn the features of Dataset 3 as well.However, the improved prediction accuracy of the ConvLSTM-Seq2Seq model comes at the expense of longer computational runtime.To quantify this trade-off, the inference times of the ConvLSTM-Seq2Seq, LSTM-Seq2Seq, and Bi-LSTM (Attention) models were benchmarked by measuring the duration taken to estimate 60 min ship trajectories using Dataset 1.The results, tabulated in Table 7, demonstrate that the ConvLSTM-Seq2Seq architecture exhibits substantially higher time consumption relative to the baseline LSTM-Seq2Seq and Bi-LSTM(Attention) models.In summary, the ConvLSTM-Seq2Seq model performs best overall due to its powerful feature extraction capabilities, which allow it to learn the characteristics of trajectories with curves effectively.

Conclusions
This paper proposed a high-precision trajectory prediction method that combines Con-vLSTM and Seq2Seq models to address the long-term ship trajectory prediction problem.To alleviate potential defects of AIS equipment in receiving and sending ship information, this paper preprocessed the AIS data using methods such as abnormal data elimination, HDB-SCAN clustering, and cubic spline interpolation to enable subsequent feature extraction through the proposed model.As the ConvLSTM model was effective in extracting spatialrelated features, this paper combined it with the Seq2Seq model to develop a ship trajectory prediction model.The research explored the appropriate input and output lengths of the proposed model and compared it with the LSTM-Seq2Seq and Bi-LSTM (Attention) models.The experimental results revealed that the ConvLSTM-Seq2Seq model proposed in this paper exhibited excellent accuracy for turning trajectories.In direct trajectory prediction, the accuracy of the proposed model was slightly lower (by about 10% when predicting 20 min ahead) than that of the LSTM-Seq2Seq baseline model.However, the proposed model still demonstrated decent performance overall.Moreover, by setting the ratio of the number of input trajectory points to output trajectory points at p = 20, q = 20, the proposed model performed optimally in the dataset of straight and curve trajectories.When p = 25, q = 25, the proposed model performed better in datasets with long-time trajectories.Nevertheless, it should be noted that increasing the length of the input and output does not always guarantee a significant improvement in model accuracy.In fact, there exists a trend where accuracy may first increase and then decrease as the lengths are extended.In comparison experiments with other models, the proposed model showed the best results in two of the datasets and also had good accuracy in the other dataset.Furthermore, the cumulative error accumulation of long-term prediction (60 min) on the trajectory was significantly smaller than those of other models.Therefore, the proposed model could be regarded as an effective method for more accurate ship trajectory predictions in a wider range of scenarios.The proposed ship trajectory prediction method could enable accurate risk avoidance, intelligent management and monitoring of ships, aligning with the development trends in future intelligent vessels.Specifically, the method allowed the discovery of abnormal ship behaviors by comparing predicted and actual trajectories and early warning generation.Additionally, precise trajectory forecasts assisted autonomous navigation systems in identifying collision risks and making sensible route-planning decisions.Overall, this work represented a noteworthy contribution to the field of ship trajectory prediction and could help bolster the safety and efficiency of ship navigation in complex marine environments.
In future work, other factors that may affect ship trajectory prediction, such as Speed Over Ground (SOG), Course Over Ground (COG), and environmental information, can be added to the process of spatial extraction of trajectory to further improve the accuracy of the trajectory prediction model.Additionally, when predicting trajectories, incorporating the influence of surrounding vessels into the prediction model could be explored to develop a ship trajectory forecasting approach with enhanced practicality and fidelity to real-world navigation.
) Ship trajectory prediction based on sequence-to-sequence model and ConvLSTM: On the basis of the data preprocessing, the ConvLSTM network was applied to extract the features of the trajectory data from two aspects of time and space to improve the feature extraction ability of the model.Combining the ConvLSTM network and the Seq2Seq model, a sequence-to-sequence ship trajectory prediction model with stronger spatiotemporal feature extraction and reconstruction capabilities was established.The preprocessed data were used to train the model, and a ship trajectory prediction method with the advantage of trajectory spatiotemporal feature extraction ability was obtained.

Figure 1 .
Figure 1.Overall model design flow chart.Figure 1. Overall model design flow chart.

Figure 1 .
Figure 1.Overall model design flow chart.Figure 1. Overall model design flow chart.
t; W xi and b i are the weight and threshold of the input gate, respectively; W x f and b f are the weight and threshold of the forget gate, respectively; W xc and b c are the weight and threshold of the state gate, respectively; W xo and b o are the weight and threshold of the output gate, respectively.

Figure 6 .
Figure 6.The raw AIS trajectory data in the research area.

Figure 6 .
Figure 6.The raw AIS trajectory data in the research area.

Figure 8 .
Figure 8. Cubic Spline Interpolation:(a) Interpolation of ship trajectory in a curvilinear section.(b) Interpolation of ship trajectory in a rectilinear section.

Figure 8 .
Figure 8. Cubic Spline Interpolation: (a) Interpolation of ship trajectory in a curvilinear section.(b) Interpolation of ship trajectory in a rectilinear section.
is the maximum value of the sample data, { } min min z is the minimum value of the sample data, and the converted data are all within [0,1].

Figure 10 .
Figure 10.Prediction Results of Dataset 2 (20 min): (a) Predicted trajectory with 5 input and output points; (b) Predicted trajectory with 10 input and output points; (c) Predicted trajectory with 15 input and output points; (d) Predicted trajectory with 20 input and output points; (e) Predicted trajectory with 25 input and output points.

Figure 10 .
Figure 10.Prediction Results of Dataset 2 (20 min): (a) Predicted trajectory with 5 input and output points; (b) Predicted trajectory with 10 input and output points; (c) Predicted trajectory with 15 input and output points; (d) Predicted trajectory with 20 input and output points; (e) Predicted trajectory with 25 input and output points.

Figure 11 .
Figure 11.Prediction Results of Dataset 3 (20 min): (a) Predicted trajectory with 5 input and output points; (b) Predicted trajectory with 10 input and output points; (c) Predicted trajectory with 15 input and output points; (d) Predicted trajectory with 20 input and output points; (e) Predicted trajectory with 25 input and output points.

Figure 11 .
Figure 11.Prediction Results of Dataset 3 (20 min): (a) Predicted trajectory with 5 input and output points; (b) Predicted trajectory with 10 input and output points; (c) Predicted trajectory with 15 input and output points; (d) Predicted trajectory with 20 input and output points; (e) Predicted trajectory with 25 input and output points.

Figure 12 .
Figure 12.Prediction Results of Dataset 1 (60 min): (a) Predicted trajectory with 5 input and output points; (b) Predicted trajectory with 10 input and output points; (c) Predicted trajectory with 15 input and output points; (d) Predicted trajectory with 20 input and output points; (e) Predicted trajectory with 25 input and output points.

Figure 12 .
Figure 12.Prediction Results of Dataset 1 (60 min): (a) Predicted trajectory with 5 input and output points; (b) Predicted trajectory with 10 input and output points; (c) Predicted trajectory with 15 input and output points; (d) Predicted trajectory with 20 input and output points; (e) Predicted trajectory with 25 input and output points.

( 1 )
Bi-attention-LSTM: The Bi-LSTM model can learn the characteristics of future moment information while using the data information of the past moment and perform recursion and feedback on it.At the same time, adding the attention mechanism will help the Bi-LSTM model to further optimize the ability of data information feature extraction and improve the accuracy of the model prediction.The model adopts the form of single-step prediction cumulative error, takes the trajectory points of the first five consecutive time steps as input, and predicts the trajectory points at the next moment.(2) LSTM-Seq2Seq: Sequence to Sequence consists of three parts: encoder, intermediate vector, and decoder.The composition of the encoder and the decoder is basically the same, and this paper uses LSTM as its cycle unit.The model adopts the form of multi-step prediction cumulative error, takes the trajectory points of the first 20 continuous time steps as input, and predicts the trajectory points of the last 20 continuous time steps.(3) ConvLSTM-Seq2Seq: The ConvLSTM-Seq2Seq model utilized the same set of parameters as described in Section 4.3.Additionally, for Dataset 1, the model took as input the trajectory points of the first 25 consecutive time steps and predicted the trajectory points of the next 25 time steps.For Datasets 2 and 3, the model took as input the trajectory points of the first 20 consecutive time steps and predicted the trajectory points of the next 20 time steps.
hidden states

Table 1 .
Description of the case study.
• N to 31.00 • N; Longitude: 122.0 • E to 122.4 • E The number of research ship trajectories 297 Trajectory data sources Yangtze River Estuary, China on 1 May 2019, provided by Wuhan University of Technology Ship type Cargo ship ci.Eng.2023, 11, x FOR PEER REVIEW 11 of 26

Table 1 .
Description of the case study.
Item ConfigurationBoundary Latitude: 31.08°N to 31.00°N; Longitude: 122.0°E to 122.4° E The number of research ship trajectories 297 Trajectory data sources YangVe River Estuary, China on 1 May 2019, provided by Wuhan University of Technology

Table 2 .
Prediction results of different input and output lengths (Dataset 2).

Table 3 .
Prediction results of different input and output lengths (Dataset 3).

Table 4 .
Prediction results of different input and output lengths (Dataset 1).

Table 5 .
Experimental parameter settings of the three models.

Table 6 .
Experimental results of three models in different data sets.

Table 7 .
Estimated time consumed by different models.