LSTM ship trajectory prediction method and system based on automatic trajectory set clustering

By preprocessing and clustering the ship's historical trajectory data, combining the two-way LSTM network to generate trajectory mode probability model and prediction model, the problems of low accuracy of ship trajectory prediction and complex calculation in the prior art are solved, and efficient and accurate prediction in complex navigation environments are achieved.

CN120493047APending Publication Date: 2025-08-15SHANGHAI SHIP & SHIPPING RES INST CO LTD +2
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510469221.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-04-14
Publication Date
2025-08-15

AI Technical Summary

Technical Problem

The existing ship trajectory prediction methods have low accuracy in complex navigation environments, especially in insufficient prediction accuracy at bends and high calculation complexity.

Method used

The LSTM ship trajectory prediction method based on automatic trajectory clustering is adopted, and the ship's historical trajectory data is preprocessed, and the trajectory mode is divided using the k-means clustering algorithm, and the trajectory mode probability model and trajectory prediction model are generated in combination with the bidirectional LSTM network, and the basic trajectory prediction module, SHA module and TCA module are trained to adapt to complex scenarios such as turn.

Benefits of technology

It significantly improves the accuracy and scope of application of ship trajectory prediction, especially adapts to complex scenarios such as turn and acceleration, and improves the robustness and efficiency of prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120493047A_ABST
    Figure CN120493047A_ABST
Patent Text Reader

Abstract

The invention provides an LSTM ship trajectory prediction method and system based on automatic trajectory set clustering, and the method comprises the following steps: carrying out the preprocessing of the historical trajectory data of a ship, extracting the starting point and end point of each trajectory, and forming an automatic trajectory set; clustering a starting point and an end point in the automatic track set by using a k-means clustering algorithm, and dividing different track modes; inputting the historical track data subjected to automatic track set preprocessing into a bidirectional LSTM network for pre-training so as to generate a track mode probability model; inputting a track to be predicted into the track mode probability model, and outputting the probability of the track mode to which the track belongs; training a basic trajectory prediction module and an SHA module of a trajectory prediction model based on LSTM by using historical trajectory data corresponding to the trajectory mode with the maximum trajectory number, and training a TCA module of the trajectory prediction model by using historical trajectory data corresponding to other trajectory modes; and predicting a final prediction trajectory by using the trajectory prediction model corresponding to the trajectory mode with the maximum probability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of ship trajectory prediction, and in particular to an LSTM ship trajectory prediction method and system based on automatic trajectory clustering. Background Art

[0002] Ship trajectory prediction is a key capability for ships to ensure safety and efficiency in complex navigation environments. Accurate trajectory prediction not only provides a basis for maritime traffic management, but also effectively warns of accidents such as ship collisions and groundings, and has important application value. In recent years, with the popularization of automatic identification systems (AIS) and sensor technology, it has become more convenient to obtain spatiotemporal data of ships, providing data support for trajectory prediction. The AIS system sends and receives signals through sea, land, and air base stations (such as berths, ground stations, and AIS satellites), enabling ships to exchange static information (such as maritime mobile service identification, ship size, etc.) and dynamic information (such as location, course over the ground, speed over the ground, etc.). This information exchange helps ships avoid collisions during navigation and plan future trajectories.

[0003] However, ship trajectory prediction faces numerous challenges. In areas where traffic separation schemes are in place, ship trajectories are restricted by sea lanes, and actual trajectories can deviate significantly from planned trajectories due to the influence of currents, reefs, and traffic conditions. This scenario-dependent nature highlights the importance of considering environmental factors in trajectory prediction. Therefore, extracting effective information from massive amounts of AIS data and making accurate trajectory predictions has become a complex and challenging task.

[0004] Ship trajectory prediction is of great significance in areas such as autonomous navigation, collision avoidance, and multi-agent collaboration. Currently, trajectory prediction methods can be divided into three categories: kinematic model-based methods, recurrent neural network-based methods, and clustering-based methods. Early studies of kinematic model-based methods primarily relied on physical models of ship motion. For example, Sutulo et al. proposed a dynamic mathematical model based on ship velocity and acceleration, while Perera et al. utilized the extended Kalman filter (EKF) combined with noise estimation for trajectory prediction. Assaf et al. used the unscented Kalman filter (UKF) to predict trajectories for underactuated ships. However, these methods have limitations: first, it is difficult to establish an accurate mathematical model, especially when considering dynamic factors such as wind and currents; second, long-term predictions are less reliable, as ship trajectories are often highly nonlinear due to crew decisions. Forti et al. applied a long short-term memory (LSTM) network model to AIS ship data from the Port of Portoferraio, Italy, demonstrating superior fitting results compared to other methods. Liu et al. combined AIS data with weather data and input them into an LSTM network model, further improving ship fitting accuracy. However, the above method only utilizes the longitude and latitude information in AIS data, ignoring the importance of other information in trajectory prediction. While it performs well when predicting linear trajectories, its performance degrades significantly when faced with complex situations such as turns, acceleration, and deceleration. In recent years, clustering-based methods have been widely used in trajectory prediction. Li et al. used the DBSCAN clustering method to extract spatial features of adjacent vehicles. However, this density-based clustering method requires the inclusion of complete trajectories and the modification of clustering parameters based on specific circumstances. This is computationally intensive and complex. Summary of the Invention

[0005] In order to solve the problems of low prediction accuracy, insufficient prediction precision at turns and complex calculations in the existing technology, the present invention provides an LSTM ship trajectory prediction method and system based on automatic trajectory clustering. This method uses automatic trajectory clustering technology and integrates multiple deep neural network technologies to construct and conduct specific training of trajectory pattern probability models and trajectory prediction models. It can predict multiple trajectories and probability distributions, thereby more accurately judging the possible forward routes of the ship. This method is particularly suitable for complex scenarios such as turns and acceleration in the trajectory, and significantly improves the accuracy, scope of application and robustness of the prediction.

[0006] The present invention is achieved through the following technical solutions:

[0007] An LSTM ship trajectory prediction method based on automatic trajectory clustering includes the following steps:

[0008] Steps for obtaining an automatic trajectory set: preprocess the historical trajectory data of the ship and extract the starting point and end point of each trajectory to form an automatic trajectory set;

[0009] Trajectory pattern clustering step: Use the k-means clustering algorithm to cluster the starting points and end points in the automatic trajectory set, and divide different trajectory patterns according to the clustering results;

[0010] Trajectory pattern probability model pre-training step: the historical trajectory data after automatic trajectory centralization pre-processing is input into the bidirectional LSTM network for pre-training to generate a trajectory pattern probability model for predicting the ship's destination and corresponding probability;

[0011] Trajectory pattern classification step: inputting the trajectory to be predicted into the trajectory pattern probability model, outputting the probability of the trajectory pattern to which the trajectory belongs, and selecting the trajectory pattern with the highest probability;

[0012] Trajectory prediction model training steps: Use the historical trajectory data pre-processed from the automatic trajectory set corresponding to the trajectory pattern with the largest number of trajectories to train an LSTM-based trajectory prediction model. The trajectory prediction model includes a basic trajectory prediction module, a SHA module, a trajectory output module, and a TCA module. The basic trajectory prediction module is used to learn the basic characteristics of the trajectory. The SHA module is used to correct the trajectory according to the ship's speed and heading information. The trajectory output module is used to generate the final predicted trajectory. The TCA module is used to adapt to different trajectory patterns. The training process is divided into three stages:

[0013] The first stage trains the basic prediction function: input the historical trajectory data corresponding to the trajectory pattern with the largest number of trajectories into the trajectory output module, freeze the TCA module and SHA module, and train the basic trajectory prediction module;

[0014] The second stage trains the dynamic correction function: unfreeze the SHA module, and jointly train the corrected trajectory with the speed and heading dynamic information in the automatic trajectory set and the trajectory output module;

