Ship trajectory prediction method, system and device, medium and terminal
By integrating a spatiotemporally aware Transformer with a dynamic clustering enhancement mechanism, the ship trajectory prediction method solves the problems of insufficient dynamic spatiotemporal dependency modeling and long-term prediction performance degradation, achieving high-precision and robust ship trajectory prediction, which can be applied to maritime supervision systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- GUILIN UNIVERSITY OF TECHNOLOGY
- Filing Date
- 2025-10-31
- Publication Date
- 2026-05-12
AI Technical Summary
Existing technologies are insufficient in modeling dynamic spatiotemporal dependencies in ship trajectory prediction, resulting in long-term prediction performance degradation and insufficient robustness to noisy data.
We adopt a spatiotemporally aware Transformer architecture and a dynamic clustering enhancement mechanism. Through multimodal embedding layers, positional encoding, causal self-attention mechanism and fuzzy loss function, we construct a dynamic clustering module to improve the model’s ability to capture spatiotemporal continuity and dynamic dependencies and reduce the impact of noise.
It achieves high-precision, long-cycle ship trajectory prediction, reduces noise errors, improves the robustness and prediction accuracy of the model, and can effectively identify collision risks and reduce maritime accidents.
Smart Images

Figure CN122020273A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to, but is not limited to, the field of propagation trajectory prediction technology, and particularly relates to a method, system, device, medium, and terminal for ship trajectory prediction based on spatiotemporal perception Transformer and dynamic clustering enhancement. Background Technology
[0002] As a core component of modern transportation networks, the intelligent development of waterway transportation is crucial for improving global shipping efficiency and safety. With the widespread adoption of Automatic Identification Systems (AIS), the real-time collection of vast amounts of spatiotemporal data has provided new opportunities for ship trajectory prediction. This data can not only be used for real-time traffic monitoring and congestion mitigation, but also for predicting ship behavior to proactively avoid collision risks, becoming a key technological support for intelligent shipping systems. However, the dynamic complexity of the maritime environment (such as route diversity and weather changes) and the heterogeneity of AIS data (such as noise interference and uneven sampling) still pose significant challenges to high-precision, long-term trajectory prediction.
[0003] In recent years, deep learning technology has injected new vitality into ship trajectory prediction. Early research was mostly based on a hybrid architecture of traditional temporal methods and recurrent neural networks. For example, the ARIMA-LSTM method decomposes linear and nonlinear features through moving average filtering and models and predicts them separately. However, when it relies on a fixed time window, it is difficult to capture long-term dependencies. The IS-STGCNN method, although it extracts ship interaction features through spatiotemporal graph convolution, cannot adapt to dynamic spatial relationships due to its pre-set static graph structure. While the bilinear autoencoder method can generate future trajectories, it lacks robustness to noisy data and does not consider the diversity of navigation modes. A comprehensive analysis of existing methods reveals two bottlenecks that urgently need to be overcome: the first bottleneck is insufficient modeling of dynamic spatiotemporal dependencies; the second bottleneck is the degradation of long-term prediction performance.
[0004] Based on the above analysis, the urgent technical problems that need to be solved in the existing technology are: insufficient dynamic spatiotemporal dependency modeling and long-term prediction performance degradation. Summary of the Invention
[0005] To address the problems existing in the prior art, this invention provides a method, system, device, medium, and terminal for ship trajectory prediction. By integrating a spatiotemporal-aware Transformer architecture with a dynamic clustering enhancement mechanism, it aims to improve the accuracy of ship trajectory prediction while increasing its resistance to noise interference.
[0006] This invention is implemented as follows: a method for predicting ship trajectories, comprising:
[0007] Step 1: Construct a ship trajectory prediction model based on dynamic clustering and spatiotemporal awareness Transformer architecture, and initialize the global model;
[0008] Step 2: Preprocess the AIS data, including data cleaning and data transformation, and extract multimodal features of the ship trajectory, including longitude, latitude, speed and heading;
[0009] Step 3: Map each feature to the semantic space through a multimodal embedding layer, and then input it into the dynamic clustering module;
[0010] Step 4: In the dynamic clustering module, all time series data are standardized to eliminate scale differences between different time series, and then cluster centers are initialized.
[0011] Step 5: The similarity between each time series and the cluster center is evaluated by shape similarity measurement. Based on the similarity, the time series is assigned to the cluster center with the most similarity. Then the cluster center is updated and the updated data is input into the historical cluster memory module.
[0012] Step 6: Determine if the clustering is stable. If it is stable, output each cluster label. If it is unstable, repeat step 5 until the clustering is stable.
[0013] Step 7: Input the data with cluster labels into the spatially aware Transformer architecture and introduce learnable positional encoding;
[0014] Step 8: Utilize causal self-attention mechanism and partitioning modeling strategy to dynamically partition the feature space to adapt to the non-uniform spatiotemporal distribution of AIS data;
[0015] Step 9: After the data passes through the causal autonomous attention mechanism, it undergoes a series of iterative training processes, including layer normalization, backpropagation, and residual connections. A fuzzy loss function is introduced during the iterative training, and various parameters are adjusted using the AdamW optimizer.
[0016] Step 10: After training is complete, predict the ship's trajectory and output the prediction results.
[0017] Furthermore, the dynamic clustering and spatiotemporally aware Transformer architecture effectively captures the spatiotemporal continuity and dynamic dependencies of ship trajectories by integrating a multimodal embedding layer, position encoding, and a causal self-attention mechanism. Specifically, the multimodal embedding layer designs independent embedding functions for multidimensional features such as longitude, latitude, heading, and speed in ship trajectory data, mapping these features to a high-dimensional semantic space, thereby avoiding coupling between features and enhancing the model's ability to distinguish different features. The position encoding layer introduces learnable position codes to explicitly model the temporal relationships in the time series, enabling the model to better capture the spatiotemporal continuity of the trajectory. The causal self-attention mechanism, through strict causal masking constraints, ensures that the model relies only on historical information when predicting the trajectory at the current moment, avoiding the leakage of future information, thereby improving the model's ability to model long-sequence data and its prediction accuracy.
[0018] Furthermore, during step 2, data preprocessing involves cleaning and transforming the raw AIS data. First, AIS information with an SOG greater than or equal to 30 knots was excluded; second, records of anchored or moored vessels were removed, as these vessels typically do not contain dynamic information; next, AIS data within 1 nautical mile of the coastline was removed; then, discontinuous voyages were processed by segmenting them into continuous segments; additionally, voyages shorter than 20 observation points or lasting less than 4 hours were removed. Regarding data transformation, the AIS data sampling rate was set to once every 10 minutes, and long voyages exceeding 20 hours were segmented into multiple shorter voyages.
[0019] During the execution of step 3, the ship's trajectory includes multi-dimensional dynamic features such as longitude (LAT), latitude (LON), speed (SOG), and heading (COG). To avoid feature coupling, this invention designs an independent embedding layer to map each feature to a high-dimensional semantic space, as shown in the following expression:
[0020]
[0021] in, , For attributes The embedding function. The final embedding vector is generated through weighted fusion, as shown in the following expression:
[0022]
[0023] in, These are learnable weights used to dynamically adjust the importance of various features.
[0024] Furthermore, during the execution of step 4, when initializing the cluster centers, kernel density estimation is used to select the initial centroids. First, the spatial density distribution of the AIS data points is calculated, and then the initial centroids are selected. High-density points are used as initial cluster centers, as expressed below:
[0025]
[0026] in, For Gaussian kernel function, For bandwidth, The length between sequences.
[0027] During the execution of step 5, when calculating shape similarity, DTW distance and information entropy are fused together. DTW (Dynamic Time Adjustment) finds the optimal correspondence between two time series by flexibly matching them, and then fuses it with information entropy to reduce performance degradation caused by noise. The expression is as follows:
[0028]
[0029]
[0030] in, and These are two time series, where n and m are the sequence numbers respectively. and Length, It is the Euclidean distance between two sequence points. It is a mapping that defines a sequence. points and sequences in The correspondence between points in the map. Summation is performed across all possible mappings. The goal is to minimize the total matching clusters. For sequence and The joint entropy is expressed as follows:
[0031]
[0032] in, The balance coefficient (set to 0.1 in experiments) is used to suppress noise interference by quantifying the disorder of the sequence through entropy.
[0033] Furthermore, during the execution of step 6, the maximum number of iterations is set to 100 until the cluster centers change very little or the maximum number of iterations is reached.
[0034] During the execution of step 7, in order to display the modeled temporal relationships, a learnable positional encoding is introduced, the expression of which is as follows:
[0035]
[0036] in, For linear transformation layers, the time steps are... The mapping is to a positional encoding with the same dimension as the embedding vector. The embedding vector and the positional encoding are added together and then input into subsequent modules, as shown in the following expression:
[0037]
[0038] Furthermore, during the execution of step 8, a causal self-attention mechanism is employed, using a lower triangular mask matrix. Constrained attention, expressed as follows:
[0039]
[0040] in, This represents three different representation spaces: query, key, and value; It is the dimension of the key. Used to scale the dot product to prevent the vanishing gradient problem; mask matrix The definition of is as follows:
[0041]
[0042] During the execution of step 9, to improve the model's robustness to noise, a fuzzy loss function module is designed. This module uses KL divergence matching to predict the distribution and the true distribution, as shown in the following expression:
[0043]
[0044] in, The uncertainty of discrete observations is blurred by estimating the Gaussian kernel density of the real trajectory.
[0045] Another object of the present invention is to provide a ship trajectory prediction system for implementing the aforementioned ship trajectory prediction method, comprising:
[0046] Model building module: Constructs a ship trajectory prediction model based on dynamic clustering and spatiotemporal awareness Transformer architecture, and initializes the global model;
[0047] Preprocessing module: Preprocesses AIS data, including data cleaning and data transformation, and extracts multimodal features of ship trajectories, including longitude, latitude, speed and heading;
[0048] Feature mapping module: Maps each feature to the semantic space through a multimodal embedding layer, and then inputs it into the dynamic clustering module;
[0049] Cluster center initialization module: In the dynamic clustering module, all time series data are standardized to eliminate scale differences between different time series, and then the cluster centers are initialized.
[0050] Cluster center update module: The similarity between each time series and the cluster center is evaluated by shape similarity measurement. Based on the similarity, the time series is assigned to the cluster center with the most similarity. Then the cluster center is updated and the updated data is input into the historical cluster memory module.
[0051] Cluster stability determination module: Determines whether the clusters are stable. If stable, outputs each cluster label. If unstable, repeats the cluster center update until the clusters are stable.
[0052] Location encoding module: Inputs data with clustering labels into the spatially aware Transformer architecture and introduces learnable location encoding;
[0053] Feature space partitioning module: Utilizes causal self-attention mechanism and partitioning modeling strategy to dynamically partition the feature space, adapting to the non-uniform spatiotemporal distribution of AIS data;
[0054] Parameter tuning module: After the data passes through the causal autonomous attention mechanism, it undergoes a series of iterative training processes such as layer normalization, backpropagation, and residual connections. A fuzzy loss function is introduced during the iterative training, and various parameters are adjusted through the AdamW optimizer.
[0055] Prediction Result Output Module: After training is completed, the module predicts the ship trajectory and outputs the prediction results.
[0056] Another object of the present invention is to provide a computer device including a memory and a processor, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor performs the steps of the ship trajectory prediction method.
[0057] Another object of the present invention is to provide a computer-readable storage medium storing a computer program, which, when executed by a processor, causes the processor to perform the steps of the ship trajectory prediction method.
[0058] Another objective of this invention is to provide an information data processing terminal, which includes the aforementioned ship trajectory prediction system.
[0059] Based on the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solution to be protected by this invention are as follows:
[0060] This invention provides a ship trajectory prediction method that integrates a spatiotemporally aware Transformer architecture with a dynamic clustering enhancement mechanism. Addressing the heterogeneity of maritime traffic data and the problem of long-term prediction error accumulation, the method first enhances the model's ability to capture the spatiotemporal continuity of trajectories by fusing multimodal embedding and location encoding. Second, it employs a causal self-attention mechanism and a partitioning modeling strategy, using dynamic feature partitioning and mask constraints to accurately capture spatiotemporal dependencies. Third, it introduces dynamic time-curvature entropy and density-driven cluster centers for initialization, further improving the robustness of the K-Shape clustering algorithm. Finally, it uses historical clustering results to guide the current iteration of the model, adjusting weights to favor feature regions with higher data quality. Furthermore, this invention introduces a fuzzy loss function to reduce the impact of noise on the model, thereby improving overall prediction performance.
[0061] (1) The expected benefits and commercial value of the technical solution of this invention after transformation are as follows:
[0062] The model can achieve high-precision, long-term (e.g., 18-hour) ship trajectory prediction and can be integrated into maritime regulatory systems to help regulatory authorities identify collision risks and abnormal navigation patterns in advance, thereby reducing the incidence of maritime accidents. According to industry data, the losses from a single ship collision often reach millions of yuan. After the model is widely adopted, it can significantly reduce these direct economic losses, while also reducing the indirect costs caused by casualties and environmental pollution.
[0063] The technical solution can be transformed into three types of commercial products: first, an "intelligent trajectory prediction and risk warning system" for maritime regulatory departments; second, a "route optimization and operation management tool" for shipping companies; and third, a "vessel arrival time prediction module" for port scheduling. These products can be charged on a subscription basis (such as an annual service fee) or through customized development. Referring to the pricing of similar maritime technology products, the average annual revenue per system can reach hundreds of thousands of yuan. The market covers major shipping regions and ports worldwide, with enormous commercial potential.
[0064] (2) The technical solution of this invention fills a technical gap in the industry both domestically and internationally:
[0065] Existing models, both domestically and internationally, either rely solely on Transformers for spatiotemporal modeling, failing to adapt to the non-uniform distribution characteristics of AIS data; or they use clustering algorithms alone without deep integration with spatiotemporal prediction. This invention, however, is the first to construct a collaborative framework of "spatiotemporally perceptive Transformer + dynamic clustering enhancement." Through DTW-Entropy similarity measurement and density-driven clustering initialization, it embeds navigation pattern recognition into the trajectory prediction process, filling the industry gap of disconnect between "prediction accuracy" and "pattern adaptation."
[0066] Existing models generally suffer from error accumulation in long-term predictions exceeding 12 hours. This invention, through causal self-attention, partitioned modeling, and a historical memory module, reduces the prediction error to 1.4022 nautical miles within an 18-hour prediction window, filling the technological gap in long-term, high-precision ship trajectory prediction and providing a feasible solution for the long-standing unresolved issue of "long-distance navigation prediction" in the industry.
[0067] (3) The technical solution of the present invention solves a technical problem that people have long wanted to solve but have never been able to solve successfully:
[0068] AIS data often contains noise (such as signal interference and sampling errors). Traditional models are sensitive to noise; adding Gaussian noise (standard deviation 0.01) can increase the error by more than 15%. This invention fuses information entropy and dynamic time warping distance using DTW-Entropy, and simultaneously introduces a fuzzy loss function to optimize probability distribution prediction. The noise error increase is only 14.15%, significantly lower than similar models, solving the problem of insufficient robustness of long sequence prediction in noisy environments.
[0069] Traditional K-Shape clustering uses random initialization of cluster centers, which is prone to convergence oscillations and affects the accuracy of navigation pattern recognition. This invention selects Top-k high-density points as initial cluster centers through kernel density estimation and combines the iterative results with a historical memory module, thus avoiding convergence fluctuations and solving the long-standing technical problem of unstable cluster initialization that has plagued the industry. Attached Figure Description
[0070] Figure 1 This is a schematic diagram of the ship trajectory prediction model constructed by the dynamic clustering and spatiotemporal awareness Transformer architecture of the present invention, provided in an embodiment of the present invention.
[0071] Figure 2 This is a schematic diagram of the dynamic clustering enhancement method provided in an embodiment of the present invention;
[0072] Figure 3 This is a schematic diagram showing the increase in MAE noise error when comparing the method of this invention with several currently advanced deep learning methods when the Gaussian noise is 1e-3.
[0073] Figure 4 This is a schematic diagram showing the increase in RMSE noise error when comparing the method of this invention with several currently advanced deep learning methods when the Gaussian noise is 1e-3.
[0074] Figure 5 This is a schematic diagram showing the increase in MAE noise error when comparing the method of this invention with several currently advanced deep learning methods when the Gaussian noise is 1e-2.
[0075] Figure 6 This is a schematic diagram showing the increase in RMSE noise error when comparing the method of this invention with several currently advanced deep learning methods when the Gaussian noise is 1e-2.
[0076] Figure 7 This is a schematic diagram illustrating the random selection of four trajectories in the prediction results by the method of the present invention and several currently advanced deep learning methods provided in the embodiments of the present invention. Detailed Implementation
[0077] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0078] This invention provides a ship trajectory prediction method based on spatiotemporal awareness Transformer and dynamic clustering enhancement, comprising the following steps:
[0079] Step S1: Construct a ship trajectory prediction model based on dynamic clustering and spatiotemporal awareness Transformer architecture, and initialize the global model;
[0080] Step S2: Preprocess the AIS data, including data cleaning and data transformation, and extract multimodal features of the ship trajectory, including longitude, latitude, speed and heading;
[0081] Step S3: Map each feature to the semantic space through a multimodal embedding layer, and then input it into the dynamic clustering module;
[0082] Step S4: In the dynamic clustering module, all time series data are standardized to eliminate scale differences between different time series, and then cluster centers are initialized.
[0083] Step S5: The similarity between each time series and the cluster center is evaluated by shape similarity measurement. Based on the similarity, the time series is assigned to the cluster center with the most similarity. Then the cluster center is updated and the updated data is input into the historical cluster memory module.
[0084] Step S6: Determine if the clustering is stable. If it is stable, output each cluster label. If it is unstable, repeat step S5 until the clustering is stable.
[0085] Step S7: Input the data with clustering labels into the spatially aware Transformer architecture and introduce learnable positional encoding;
[0086] Step S8: Utilize causal self-attention mechanism and partitioning modeling strategy to dynamically divide the feature space to adapt to the non-uniform spatiotemporal distribution of AIS data;
[0087] Step S9: After the data passes through the causal autonomous attention mechanism, it undergoes a series of iterative training processes, including layer normalization, backpropagation, and residual connections. A fuzzy loss function is introduced during the iterative training, and various parameters are adjusted using the AdamW optimizer.
[0088] Step S10: After training is complete, predict the ship trajectory and output the prediction results.
[0089] Step S1, the constructed ship trajectory prediction model based on dynamic clustering and spatiotemporal awareness Transformer architecture is as follows: Figure 1 As shown, the spatiotemporal-aware Transformer architecture effectively captures the spatiotemporal continuity and dynamic dependencies of ship trajectories by integrating a multimodal embedding layer, position encoding, and a causal self-attention mechanism. Specifically, the multimodal embedding layer designs independent embedding functions for multidimensional features such as longitude, latitude, heading, and speed in ship trajectory data, mapping these features to a high-dimensional semantic space, thereby avoiding coupling between features and enhancing the model's ability to distinguish different features. The position encoding layer introduces learnable position encoding to explicitly model the temporal relationships in the time series, enabling the model to better capture the spatiotemporal continuity of the trajectory. The causal self-attention mechanism, through strict causal masking constraints, ensures that the model relies only on historical information when predicting the trajectory at the current moment, avoiding the leakage of future information, thereby improving the model's ability to model long-sequence data and its prediction accuracy.
[0090] Step S2, data preprocessing, involves cleaning and transforming the raw AIS data. First, AIS information with an SOG greater than or equal to 30 knots is excluded; second, records of anchored or moored vessels are removed, as these vessels typically do not contain dynamic information; next, AIS data within 1 nautical mile of the coastline is removed; then, discontinuous voyages are processed by segmenting them into continuous segments; additionally, voyages shorter than 20 observation points or lasting less than 4 hours are removed. For data transformation, the AIS data sampling rate is set to once every 10 minutes, and long voyages exceeding 20 hours are segmented into multiple shorter voyages.
[0091] Step S3: The ship's trajectory includes multi-dimensional dynamic features such as longitude (LAT), latitude (LON), speed (SOG), and heading (COG). To avoid feature coupling, this invention designs an independent embedding layer to map each feature to a high-dimensional semantic space, as shown in the following expression:
[0092]
[0093] in, , For attributes The embedding function. The final embedding vector is generated through weighted fusion, as shown in the following expression:
[0094]
[0095] in, These are learnable weights used to dynamically adjust the importance of various features.
[0096] Step S4, dynamic clustering enhancement method as follows Figure 2 As shown, when initializing cluster centers, kernel density estimation is used to select initial centroids. First, the spatial density distribution of AIS data points is calculated, and then the initial centroids are selected. High-density points are used as initial cluster centers, as expressed below:
[0097]
[0098] in, For Gaussian kernel function, For bandwidth, The length between sequences.
[0099] Step S5: When calculating shape similarity, DTW distance and information entropy are fused together. DTW (Dynamic Time Adjustment) finds the optimal correspondence between two time series by elastically matching them, and then fuses it with information entropy to reduce performance degradation caused by noise. The expression is as follows:
[0100]
[0101]
[0102] in, and These are two time series, where n and m are the sequence numbers respectively. and Length, It is the Euclidean distance between two sequence points. It is a mapping that defines a sequence. points and sequences in The correspondence between points in the map. Summation is performed across all possible mappings. The goal is to minimize the total matching clusters. For sequence and The joint entropy is expressed as follows:
[0103]
[0104] in, The balance coefficient (set to 0.1 in experiments) is used to suppress noise interference by quantifying the disorder of the sequence through entropy.
[0105] Step S6: Set the maximum number of iterations to 100 until the cluster centers change very little or the maximum number of iterations is reached.
[0106] Step S7: To display the modeled temporal relationships, a learnable positional encoding is introduced, expressed as follows:
[0107]
[0108] in, For linear transformation layers, the time steps are... The mapping is to a positional encoding with the same dimension as the embedding vector. The embedding vector and the positional encoding are added together and then input into subsequent modules, as shown in the following expression:
[0109]
[0110] Step S8: Employ a causal self-attention mechanism using a lower triangular mask matrix. Constrained attention, expressed as follows:
[0111]
[0112] in, This represents three different representation spaces: query, key, and value; It is the dimension of the key. Used to scale the dot product to prevent the vanishing gradient problem; mask matrix The definition of is as follows:
[0113]
[0114] Step S9: To improve the model's robustness to noise, a fuzzy loss function module is designed. The predicted distribution is matched with the true distribution using KL divergence, and the expression is as follows:
[0115]
[0116] in, The uncertainty of discrete observations is blurred by estimating the Gaussian kernel density of the real trajectory.
[0117] To verify the performance improvement and advantages of the method of this invention compared to other existing ship trajectory prediction methods, please refer to [link / reference]. Figures 3 to 7Referring to Tables 1 and 2, this invention uses the AIS dataset provided by the Danish Maritime Authority (DMA) to compare with several currently advanced deep learning methods, namely LSTM, LSTM_seq2seq, LSTM_seq2seq with attention, Transformer, TrAISformer, TrAISformer with K-Shape, and ST-MetaNet. The following metrics are used for experimental comparison:
[0118] 1. Haversine error: The prediction error is calculated using Haversine distance to determine the distance between the predicted and actual locations.
[0119] 2. Mean Absolute Error (MAE): MAE represents the mean absolute error of the Haversine distance between all predicted points and the true points.
[0120] 3. Root Mean Square Error (RMSE): RMSE is calculated by taking the square root of the mean of the squared errors, thus amplifying the penalty weight of the errors.
[0121] 4. Noise Error Amplification: This invention adds Gaussian noise with different standard deviations to the original AIS dataset and calculates the MAE and RMSE of different methods under noise conditions. By comparing the error under noise conditions with the error under noise-free conditions, the noise error amplification is obtained.
[0122] 5. Prediction of different trajectories: The similarity between the predicted trajectory and the actual trajectory in this invention.
[0123] The method proposed in this invention is implemented based on the PyTorch framework and Python 3.9. The Transformer has 8 layers, the data batch size is set to 32, the model optimizer is AdamW, and the learning rate is set to 0.0001. The backpropagation algorithm is used to adjust various parameters to minimize the loss function.
[0124] Figures 3 to 6 The noise error amplification of MAE and RMSE under different noise conditions was compared between the method of this invention (named: Sea-KSformer) and several currently advanced deep learning methods. Figures 3 to 4 This is the increase when the Gaussian noise is 1e-3. Figures 3 to 4 The increase is when the Gaussian noise is 1e-2. The MAE and RMSE of the method of the present invention are the smallest compared with other methods when there are different noise increases. This shows that the method of the present invention has low noise sensitivity and good stability and robustness.
[0125] Figure 7 This paper compares the method of this invention (named Sea-KSformer) with several advanced deep learning methods in predicting different trajectories. The comparison shows that the method of this invention achieves the highest accuracy in predicting different trajectories compared to the other methods, indicating that the method of this invention is more ideal in terms of trajectory prediction precision. In summary, the spatiotemporal awareness Transformer and dynamic clustering-enhanced ship trajectory prediction method of this invention provides a more effective solution for ship trajectory prediction at sea, exhibiting not only high accuracy but also stronger robustness and stability.
[0126] Example 1: AIS Data Trajectory Modeling Based on Multimodal Dynamic Clustering
[0127] This embodiment uses AIS data provided by the Danish Maritime Authority as the input sample. The data covers the period from January 1, 2019 to March 31, 2019, and the geographical area is the sea area between longitude 10.3°E and 13.0°E and latitude 55.5°N and 58.0°N (this area is located between Denmark and Sweden in Northern Europe, covering part of the North Sea and the Kattegat Strait, and is an important maritime traffic route in Northern Europe, including commercial shipping, fishing operations, and various maritime transport activities). The data sample includes key information such as ship position (longitude and latitude), speed (SOG), heading (COG), ship identification information (MMSI number), and time step. The original data contains approximately 1 million records. The original AIS data is cleaned to exclude records with a speed greater than 30 knots, those at anchor, and those within 1 nautical mile of the coast. The sampling frequency is uniformly set to once every 10 minutes. The system uses the Gaussian kernel density estimation method to select the initial cluster centers. By calculating the spatial density distribution of trajectory points, high-density points are selected as centroids to form the initial dynamic cluster structure.
[0128] In the clustering process, a shape similarity calculation method that integrates dynamic time warping distance (DTW) and information entropy is employed to elastically measure trajectory shape differences. An adaptive balancing coefficient λ is used to adjust the weight ratio of DTW and entropy values, reducing the clustering's sensitivity to trajectory outliers. Experimental results show that, under the same parameters, this clustering method improves the accuracy of MAE and RMSE by 55% and 49%, respectively, compared to the model without this clustering method. This provides stable and reliable label input for subsequent Transformer models and strongly guarantees the prediction accuracy of this invention.
[0129] Example 2: Modular Implementation of Ship Trajectory Prediction System
[0130] This embodiment uses Python and the TensorFlow deep learning framework to build a complete ship trajectory prediction system. The system includes a model building module, a preprocessing module, a feature mapping module, a dynamic clustering module, a Transformer analysis module, a parameter optimization module, and a prediction output module. Data flow between modules is achieved through message queue communication. The system runs on an NVIDIA RTX 4060Ti GPU and can process multiple trajectory data simultaneously.
[0131] During system operation, the preprocessing module first cleans and transforms the AIS data. Then, the feature mapping module performs multimodal embedding and sends the data to the dynamic clustering module for cluster analysis. The clustering results are then passed to the Transformer analysis module for prediction and inference. The final results are visualized on the control terminal by the prediction output module. Test results show that with 1 million trajectory samples, the system can complete model training and trajectory prediction within 1 hour and 14 minutes, with a single trajectory prediction time of 235.73ms. Compared to other comparative models, this only takes a few minutes longer, but the prediction accuracy is significantly higher.
[0132] Table 1:
[0133]
[0134] With all parameters fixed, the clustering module in this invention was removed. The model after removal was then tested, and the MAE and RMSE results were compared with those of this invention. The results are shown in the table above. The comparison concludes that the MAE and RMSE values in the model without clustering are significantly higher than those of this invention, demonstrating that the clustering component has a significant impact on the prediction accuracy of this invention.
[0135] Table 2:
[0136]
[0137] The training time and average duration per trajectory of this invention are compared with all the comparison models, as shown in the table above. Although the total training time and average duration per trajectory of this invention are not optimal, it is optimal in terms of MAE and RMSE. Compared with the time-optimal model, the time difference of this invention is not significant, but its accuracy is far superior to other models.
[0138] Table 3 is a comparison of the method of the present invention with several advanced deep learning methods in specific embodiments of the present invention. It is a schematic table comparing the Haversine error of the following methods: LSTM, LSTM_seq2seq, LSTM_seq2seq with attention, Transformer, TrAISformer, TrAISformer with K-Shape and ST-MetaNet (unit: nautical miles).
[0139] Table 4 is a comparison of the method of the present invention with several advanced deep learning methods in specific embodiments of the present invention. The comparison of MAE and RMSE of the methods LSTM, LSTM_seq2seq, LSTM_seq2seq with attention, Transformer, TrAISformer, TrAISformer with K-Shape and ST-MetaNet is shown in nautical miles.
[0140] Table 3
[0141]
[0142] Table 4
[0143]
[0144] It should be noted that embodiments of the present invention can be implemented in hardware, software, or a combination of both. The hardware portion can be implemented using dedicated logic; the software portion can be stored in memory and executed by a suitable instruction execution system, such as a microprocessor or dedicated-design hardware. Those skilled in the art will understand that the above-described devices and methods can be implemented using computer-executable instructions and / or included in processor control code, for example, such code provided on a carrier medium such as a disk, CD, or DVD-ROM, a programmable memory such as read-only memory (firmware), or a data carrier such as an optical or electronic signal carrier. The devices and modules of the present invention can be implemented by hardware circuitry such as very large-scale integrated circuits or gate arrays, semiconductors such as logic chips, transistors, or programmable hardware devices such as field-programmable gate arrays, programmable logic devices, etc., or by software executed by various types of processors, or by a combination of the above-described hardware circuitry and software, such as firmware.
[0145] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any modifications, equivalent substitutions, and improvements made by those skilled in the art within the scope of the technology disclosed in the present invention, and within the spirit and principles of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A method for predicting ship trajectories, characterized in that, Includes the following steps: Step 1: Construct a ship trajectory prediction model based on dynamic clustering and spatiotemporal awareness Transformer architecture; Step 2: Clean and transform the AIS data to extract multimodal features of longitude, latitude, speed and heading; Step 3: Map each feature to a high-dimensional semantic space using independent embedding functions to form a fused trajectory representation; Step 4: Standardize the time series data in the dynamic clustering module and use kernel density estimation to select high-density points as the initial cluster centers. Step 5: Update the cluster centers based on the shape similarity measure that combines dynamic time regularization distance and information entropy, and store them in the historical cluster memory module; Step 6: Determine if the clustering is stable. If it is not stable, continue iterating until convergence. Step 7: Input the clustering label data into the spatiotemporally aware Transformer architecture to introduce learnable location encoding; Step 8: Dynamically partition spatiotemporal features using causal self-attention mechanism and partitioning modeling strategy; Step 9: Introduce the fuzzy loss function and train the model using the AdamW optimizer; Step 10: Output the ship trajectory prediction results.
2. The method according to claim 1, characterized in that, The multimodal embedding layer designs independent embedding functions for longitude, latitude, speed, and heading, maps them to a unified semantic space, and generates the final feature representation through weighted fusion. The weights of each feature can be adaptively adjusted through training to enhance the model's ability to distinguish multidimensional dynamic features.
3. The method according to claim 1, characterized in that, The kernel density estimation is used to determine the initial cluster centers by calculating the spatial density value of each AIS data point and selecting the data points with the highest density as the initial cluster centers, thereby improving the stability and convergence speed of the clustering.
4. The method according to claim 1, characterized in that, The shape similarity metric achieves elastic matching between time series while suppressing the influence of noise by weighted fusion of dynamic time-warped distance and sequence joint entropy, thereby enhancing the robustness of clustering under abnormal trajectories.
5. The method according to claim 1, characterized in that, The learnable positional encoding maps the time step to an encoding vector with the same dimension as the embedding vector through a linear transformation, and then adds it to the embedding vector before inputting it into the Transformer encoder, enabling the model to explicitly model the temporal continuity of the trajectory.
6. The method according to claim 1, characterized in that, The fuzzy loss function forms a smooth probability distribution by estimating the Gaussian kernel density of the true trajectory distribution, and uses Kullback-Leibler divergence to measure the difference between the predicted distribution and the true distribution, so as to achieve the continuity and robustness of the predicted output.
7. A ship trajectory prediction system that implements the ship trajectory prediction method as described in claim 1, characterized in that, include: The model building module is used to construct a prediction model based on dynamic clustering and spatiotemporal awareness Transformer architecture; The preprocessing module is used to clean and transform AIS data and extract multimodal features; The feature mapping module is used to embed each feature into a high-dimensional semantic space; The dynamic clustering module is used for time series standardization, cluster center initialization, and updating. The clustering stability assessment module is used to detect the clustering convergence status and output the clustering labels; The Transformer analysis module is used to perform causal self-attention computation on labeled spatiotemporal features; The parameter optimization module is used to introduce a fuzzy loss function and optimize model parameters based on the AdamW algorithm; The prediction output module is used to output the ship trajectory prediction results.
8. The system according to claim 7, characterized in that, The dynamic clustering module includes a kernel density estimation unit, a similarity calculation unit, and a historical clustering memory unit. The similarity calculation unit performs similarity calculation based on a weighted combination of dynamic time regularization distance and information entropy.
9. A spatiotemporal sensing Transformer device for modeling ship trajectory data, characterized in that, include: Multimodal embedding units are used to independently embed and weightedly fuse longitude, latitude, speed, and heading features; Learnable positional coding units are used to map time steps to a high-dimensional space; The causal self-attention unit constrains attention weights through a lower triangular mask matrix and relies solely on historical information for trajectory modeling. Partition modeling units are used to dynamically divide the feature space to adapt to the non-uniformity of spatiotemporal distribution.
10. A ship intelligent navigation prediction device based on a joint architecture of dynamic clustering and Transformer, characterized in that, It includes a data acquisition module, an embedding processing module, a cluster analysis module, a Transformer inference module, and a prediction display module. The device achieves intelligent prediction of the future position of a ship and visualization of its trajectory by integrating cluster labels with learnable temporal features.