Enhancing Maritime Navigational Safety: Ship Trajectory Prediction Using ACoAtt–LSTM and AIS Data

: Predicting ship trajectories plays a vital role in ensuring navigational safety, preventing collision incidents, and enhancing vessel management efficiency. The integration of advanced machine learning technology for precise trajectory prediction is emerging as a new trend in sophisticated geospatial applications. However, the complexity of the marine environment and data quality issues pose significant challenges to accurate ship trajectory forecasting. This study introduces an innovative trajectory prediction method, combining data encoding representation, attribute correlation attention module, and long short-term memory network. Initially, we process AIS data using data encoding conversion technology to improve representation efficiency and reduce complexity. This encoding not only preserves key information from the original data but also provides a more efficient input format for deep learning models. Subsequently, we incorporate the attribute correlation attention module, utilizing a multi-head attention mechanism to capture complex relationships between dynamic ship attributes, such as speed and direction, thereby enhancing the model’s understanding of implicit time series patterns in the data. Finally, leveraging the long short-term memory network’s capability for processing time series data, our approach effectively predicts future ship trajectories. In our experiments, we trained and tested our model using a historical AIS dataset. The results demonstrate that our model surpasses other classic intelligent models and advanced models with attention mechanisms in terms of trajectory prediction accuracy and stability.


Introduction
In today's era of globalization, ships play an instrumental role in oceanic transportation, accounting for over 80% of global cargo movement [1].However, the rapid growth of maritime transport has led to an increased risk of ship collisions.As reported by the International Maritime Organization (IMO), there has been an annual average of about 75 ship collisions globally in the past decade, causing significant human and financial losses, and posing threats to the marine environment [2].Against this backdrop, the importance of ship trajectory prediction technology is increasingly evident.This technology aims to forecast the future paths of ships, helping detect potential collision risks at an early stage and enabling timely evasive actions.It also assists captains or automated navigation systems in making optimal navigational decisions, such as course adjustments and speed regulation, to respond swiftly and minimize collision risks [3].Moreover, accurate and prompt trajectory prediction can reduce economic losses from collisions, enhance navigational efficiency, and save fuel.
Ship trajectory prediction refers to the estimation of a vessel's future navigational position and status, primarily including longitude, latitude, heading, and speed.Typically, based on time scales, trajectory prediction tasks can be categorized into long-term, mediumterm, and short-term.Long-term predictions are primarily determined by navigational plans or mission requirements [4].Medium-term predictions are significantly influenced by weather information and real-time traffic conditions.For short-term predictions, the decisive factors are the ship's current and recent past motion states, from which trends in position and status changes can be extrapolated.This article focuses on short-term trajectory prediction challenges.
Short-term ship trajectory prediction is a crucial aspect of intelligent maritime navigation, aimed at forecasting a vessel's position and heading in the imminent future, spanning from a few minutes to several hours.This challenge encompasses the complex and dynamic maritime environment and intricate behavioral factors of the vessels themselves [5].Current research methods typically rely on AIS data, integrating physical and data-driven models for estimation and prediction.Advancements in short-term ship trajectory prediction are vital for enhancing maritime traffic safety, effective navigation management, and supporting maritime emergency responses.
Machine learning-based ship trajectory prediction methods have emerged as a research focus in recent years [6].With continual advancements in computational capabilities and algorithms, these techniques are rapidly evolving and maturing.Current trajectory prediction models, predominantly based on sequential deep learning models like Recurrent Neural Networks (RNN) [7] and Long Short-Term Memory (LSTM) [8], face challenges in processing time-dependent historical trajectory sequences.The sequential nature of these models often leads to dominance of near-term information and dilution or loss of long-range data, reducing efficiency in handling time dependencies [9].When dealing with extensive trajectory sequences composed of multiple trajectory points [10], serial processing methods can result in inadequate extraction of historical information.Existing ship trajectory prediction methods still face several challenges when contending with complex maritime environments and variable sailing conditions.
(1) Limitations in Data Representation Efficiency: Conventional methods for predicting ship trajectories primarily involve direct processing of raw AIS data, which often struggle to enhance the representation efficiency of large, multidimensional datasets.This can lead to information loss and constrain the extraction of advanced abstract features from the data, underscoring the necessity for innovative data handling strategies.
(2) Time Series Data Processing: Given their intrinsic temporal nature, AIS data demand models adept at managing correlations over time and historical context.Traditional forecasting techniques may encounter challenges when optimizing performance for extended time series with intricate temporal dependencies, highlighting the imperative to devise sophisticated temporal analysis methodologies.
(3) The Absence of Dynamic Feature Correlation Between Specific Attributes: Contemporary predictive methodologies may not fully capitalize on the dynamic feature correlations among specific trajectory attributes, such as the interplay between a vessel's coordinates (longitude and latitude) and variations in its velocity and course.Augmenting the research into the potential interconnectivity between attributes could inform and enrich the incorporation of these correlations into predictive models.
The Attribute Correlation Attention (ACoAtt) represents an advanced deep learning technique designed to process and analyze time series data or data with complex intrinsic relationships.Mirroring the general multi-head attention mechanism, ACoAtt might employ several "attention heads" to parallelly process data, enabling the model to capture the intricate and multidimensional relationships between attributes.It is primarily utilized in domains involving time series data and the analysis of multiple interactive attributes.To enhance the model's sensitivity to various input attributes in predicting trajectories, this paper proposes the integration of the ACoAtt mechanism.This approach aims to improve model performance by addressing the dynamic interactions among various ship attributes, such as speed, direction, and location.Unlike traditional models that might process these attributes in isolation, the ACoAtt module leverages a multi-head attention mechanism to concurrently consider the interdependencies among these attributes.This method allows for a more nuanced understanding of how changes in one attribute could potentially influence others, thereby enhancing prediction accuracy.
In light of the current research landscape and insights [11], this paper introduces an innovative method for predicting ship trajectories.This approach integrates data encoding representation, the ACoAtt module, and LSTM networks to enhance data representation efficiency and reduce complexity.Initially, we employ data encoding conversion techniques on AIS data, followed by the introduction of the ACoAtt module.This utilizes a multi-head attention mechanism to capture the complex relationships between dynamic characteristics of ships, thereby augmenting the model's comprehension of implicit temporal sequence patterns in the data.Coupled with the LSTM network's ability to model temporal dependencies in spatial semantics, this method effectively supports accurate and rapid predictions of future ship trajectories.The main contributions of this paper are as follows: (1) Novel Approaches to Data Representation: In this study, we delve into the application of data encoding transformation techniques within the realm of maritime AIS data, with the aim of augmenting the efficiency of data representation.By mitigating data complexity while preserving essential information, this method could furnish deep learning models with a more efficacious input format.Furthermore, it is juxtaposed with existing methodologies to quantify the extent of its improvements.
(2) Enhancing the Correlation of Dynamic Attributes: The introduction of the ACoAtt module represents an endeavor to effectively capture the intricate relationships between the dynamic characteristics of vessels, encompassing variations in speed and course adjustments.This initiative seeks to bolster the model's comprehension of temporal sequence patterns in maritime movement states through the implementation of a multi-head attention mechanism.
(3) Optimization of Time Series Data Processing: This study employs multi-layer LSTM networks to model the temporal dependencies present in AIS data.By harnessing the temporal processing capabilities of LSTM networks, the aim is to amplify the prediction accuracy of short-term ship trajectories, with a particular focus on the temporal dependencies of spatial semantics.
The remainder of this paper is structured as follows: Section 2 revisits related work in the domain of ship trajectory prediction.Section 3 encapsulates the trajectory prediction model explored in this study.Section 4 applies the proposed prediction methodology to actual AIS data and summarizes the outcomes.Finally, Section 5 discusses conclusions and prospects for future research.