[0015] The third stage trains the trajectory mode adaptation function: unfreeze the TCA module, input historical trajectory data corresponding to other trajectory modes, train the parameters of each trajectory mode adaptation branch separately, and freeze the trajectory output module and SHA module at the same time;

[0016] Trajectory prediction step: Call the trained trajectory prediction model corresponding to the trajectory pattern with the highest probability, optimize the trajectory shape through the TCA module, and then correct the dynamic details through the SHA module to output the final predicted trajectory.

[0017] Preferably, in the trajectory pattern probability model pre-training step, the bidirectional LSTM network includes an input layer, a bidirectional LSTM layer, a Merge layer, a one-dimensional convolution layer, a maximum pooling layer, a fully connected layer and a Softmax layer. The historical trajectory data pre-processed in the automatic trajectory set enters the bidirectional LSTM layer through the input layer. The bidirectional LSTM layer processes the ship trajectory sequence information and its reverse order, and outputs a hidden state containing sequence features; then the sequence features output by the bidirectional LSTM layer are integrated together through the Merge layer; the one-dimensional convolution layer uses the convolution kernel to scan the integrated sequence features, extracts local features through the convolution operation, and captures the correlation pattern between features; then the maximum pooling layer reduces the dimension of the convolved features; then the fully connected layer performs a linear transformation on the reduced dimension features; finally, the Softmax layer performs classification prediction, converts its output into a probability distribution through the Softmax function, and calculates the predicted probability of each category. The category with the largest probability is the result predicted by the trajectory pattern probability model.

[0018] Preferably, in the trajectory pattern clustering step, the starting points and end points in the automatic trajectory set are merged into a single point cloud, and the single point cloud is clustered using the k-means clustering algorithm to obtain the coordinates of the points forming the source / destination areas, thereby obtaining N point clusters; different trajectory patterns are divided according to the clustering results. For a scene with N source / destination areas, the total number of trajectory patterns is N(N+1) / 2; and trajectory patterns with a number of trajectories at least equal to a total trajectory threshold are selected for subsequent trajectory prediction model training.

[0019] Preferably, in the trajectory pattern probability model pre-training step, for a scenario with multiple trajectory patterns, one-hot encoding is used to label each trajectory pattern during the training phase, and the encoding is incorporated into the pre-training process of the bidirectional LSTM network to distinguish different trajectory patterns;

[0020] In the trajectory prediction step, given a new observed trajectory, it is first input into the trajectory pattern probability model to obtain the probability of the trajectory belonging to each trajectory pattern. Using a predefined probability threshold, the trajectory pattern with a probability greater than the probability threshold is selected. Then, from the trajectory patterns with a probability greater than the probability threshold, the trajectory pattern with the highest probability is selected. The trained trajectory prediction model corresponding to the trajectory pattern with the highest probability is called. The trajectory morphology is optimized by the TCA module in the trajectory prediction model, and the dynamic details are corrected by the SHA module. Finally, the final predicted trajectory of the new observed trajectory is output.

[0021] Preferably, in the step of obtaining an automatic trajectory set, the ship's historical trajectory data includes latitude and longitude information, speed, heading and timestamp information during the ship's navigation process, and the preprocessing includes outlier cleaning, and the outlier cleaning includes removing data points with abnormal timestamps, abnormal position jumps, abnormal speeds and abnormal headings;

[0022] In the trajectory pattern clustering step, k initial cluster centers are randomly selected, and the distance from each starting point and end point to each cluster center is calculated, and the cluster center is assigned to the cluster with the nearest cluster center. The cluster center of each cluster is then recalculated, and the above process is continuously iterated until the cluster center no longer changes significantly, thereby obtaining the coordinates of the points forming the source / destination area and obtaining N point clusters. Combined with the distribution characteristics of the starting points and end points in each cluster and the navigation patterns of ships, the clustering results are classified and the trajectory pattern division is completed to determine the trajectory pattern to which each trajectory belongs.

[0023] Preferably, in the second stage of training the dynamic correction function of the trajectory prediction model training step, the SHA module adopts a dynamic weight allocation strategy based on a multi-head attention mechanism to optimize the speed and heading dynamic information in the automatic trajectory set and the process of jointly training the trajectory correction with the trajectory output module, which specifically includes the following steps:

[0024] Dynamic information encoding: The speed and heading dynamic information in the automatic trajectory set are encoded into time series feature vectors and input into the SHA module;

[0025] Dynamic weight allocation: Through the multi-head attention mechanism, the correlation weight matrix between speed features and heading features is calculated to generate a dynamic correction coefficient;

[0026] Trajectory feature fusion: weighted fusion of the dynamic correction coefficient and the spatiotemporal features of the basic predicted trajectory generated by the trajectory output module to generate the corrected trajectory details;

[0027] Joint training optimization: The mean square error between the fused corrected trajectory and the true trajectory is used as the loss function. The weight parameters in the multi-head attention mechanism are optimized and iterated through the back-propagation algorithm. The loss function value gradually decreases, minimizing the mean square error between the corrected trajectory and the true trajectory, thereby optimizing the SHA module for dynamic correction of speed and heading.

[0028] An LSTM ship trajectory prediction system based on automatic trajectory set clustering includes a sequentially connected automatic trajectory set acquisition module, a trajectory pattern clustering module, a trajectory pattern probability model pre-training module, a trajectory pattern classification module, a trajectory prediction model training module and a trajectory prediction module; wherein,

[0029] The automatic trajectory set acquisition module is used to pre-process the historical trajectory data of the ship and extract the starting point and end point of each trajectory to form an automatic trajectory set;

[0030] The trajectory pattern clustering module is used to cluster the starting points and end points in the automatic trajectory set using the k-means clustering algorithm, and divide different trajectory patterns according to the clustering results;

[0031] The trajectory pattern probability model pre-training module is used to input the historical trajectory data pre-processed by the automatic trajectory collection into the bidirectional LSTM network for pre-training to generate a trajectory pattern probability model for predicting the destination of the ship and the corresponding probability;

[0032] The trajectory pattern classification module is used to input the trajectory to be predicted into the trajectory pattern probability model, output the probability of the trajectory pattern to which the trajectory belongs, and select the trajectory pattern with the highest probability;

[0033] The trajectory prediction model training module is used to train an LSTM-based trajectory prediction model using the historical trajectory data pre-processed in the automatic trajectory set corresponding to the trajectory pattern with the largest number of trajectories. The trajectory prediction model includes a basic trajectory prediction module, a SHA module, a trajectory output module, and a TCA module. The basic trajectory prediction module is used to learn the basic characteristics of the trajectory. The SHA module is used to correct the trajectory according to the speed and heading information of the ship. The trajectory output module is used to generate the final predicted trajectory. The TCA module is used to adapt to different trajectory patterns. The training process is divided into three stages:

[0034] The first stage trains the basic prediction function: input the historical trajectory data corresponding to the trajectory pattern with the largest number of trajectories into the trajectory output module, freeze the TCA module and SHA module, and train the basic trajectory prediction module;

[0035] The second stage trains the dynamic correction function: unfreeze the SHA module, and jointly train the corrected trajectory with the speed and heading dynamic information in the automatic trajectory set and the trajectory output module;

[0036] The third stage trains the trajectory mode adaptation function: unfreeze the TCA module, input historical trajectory data corresponding to other trajectory modes, train the parameters of each trajectory mode adaptation branch separately, and freeze the trajectory output module and SHA module at the same time;

[0037] The trajectory prediction module is used to call the trained trajectory prediction model corresponding to the trajectory pattern with the highest probability, optimize the trajectory shape through the TCA module, and then correct the dynamic details through the SHA module to output the final predicted trajectory.

[0038] Preferably, in the trajectory pattern probability model pre-training module, the bidirectional LSTM network includes an input layer, a bidirectional LSTM layer, a Merge layer, a one-dimensional convolution layer, a maximum pooling layer, a fully connected layer and a Softmax layer. The historical trajectory data pre-processed in the automatic trajectory set enters the bidirectional LSTM layer through the input layer. The bidirectional LSTM layer processes the ship trajectory sequence information and its reverse order, and outputs a hidden state containing sequence features; then the sequence features output by the bidirectional LSTM layer are integrated together through the Merge layer; the one-dimensional convolution layer uses the convolution kernel to scan the integrated sequence features, extracts local features through the convolution operation, and captures the correlation pattern between features; then the maximum pooling layer reduces the dimension of the convolved features; then the fully connected layer performs a linear transformation on the reduced dimension features; finally, the Softmax layer performs classification prediction, converts its output into a probability distribution through the Softmax function, and calculates the predicted probability of each category. The category with the largest probability is the result of the trajectory pattern probability model prediction.

[0039] Preferably, in the trajectory pattern clustering module, the starting points and end points in the automatic trajectory set are merged into a single point cloud, and the single point cloud is clustered using the k-means clustering algorithm to obtain the coordinates of the points forming the source / destination areas, thereby obtaining N point clusters; different trajectory patterns are divided according to the clustering results. For a scene with N source / destination areas, the total number of trajectory patterns is N(N+1) / 2; and trajectory patterns with a number of trajectories at least equal to a total trajectory threshold are selected for subsequent trajectory prediction model training.

[0040] Preferably, in the trajectory pattern probability model pre-training module, for a scenario with multiple trajectory patterns, one-hot encoding is used to label each trajectory pattern during the training phase, and the encoding is incorporated into the pre-training process of the bidirectional LSTM network to distinguish different trajectory patterns;

[0041] In the trajectory prediction module, given a new observed trajectory, it is first input into the trajectory pattern probability model to obtain the probability of the trajectory belonging to each trajectory pattern. Using a predefined probability threshold, the trajectory pattern with a probability greater than the probability threshold is selected. Then, from the trajectory patterns with a probability greater than the probability threshold, the trajectory pattern with the highest probability is selected. The trained trajectory prediction model corresponding to the trajectory pattern with the highest probability is called. The trajectory morphology is optimized by the TCA module in the trajectory prediction model, and the dynamic details are corrected by the SHA module. Finally, the final predicted trajectory of the new observed trajectory is output.

[0042] The beneficial effects of the present invention are as follows:

[0043] The present invention provides an LSTM ship trajectory prediction method based on automatic trajectory set clustering. The method preprocesses the ship's historical trajectory data and extracts the starting point and end point of each trajectory to form an automatic trajectory set. The original historical trajectory of the ship is processed by preprocessing to generate a clean, continuous and standardized trajectory set, which is convenient for subsequent analysis; the starting point and end point in the automatic trajectory set are clustered by the k-means clustering algorithm, and different trajectory patterns are divided according to the clustering results. The historical trajectory is divided into different trajectory patterns by the k-means clustering algorithm, which has low cost and high efficiency. The trajectory pattern takes into account the movement patterns of different ships and generates multiple trajectory predictions; the historical trajectory data after preprocessing such as removing abnormal points in the automatic trajectory set is input into the The bidirectional LSTM network is pre-trained to generate a trajectory pattern probability model for predicting the destination of the ship and the corresponding probability. The trajectory pattern probability model generated by the bidirectional LSTM network training can better understand the latitude and longitude information, improve the prediction accuracy, and predict the probability of going to different destinations based on partial trajectories; the trajectory to be predicted is input into the trajectory pattern probability model, the probability of the trajectory pattern to which the trajectory belongs is output, and the trajectory pattern with the largest probability is selected. The historical trajectory data after the abnormal points in the automatic trajectory set corresponding to the trajectory pattern with the largest number of trajectories are cleared is used to train a trajectory prediction model based on LSTM. The trajectory prediction model includes a basic trajectory prediction module, a SHA module, a trajectory output module and a TCA module The basic trajectory prediction module is used to learn the basic features of the trajectory, the SHA module is used to correct the trajectory according to the speed and heading information of the ship, the trajectory output module is used to generate the final predicted trajectory, the TCA module is used to adapt to different trajectory modes, and the ship's historical trajectory data corresponding to the trajectory mode with the largest number of trajectories is used to train the basic trajectory prediction module, and then the basic trajectory prediction module is combined with the SHA module for training. The SHA module takes into account the speed and heading information during training, which can more accurately judge the forward route and is more adaptable to situations such as turning and acceleration in the trajectory. The training of other trajectory modes is based on the trained basic prediction module and SHA module, which greatly reduces the number of training times and improves the training efficiency. Efficiency, a unique trajectory pattern adaptation model is trained for each trajectory pattern, so that the trained trajectory prediction model can be applied to each trajectory pattern, with a wider range of applicability and stronger robustness; the trained trajectory prediction model corresponding to the trajectory pattern with the highest probability is called, the trajectory shape is optimized through the TCA module, and the dynamic details are corrected through the SHA module to output the final predicted trajectory. Selecting the trajectory pattern with the highest probability can make the prediction more accurate. After processing by the TCA module and SHA module of the trajectory prediction model, the prediction accuracy can be significantly improved, making the result more valuable for reference. At the same time, the trained trajectory prediction models corresponding to other trajectory patterns with lower probabilities can be used for trajectory prediction, providing users with multiple reference opinions.The present invention obtains an automatic trajectory set, divides the trajectories into different trajectory patterns, trains a trajectory pattern probability model, uses the trajectory pattern probability model to predict the trajectory pattern and corresponding probability to which the trajectory to be predicted belongs, trains a trajectory prediction model, and uses the trajectory prediction model to predict the trajectory. In this way, multiple trajectories and probability distributions can be predicted, thereby more accurately determining the possible forward routes of the ship. This method is particularly suitable for complex scenarios such as turns and accelerations in the trajectory, and significantly improves the accuracy, scope of application, and robustness of the prediction.

[0044] The bidirectional LSTM network of the present invention includes an input layer, a bidirectional LSTM layer, a Merge layer, a one-dimensional convolution layer, a maximum pooling layer, a fully connected layer and a Softmax layer. The forward LSTM layer and the backward LSTM layer in the bidirectional LSTM layer can simultaneously utilize past and future contextual information to better understand the latitude and longitude information, thereby more comprehensively understanding the trajectory data; after the Merge layer merges to generate a tensor, the one-dimensional convolution layer and the maximum pooling layer can generate richer feature representations, enhancing the model's capture capability; the fully connected layer and the Softmax layer can map features to multi-category probability distributions. The bidirectional LSTM network can capture long-distance dependencies and can utilize the front-to-back correlation of sequences to improve classification effects, making the trajectory pattern of the trajectory to be predicted more accurate.

[0045] This method combines the starting and ending points from the automated trajectory collection into a single point cloud. This point cloud is then clustered using the k-means algorithm to obtain the coordinates of the points forming the source / destination regions, resulting in N point clusters. Compared to trajectory clustering methods, this method has lower computational cost and is more suitable for ship-generated trajectories. Trajectory patterns with at least a threshold number of trajectories (e.g., 50, 60, or 70) are selected for subsequent trajectory prediction model training. This filtering out of trajectory patterns with fewer trajectories can speed up trajectory prediction model training and convergence.

[0046] The present invention targets scenarios with multiple trajectory patterns. During the training phase, one-hot encoding is used to label each trajectory pattern and then incorporated into the pre-training process of a bidirectional LSTM network to distinguish between different trajectory patterns. By converting categorical variables into numerical form, one-hot encoding can provide more reasonable input for the bidirectional LSTM network, thereby improving training results and model performance. In the trajectory prediction step, given a new observed trajectory, it is first input into the trajectory pattern probability model to obtain the probability of the trajectory belonging to each trajectory pattern. Low-probability trajectory patterns are filtered out using a predefined probability threshold, and the trajectory pattern with the highest probability is then selected as the trajectory pattern of the track to be measured. This prevents the selected trajectory pattern corresponding to the track to be measured from having a low probability, which can lead to inaccurate predicted trajectory patterns and, in turn, inaccurate final predicted trajectory.