Related Work
Trajectory prediction is a formidable task, with current methodologies for forecasting maritime paths bifurcating into two distinct categories [12].The first encompasses models predicated upon statistical or physical foundations.Traditional probabilistic models, through the explicit use of probability distributions, meticulously map the uncertainties and interrelations between variables.These models are inherently interpretable, typically employed in scenarios where an in-depth understanding of underlying probability distributions is paramount.Physical models, given accurate parameters and initial states, can precisely forecast future positions.However, constructing a model that accurately and effectively incorporates all influential factors often proves to be exceedingly complex.Conversely, statistical models are frequently impacted by the quality of data.
The second category encompasses machine learning-based methods for predicting ship trajectories.This includes models that utilize architectures such as Convolutional Neural Networks (CNN) or RNN, which are also formulated within a probabilistic framework.These models, by deciphering complex patterns within the data, implicitly estimate the underlying probability distributions of data features.However, in contrast to traditional probabilistic models, machine-based models typically prioritize predictive performance and the capacity to process high-dimensional data over explicit probabilistic interpretations.
Learning models are capable of probabilistically forecasting future positions with merely historical motion data, encapsulating all internal system states and influencing factors within a single model.The efficacy of these models is significantly contingent upon the quality of data and the model's learning capabilities.Particularly in the context of ship trajectory prediction, the complexity and volume of data may render deep learning models preferable for their superior pattern recognition prowess, despite both approaches sharing a probabilistic foundation.

Ship Trajectory Prediction Methods Based on Statistical or Physical Models
Methods for predicting ship trajectories based on statistical or physical models leverage mathematical and physical equations to statistically evaluate the movement of ships, deriving maritime characteristics through mathematical calculations or physical laws.Researchers typically estimate future positions using current locations and velocities, predicting future positions with constant speed and course values.Innovations in the field include M. Üney's development of a trajectory prediction algorithm using directed graphs and Bayesian inference, combining historical and real-time data, particularly validated for maritime dynamics [13].Perera et al. [14] applied Extended Kalman Filters (EKF) to design detection, tracking, and trajectory prediction methods for maritime surveillance systems, demonstrating improved navigational safety.Jaskólski et al.'s [15] research introduced a Fourier transform-based predictive model using AIS data.Li et al. [16] proposed an enhanced fuzzy prediction algorithm, incorporating the degree of membership of errors between predicted outputs and set points into the system's fuzzy constraints, thereby boosting the algorithm's adaptability.Lian et al.'s [17] comparative analysis affirmed the accuracy and timeliness of particle filter-based AIS data prediction, showing superiority under nonlinear conditions.Liao et al. [18] designed a hybrid prediction model, combining empirical, data-driven, and physical methods to tackle complex system prediction challenges, showcasing the potential advantages of hybrid predictive approaches.Murray et al. [19] evaluated historical AIS data to devise a single-point neighborhood search method and a multi-trajectory extraction method for more accurate trajectory prediction.Tan et al. [20] designed a variable direction rotation module, enhancing and normalizing direction prediction by introducing additional directional feature inputs.
Predictive methods for ship trajectories based on statistics or physics have evolved significantly over the years, underpinned by mature theories and robust mathematical support, yielding highly interpretable results.Compared to complex machine learning models, statistical methods are generally more stable, less susceptible to random fluctuations.However, these approaches have limitations; statistical models often fall short in handling complex data features, particularly in high-dimensional data.Additionally, for nonlinear and non-stationary data series, the predictive capabilities of traditional statistical methods may be constrained.

Methods for Predicting Ship Trajectories Using Machine Learning
Machine learning-based ship trajectory prediction methods, utilizing historical motion data, estimate future ship positions probabilistically.These methods integrate data characteristics of internal system states and various influencing factors into a unified model.The effectiveness largely depends on the quality of data used and the model's learning capabilities.The current trend focuses on deep learning with extensive historical AIS data to enhance the accuracy of trajectory prediction.Liu et al. [21] developed a ship trajectory prediction model based on Support Vector Regression (SVR).This model employs a wavelet threshold denoising method for processing AIS data and optimizes model parameters using an Adaptive Chaotic Differential Evolution (ACDE) algorithm.This approach enhances both the convergence speed and the accuracy of the predictions.Wang et al. [22] integrated DP algorithm and DTW to cluster the AIS data of container ships and predict probabilistic routes; this innovative approach aims to enhance the efficiency of decision support in preventing ship collisions.Yang et al. [23] developed a novel ship trajectory prediction method that integrates data denoising with deep learning models, utilizing Bidirectional Long Short-Term Memory Networks (Bi-LSTM) for trajectory forecasting.Liu et al. [24] have innovated an improved LSTM model based on attention mechanisms.This model, enriched by data preprocessing and time series analysis, facilitates predictions about the dynamic navigation of ships.Yu et al. [25] utilized AIS data to compare the effectiveness of BP and LSTM algorithms in predicting ship trajectories.They found that LSTM, enhanced through data preprocessing and parameter optimization, outperformed BP in overall and detailed performance.Gao et al. [26] proposed a multi-step prediction method for ship trajectories based on physical assumptions, using cubic spline interpolation and historical trajectory data, integrating the strengths of TPNet and LSTM for real-time analysis and improved accuracy.Zhao et al. [27] employed a genetic algorithm to optimize the hidden layer nodes, weights, and thresholds of BP neural networks, conducting real-time predictive simulations of ship trajectories.Zhao et al. [9] developed an encoder-decoder learning model for ship trajectory prediction based on AIS data, integrating LSTM and attention mechanisms to enhance the feature fusion between input trajectory sequences, useful for ship route planning and collision avoidance.
In summary, machine learning-based methods for predicting ship trajectories have emerged as a focal point within this domain [28].Deep learning models, particularly those utilizing LSTM and attention mechanisms, are highly esteemed for their robust capabilities in processing spatiotemporal data and automating feature extraction [29].However, despite the potential for traditional machine learning techniques and clustering algorithm-based methods to forecast ship trajectories, these models often encounter significant challenges in construction and tend to produce substantial predictive errors, revealing their limitations.Moreover, there is a notable scarcity in the in-depth exploration of ship movement patterns, making it challenging to underscore the correlations between ship positions and velocities during the prediction process, and consequently, achieving satisfactory outcomes in practical applications proves to be formidable.
In comparison to previous studies, the model proposed in this manuscript endeavors to incorporate data encoding transformation techniques for feature fusion, thereby generating novel representations of sequential features.This effort aims to explore the potential for enhancing the extraction of advanced abstract characteristics from historical data.Subsequently, with the introduction of the ACoAtt mechanism, there is an aspiration to capture the long-term dependency correlations between attributes from historical trajectory data.By amalgamating trajectory positions and states, the model seeks to unveil hidden information within sequences, capturing the spatiotemporal correlations among sequential feature data, thereby augmenting the accuracy of ship trajectory predictions.