[0047] The present invention pre-processes the ship's historical trajectory data by removing data points with abnormal timestamps, abnormal position jumps, abnormal speeds, and abnormal headings. This can produce a complete and smooth navigation trajectory that more realistically reflects the ship's actual path, making the trajectory pattern division of the ship's historical trajectory data more accurate. The K-Means algorithm is used to cluster the starting and end points of the ship's trajectory to obtain point clusters, directly ignoring the dynamic changes of intermediate trajectory points. Multidimensional time series data (such as time, speed, and heading) are simplified into two-dimensional or three-dimensional spatial coordinates (latitude and longitude), significantly reducing the data dimension. Compared with the full trajectory clustering method, this method can significantly reduce the computational cost, obtain analysis results more quickly, and thus quickly complete the trajectory pattern division of the ship's trajectory.

[0048] The SHA module of the present invention adopts a dynamic weight allocation strategy based on a multi-head attention mechanism to optimize the process of jointly training and correcting the trajectory of the speed and heading dynamic information in the automatic trajectory set with the trajectory output module. It specifically includes four steps: dynamic information encoding, dynamic weight allocation, trajectory feature fusion and joint training optimization. Through the multi-head attention mechanism, the SHA module can dynamically calculate the associated weights of speed and heading features at different time steps (such as strengthening heading correction when the speed changes suddenly), which can avoid the limitations of manually preset weights; multi-head attention can simultaneously focus on local and global temporal patterns (such as the cumulative impact of historical speed on the current trajectory), solving the long-range dependency attenuation problem of traditional RNN / LSTM; deeply integrate the speed (continuous value), heading (angle) and the spatiotemporal features of the basic trajectory (such as position sequence), and realize adaptive weighting of multimodal information through attention weights, which can avoid feature importance imbalance; by weighted fusion of the basic predicted trajectory and the dynamic correction coefficient, the SHA module can generate more refined trajectory details (such as turning radius, mooring point fine-tuning); through back propagation of mean square error loss, global parameter optimization is achieved to avoid error accumulation in staged training. The SHA module, trained through a dynamic weight allocation strategy based on a multi-head attention mechanism, is particularly adaptable to complex scenarios such as turns and acceleration in the trajectory, significantly improving the accuracy of predictions.

[0049] The present invention also relates to an LSTM ship trajectory prediction system based on automatic trajectory clustering. The system corresponds to the above-mentioned LSTM ship trajectory prediction method based on automatic trajectory clustering, and can be understood as a system that implements the above-mentioned LSTM ship trajectory prediction method based on automatic trajectory clustering, including an automatic trajectory set acquisition module, a trajectory pattern clustering module, a trajectory pattern probability model pre-training module, a trajectory pattern classification module, a trajectory prediction model training module and a trajectory prediction module. Each module works together to construct a trajectory prediction model including a basic trajectory prediction module, a SHA module and a TCA module, etc. The basic trajectory prediction module is mainly used to learn the basic features of the trajectory, and the SHA module is mainly used to correct the trajectory according to the ship's speed and heading information, so that it can adapt to complex scenarios such as turning and acceleration in the trajectory, and significantly improve the accuracy of the prediction. By dividing historical ship trajectories into distinct trajectory patterns, different ship motion patterns can be processed independently. During training, the parameters of each trajectory pattern adaptation branch of the SHA module can be trained independently for each trajectory pattern, eliminating the need to train the basic trajectory prediction module and the SHA module. This reduces training frequency and time. Since trajectories within the same trajectory pattern are similar, the TCA module can focus on key features within the trajectory pattern, making the trained TCA module more targeted and thereby improving the trajectory prediction model's accuracy. Therefore, the trajectory prediction model, which combines the basic trajectory prediction module, the SHA module, and the TCA module, can significantly improve prediction accuracy, applicability, and robustness. BRIEF DESCRIPTION OF THE DRAWINGS

[0050] Figure 1 This is a flow chart of the LSTM ship trajectory prediction method based on automatic trajectory clustering of the present invention.

[0051] Figure 2 This is an example diagram of the ship trajectory data of the present invention.

[0052] Figure 3 This is an example diagram of ship trajectory data files in different areas of the present invention.

[0053] Figure 4 This is a preferred example diagram of the k-means algorithm steps of the present invention.

[0054] Figure 5 This is an example diagram of the results of point clustering using the k-means algorithm of the present invention.

[0055] Figure 6 Schematic diagram of a bidirectional LSTM network for TC classification according to the present invention.

[0056] Figure 7 This is an example diagram of the trajectory prediction process of the trajectory prediction model of the present invention.

[0057] Figure 8 This is an example diagram comparing the ship trajectory prediction results of the present invention.

[0058] Figure 9 This is a structural block diagram of the LSTM ship trajectory prediction system based on automatic trajectory clustering of the present invention. DETAILED DESCRIPTION

[0059] The present invention discloses an LSTM ship trajectory prediction method based on automatic trajectory clustering. The method aims to solve the problems of low prediction accuracy, insufficient prediction accuracy at turns, and complex calculation in the existing technology. By using automatic trajectory clustering technology and integrating multiple deep neural network technologies, a trajectory pattern probability model and a trajectory prediction model are constructed and specifically trained to achieve special adaptation to complex scenarios such as turns and acceleration in the trajectory, significantly improving the accuracy, scope of application, and robustness of the prediction. The method can be executed by a processor or an electronic device with processing capabilities, such as Figure 1 As shown in the figure, the ship's historical trajectory data is first preprocessed to form an automatic trajectory set. Then, the k-means clustering algorithm is used to cluster the starting points and end points in the automatic trajectory set and divide different trajectory patterns. The historical trajectory data in the automatic trajectory set is used to train a trajectory pattern probability model based on a bidirectional LSTM network. Then, the trajectory to be predicted is input into the trajectory pattern probability model, and the probability of the trajectory pattern to which the trajectory belongs is output. Then, the historical trajectory data in the automatic trajectory set corresponding to the trajectory pattern with the highest probability is used to train the basic trajectory prediction module and SHA module of the trajectory prediction model based on the bidirectional LSTM network. The historical trajectory data in the automatic trajectory set corresponding to other trajectory patterns are used to train the TCA module of the trajectory prediction model. Three-stage training is implemented, and a unique trajectory prediction model for each trajectory pattern is formed based on the TCA module, the basic trajectory prediction module, and the SHA module. Finally, the trained trajectory prediction model corresponding to the trajectory pattern with the highest probability is called, the trajectory morphology is optimized by the TCA module, and the dynamic details are corrected by the SHA module to output the final predicted trajectory. This method utilizes a trajectory pattern probability model based on a bidirectional LSTM network, taking into account the motion patterns of different ships and capable of predicting multiple trajectories and their probability distributions. The trajectory prediction model based on a bidirectional LSTM network is particularly well-suited for complex scenarios such as turns and accelerations within a trajectory. Specifically, the method includes the following steps:

[0060] 1. Steps for obtaining the automatic trajectory set: pre-process the ship's historical trajectory data and extract the starting point and end point of each trajectory to form an automatic trajectory set.

[0061] Because historical ship trajectory data may contain noise or outliers due to equipment failure, signal interference, human error, or abnormal behavior, the present invention first cleans the historical ship trajectory data by removing data points with abnormal timestamps, position jumps, speed, and heading. This ensures that the preprocessed historical ship trajectory data is clean, continuous, and standardized. The starting and ending points of each preprocessed trajectory are then extracted to form an automatic trajectory set for subsequent clustering.

[0062] like Figure 2 Some trajectory data information is shown, where MMSI represents the International Maritime Mobile Identity, which is the unique identifier of the ship; BaseDateTime represents the timestamp of the data record; LAT represents the latitude coordinate of the ship; LON represents the longitude coordinate of the ship; SOG represents the speed of the ship relative to the ground, in knots; COG represents the course of the ship relative to the ground, in degrees; Heading represents the direction of the bow of the ship, in degrees; VesselName represents the registered name of the ship; IMO represents the International Maritime Organization number, which is the internationally unique identification code of the ship; CallSign represents the radio call sign of the ship; VesselType represents the type of ship; Status represents the current status of the ship, such as anchored, sailing, etc.; Length represents the length of the ship; Width represents the width of the ship; Draft represents the draft of the ship; Cargo represents the type of cargo loaded on the ship; TransceiverClass represents the class of the ship's AIS equipment. Figure 3 These are ship trajectory data files for different regions.

[0063] 2. Trajectory pattern clustering step: Use the k-means clustering algorithm to cluster the starting points and end points in the automatic trajectory set, and divide different trajectory patterns according to the clustering results.

[0064] Ship trajectory data typically contains a large number of trajectory points and complex motion patterns. Traditional trajectory clustering methods require calculating the distances between pairs of trajectory points, which becomes computationally expensive when the number of trajectories and the number of points per trajectory are large. A traffic cluster (TC) represents a specific ship motion pattern, where a ship departs from a source region and exits the scene through a target region. Therefore, the entire trajectory clustering problem can be transformed into a clustering task for source and target regions. To obtain the point coordinates that form the source and target regions, the start and end points of all trajectories are extracted from the ship's historical trajectory. Since ships can move from region A to region B or vice versa in crowded scenes, all start and end points can be merged into a single point cloud. Different motion patterns result in different trajectory clusters, so the trajectories need to be clustered to handle different motion patterns separately. In this embodiment of the present invention, the merged point cloud can be clustered using the k-means algorithm to obtain N point clusters, each representing a source or target region. For a scene with N source / destination regions, the theoretical total number of TCs is equal to N(N+1) / 2. Compared with directly clustering trajectories, point cloud clustering transforms the complex trajectory clustering problem into a simple point clustering problem, which reduces the complexity of the problem and has lower computational cost.