Problem Formulation
During maritime navigation, ships can observe the navigation status of surrounding vessels via AIS.This paper utilizes the maritime mobile service identity (MMSI) as a unique index for ship AIS data.It defines T n as the entirety of a ship's trajectory, thereby deriving a discrete time series definition for ship trajectories, as indicated in Equation (1).
T n = (S t 1 t 2 , . . ., S t n−1 t n ) i = (P t 1 , P t 2 , . . ., In this context, i signifies the MMSI number, S t i t j denotes a segment of the trajectory, and P t n refers to the position point corresponding to the timestamp t n .It is composed of a four-dimensional feature vector defined by Equation (2).
Within this framework, lon represents longitude, lat denotes latitude, v signifies the ship's speed over ground, and w encapsulates the vessel's course over ground.
The schematic illustration of ship trajectory prediction, as depicted in Figure 1, entails designating the vessel's state information from time t 1 to t n as the input for the prediction model.The position data at moment t n+1 are then used as the model's output, as delineated in Equation (3).
Y t n+1 = F(P t 1 :t n ) Within this framework, lon represents longitude, lat denotes latitude, v signifies the ship's speed over ground, and w encapsulates the vessel's course over ground.
The schematic illustration of ship trajectory prediction, as depicted in Figure 1, entails designating the vessel's state information from time 1 t to n t as the input for the prediction model.The position data at moment +1 n t are then used as the model's output, as delineated in Equation (3).( ) In this model, F represents the predictive function for the vessel's trajectory ob- tained through our model.

Design of the Vessel Trajectory Prediction Algorithm Model
Addressing the challenge of short-term vessel trajectory prediction, our research introduces an innovative predictive model structure.This model harmoniously integrates binary code representation, ACoAtt mechanism, and LSTM networks for processing AIS data to accurately forecast future maritime trajectories.As depicted in Figure 2, the model consists of three primary modules, each offering solutions to different challenges encountered in the trajectory prediction process.
Initially, the AIS data processing module applies binary encoding to the raw AIS data, transforming continuous numerical attributes into efficient binary formats.This not only simplifies the data but also retains crucial information vital for model training, enhancing the input format's dimensionality and efficiency.The binary encoding retains key data features and offers an effective format for deep learning models.The ACoAtt module, utilizing multi-head attention mechanisms, captures complex relationships between dynamic navigational characteristics like speed and direction changes.The ACoAtt module focuses on significant positional changes within the prediction sequence, greatly enhancing the model's understanding of latent temporal patterns.The model integrates multilevel LSTM networks, effectively modeling dependencies in AIS data and excelling in processing spatial semantics and temporal dependencies.The predictive output conversion module is tasked with receiving the forecasted trajectory, transforming the binary representation of the trajectory prediction through a decoding process into scalar attributes, aligning them with real-world coordinates or the standard formats required by navigational systems.This supports accurate short-term vessel trajectory prediction and In this model, F represents the predictive function for the vessel's trajectory obtained through our model.Y t n+1 signifies the predicted ship state information at moment t n+1 .

Design of the Vessel Trajectory Prediction Algorithm Model
Addressing the challenge of short-term vessel trajectory prediction, our research introduces an innovative predictive model structure.This model harmoniously integrates binary code representation, ACoAtt mechanism, and LSTM networks for processing AIS data to accurately forecast future maritime trajectories.As depicted in Figure 2, the model consists of three primary modules, each offering solutions to different challenges encountered in the trajectory prediction process.
Initially, the AIS data processing module applies binary encoding to the raw AIS data, transforming continuous numerical attributes into efficient binary formats.This not only simplifies the data but also retains crucial information vital for model training, enhancing the input format's dimensionality and efficiency.The binary encoding retains key data features and offers an effective format for deep learning models.The ACoAtt module, utilizing multi-head attention mechanisms, captures complex relationships between dynamic navigational characteristics like speed and direction changes.The ACoAtt module focuses on significant positional changes within the prediction sequence, greatly enhancing the model's understanding of latent temporal patterns.The model integrates multi-level LSTM networks, effectively modeling dependencies in AIS data and excelling in processing spatial semantics and temporal dependencies.The predictive output conversion module is tasked with receiving the forecasted trajectory, transforming the binary representation of the trajectory prediction through a decoding process into scalar attributes, aligning them with real-world coordinates or the standard formats required by navigational systems.This supports accurate short-term vessel trajectory prediction and optimizes model parameters through backpropagation of the error calculated between predicted and actual values.Finally, the model's reliability and effectiveness are tested in practical applications.
optimizes model parameters through backpropagation of the error calculated between predicted and actual values.Finally, the model's reliability and effectiveness are tested in practical applications.

Preprocessing and Transformation of AIS Data
Data preprocessing aims to eliminate any anomalous data to mitigate their impact on subsequent trajectory modeling.For AIS data of vessels uniquely identified by MMSI, handling missing or aberrant data is crucial [30], as illustrated in Figure 3.This processing ensures the accuracy of data fed into the trajectory prediction model.For mathematical modeling and computational convenience, converting latitude and longitude into twodimensional plane coordinates simplifies the model's handling of the Earth's curvature complexity.This simplification, particularly in short-range predictions, hardly affects the predictive accuracy.

Preprocessing and Transformation of AIS Data
Data preprocessing aims to eliminate any anomalous data to mitigate their impact on subsequent trajectory modeling.For AIS data of vessels uniquely identified by MMSI, handling missing or aberrant data is crucial [30], as illustrated in Figure 3.This processing ensures the accuracy of data fed into the trajectory prediction model.For mathematical modeling and computational convenience, converting latitude and longitude into twodimensional plane coordinates simplifies the model's handling of the Earth's curvature complexity.This simplification, particularly in short-range predictions, hardly affects the predictive accuracy.
optimizes model parameters through backpropagation of the error calculated between predicted and actual values.Finally, the model's reliability and effectiveness are tested in practical applications.

Preprocessing and Transformation of AIS Data
Data preprocessing aims to eliminate any anomalous data to mitigate their impact on subsequent trajectory modeling.For AIS data of vessels uniquely identified by MMSI, handling missing or aberrant data is crucial [30], as illustrated in Figure 3.This processing ensures the accuracy of data fed into the trajectory prediction model.For mathematical modeling and computational convenience, converting latitude and longitude into twodimensional plane coordinates simplifies the model's handling of the Earth's curvature complexity.This simplification, particularly in short-range predictions, hardly affects the predictive accuracy.

Imputation Procedures for Missing AIS Data Values
Let ∆t i represent the time interval between two consecutive timestamps t i and t i+1 .In this study, if the interval ∆t i exceeds 20 min, it is inferred that a data gap exists between points P t i and P t i+1 , necessitating missing value imputation.The number of missing values n requiring imputation is defined as: Upon determining the quantity of missing values requiring interpolation, this study employs a bidirectional weighted-average interpolation method for latitude and longitude imputation.This approach considers the vessel's speed and direction during the missing period, in conjunction with the current acceleration of the ship, to simulate its actual motion.It calculates the distance traveled and the direction of travel over a short period, thereby determining the position at the time of interpolation, which in turn yields the latitude and longitude coordinates of the missing data.
Assuming a section of AIS data sequence with missing values, where endpoints are designated as P t i and P t j , and given that endpoint P t i 's current ground speed, direction, and acceleration are known, their latitude and longitude coordinates can be projected onto a plane.In the bidirectional weighted interpolation for latitude and longitude, the number of missing values to be interpolated is n.The Lagrange interpolation method calculates interpolated speed and direction.Forward Lagrange interpolation yields the ground speed sequence [v 1 , v 2 . . .v n ] and direction [w 1 , w 2 . . .w n ] from P t i to P t j , while interpolating missing values and speed to determine acceleration [a 1 , a 2 . . .a n ].Similarly, from P t j to At this juncture, it is presumed that the vessel progresses along its current ground course w t i , advancing at speed v t i for a duration ∆t i , arriving at the initial interpolation point.Consequently, the plane coordinates for the first missing value are: Once the initial missing value is determined by this method, it can be treated as a new endpoint to recursively determine the coordinates of the next missing value.This process is repeated to calculate all missing values.The formula for recursively solving the coordinates of missing values is as follows, where k = 1, 2, . . ., n.
Concurrently, it is imperative to correct for missing values in reverse order.The plane coordinates for these missing values are as follows, where m = n, n − 1, . . ., 1.
By employing a bidirectional calculation, the method obtains different sequences of missing values from varying starting points.These sequences are then merged, assigning distinct weights to them.The bidirectional weighted interpolation assigns varying weights based on the time difference between the missing values and endpoints P t i and P t j .Greater weight is allocated when the time difference with an endpoint is smaller.The formula for the distribution of weights α and β is as follows: ISPRS Int.J. Geo-Inf.2024, 13, 85 9 of 24 The coordinates calculated through the weighted average method are the longitudinal and latitudinal values sought for the missing data, x n and y n .The values for these coordinates are as follows: x n = αx k + βx m y n = αy k + βy m (9)

AIS Data Deviations
For significantly deviated trajectory points, they are considered as missing values, and methods for missing value imputation are employed to address these anomalies.By comparing a ship's trajectory point with its adjacent points, the deviated trajectory points are identified.If the distance between the current trajectory point P t i and its neighboring points P t i−1 and P t i+1 is substantially different, exceeding a predefined threshold, then point P t i is deemed a trajectory deviation point.
Moreover, by calculating the average speed between a drift point and its adjacent trajectory points, based on their distance and time interval, erroneous data can be detected.If the computed average speed exceeds the vessel's maximum speed, the trajectory point is deemed erroneous.The specific formula for this determination is outlined in Equation (10).(10) where v max represents the maximum speed of the target vessel, drift point P t i is determined and subjected to mean value interpolation.The interpolated data point P ′ t i at time t i , calculated using the trajectory points adjacent to the drift point, is computed as shown in Equation (11).

Vector Transformation
Transforming a ship's AIS data (lon, lat, v, w) into position and velocity coordinates (x, y, v x , v y ) within a two-dimensional plane is a crucial process for trajectory prediction models.This transformation geometrizes geographical location data, making them more suitable for mathematical manipulation and model application.Such conversions aid in intuitively representing and analyzing trajectories on a two-dimensional plane, allowing prediction models to uncover and learn the intricate dynamics of ship behavior from extensive data.This approach significantly enhances the precision and efficiency of forecasting future ship positions.
Given the Earth's approximation as an oblate spheroid, for the sake of simplicity in calculations, it is conventionally regarded as a sphere.We typically employ cartographic projection techniques to transform latitude and longitude into a planar coordinate system.A prevalent method utilized is the Mercator projection [31], particularly suitable for navigation within smaller regions, the equations of which are as follows: where R represents the Earth's radius, lon 0 is the reference longitude, and lat 0 is the reference latitude, both measured in degrees.To reduce the data bit length and thereby simplify computational complexity, this paper selects the latitude and longitude of the first position point in the test data as the reference coordinates.

AIS Data Encoding Process
In contemporary ship trajectory prediction methods, a five-dimensional vector typically represents a ship's position and state, including longitude, latitude, speed, direction, and time.The high dimensionality and complexity of raw AIS data make processing and analysis challenging, especially without appropriate feature engineering.This complexity can obscure the temporal and spatial relationships in the data, making it difficult to extract implicit semantic features of trajectory points and sequences from low-dimensional neural network representations during model training.Therefore, proper data preprocessing and transformation techniques in AIS data-based trajectory prediction research are crucial.
Against this backdrop, this paper innovatively proposes binary encoding of AIS data.This method's essence lies in transforming complex ship trajectory data into a more manageable and analyzable format.It aims to mitigate the influence of varying attributes and enhance the information capacity for data mining tasks, thereby effectively boosting the performance and accuracy of trajectory prediction models.
Initially, it is necessary to quantify each continuous attribute in AIS data.Quantization is a process of mapping continuous values to a finite set of symbols.In AIS data, continuous attributes like a ship's position coordinates (x and y) and speed (velocity components v x , v y ) need to be converted into the values within a suitable numerical range.This can be achieved using a predefined quantization factor q, which is represented as: where Q( ) signifies the quantification process equation.⌊•⌋ signifies the floor function.The choice of quantization factor q depends on the desired level of decimal precision retention.Subsequently, the quantized values are converted into binary representation.Given a quantized attribute range of [−M, M], where M is the maximum absolute value of the quantized values, the number of binary encoding bits N for each attribute is set as: where ⌈•⌉ represents the ceiling function.Due to the possibility of negative values in AIS data attributes, it is crucial to consider the sign while converting to binary representation.If an element value is negative, its leading bit is set to 1 to signify the negative sign, while the subsequent bits represent the binary depiction of the element's absolute value, resulting in the binary-encoded representation of AIS data, denoted as B Q(P ′ t n ) : where a 1B , a 2B , a 3B , and a 4B correspond to the encoded data of x, y, v x , and v y , respectively.By assembling the binary representations of each element, it can be viewed as an n-hot vector.This method converts the continuous attribute values of AIS data into a format suitable for machine learning models.The binary encoding not only reduces the dimensions of the original data but also captures the significant features of the data more precisely, providing a more robust data representation for ship trajectory prediction.

The Design of Correlation Attention Mechanism
To further enhance the correlation between position and speed in ship trajectory prediction, we have delved into the design of an ACoAtt module, as depicted in Figure 4. We hypothesize that this module possesses the potential to transpose encoded data into a more condensed and highly abstracted embedding space, thereby unearthing the profound interrelations among attributes [32].To corroborate this hypothesis, the ACoAtt design integrates a multidimensional correlation attention mechanism, dedicated to elevating the model's proficiency in deciphering complex behavioral patterns of vessels within maritime environments.By employing several fully connected layers to funnel trajectory attributes into the model, and through the implementation of a multi-head attention mechanism, ACoAtt aspires to perform a detailed analysis and learning of the interplay among diverse attributes.Specifically, each attention head is engineered to detect the interactions among different types of attributes, with each interaction having a distinct impact on trajectory prediction.For instance, certain heads may concentrate more on dissecting the influence of velocity fluctuations on future positions, while others investigate the repercussions of temporal intervals on speed and directional alterations.This strategic approach enables the model to contemplate multiple factors in forecasting future trajectories, theoretically advancing the precision of predictions.
To further enhance the correlation between position and speed in ship trajectory prediction, we have delved into the design of an ACoAtt module, as depicted in Figure 4. We hypothesize that this module possesses the potential to transpose encoded data into a more condensed and highly abstracted embedding space, thereby unearthing the profound interrelations among attributes [32].To corroborate this hypothesis, the ACoAtt design integrates a multidimensional correlation attention mechanism, dedicated to elevating the model's proficiency in deciphering complex behavioral patterns of vessels within maritime environments.By employing several fully connected layers to funnel trajectory attributes into the model, and through the implementation of a multi-head attention mechanism, ACoAtt aspires to perform a detailed analysis and learning of the interplay among diverse attributes.Specifically, each attention head is engineered to detect the interactions among different types of attributes, with each interaction having a distinct impact on trajectory prediction.For instance, certain heads may concentrate more on dissecting the influence of velocity fluctuations on future positions, while others investigate the repercussions of temporal intervals on speed and directional alterations.This strategic approach enables the model to contemplate multiple factors in forecasting future trajectories, theoretically advancing the precision of predictions.

Vector trans formation
Processi ng of data encoding Attention Mechanism s In practical applications, the ACoAtt module initially calculates the self-attention weights for each attribute embedding, subsequently leveraging these weights to augment the embeddings, thereby accentuating the attributes most pertinent to the current moment.Notably, distinct CoAtt modules are designed to recalibrate the embeddings of each ship trajectory attribute independently.The interplay between x and x v , as well as y In practical applications, the ACoAtt module initially calculates the self-attention weights for each attribute embedding, subsequently leveraging these weights to augment the embeddings, thereby accentuating the attributes most pertinent to the current moment.Notably, distinct CoAtt modules are designed to recalibrate the embeddings of each ship trajectory attribute independently.The interplay between x and v x , as well as y and v y , is orchestrated in a manner that fosters mutual influence, with each module addressing different dimensions of attribute relationships and data characteristics.
Initially, the binary-encoded data B Q(P ′ t n ) are transformed into attribute-embedding vectors e a by mapping them through a fully connected layer into the embedding space.This transformation can be articulated using the following equation: where W e represents the weight matrix of the fully connected layer, and b e signifies the bias element.Subsequently, in the embedding space, the attribute-embedding vectors are processed through a multi-head attention mechanism, involving three primary steps: initially, the generation of Query (Q), Key (K), and Value (V) vectors.
where W q , W k , and W v represent respective weight matrices.Following this, the attention weights are calculated.
In the formula, d k represents the dimension of the key vector, and the so f tmax function is utilized to normalize the weights.Finally, these weights are applied to the value V to obtain the final output.
e ′ a = AV The CoAtt module is ingeniously designed to intricately parse the interrelations between different navigational attributes, particularly between the ship's position and speed.Leveraging the dynamics of prior knowledge, it is presumed that changes in position are closely linked to the preceding velocity.This module enables the model to not only capture the unique features of each attribute but also to comprehend how these attributes evolve over time in unison, thereby enhancing the accuracy of future position predictions for the ship.

LSTM Prediction Network
Building upon the encoding and ACoAtt module discussed in previous chapters, the LSTM Prediction Network section is dedicated to employing the capabilities of Long Short-Term Memory networks for processing and predicting time series in AIS data of ships.Renowned for its proficiency in handling sequential data, the LSTM network is ideally suited for the task of predicting ship trajectories.This section focuses on the implementation of a multi-layered LSTM structure to model temporal dependencies in ship trajectories, thereby forecasting their future positions.
LSTM is a specialized form of RNN and excels at learning long-term dependencies within sequence data.A typical LSTM unit, as depicted in Figure 5, comprises a storage cell that maintains its state over time and three nonlinear "regulators" or gates that control the flow of information within the unit.
where W and b represent the weight matrices and bias terms, respectively.σ de- notes the sigmoid function.is the input at the current time step.The newly generated information t C  and the cell state at the current time step t C are given by: [ ] ( ) In this diagram, h t and C t represent the hidden state and cell state at time step t, respectively.The cell state retains information learned from previous time steps.Information can be added to or removed from the cell state using these gates: the input gate (i), the forget gate (f ), and the output gate (o).At each time step t, the module uses the past state of the network (C t−1 and h t−1 ) and the input x t to compute the output h t and the updated cell state C t .The hidden state and cell state are recurrently connected back to the block input.All gates are controlled by the hidden state from the previous cycle and the input vector x.Most modern research incorporates many improvements made since the initial proposal of the LSTM architecture.The mathematical expressions for each gate of the LSTM can be formulated as follows: where W and b represent the weight matrices and bias terms, respectively.σ denotes the sigmoid function.h t−1 is the hidden state from the previous time step, while x t is the input at the current time step.The newly generated information C t and the cell state at the current time step C t are given by: In the formula, tanh represents the hyperbolic tangent function.Based on the mathematical expressions for each gate of the LSTM unit as per Equations ( 19) and ( 20), the output function of the LSTM unit can be represented as follows:

Experimental Validation
In this study, we developed an innovative method for predicting ship trajectories by combining data encoding transformation, the ACoAtt module, and LSTM networks.This approach aimed to validate the effectiveness, reliability, and real-time capabilities of the proposed algorithm through various simulation experiments, followed by in-depth discussion and analysis of the results.

Description of Experimental Data
The study utilized publicly available AIS data from the Marinecadastre website, focusing on segments of ship trajectories from 2022 for experimental analysis.We conducted a comprehensive analysis using the navigational trajectory data of 42 vessels, with the dataset featuring an average of 874 AIS data points per vessel.These trajectories span multiple maritime areas and encompass a broad spectrum of environmental conditions, aiming to thoroughly evaluate the performance of our proposed model across diverse scenarios.The trajectories of six ships in six different regions, as depicted in Table 1, represent merely a fraction of our experimental dataset.The selected AIS data encompassed details like ship identification numbers (MMSI), longitude, latitude, speed over ground (SOG), and course over ground (COG).To ensure precise experimental prediction outcomes, longitude and latitude were recorded to five decimal places, equating to roughly 1 m accuracy.Speed was measured in knots with one decimal place accuracy, while the course was recorded in degrees, also with one decimal place precision.A sample of these trajectories is presented in Table 2. To thoroughly evaluate the performance of the proposed model, we segmented the trajectory prediction dataset, adopting an 8:2 ratio to bifurcate the dataset into a training set and a testing set.Specifically, 80% of the data were designated as the training set, dedicated to the model's learning and optimization processes, while the remaining 20% were allocated to the testing set, intended for subsequent performance evaluation and verification.Within the testing set, we deliberately selected data encompassing linear and maneuvering trajectory patterns, to conduct an in-depth analysis of the model's accuracy and robustness in handling diverse navigational behaviors.

Design of Experimental Evaluation Indicators
When evaluating the accuracy of the predictive model used, it is essential to consider the discrepancy between the predicted results and the actual values due to various factors.The study employs three metrics for assessing the model's performance: mean absolute error (MAE), root-mean-square error (RMSE), and hit rate.These metrics provide a comprehensive evaluation of the model's predictive accuracy and reliability.
where Y i represents the actual values of the ship's navigational data, while Ŷ denotes the predicted estimates of the ship's trajectory data.N refers to the number of AIS data samples used for testing purposes.In this study, the prediction of a ship's navigational trajectory is conducted by forecasting individual trajectory points.The hit rate serves as an intuitive indicator of the model's precision in predicting these trajectory points.A prediction is considered accurate when the distance between the forecasted and actual points is relatively close.To calculate the hit rate, the first step involves computing the straight-line distance d i between the actual and predicted trajectory points.
In this context, lon i and l ât i denote the predicted latitude and longitude coordinates, respectively, while lon i and lat i represent the actual latitude and longitude coordinates.R signifies the Earth's radius, measured in kilometers.
A threshold for maximum prediction error ∆, measured in meters, is established.If the distance d i between the predicted and actual points is less than ∆, the prediction is considered accurate, a "hit".If d i exceeds ∆, it is a "miss", indicating a failed prediction.The hit rate, representing the success rate of accurate predictions, is calculated as the number of hits hits divided by the total number of predictions N.
In the ship trajectory prediction experiments of this section, a larger value of Hit Rate indicates a smaller difference between the predicted value and the actual value, signifying higher prediction accuracy.Conversely, smaller values of RMSE and MAE indicate that the predictions are closer to the actual data, further illustrating the precision of the predictive model.

Comparison of Experimental Prediction Methods
To evaluate the proposed ship trajectory prediction framework, three comparative prediction methods were designed for the experiments: (1) Kalman Filter prediction model: The Kalman Filter (KF) algorithm involves two processes: time updating (prediction) and measurement updating (correction).The prediction process uses the values determined at any given moment for prior estimation, and then estimates the next moment.The measurement update process corrects the model using measured values, offering a posterior estimate improved from the current state.To ensure the accuracy and effectiveness of the KF algorithm, it has been extended in this study to adapt to the dynamic characteristics of ship movement.The state vector is defined to include position (longitude and latitude), speed, acceleration, and rate of turn.
(2) LSTM network-based prediction model: The ability of LSTM networks is particularly suitable for processing time series in ship AIS data, as these often contain complex spatiotemporal patterns and dynamics.Through training, LSTM networks can learn patterns extracted from historical data and use these to accurately predict future ship positions and behaviors.Furthermore, comparing the LSTM network with the prediction framework proposed in this study allows for the validation of the effectiveness of the associative attention mechanism introduced in the paper.
(3) Transformer-based time series forecasting: Since its inception, the surge in Transformerbased solutions for time series forecasting tasks has been noteworthy [33].Transformers, with their adeptness at extracting semantic correlations among elements within extensive sequences, boast remarkable capabilities in parallel sequence processing, rendering them highly suitable for modeling time series characterized by pronounced periodicity and elongated sequence lengths.This model, reliant on the parallel processing of self-attention mechanisms, facilitates the effortless extraction of relationships between temporally distant steps within a sequence.
The proposed prediction model in the paper is configured as follows: After vector transformation of AIS data elements, 18-bit binary encoding is used to represent positions in the x and y directions, and 10-bit binary encoding is used for speeds in these directions, with the highest bit indicating the sign of the value.The correlation attention mechanism module uses four multi-head attention operators.In the LSTM main prediction network part, six stacked LSTM networks are set as the main model, with each LSTM layer having a count of three.The number of hidden units per layer ranges from 32 to 256.The training simulation is run for 500 iterations using the Adam adaptive learning rate optimization algorithm, with an initial learning rate of 0.2.To prevent model overfitting, L2 regularization is adjusted with a coefficient set at 0.01.

Results and Analysis
For the test experiments of the model, the following hardware conditions were used: The operating system was Windows 10, the CPU was an Intel ® i7-11700F, which produced by Intel Corporation in Santa Clara, CA, USA, and the GPU was an NVIDIA GeForce GTX 1080Ti, manufactured by NVIDIA Corporation located in Santa Clara, CA, USA.The programming language used was Python 3.8, and the deep learning framework utilized was PyTorch 2.0.

Comparison of Different Types of Trajectory Predictions
This experiment compares various trajectory prediction models, including the Kalman Filter prediction model, LSTM-based prediction model, Transformer prediction model, and the model proposed in this study, for different types of trajectories such as straight-line navigation and turning maneuvers.The first 30 moments of ship navigation trajectory points are used as inputs for the models, predicting the trajectories for the subsequent 10 sampling time points, which corresponds to approximately 12 min of trajectory prediction.
(1) Straight-line navigation In the case of straight-line navigation, the real trajectory involved sailing in a nearly straight line with a course of about 89.7 • and a speed of around 10 knots.The target ship started sailing along a planned route, maintaining relatively stable direction and speed.Trajectory predictions were made using different methods starting from the 7th point in the trajectory.A comparison of the predictions from these various methods is illustrated in Figure 6.An error analysis was performed on the latitude and longitude predictions from different methods at the same forecast point.This analysis provided a comparison of the latitudinal and longitudinal predictions and their errors for each method, as depicted in Figure 7.
(2) Curved maneuver navigation  The real trajectory involved curved maneuvering, starting at a course of approximately 175 • and ending at about 262 • .The initial speed was around 9 knots, slowing down and then speeding up during the turn, ending at approximately 12 knots.Similar to the previous case, at the 7th point in the chart, different methods were used to predict the trajectory.The comparative results of these different prediction methods are illustrated in Figure 8.The study also conducted an error analysis on the latitude and longitude predictions for different prediction points, comparing the results and errors of each prediction method.This comparison and error analysis are depicted in Figure 9.
The paper conducted a comprehensive analysis of simulation results, comparing the longitude and latitude prediction errors of four models.It also calculated key performance metrics for each model, including average absolute error, root-mean-square error, and prediction hit rate.The performance analysis of the proposed model and the other three models is detailed in Table 3.We set a maximum prediction error of 150 m as a benchmark to assess the prediction hit rates of the various algorithms.(2) Curved maneuver navigation The real trajectory involved curved maneuvering, starting at a course of approximately 175° and ending at about 262°.The initial speed was around 9 knots, slowing down and then speeding up during the turn, ending at approximately 12 knots.Similar to the previous case, at the 7th point in the chart, different methods were used to predict the trajectory.The comparative results of these different prediction methods are illustrated in Figure 8.The study also conducted an error analysis on the latitude and longitude predictions for different prediction points, comparing the results and errors of each prediction method.This comparison and error analysis are depicted in Figure 9.The study's model exhibited superior predictive performance in both linear and curvilinear ship trajectory prediction compared to the KF model, LSTM-based model, and Transformer model.It achieved the lowest root-mean-square error, average absolute error, and hit rate across different scenarios, outperforming other models, especially in linear prediction scenarios where the KF model showed significant errors.The Transformer model followed in effectiveness, with the multi-layer LSTM model next in line.This highlights the advanced predictive capability of the proposed model over traditional and other intelligent prediction methods.Furthermore, the study's model, alongside LSTMbased and Transformer models, showed similar patterns of increasing prediction errors with longer prediction steps.While the initial prediction errors were marginally different, the root-mean-square errors varied significantly among the models.In curvilinear motion prediction, the study's model exhibited markedly lower root-mean-square errors in both latitude and longitude (0.000437 and 0.000411, respectively) compared to other methods.This indicates the model's superior predictive performance over traditional KF predictions and other intelligent algorithms.
On the other hand, by contrasting the predictive outcomes and statistics of our model with those of the multi-layer LSTM network, our approach demonstrates superior accuracy in predicting various feature attributes in both scenarios.Specifically, in straight-line navigation, there is a notable reduction in the mean absolute error (MAE) for latitude and longitude predictions, and a similar trend is observed in curvilinear motion scenarios.Additionally, our model shows greater stability for longer prediction intervals compared to the multi-layer LSTM model.The results validate the efficacy of the proposed ACoAtt, effectively integrating historical trajectory and current state information to uncover hidden inter-sequential information.This approach distinctly captures the feature interrelations post binary encoding, demonstrating that the proposed model architecture significantly enhances the accuracy of ship trajectory prediction.

Comparison of Multi-Step Trajectory Prediction
To assess the robustness and stability of the proposed method across varying prediction lengths, this section opts for a test set comprising navigational trajectories under curvilinear maneuvering conditions.Predictions are made for ship trajectory points at 5, 10, and 20 moments in time, corresponding to approximate durations of 6 min 30 s, 13 min, and 26 min, respectively.This approach serves to validate the testing model's performance in short-to-medium-term ship trajectory forecasting.
The real trajectory of the ship involved curve maneuvering, starting at an initial course of about 83 • , ending around 27 • , with an initial speed of about 11 knots, decreasing during the turn, and ending at about 9 knots.Predictions began from the seventh point in the trajectory, and the comparative results of different prediction methods are shown in Figure 10.
To further assess the impact of step length on ship trajectory prediction tasks, the MAE of different prediction methods at 5, 10, and 20 moments was statistically analyzed.Box plots were used to display the MAE of latitude and longitude attributes, as shown in Figure 11.Additionally, the average RMSE of the four models at different prediction lengths is depicted in Table 4.
The statistical analysis of the experimental simulation results for predicting ship trajectories over consecutive 5, 10, and 20 moments is outlined in Table 4.
Commencing with an analysis grounded in the visualization outcomes, an examination of predictive accuracy is undertaken.The model introduced herein achieves the pinnacle of predictive performance.Furthermore, as the prediction horizon extends, various forecasting methodologies tend to incur greater predictive discrepancies.When the trajectory point prediction length is minimal, each model can accurately forecast future trajectories within the initial four prediction steps (approximately 5 min), with the average absolute error and root-mean-square error of the four models being comparably close.This suggests that the current methodologies can adequately meet the demands for ultra-shortterm trajectory forecasting, with the model presented in this paper exhibiting superior performance.However, as the number of prediction steps increases, some predicted tra-jectories gradually diverge from the actual scenarios, leading to a decline in trajectory forecasting precision across all four models.Yet, the rate of decline in predictive accuracy for the model discussed in this paper is significantly lower than that of the Kalman Filter prediction model, LSTM network-based prediction model, and Transformer prediction model.At a prediction length of 20 trajectory points, the average root-mean-square error is substantially lower than the other three comparative methods.This indicates that for the problem of longer continuous ship trajectory prediction, the model designed in this paper is capable of achieving commendable predictive outcomes.
interrelations post binary encoding, demonstrating that the proposed model architecture significantly enhances the accuracy of ship trajectory prediction.

Comparison of Multi-Step Trajectory Prediction
To assess the robustness and stability of the proposed method across varying prediction lengths, this section opts for a test set comprising navigational trajectories under curvilinear maneuvering conditions.Predictions are made for ship trajectory points at 5, 10, and 20 moments in time, corresponding to approximate durations of 6 min 30 s, 13 min, and 26 min, respectively.This approach serves to validate the testing model's performance in short-to-medium-term ship trajectory forecasting.
The real trajectory of the ship involved curve maneuvering, starting at an initial course of about 83°, ending around 27°, with an initial speed of about 11 knots, decreasing during the turn, and ending at about 9 knots.Predictions began from the seventh point in the trajectory, and the comparative results of different prediction methods are shown in Figure 10.To further assess the impact of step length on ship trajectory prediction tasks, the MAE of different prediction methods at 5, 10, and 20 moments was statistically analyzed.Box plots were used to display the MAE of latitude and longitude attributes, as shown in Figure 11.Additionally, the average RMSE of the four models at different prediction lengths is depicted in Table 4.
The statistical analysis of the experimental simulation results for predicting ship trajectories over consecutive 5, 10, and 20 moments is outlined in Table 4.
Commencing with an analysis grounded in the visualization outcomes, an examination of predictive accuracy is undertaken.The model introduced herein achieves the pinnacle of predictive performance.Furthermore, as the prediction horizon extends, various forecasting methodologies tend to incur greater predictive discrepancies.When the trajectory point prediction length is minimal, each model can accurately forecast future trajectories within the initial four prediction steps (approximately 5 min), with the average absolute error and root-mean-square error of the four models being comparably close.This suggests that the current methodologies can adequately meet the demands for ultra-shortterm trajectory forecasting, with the model presented in this paper exhibiting superior performance.However, as the number of prediction steps increases, some predicted trajectories gradually diverge from the actual scenarios, leading to a decline in trajectory forecasting precision across all four models.Yet, the rate of decline in predictive accuracy   Subsequently, an analysis focused on the trend-following aspect of predictions was conducted.The method proposed in this manuscript, in comparison to other models, can swiftly forecast future motion trends within several prediction steps, as depicted in Figure 10.The model presented here is capable of stably and accurately predicting ships' curvilinear maneuvering navigation.In contrast, the Transformer model, due to its attention mechanism, can correctly predict trajectory change trends, yet its predictive accuracy falls short.The LSTM-based prediction model, on the other hand, erroneously estimates the ships' maneuvering intent, gradually diverging from the true course in subsequent prediction steps.Kalman Filter predictions made more accurate forecasts regarding future trajectory trends in this round of testing, but the deviation between predicted points and actual trajectory points was too significant, resulting in subpar overall predictive performance.
Lastly, an analysis focusing on the stability of prediction lengths was undertaken.According to the test outcomes, the method proposed in this manuscript, alongside the Transformer model, exhibited commendable performance within the initial ten prediction steps.However, as the prediction length extended, the predictive trend gradually deviated, rendering the results unreliable.Consequently, in the realm of short-term ship trajectory prediction applications, the method introduced herein demonstrates superior stability and outperforms other comparative forecasting techniques, albeit its efficacy wanes in mid-term predictive applications.
To further evaluate the predictive capabilities of the model, we selectively extracted data from the test set, which constitutes 20% of the navigational trajectory data of 42 vessels, resulting in a total of 64 linear navigation test trajectories and 12 curvilinear maneuvering trajectories.These were subjected to tests using various predictive methods, with a prediction length set at 10 steps.The model's forecasts were assessed based on the error between predicted and actual latitude and longitude, with a comparative statistical analysis of the outcomes from different predictive approaches, as illustrated in Table 5.As evidenced by Table 5, our model demonstrates a general improvement across three performance evaluation metrics, both in terms of accuracy and stability.Quantitatively speaking, it achieved the best results in longitude prediction across all evaluative indicators, showcasing the highest accuracy and commendable predictive performance.The test outcomes affirm that the predictive framework proposed in this paper can effectively unearth the correlations between target feature attributes, producing highly confident predictive trajectory outcomes.It supports an extended short-term prediction process, contributing to the enhancement of maritime performance and presenting a significant advantage in trajectory prediction.

Conclusions
This paper introduces an innovative method for predicting ship trajectories based on AIS data.The approach combines data encoding transformation, the ACoAtt module, and LSTM networks.Data encoding effectively represents AIS data, reducing complexity while retaining key information.The ACoAtt module, using a multi-head attention mechanism, captures complex relationships between dynamic ship features, enhancing understanding of hidden time series patterns in the data.Finally, the LSTM network accurately predicts future ship trajectories by processing time series data.By testing with historical AIS datasets, the proposed method in this article has been proven to outperform classical prediction models and other latest models with attention mechanisms in trajectory prediction accuracy.It significantly enhances the performance of existing models, offering superior accuracy and stability in trajectory prediction.This research addresses challenges in ship trajectory prediction due to the complexity of ship movements, providing notable improvements in data representation efficiency, time series data processing, and dynamic feature correlation analysis.Moreover, this algorithm can also be adapted for applications in other geospatial applications.
In our future work, we intend to focus on the application of this method for ship collision avoidance, aiming to establish a new paradigm in maritime safety and further enhance the security of ship navigation.Additionally, we are exploring more effective ways to utilize historical trajectory data to predict longer step lengths in accurate trajectory distributions.

Figure 2 .
Figure 2. Proposed framework for ship trajectory prediction model.

Figure 2 .
Figure 2. Proposed framework for ship trajectory prediction model.

Figure 4 .
Figure 4. Schematic diagram of the correlation attention mechanism.

Figure 4 .
Figure 4. Schematic diagram of the correlation attention mechanism.

Figure 6 .
Figure 6.Comparative results of forecasts for straight-line routes.

Figure 7 .
Figure 7.Comparison of prediction results and errors for straight-line routes.(a) Results in the direction of longitude.(b) Errors in the direction of longitude.(c) Results in the direction of latitudinal.(d) Errors in the direction of latitudinal.

Figure 8 .
Figure 8. Comparative results of curvilinear maneuvering trajectory predictions.Figure 8. Comparative results of curvilinear maneuvering trajectory predictions.

Figure 8 .
Figure 8. Comparative results of curvilinear maneuvering trajectory predictions.Figure 8. Comparative results of curvilinear maneuvering trajectory predictions.

Figure 9 .
Figure 9.Comparison of prediction results and errors for curved maneuver routes.(a) Comparison of predictive outcomes in longitude.(b) Contrast of predictive errors in longitude.(c) Comparison of predictive outcomes in latitude.(d) Contrast of predictive errors in latitude.

Figure 9 .
Figure 9.Comparison of prediction results and errors for curved maneuver routes.(a) Comparison of predictive outcomes in longitude.(b) Contrast of predictive errors in longitude.(c) Comparison of predictive outcomes in latitude.(d) Contrast of predictive errors in latitude.

Figure 10 .
Figure 10.Comparative results of multi-step prediction.

Figure 10 .
Figure 10.Comparative results of multi-step prediction.

Figure 11 .
Figure 11.Box plots of errors for different prediction step sizes.(a) Prediction error in longitude for length of 5 steps.(b) Prediction error in latitude for length of 5 steps.(c) Prediction error in longitude for length of 10 steps.(d) Prediction error in latitude for length of 10 steps.(e) Prediction error in longitude for length of 20 steps.(f) Prediction error in latitude for length of 20 steps.
. The hidden state and cell state are recurrently connected back to the block input.All gates are controlled by the hidden state from the previous cycle and the input vector x .Most modern research incorporates many improvements made since the initial proposal of the LSTM architecture.The mathematical expressions for each gate of the LSTM can be formulated as follows: C represent the hidden state and cell state at time step t , respectively.The cell state retains information learned from previous time steps.Information can be added to or removed from the cell state using these gates: the input gate (i), the forget gate (f), and the output gate (o).At each time step t , the module uses the past state of the network ( C

Table 1 .
Experimental data of ship trajectories.

Table 2 .
Sample AIS data for ship trajectories.

Table 3 .
Results of various prediction algorithms under different scenarios.

Table 4 .
Statistics on the predictions of the four models at different prediction lengths.for the model discussed in this paper is significantly lower than that of the Kalman Filter prediction model, LSTM network-based prediction model, and Transformer prediction model.At a prediction length of 20 trajectory points, the average root-mean-square error is substantially lower than the other three comparative methods.This indicates that for the problem of longer continuous ship trajectory prediction, the model designed in this paper is capable of achieving commendable predictive outcomes.

Table 5 .
Repetitive verification results statistics.