[0065] For example, Figure 4 An implementation of the k-means algorithm shown in Figure 1 randomly selects k initial cluster centers ( Figure 4 The number of clusters K in the dataset is calculated, and the distance from each starting point and end point to each cluster center is calculated, and the cluster center is assigned to the cluster with the closest cluster center. Then the cluster center of each cluster is recalculated, and the above process is iterated until the change of the cluster center is less than the iteration termination threshold δ, thereby obtaining the coordinates of the points forming the source / destination area and obtaining N point clusters. For each round of iteration v, all data objects x are traversed. i , calculate each data object x i Go to the center of each cluster k The distance dist(x i ,Center k ), the distance calculation here uses the Euclidean distance formula (corresponding to Figure 4 Formula (1) in ):

[0066]

[0067] Among them, d(x i ,x j ) represents the data object x i To cluster center x j (Center k ), x iRepresents a data object, x j represents the center of cluster j, n represents the number of clusters, Represents the data object x i The square root of the sum of the squared differences in distance to the centers of each cluster;

[0068] Then, the data object x i Divide it into the cluster where the cluster center closest to it is located. When all data objects are divided, according to the following formula (corresponding to Figure 4 Formula (2) in the above example updates the centers of all clusters:

[0069]

[0070] Among them, C j is the center of cluster j, S j are all data objects in cluster j, x i Represents a data object, represents the sum of all data objects of cluster j;

[0071] Finally, using the SSE (Sum of Squared Errors, error sum squared) formula (corresponding to Figure 4 The difference between two iterations is calculated using the formula (3) in

[0072]

[0073] Among them, ΔJ represents the difference between two iterations, which is an indicator to measure the degree of change in cluster division, k represents the number of clusters, and x i Represents a data object, S j are all data objects in cluster j, c j represents the center of cluster j, d(x i ,c j ) 2 Represents the data object x i To cluster center c j The square of the Euclidean distance;

[0074] If ΔJ<δ, it means that the cluster division is basically stable, the algorithm converges, the clustering results are output and the iteration ends; otherwise, the next round of iteration continues. Figure 5 An example of the result after k-means clustering is shown. Figure 5 1, 2, 3, 4, and 5 are the starting points / end points. Based on this, the trajectory pattern is divided. Using the formula N(N+1) / 2, we can know that Figure 5 N in is equal to 5, and the final total number of TCs is 15.

[0075] 3. Pre-training of trajectory pattern probability model: The historical trajectory data after removing abnormal points in the automatic trajectory set is input into the bidirectional LSTM network for pre-training to generate a trajectory pattern probability model for predicting the ship's destination and corresponding probability.

[0076] In the process of clustering the historical trajectory data of ships in the embodiment of the present invention, the complete trajectory data is used to determine the TC. However, in the trajectory prediction stage, only part of each trajectory data is known, and the final destination of the trajectory is unknown. Therefore, these trajectories cannot be directly clustered to determine the TC. The model can be used to predict the possible potential TC of the observed trajectory. This is a multi-class classification problem, where the number of classes is equal to the number of determined TCs. To address the above problem, the embodiment of the present invention generates a trajectory pattern probability model based on bidirectional LSTM (Bi-LSTM) network training, such as Figure 6As shown in the figure, the bidirectional LSTM network includes an input layer, a bidirectional LSTM layer, a Merge layer, a one-dimensional convolution layer (One-Dimensional Convolution), a maximum pooling layer (Pooling), a fully connected layer (FC) and a softmax layer. The historical trajectory data after the abnormal points in the automatic trajectory set are cleared enters the bidirectional LSTM layer through the input layer. The bidirectional LSTM layer processes the ship trajectory sequence information and its reverse order, and outputs a hidden state containing sequence features. The forward LSTM layer in the bidirectional LSTM layer processes the input trajectory data from the starting point to the ending point to capture the past context. The backward LSTM layer in the bidirectional LSTM layer processes the input trajectory data from the ending point to the starting point to capture the future context. After processing, two vectors are output to the merge layer (Merge layer). The length of these two output vectors in the time series format is equal to the time length of the input trajectory. The size of each time step vector of each time series is Rr, where r is the hidden dimension of the bidirectional LSTM layer. This processing can better understand the longitude and latitude information, thereby more comprehensively understanding the trajectory data; then, The Merge layer integrates the sequence features output by the bidirectional LSTM layer to form a comprehensive feature representation, that is, the output vectors of the forward LSTM and the backward LSTM are added to generate a fused tensor; the one-dimensional convolution layer then uses the convolution kernel to scan the integrated sequence features, extracts local features through the convolution operation, and captures the correlation patterns between features; then the maximum pooling layer performs dimensionality reduction on the convolved features to reduce the amount of data and computation while retaining important features; then the fully connected layer performs a linear transformation on the reduced dimensionality features, mapping the features to a specific dimension in preparation for the final classification task; finally, the Softmax layer performs classification prediction, converts its output into a probability distribution through the Softmax function, calculates the predicted probability of each category, outputs the possible TC and probability, and completes the multi-class classification task. The category with the highest probability is the result predicted by the trajectory pattern probability model.

[0077] Furthermore, in the embodiment of the present invention, one-hot encoding is used to label each trajectory pattern during the training phase, and is incorporated into the pre-training process of the bidirectional LSTM network to distinguish different trajectory patterns.

[0078] 4. Trajectory pattern classification step: input the trajectory to be predicted into the trajectory pattern probability model, output the probability of the trajectory pattern to which the trajectory belongs, and select the trajectory pattern with the highest probability.

[0079] In the embodiment of the present invention, there may be multiple trajectory patterns of the trajectory to be predicted using the trajectory pattern probability model, and a trajectory pattern with a probability greater than a predefined probability threshold is selected for subsequent trajectory prediction.

[0080] 5. Trajectory prediction model training step: Using the historical trajectory data corresponding to the trajectory pattern with the largest number of trajectories after removing outliers from the automatic trajectory set, an LSTM-based trajectory prediction model is trained. The trajectory prediction model includes a basic trajectory prediction module, a SHA module, a trajectory output module, and a TCA module. The basic trajectory prediction module is used to learn the basic characteristics of the trajectory. The SHA module is used to correct the trajectory based on the ship's speed and heading information. The trajectory output module is used to generate the final predicted trajectory. The TCA module is used to adapt to different trajectory patterns. The training process is divided into three stages:

[0081] The first stage trains the basic prediction function: input the historical trajectory data corresponding to the trajectory pattern with the largest number of trajectories into the trajectory output module, freeze the TCA module and SHA module, and train the basic trajectory prediction module;

[0082] The second stage trains the dynamic correction function: unfreeze the SHA module, and jointly train the corrected trajectory with the speed and heading dynamic information in the automatic trajectory set and the trajectory output module;

[0083] The third stage trains the trajectory mode adaptation function: unfreeze the TCA module, input historical trajectory data corresponding to other trajectory modes, train the parameters of each trajectory mode adaptation branch separately, and freeze the trajectory output module and SHA module at the same time.

[0084] In the embodiment of the present invention, a trajectory prediction model is trained for each TC. However, in order to reduce the number of training times and improve training efficiency, the embodiment of the present invention divides the trajectory prediction model into a basic trajectory prediction module, a SHA module (i.e., a speed and heading correction module), a trajectory output module, and a TCA module (i.e., a trajectory pattern adaptation module). The basic trajectory prediction module is trained using the historical trajectory data corresponding to the TC with the largest number of trajectories, after outliers have been removed from the automatic trajectory set. After the basic trajectory prediction module is trained, the basic trajectory prediction module is connected to the SHA module and trained using the historical trajectory data corresponding to the TC with the largest number of trajectories, after outliers have been removed from the automatic trajectory set. The output of the basic trajectory prediction module is used as the input parameter of the SHA module, and the speed, heading, and other information in the historical trajectory data are used as the input data of the SHA module to achieve a more accurate judgment of the forward route and better adaptability to situations such as turning and acceleration in the trajectory. Then, the parameters of each trajectory pattern adaptation branch of the TCA module are trained separately, so that each trajectory pattern corresponds to a unique TCA module. Finally, the trajectory prediction model is formed in the order of the TCA module, the basic trajectory prediction module, the SHA module, and the TCA module.

[0085] The SHA module of the embodiment of the present invention adopts a dynamic weight allocation strategy based on a multi-head attention mechanism to optimize the process of jointly training and correcting the trajectory of the speed and heading dynamic information in the automatic trajectory set and the trajectory output module, which specifically includes the following steps:

[0086] Dynamic information encoding: The speed and heading dynamic information in the automatic trajectory set are encoded into time series feature vectors and input into the SHA module;

[0087] Dynamic weight allocation: Through the multi-head attention mechanism, the correlation weight matrix between speed features and heading features is calculated to generate a dynamic correction coefficient;

[0088] Trajectory feature fusion: weighted fusion of the dynamic correction coefficient and the spatiotemporal features of the basic predicted trajectory generated by the trajectory output module to generate the corrected trajectory details;

[0089] Joint training optimization: The mean square error between the fused corrected trajectory and the true trajectory is used as the loss function. The weight parameters in the multi-head attention mechanism are optimized and iterated through the back-propagation algorithm. The loss function value gradually decreases, minimizing the mean square error between the corrected trajectory and the true trajectory, thereby optimizing the SHA module for dynamic correction of speed and heading.

[0090] 6. Trajectory prediction step: Call the trained trajectory prediction model corresponding to the trajectory pattern with the highest probability, optimize the trajectory shape through the TCA module, and then correct the dynamic details through the SHA module to output the final predicted trajectory.

[0091] In the embodiment of the present invention, the trajectory prediction model corresponding to the TC with the highest probability can be selected to predict the final direction of the trajectory to be predicted. At the same time, the trajectory prediction models corresponding to all TCs can also be used to perform predictions separately, providing users with multiple sets of reference results.

[0092] Furthermore, the embodiment of the present invention selects a trajectory pattern with a probability greater than a predefined probability threshold for trajectory prediction.

[0093] For example, Figure 7 A trajectory prediction process shown in Figure 1, input X obs ,BiLSTM,sub-LSTMs,τ,outputX pred 、P pred , where X obs represents the newly observed trajectory data of the ship to be tested for a certain point of interest (POI). BiLSTM represents the trained bidirectional long short-term memory trajectory pattern probability model. By using the bidirectional structure, it can simultaneously learn the forward and backward information of the trajectory data to preliminarily process the observed trajectory data X. obs , the probability p of the output trajectory belonging to a specific mode j; sub-LSTMs represents multiple trained sub-long short-term memory trajectory prediction models, m represents the number of sub-LSTM models, which determines the number of cycles of traversing and calling these sub-models, τ represents the probability threshold, X pred represents the final predicted trajectory set, P pred Indicates the probability corresponding to each trajectory in the trajectory set. When predicting, given a new observation trajectory X obs , the probability p corresponding to each trajectory pattern is calculated through the trained BiLSTM trajectory pattern probability model j , the predefined probability threshold τ is used as the screening criterion, the probability p j The sub-LSTM corresponding to the trajectory pattern greater than or equal to the probability threshold τ j The sub-model (i.e. the trained trajectory prediction model) will be used to generate the predicted trajectory X j pred Finally, the predicted trajectory set X that meets the conditions pred and its corresponding probability set P pred Output.

[0094] For example, Figure 8 The ship trajectory prediction results for different models are shown. Observed represents the trajectory to be predicted, serving as the model's input data; GroundTruth represents the actual trajectory data following the predicted trajectory, used to evaluate the accuracy of the prediction results. BGB and Transformer are two existing prediction methods, while Bi-LSTM is the prediction method of the present invention. As can be seen from the figure, the prediction results of the Bi-LSTM model of the present invention are closest to the actual trajectory, especially at turns.

[0095] Based on the same inventive concept, one or more embodiments of this specification also provide an LSTM ship trajectory prediction system based on automatic trajectory clustering. Since the principle of the problem solved by the LSTM ship trajectory prediction system based on automatic trajectory clustering is similar to the aforementioned LSTM ship trajectory prediction method based on automatic trajectory clustering, the implementation of the LSTM ship trajectory prediction system based on automatic trajectory clustering can refer to the aforementioned implementation of the LSTM ship trajectory prediction method based on automatic trajectory clustering, and the repeated parts will not be repeated.

[0096] Figure 9 This is a block diagram of the structure of the LSTM ship trajectory prediction system based on automatic trajectory clustering provided in one or more embodiments of this specification. Figure 9As shown, the LSTM ship trajectory prediction system based on automatic trajectory set clustering includes a sequentially connected automatic trajectory set acquisition module 101, a trajectory pattern clustering module 102, a trajectory pattern probability model pre-training module 103, a trajectory pattern classification module 104, a trajectory prediction model training module 105 and a trajectory prediction module 106.

[0097] The automatic trajectory set acquisition module 101 is used to pre-process the historical trajectory data of the ship and extract the starting point and the end point of each trajectory to form an automatic trajectory set.

[0098] The trajectory pattern clustering module 102 is used to cluster the starting points and end points in the automatic trajectory set using the k-means clustering algorithm, and divide different trajectory patterns according to the clustering results.

[0099] The trajectory pattern probability model pre-training module 103 is used to input the historical trajectory data that has been pre-processed by removing abnormal points in the automatic trajectory collection into the bidirectional LSTM network for pre-training to generate a trajectory pattern probability model for predicting the destination of the ship and the corresponding probability.

[0100] The trajectory pattern classification module 104 is configured to input the trajectory to be predicted into the trajectory pattern probability model, output the probability of the trajectory pattern to which the trajectory belongs, and select the trajectory pattern with the highest probability.

[0101] The trajectory prediction model training module 105 is used to train an LSTM-based trajectory prediction model using the historical trajectory data after outliers are removed from the automatic trajectory set corresponding to the trajectory pattern with the largest number of trajectories. The trajectory prediction model includes a basic trajectory prediction module, a SHA module, a trajectory output module, and a TCA module. The basic trajectory prediction module is used to learn the basic characteristics of the trajectory. The SHA module is used to correct the trajectory according to the speed and heading information of the ship. The trajectory output module is used to generate the final predicted trajectory. The TCA module is used to adapt to different trajectory patterns. The training process is divided into three stages:

[0102] The first stage trains the basic prediction function: input the historical trajectory data corresponding to the trajectory pattern with the largest number of trajectories into the trajectory output module, freeze the TCA module and SHA module, and train the basic trajectory prediction module;

[0103] The second stage trains the dynamic correction function: unfreeze the SHA module, and jointly train the corrected trajectory with the speed and heading dynamic information in the automatic trajectory set and the trajectory output module;

[0104] The third stage trains the trajectory mode adaptation function: unfreeze the TCA module, input historical trajectory data corresponding to other trajectory modes, train the parameters of each trajectory mode adaptation branch separately, and freeze the trajectory output module and SHA module at the same time.

[0105] The trajectory prediction module 106 is used to call the trained trajectory prediction model corresponding to the trajectory pattern with the highest probability, optimize the trajectory shape through the TCA module, correct the dynamic details through the SHA module, and output the final predicted trajectory.

[0106] Furthermore, in the trajectory pattern probability model pre-training module 103, the bidirectional LSTM network includes an input layer, a bidirectional LSTM layer, a Merge layer, a one-dimensional convolution layer, a maximum pooling layer, a fully connected layer and a Softmax layer. The historical trajectory data after the abnormal points in the automatic trajectory set are cleared enters the bidirectional LSTM layer through the input layer. The bidirectional LSTM layer processes the ship trajectory sequence information and its reverse sequence, and outputs a hidden state containing sequence features; then the sequence features output by the bidirectional LSTM layer are integrated together through the Merge layer; the one-dimensional convolution layer uses the convolution kernel to scan the integrated sequence features, extracts local features through the convolution operation, and captures the correlation pattern between features; then the maximum pooling layer reduces the dimension of the convolved features; then the fully connected layer performs a linear transformation on the reduced dimension features; finally, the Softmax layer performs classification prediction, converts its output into a probability distribution through the Softmax function, and calculates the predicted probability of each category. The category with the largest probability is the result predicted by the trajectory pattern probability model.

[0107] Furthermore, in the trajectory pattern clustering module 102, the starting points and end points in the automatic trajectory set are merged into a single point cloud, and the single point cloud is clustered using the k-means clustering algorithm to obtain the coordinates of the points forming the source / destination areas, thereby obtaining N point clusters. Different trajectory patterns are divided according to the clustering results. For a scene with N source / destination areas, the total number of trajectory patterns is N(N+1) / 2. Trajectory patterns with a number of trajectories at least equal to the total number of trajectories threshold are selected for subsequent trajectory prediction model training.

[0108] Furthermore, in the trajectory pattern probability model pre-training module 103, for scenarios with multiple trajectory patterns, one-hot encoding is used to label each trajectory pattern during the training phase and incorporated into the pre-training process of the bidirectional LSTM network to distinguish different trajectory patterns;

[0109] In the trajectory prediction module 106, given a new observed trajectory, it is first input into the trajectory pattern probability model to obtain the probability of the trajectory belonging to each trajectory pattern. Using a predefined probability threshold, the trajectory pattern with a probability greater than the probability threshold is selected. Then, from the trajectory patterns with a probability greater than the probability threshold, the trajectory pattern with the highest probability is selected. The trained trajectory prediction model corresponding to the trajectory pattern with the highest probability is called. The trajectory morphology is optimized by the TCA module in the trajectory prediction model, and the dynamic details are corrected by the SHA module. Finally, the final predicted trajectory of the new observed trajectory is output.

[0110] It should be noted that the specific embodiments described above can enable those skilled in the art to more fully understand the present invention, but do not limit the present invention in any way. Therefore, although this specification has described the present invention in detail with reference to the drawings and embodiments, those skilled in the art should understand that the present invention can still be modified or replaced with equivalents. In short, all technical solutions and improvements that do not depart from the spirit and scope of the present invention should be included in the scope of protection of the patent for the present invention.

Claims

1. An LSTM ship trajectory prediction method based on automatic trajectory clustering, characterized in that: The steps include: Steps for obtaining an automatic trajectory set: preprocess the historical trajectory data of the ship and extract the starting point and end point of each trajectory to form an automatic trajectory set; Trajectory pattern clustering step: Use the k-means clustering algorithm to cluster the starting points and end points in the automatic trajectory set, and divide different trajectory patterns according to the clustering results; Trajectory pattern probability model pre-training step: the historical trajectory data after automatic trajectory centralization pre-processing is input into the bidirectional LSTM network for pre-training to generate a trajectory pattern probability model for predicting the ship's destination and corresponding probability; Trajectory pattern classification step: inputting the trajectory to be predicted into the trajectory pattern probability model, outputting the probability of the trajectory pattern to which the trajectory belongs, and selecting the trajectory pattern with the highest probability; Trajectory prediction model training steps: Use the historical trajectory data pre-processed from the automatic trajectory set corresponding to the trajectory pattern with the largest number of trajectories to train an LSTM-based trajectory prediction model. The trajectory prediction model includes a basic trajectory prediction module, a SHA module, a trajectory output module, and a TCA module. The basic trajectory prediction module is used to learn the basic characteristics of the trajectory. The SHA module is used to correct the trajectory according to the ship's speed and heading information. The trajectory output module is used to generate the final predicted trajectory. The TCA module is used to adapt to different trajectory patterns. The training process is divided into three stages: The first stage trains the basic prediction function: input the historical trajectory data corresponding to the trajectory pattern with the largest number of trajectories into the trajectory output module, freeze the TCA module and SHA module, and train the basic trajectory prediction module; The second stage trains the dynamic correction function: unfreeze the SHA module, and jointly train the corrected trajectory with the speed and heading dynamic information in the automatic trajectory set and the trajectory output module; The third stage trains the trajectory mode adaptation function: unfreeze the TCA module, input historical trajectory data corresponding to other trajectory modes, train the parameters of each trajectory mode adaptation branch separately, and freeze the trajectory output module and SHA module at the same time; Trajectory prediction step: Call the trained trajectory prediction model corresponding to the trajectory pattern with the highest probability, optimize the trajectory shape through the TCA module, and then correct the dynamic details through the SHA module to output the final predicted trajectory.

2. The method according to claim 1, characterized in that In the trajectory pattern probability model pre-training step, the bidirectional LSTM network includes an input layer, a bidirectional LSTM layer, a Merge layer, a one-dimensional convolution layer, a maximum pooling layer, a fully connected layer and a Softmax layer. The historical trajectory data pre-processed in the automatic trajectory set enters the bidirectional LSTM layer through the input layer. The bidirectional LSTM layer processes the ship trajectory sequence information and its reverse order, and outputs a hidden state containing sequence features; then the sequence features output by the bidirectional LSTM layer are integrated together through the Merge layer; the one-dimensional convolution layer scans the integrated sequence features using a convolution kernel, extracts local features through the convolution operation, and captures the correlation pattern between features; then the maximum pooling layer reduces the dimension of the convolved features; then the fully connected layer performs a linear transformation on the reduced dimension features; finally, the Softmax layer performs classification prediction, converts its output into a probability distribution through the Softmax function, and calculates the predicted probability of each category. The category with the largest probability is the result predicted by the trajectory pattern probability model.

3. The method according to claim 1, characterized in that In the trajectory pattern clustering step, the starting points and end points in the automatic trajectory set are merged into a single point cloud, and the single point cloud is clustered using the k-means clustering algorithm to obtain the coordinates of the points forming the source / destination areas, obtaining N point clusters. Different trajectory patterns are divided according to the clustering results. For a scene with N source / destination areas, the total number of trajectory patterns is N(N+1) / 2. Trajectory patterns with a number of trajectories at least equal to the total trajectory threshold are selected for subsequent trajectory prediction model training.

4. The method according to any one of claims 1 to 3, characterized in that In the trajectory pattern probability model pre-training step, for scenarios with multiple trajectory patterns, each trajectory pattern is labeled using one-hot encoding during the training phase and incorporated into the pre-training process of the bidirectional LSTM network to distinguish different trajectory patterns. In the trajectory prediction step, given a new observed trajectory, it is first input into the trajectory pattern probability model to obtain the probability of the trajectory belonging to each trajectory pattern. Using a predefined probability threshold, the trajectory pattern with a probability greater than the probability threshold is selected. Then, from the trajectory patterns with a probability greater than the probability threshold, the trajectory pattern with the highest probability is selected. The trained trajectory prediction model corresponding to the trajectory pattern with the highest probability is called. The trajectory morphology is optimized by the TCA module in the trajectory prediction model, and the dynamic details are corrected by the SHA module. Finally, the final predicted trajectory of the new observed trajectory is output.

5. The method according to claim 3, characterized in that In the step of obtaining the automatic trajectory set, the ship's historical trajectory data includes the latitude and longitude information, speed, heading and timestamp information during the ship's navigation process, and the preprocessing includes outlier cleaning, which includes removing data points with abnormal timestamps, abnormal position jumps, abnormal speeds and abnormal headings; In the trajectory pattern clustering step, k initial cluster centers are randomly selected, the distances from each starting point and end point to each cluster center are calculated, and the points are assigned to the cluster with the closest cluster center. Then, the cluster center of each cluster is recalculated, and the above process is iterated continuously until the cluster center no longer changes significantly, thereby obtaining the coordinates of the points forming the source / destination area and obtaining N point clusters. Combined with the distribution characteristics of the starting and end points in each cluster and the navigation patterns of ships, the clustering results are classified and the trajectory pattern division is completed to determine the trajectory pattern to which each trajectory belongs.

6. The method according to any one of claims 1 to 3, characterized in that In the second stage of training the dynamic correction function of the trajectory prediction model training step, the SHA module adopts a dynamic weight allocation strategy based on the multi-head attention mechanism to optimize the speed and heading dynamic information in the automatic trajectory set and the process of jointly training the trajectory correction with the trajectory output module, which specifically includes the following steps: Dynamic information encoding: The speed and heading dynamic information in the automatic trajectory set are encoded into time series feature vectors and input into the SHA module; Dynamic weight allocation: Through the multi-head attention mechanism, the correlation weight matrix between speed features and heading features is calculated to generate a dynamic correction coefficient; Trajectory feature fusion: weighted fusion of the dynamic correction coefficient and the spatiotemporal features of the basic predicted trajectory generated by the trajectory output module to generate the corrected trajectory details; Joint training optimization: The mean square error between the fused corrected trajectory and the true trajectory is used as the loss function. The weight parameters in the multi-head attention mechanism are optimized and iterated through the back-propagation algorithm. The loss function value gradually decreases, minimizing the mean square error between the corrected trajectory and the true trajectory, thereby optimizing the SHA module for dynamic correction of speed and heading.

7. An LSTM ship trajectory prediction system based on automatic trajectory clustering, characterized by: It includes an automatic trajectory set acquisition module, a trajectory pattern clustering module, a trajectory pattern probability model pre-training module, a trajectory pattern classification module, a trajectory prediction model training module and a trajectory prediction module connected in sequence; wherein, The automatic trajectory set acquisition module is used to pre-process the historical trajectory data of the ship and extract the starting point and end point of each trajectory to form an automatic trajectory set; The trajectory pattern clustering module is used to cluster the starting points and end points in the automatic trajectory set using the k-means clustering algorithm, and divide different trajectory patterns according to the clustering results; The trajectory pattern probability model pre-training module is used to input the historical trajectory data pre-processed by the automatic trajectory collection into the bidirectional LSTM network for pre-training to generate a trajectory pattern probability model for predicting the destination of the ship and the corresponding probability; The trajectory pattern classification module is used to input the trajectory to be predicted into the trajectory pattern probability model, output the probability of the trajectory pattern to which the trajectory belongs, and select the trajectory pattern with the highest probability; The trajectory prediction model training module is used to train an LSTM-based trajectory prediction model using the historical trajectory data pre-processed in the automatic trajectory set corresponding to the trajectory pattern with the largest number of trajectories. The trajectory prediction model includes a basic trajectory prediction module, a SHA module, a trajectory output module, and a TCA module. The basic trajectory prediction module is used to learn the basic characteristics of the trajectory. The SHA module is used to correct the trajectory according to the speed and heading information of the ship. The trajectory output module is used to generate the final predicted trajectory. The TCA module is used to adapt to different trajectory patterns. The training process is divided into three stages: The first stage trains the basic prediction function: input the historical trajectory data corresponding to the trajectory pattern with the largest number of trajectories into the trajectory output module, freeze the TCA module and SHA module, and train the basic trajectory prediction module; The second stage trains the dynamic correction function: unfreeze the SHA module, and jointly train the corrected trajectory with the speed and heading dynamic information in the automatic trajectory set and the trajectory output module; The third stage trains the trajectory mode adaptation function: unfreeze the TCA module, input historical trajectory data corresponding to other trajectory modes, train the parameters of each trajectory mode adaptation branch separately, and freeze the trajectory output module and SHA module at the same time; The trajectory prediction module is used to call the trained trajectory prediction model corresponding to the trajectory pattern with the highest probability, optimize the trajectory shape through the TCA module, and then correct the dynamic details through the SHA module to output the final predicted trajectory.

8. The system according to claim 7, characterized in that In the trajectory pattern probability model pre-training module, the bidirectional LSTM network includes an input layer, a bidirectional LSTM layer, a Merge layer, a one-dimensional convolution layer, a maximum pooling layer, a fully connected layer and a Softmax layer. The historical trajectory data pre-processed in the automatic trajectory set enters the bidirectional LSTM layer through the input layer. The bidirectional LSTM layer processes the ship trajectory sequence information and its reverse sequence, and outputs a hidden state containing sequence features; then the sequence features output by the bidirectional LSTM layer are integrated together through the Merge layer; the one-dimensional convolution layer scans the integrated sequence features using the convolution kernel, extracts local features through the convolution operation, and captures the correlation pattern between features; then the maximum pooling layer reduces the dimension of the convolved features; then the fully connected layer performs a linear transformation on the reduced dimension features; finally, the Softmax layer performs classification prediction, converts its output into a probability distribution through the Softmax function, and calculates the predicted probability of each category. The category with the largest probability is the result predicted by the trajectory pattern probability model.

9. The system according to claim 7, wherein: In the trajectory pattern clustering module, the starting and ending points in the automatic trajectory set are merged into a single point cloud. The single point cloud is clustered using the k-means clustering algorithm to obtain the coordinates of the points forming the source / destination areas, obtaining N point clusters. Different trajectory patterns are divided according to the clustering results. For a scene with N source / destination areas, the total number of trajectory patterns is N(N+1) / 2. Trajectory patterns with a number of trajectories at least equal to the total trajectory threshold are selected for subsequent trajectory prediction model training.

10. The system according to any one of claims 7 to 9, characterized in that In the trajectory pattern probability model pre-training module, for scenarios with multiple trajectory patterns, one-hot encoding is used to label each trajectory pattern during the training phase and incorporated into the pre-training process of the bidirectional LSTM network to distinguish different trajectory patterns. In the trajectory prediction module, given a new observed trajectory, it is first input into the trajectory pattern probability model to obtain the probability of the trajectory belonging to each trajectory pattern. Using a predefined probability threshold, the trajectory pattern with a probability greater than the probability threshold is selected. Then, from the trajectory patterns with a probability greater than the probability threshold, the trajectory pattern with the highest probability is selected. The trained trajectory prediction model corresponding to the trajectory pattern with the highest probability is called. The trajectory morphology is optimized by the TCA module in the trajectory prediction model, and the dynamic details are corrected by the SHA module. Finally, the final predicted trajectory of the new observed trajectory is output.