Ship trajectory prediction method, system, computer device and storage medium

Through the improved double-layer LSTM-Transformer model, combined with the advantages of LSTM and Transformer models, the problem of low prediction accuracy of ship trajectory is solved, and higher prediction accuracy and efficiency are achieved.

CN119066373BActive Publication Date: 2025-03-18SHANDONG UNIV OF SCI & TECH
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411561678.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-05
Publication Date
2025-03-18
Estimated Expiration
2044-11-05

AI Technical Summary

Technical Problem

The existing ship trajectory prediction methods have low prediction accuracy in complex and variable sea areas, making it difficult to effectively capture complex ship behavior patterns.

Method used

The improved double-layer LSTM-Transformer model is used, combining the long-term short-term memory function of the LSTM model and the multi-query attention mechanism of the improved Transformer model to predict ship trajectories.

Benefits of technology

It improves the accuracy and prediction efficiency of ship trajectory prediction, reduces the prediction error caused by missing data, and provides more reliable navigation support under variable sea conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119066373B_ABST
    Figure CN119066373B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of marine ship trajectory prediction, and specifically discloses a ship trajectory prediction method, system, computer equipment and storage medium. The present invention builds a ship trajectory prediction model. At the model input level, model predictive control is used to interpolate trajectory data, fill in the gaps in the trajectory, repair missing or incomplete trajectory points, and provide more continuous and complete data input for the model. In terms of network structure, the double-layer LSTM structure enables the model to better capture and process complex time series data, and can provide more reliable navigation support under changeable marine conditions. In addition, the present invention combines the multi-query attention mechanism of the improved Transformer model, so that the model can more effectively capture key information and contextual relationships in the entire sequence, the marine ship trajectory prediction is more accurate, and the model prediction efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of marine ship trajectory prediction, and in particular relates to a ship trajectory prediction method, system, computer equipment and storage medium. Background Art

[0002] The Automatic Identification System (AIS) is an automatic tracking system installed on ships. It exchanges electronic data with neighboring ships, AIS shore stations, satellites and other equipment, and is used for identification and positioning by Vessel Traffic Control (VTS). The introduction of AIS enables crew members and ports to grasp the traffic conditions of ships at sea more quickly and in detail. The implementation of this system is crucial to improving the navigation safety of ships in complex and changing waters. Therefore, the intelligent navigation system with integrated trajectory prediction function has become the key to optimizing the automation and intelligence level of maritime supervision. Effective trajectory prediction can not only reduce the occurrence of maritime accidents and violations, but also significantly improve the safety and controllability of navigation.

[0003] In order to enhance the navigation safety of ships in these complex and changeable seas, it is necessary to integrate trajectory prediction functions into the ship's intelligent navigation system. This will improve the automation and intelligence level of maritime supervision, reduce maritime accidents and violations, and ensure the safety and controllability of maritime navigation. However, the complexity and challenge of ship trajectory prediction mainly stems from the fact that the navigation status is greatly affected by the surrounding environment, and the dynamic and changeable nature of the ship's trajectory itself, which together make the prediction work more complicated.

[0004] At present, ship trajectory prediction is mainly based on the motion characteristics of historical data, using motion equations to predict the ship's position, while also considering environmental factors such as water flow and wind speed. The presence of uncertainty and randomness greatly increases the difficulty of modeling. Therefore, ship trajectory prediction based on historical AIS data has become a research hotspot, and the advancement of artificial intelligence has provided more possibilities for this. Compared with traditional trajectory prediction methods, machine learning has the advantages of quickly processing large amounts of data and analyzing and extracting effective information. By using these models, researchers are able to analyze AIS data more deeply, revealing complex ship behavior patterns, and thus effectively avoiding potential dangers. However, improving the accuracy of ship trajectory prediction remains one of the main challenges of current research. Summary of the invention

[0005] In view of the problem of low accuracy in current ship trajectory prediction, the present invention proposes a ship trajectory prediction method. The method integrates the long short-term memory function of the LSTM model and the multi-query attention mechanism of the improved Transformer model through the proposed improved two-layer LSTM-Transformer model, which is beneficial to improving the accuracy and prediction efficiency of marine ship trajectory prediction.

[0006] In order to achieve the above object, the present invention adopts the following technical scheme:

[0007] A ship trajectory prediction method comprises the following steps:

[0008] Step 1. Obtain the public AIS historical ship data and pre-process the AIS historical ship data;

[0009] Step 2. Build a ship trajectory prediction model based on a double-layer LSTM model and an improved Transformer model;

[0010] The input of the ship trajectory prediction model is the AIS data of four attributes: latitude, longitude, speed, and heading. The unique hot encodings of the four attributes are concatenated into a four-hot vector and normalized. The concatenated vector is used as the input of the model.

[0011] The ship trajectory prediction model includes an embedding layer, a Transformer Block layer, a first LSTM layer, a second LSTM layer, a linear transformation layer, and a normalization layer; the processing flow of the ship trajectory prediction model is as follows:

[0012] First, the four-hot vector of the input model is added to the positional encoding as the input of the Transformer Block layer, and then processed by each Transformer block in the Transformer Block layer in turn to capture the global dependencies in the data;

[0013] Each of the Transformer blocks adopts a multi-query attention mechanism, which modifies the key and value linear mapping matrix of the multi-head attention of each layer in the original Transformer model to be shared by all heads in the layer, that is:

[0014] Each layer has only one K and one V matrix, while the Q matrix remains unchanged, and its number is still equal to the number of attention heads;

[0015] The output features of the Transformer Block layer are passed through the first layer of LSTM to extract primary time features, and further passed through the second layer of LSTM to extract complex time-dependent features to improve the accuracy of long-term prediction;

[0016] The output features of the second LSTM are sequentially transformed through the linear transformation layer and the normalization layer to output the predicted trajectory point sequence;

[0017] Step 3. Based on the data set preprocessed in step 1, the ship trajectory prediction model built in step 2 is trained, and the trained model is used to predict the ship trajectory and output the time series of trajectory points in the future time period.

[0018] In addition, based on the ship trajectory prediction method, the present invention also proposes a ship trajectory prediction system adapted to the ship trajectory prediction method, and the ship trajectory prediction system adopts the following technical solutions:

[0019] A ship trajectory prediction system, comprising:

[0020] A preprocessing module is used to obtain public AIS historical ship data and preprocess the AIS historical ship data;

[0021] Model building module, used to build a ship trajectory prediction model based on a double-layer LSTM model and an improved Transformer model;

[0022] The input of the ship trajectory prediction model is the AIS data of four attributes. The unique hot encodings of the four attributes are concatenated into a four-hot vector and normalized. The concatenated vector is used as the input of the model.

[0023] The ship trajectory prediction model includes an embedding layer, a Transformer Block layer, a first LSTM layer, a second LSTM layer, a linear transformation layer, and a normalization layer; the processing flow of the ship trajectory prediction model is as follows:

[0024] First, the four-hot vector of the input model is added to the positional encoding as the input of the Transformer Block layer, and then processed by each Transformer block in the Transformer Block layer in turn to capture the global dependencies in the data;

[0025] Each of the Transformer blocks adopts a multi-query attention mechanism, which modifies the key and value linear mapping matrix of the multi-head attention of each layer in the original Transformer model to be shared by all heads in the layer, that is:

[0026] Each layer has only one K and one V matrix, while the Q matrix remains unchanged, and its number is still equal to the number of attention heads;

[0027] The output features of the Transformer Block layer are passed through the first layer of LSTM to extract primary time features, and further passed through the second layer of LSTM to extract complex time-dependent features to improve the accuracy of long-term prediction;

[0028] The output features of the second LSTM are sequentially transformed through the linear transformation layer and the normalization layer to output the predicted trajectory point sequence;

[0029] As well as the model training and prediction module, it is used to train the constructed ship trajectory prediction model based on the preprocessed data set, and use the trained model to predict the ship trajectory and output the trajectory point time series for the future time period.

[0030] In addition, based on the above-mentioned ship trajectory prediction method, the present invention also proposes a computer device, which includes a memory and one or more processors; the memory stores executable code, and when the processor executes the executable code, it is used to implement the steps of the ship trajectory prediction method mentioned above.

[0031] In addition, based on the above-mentioned ship trajectory prediction method, the present invention also proposes a computer-readable storage medium on which a program is stored; when the program is executed by a processor, it is used to implement the steps of the ship trajectory prediction method mentioned above.

[0032] The present invention has the following advantages:

[0033] As described above, the present invention relates to a ship trajectory prediction method, which builds a ship trajectory prediction model based on a double-layer LSTM model and an improved Transformer model. Among them, at the model input level, the present invention uses model predictive control to interpolate the trajectory data, which can effectively fill the gaps in the trajectory and repair missing or incomplete trajectory points, thereby providing a more continuous and complete data input for the model. This method not only improves the data quality, but also reduces the prediction error caused by missing data. In terms of network structure, the present invention adopts a double-layer LSTM structure to enable the model to better capture and process complex time series data. This structure improves the model's understanding of sequence patterns and sequences on different time scales, thereby providing more reliable navigation support under variable maritime conditions. In addition, the present invention combines the multi-query attention mechanism of the improved Transformer model, and the model can more effectively capture key information and contextual relationships in the entire sequence, making the prediction more accurate and detailed and improving the model operation efficiency. Compared with traditional models, the method of the present invention shows lower errors, higher precision and higher prediction efficiency in predicting the trajectory of ships at sea. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 Schematic diagram of the overall process of the ship trajectory prediction method in an embodiment of the present invention;

[0035] Figure 2 A network structure diagram of a ship trajectory prediction model in an embodiment of the present invention;

[0036] Figure 3 is a structural diagram of a Transformer block in an embodiment of the present invention;

[0037] Figure 4 This is a structural diagram of the multi-query attention mechanism in the Transformer model of an embodiment of the present invention. DETAILED DESCRIPTION

[0038] The present invention is further described in detail below with reference to the accompanying drawings and specific embodiments:

[0039] Example 1

[0040] This embodiment 1 describes a ship trajectory prediction method based on an improved double-layer LSTM-Transformer model. The model first proposes a new expression method for AIS data. In order to better capture the complex patterns in the data and deal with the overfitting problem caused by high-dimensional features, four-hot encoding is used to increase the dimension of AIS data features. Secondly, the model adopts an improved double-layer LSTM-Transformer model, which combines the long-term and short-term memory function of LSTM and the multi-query attention mechanism of the improved Transformer, which can further improve the accuracy of ship trajectory prediction and reduce prediction errors. In addition, the double-layer LSTM structure can enhance the depth and expressiveness of the model. Finally, the present invention uses a multi-granularity cross-loss entropy function to calculate the difference between the probability distribution predicted by the model and the actual observed position, update the model parameters, and improve the model prediction accuracy.

[0041] like Figure 1 As shown, this embodiment relates to a ship trajectory prediction method, which includes the following steps:

[0042] Step 1. Obtain public AIS historical ship data and preprocess the AIS historical ship data.

[0043] The specific steps of step 1 are:

[0044] Step 1.1. Download the public AIS data set according to the time and the range of the required ship track. The AIS historical ship data in this embodiment comes from the public AIS historical ship data provided by the Danish Maritime Administration.

[0045] Step 1.2. Select AIS data within the preset longitude and latitude range, retain the data features used for the model in the AIS data, including Maritime Mobile Service Identity (MMSI), time, longitude, latitude, navigation speed and heading over ground, and delete unnecessary features, including navigation status, ship call sign, ship type, antenna size, etc.

[0046] Step 1.3. Aggregate the trajectory data of the same ship according to the ship MMSI number.

[0047] The ship trajectory is divided according to a preset time interval, such as 12 hours, and the trajectory point information of the ship at sea is extracted from the AIS data processed in step 1.2 to form a historical trajectory point time series.

[0048] Step 1.4. Use Model Predictive Control (MPC) to interpolate the ship trajectory of the historical trajectory point sequence in step 1.3, repair the blank parts between the ship trajectories, and form complete ship trajectory data.

[0049] The specific steps of step 1.4 are as follows:

[0050] Step 1.4.1. Set the ship's state variables as the input of the model predictive control MPC. The ship's state variables include MMSI, time, longitude, latitude, speed and heading.

[0051] The time interval between the start point and the end point of the interpolation trajectory is calculated according to the current trajectory point, that is, based on the state variable of the current point, the time interval between the start point of the interpolation trajectory, i.e. the current point, and the end point of the interpolation trajectory segment, i.e. the next target point, is calculated.

[0052] Step 1.4.2. Set the time interval for interpolation (for example, interpolate the ship trajectory at 10 minutes), and determine whether the time interval between two adjacent points exceeds the preset time interval; if it exceeds, interpolate to refine the trajectory data.

[0053] Step 1.4.3. Based on the AIS data processed in step 1.3 and its predicted target, construct the objective function; use the gradient descent method to solve the objective function, initialize the control input, iteratively update the control input, calculate the objective function value and its gradient, and optimize the control input according to the gradient information; after obtaining the optimal control input, substitute it into the kinematic model, that is, the position update formula and the velocity update formula to calculate the interpolation trajectory points.

[0054] The specific process is as follows:

[0055] First, because the acceleration of the ship is not provided in the information in the AIS data, the acceleration needs to be estimated based on the speed and time of the ship's neighboring nodes.

[0056] Let the speed be v and the time be t.

[0057] Assumptions and The neighboring points of and , , , and The corresponding speeds are , , , .

[0058] The time difference is: , , ;

[0059] The speed difference is: , , ;

[0060] when hour, ;

[0061] when hour, ;

[0062] in, For ships in The acceleration of time.

[0063] Then, according to the input ship state variables, the ship's position is (x, y), the ship's speed is v, and the heading is , the acceleration is a, and the following kinematic model is constructed:

[0064] The position update formula is as follows:

[0065] ;

[0066] in,( , )express The ship's position at the time, , )express The ship's position at the moment, express The speed of the ship at the moment, express The direction of the moment, represents the time increment;

[0067] The speed update formula is as follows:

[0068] ;

[0069] in, express The speed of time.

[0070] In order to optimize the trajectory interpolation effect of the model, two objective functions are constructed: one for position error and one for acceleration error. The final objective function is the weighted sum of these two parts. The objective function is usually used to quantify the difference between the predicted value and the actual value. By minimizing the objective function, the prediction error of the model can be reduced.

[0071] The objective function is constructed as follows:

[0072] ;

[0073] ;

[0074] ;

[0075] in, represents the position error objective function, represents the acceleration error objective function, represents the overall objective function, Represents the weight coefficient of acceleration error, ( , ) represents the predicted ship trajectory, ( , ) represents the actual ship trajectory, and N represents the number of time steps.

[0076] Step 1.4.4. Use the interpolated trajectory points generated in step 1.4.3 as the repaired trajectory, and update the trajectory sequence to fill the blank parts in the original ship trajectory to form complete ship trajectory data.

[0077] The AIS dataset consisting of the complete ship trajectory data is divided into 80% training set, 10% validation set and 10% test set, which are used for training, validation and testing of the following ship trajectory prediction model respectively.

[0078] The processed AIS data is input into the improved two-layer LSTM-Transformer model, and the constructed ship trajectory prediction model is used to process the historical trajectory point time series to generate and output the trajectory point time series for the future time period.

[0079] Step 2. Build a ship trajectory prediction model based on a double-layer LSTM model and an improved Transformer model, namely Figure 2 The two-layer LSTM-Transformer model shown in .

[0080] Specifically, the input of the ship trajectory prediction model is the AIS data of four attributes. The unique hot encodings of the four attributes are concatenated into a four-hot vector and normalized, and the obtained concatenated vector is used as the input of the model.

[0081] The concatenation vector for the input model is formed as follows:

[0082] In the input layer, input the AIS data with batch size B, sequence length seqlen, and four attributes. The formula is as follows:

[0083] .

[0084] Increase the dimension of LAT and LON to 256, and increase the dimension of SOG and COG to 128.

[0085] ;

[0086] Among them, LAT, LON, SOG and COG represent latitude, longitude, speed and heading respectively.

[0087] Concatenate the one-hot encodings of the four attributes into a four-hot vector , and normalized, the expression is as follows:

[0088] , ;

[0089] in, represents the concatenated vector, and the obtained concatenated vector is used as the input of the ship trajectory prediction model.

[0090] like Figure 2 As shown, the ship trajectory prediction model built in this embodiment includes an embedding layer, a TransformerBlock layer, a first LSTM layer, a second LSTM layer, a linear transformation layer and a normalization layer.

[0091] The processing flow of the ship trajectory prediction model is as follows:

[0092] First, the four-hot vector of the input model is added to the positional encoding as the input of the Transformer Block layer, and then processed by each Transformer block in the Transformer Block layer in turn to capture the global dependencies in the data.

[0093] Each of the Transformer blocks adopts a multi-query attention mechanism, which modifies the key and value linear mapping matrix of the multi-head attention of each layer in the original Transformer model to be shared by all heads in the layer, that is:

[0094] Each layer has only one K and one V matrix, while the Q matrix remains unchanged, and its number is still equal to the number of attention heads.

[0095] The output features of the Transformer Block layer are passed through the first layer of LSTM to extract primary time features, and further through the second layer of LSTM to extract complex time-dependent features to improve the accuracy of long-term prediction.

[0096] The output features of the second LSTM are sequentially transformed through the linear transformation layer and the normalization layer to output the predicted trajectory point sequence.

[0097] Specifically, the embedding layer in this embodiment adopts a learnable position embedding layer.

[0098] The resulting four-hot vector is added to the positional encoding as the input to the Transformer Block layer. The addition process is as follows:

[0099] ;

[0100] in, is the location code, latitude is the embedding dimension of the model, As the input of the Transformer Block layer, the position encoding uses learnable position embedding. Learnable position encoding is a parameterized method, that is, these position encodings are no longer calculated based on fixed functions, but are learned through training. The learnable position encodings are updated and adjusted like weight matrices during model training, allowing the model to adaptively adjust these encodings according to the training data.

[0101] The model position encoding uses learnable position embedding, which is different from the traditional static sine and cosine position encoding. The learnable position embedding allows the model to flexibly adjust the position embedding during training to better adapt to specific tasks.

[0102] After position encoding, the AIS data is input into the Transformer Block.

[0103] like Figure 2 As shown, the Transformer Block consists of N Transformer blocks. Figure 2 Nx indicates that you can set the number of Transformer blocks you need.

[0104] like Figure 3 As shown in the figure, each Transformer block consists of a normalization layer, a multi-query attention mechanism, a residual layer, and a feedforward network, which can capture the global dependencies in the data. The general processing flow is as follows:

[0105] The input features are first normalized by a normalization layer, then the multi-query attention mechanism is used for attention calculation, which can significantly improve the calculation efficiency, and then the residual layer is used to maintain the input features, and then the feedforward network is used for feature processing, and then the normalization layer and a residual are used for output.

[0106] First, the input features are normalized by a normalization layer.

[0107] .

[0108] in, Represents normalization processing to ensure that the features are at the same scale for subsequent calculations.

[0109] In order to improve the efficiency of Transformer in the incremental reasoning stage, the present invention does not adopt a multi-layer attention mechanism, but a multi-query attention mechanism, that is, the key and value linear mapping matrix of the multi-head attention of each layer in the original Transformer model is modified to be shared within the layer, that is, each layer has only one K and one V matrix, while the Q matrix remains unchanged, and its number is still equal to the number of attention heads. The multi-query attention mechanism is as follows Figure 4 shown.

[0110] The output of the multi-query attention mechanism is connected to the input residual, which effectively solves the problem of gradient disappearance. The formula is as follows:

[0111] .

[0112] in, Represents a multi-query attention mechanism, which can significantly improve computational efficiency.

[0113] The feedforward neural network is used to further process the features. It is a two-layer MLP network with a GELU activation function:

[0114] .

[0115] in, are trainable weights and biases. The output of the feedforward neural network is connected to the input through a residual connection, which effectively solves the problem of gradient disappearance, and the final output is obtained through the second normalization layer:

[0116] .

[0117] Add the first LSTM layer after the Transformer Block. Extract the primary time series model, which is represented as follows:

[0118] .

[0119] The second LSTM layer further extracts complex time-dependent features to improve the accuracy of long-term predictions, as shown below:

[0120] .

[0121] Stacking two LSTM layers can effectively increase the depth and complexity of the model, thereby better processing complex sequence data, especially in the task of ship trajectory prediction in complex marine environments.

[0122] The trajectory of ships at sea is affected by many factors, such as weather, ocean currents, and interactions between ships, which makes trajectory prediction more challenging. By stacking two LSTMs in the model, the present invention can better extract short-term and long-term dependencies in the data, thereby improving the model's adaptability to complex marine environments.

[0123] Step 3. Based on the data set preprocessed in step 1, the ship trajectory prediction model built in step 2 is trained, and the trained model is used to predict the ship trajectory and output the time series of trajectory points in the future time period.

[0124] In the process of training the ship trajectory prediction model, the embodiment of the present invention uses a multi-granularity cross entropy loss function to calculate the difference between the probability distribution predicted by the model and the actual observed position. The formula is as follows:

[0125] .

[0126] in, represents the probability distribution of the model output, represents the true label, Represents the cross entropy loss function, which is used to measure the difference between the probability distribution of the model output and the true label.

[0127] Based on the results of the above multi-granularity cross entropy loss function, the back propagation algorithm is used to update the parameters of the ship trajectory prediction model to reduce the error between the predicted distribution and the actual data, thereby completing the model training.

[0128] After the model is trained, the trained model is used to predict the ship trajectory and output the time series of trajectory points in the future time period. Specifically, for the input real-time AIS ship trajectory data, it is first preprocessed according to step 1 to obtain a four-hot vector, and the four-hot vector is input into the trained model to output the time series of trajectory points in the future time period.

[0129] In addition, in order to verify the effectiveness of the method proposed in the present invention, the following specific experimental process is also given.

[0130] In the experiment, the prediction performance of the improved double-layer LSTM-Transformer model in the embodiment of the present invention is analyzed and compared with other models such as the LSTM model, the Transformer model and the single-layer LSTM-Transformer model.

[0131] According to the Haversine formula, the prediction error between the predicted trajectory and the true trajectory is calculated.

[0132] .

[0133] in, represents the prediction error value between trajectories, is the radius of the Earth, , , and Indicates the latitude of the predicted trajectory and the true trajectory, and Indicates the longitude of the predicted trajectory and the true trajectory.

[0134] The trajectory prediction performance of the model of the present invention is analyzed and compared with other models. Compared with the traditional LSTM model, Transformer model and single-layer LSTM-Transformer model, the improved double-layer LSTM-Transformer model of the present invention shows lower error, higher accuracy and higher prediction efficiency in ship trajectory prediction.

[0135] Example 2

[0136] This embodiment 2 describes a ship trajectory prediction system, which is based on the same inventive concept as the ship trajectory prediction method in embodiment 1.

[0137] A ship trajectory prediction system includes the following modules:

[0138] A preprocessing module is used to obtain public AIS historical ship data and preprocess the AIS historical ship data;

[0139] Model building module, used to build a ship trajectory prediction model based on a double-layer LSTM model and an improved Transformer model;

[0140] The input of the ship trajectory prediction model is the AIS data of four attributes. The unique hot encodings of the four attributes are concatenated into a four-hot vector and normalized. The concatenated vector is used as the input of the model.

[0141] The ship trajectory prediction model includes an embedding layer, a Transformer Block layer, a first LSTM layer, a second LSTM layer, a linear transformation layer, and a normalization layer; the processing flow of the ship trajectory prediction model is as follows:

[0142] First, the four-hot vector of the input model is added to the positional encoding as the input of the Transformer Block layer, and then processed by each Transformer block in the Transformer Block layer in turn to capture the global dependencies in the data;

[0143] Each of the Transformer blocks adopts a multi-query attention mechanism, which modifies the key and value linear mapping matrix of the multi-head attention of each layer in the original Transformer model to be shared by all heads in the layer, that is:

[0144] Each layer has only one K and one V matrix, while the Q matrix remains unchanged, and its number is still equal to the number of attention heads;

[0145] The output features of the Transformer Block layer are passed through the first layer of LSTM to extract primary time features, and further passed through the second layer of LSTM to extract complex time-dependent features to improve the accuracy of long-term prediction;

[0146] The output features of the second LSTM are sequentially transformed through the linear transformation layer and the normalization layer to output the predicted trajectory point sequence;

[0147] The model training and prediction module is used to train the built ship trajectory prediction model based on the preprocessed data set, and use the trained model to predict the ship trajectory and output the trajectory point time series in the future time period.

[0148] It should be noted that, in the ship trajectory prediction system, the implementation process of the functions and effects of each functional module is specifically described in the implementation process of the corresponding steps in the method in Example 1, and will not be repeated here.

[0149] Example 3

[0150] This embodiment 3 describes a computer device, which includes a memory and one or more processors.

[0151] An executable code is stored in the memory, and when the processor executes the executable code, it is used to implement the steps of the ship trajectory prediction method in the above-mentioned embodiment 1.

[0152] In this embodiment, the computer device is any device or apparatus with data processing capability, which will not be described in detail here.

[0153] Example 4

[0154] This embodiment 4 describes a computer-readable storage medium on which a program is stored. When the program is executed by a processor, it is used to implement the steps of the ship trajectory prediction method.

[0155] The computer-readable storage medium may be an internal storage unit of any device or apparatus with data processing capabilities, such as a hard disk or memory, or an external storage device of any device with data processing capabilities, such as a plug-in hard disk, a smart media card (SMC), an SD card, a flash card, etc., equipped on the device.

[0156] Of course, the above description is only a preferred embodiment of the present invention, and the present invention is not limited to the above embodiments. It should be noted that all equivalent substitutions and obvious deformation forms made by any technician familiar with the field under the guidance of this specification fall within the essential scope of this specification and should be protected by the present invention.

Claims

1. A ship trajectory prediction method, characterized in that: The steps include: Step 1. Obtain the public AIS historical ship data and pre-process the AIS historical ship data; Step 2. Build a ship trajectory prediction model based on a double-layer LSTM model and an improved Transformer model; The input of the ship trajectory prediction model is the AIS data of four attributes: latitude, longitude, speed, and heading. The unique hot encodings of the four attributes are concatenated into a four-hot vector and normalized. The concatenated vector is used as the input of the model. The ship trajectory prediction model includes an embedding layer, a Transformer Block layer, a first LSTM layer, a second LSTM layer, a linear transformation layer, and a normalization layer; the processing flow of the ship trajectory prediction model is as follows: First, the four-hot vector of the input model is added to the positional encoding as the input of the Transformer Block layer, and then processed by each Transformer block in the Transformer Block layer in turn to capture the global dependencies in the data; Each of the Transformer blocks adopts a multi-query attention mechanism, which modifies the key and value linear mapping matrix of the multi-head attention of each layer in the original Transformer model to be shared by all heads in the layer, that is: Each layer has only one K and one V matrix, while the Q matrix remains unchanged, and its number is still equal to the number of attention heads; The output features of the Transformer Block layer are passed through the first layer of LSTM to extract primary time features, and further passed through the second layer of LSTM to extract complex time-dependent features to improve the accuracy of long-term prediction; The output features of the second LSTM are sequentially transformed through the linear transformation layer and the normalization layer to output the predicted trajectory point sequence; Step 3. Based on the data set preprocessed in step 1, the ship trajectory prediction model built in step 2 is trained, and the trained model is used to predict the ship trajectory and output the time series of trajectory points in the future time period.

2. The ship trajectory prediction method according to claim 1, characterized in that: The step 1 is specifically as follows: Step 1.

1. Download the public AIS dataset; Step 1.

2. Select AIS data within a preset latitude and longitude range, and retain the data features used for the model in the AIS data, including the maritime mobile communication service identifier MMSI, time, longitude, latitude, navigation speed and heading over the ground; Step 1.

3. Divide the ship trajectory according to the preset time interval, that is, extract the trajectory point information of the ship at sea from the AIS data processed in step 1.2, and form a historical trajectory point time series; Step 1.

4. Use model predictive control (MPC) to interpolate the ship trajectory of the historical trajectory point sequence in step 1.3, repair the blank parts between the ship trajectories, and form complete ship trajectory data.

3. The ship trajectory prediction method according to claim 2, characterized in that: The step 1.4 is specifically as follows: Step 1.4.

1. Set the ship's state variables as the input of the model predictive control MPC, including MMSI, time, longitude, latitude, speed and heading; Calculating the time interval between the start point and the end point of the interpolation trajectory according to the current trajectory point, that is, calculating the time interval between the start point of the interpolation trajectory, i.e., the current point, and the end point of the interpolation trajectory segment, i.e., the next target point, based on the state variable of the current point; Step 1.4.

2. Set the time interval to be interpolated, interpolate the ship trajectory, and determine whether the time interval between two adjacent points exceeds the preset time interval; if it exceeds, interpolate to refine the trajectory data; Step 1.4.

3. Construct an objective function based on the AIS data processed in step 1.3 and its prediction target; Use the gradient descent method to solve the objective function, initialize the control input, iteratively update the control input, calculate the objective function value and its gradient, and optimize the control input based on the gradient information; After obtaining the optimal control input, substitute it into the kinematic model to calculate the interpolation trajectory points; Step 1.4.

4. Use the interpolated trajectory points generated in step 1.4.3 as the repaired trajectory, and update the trajectory sequence to fill the blank parts in the original ship trajectory to form complete ship trajectory data.

4. The ship trajectory prediction method according to claim 3, characterized in that: The step 1.4.3 is specifically as follows: First, the acceleration is estimated based on the speed and time of the ship's neighboring nodes; Let the speed be v and the time be t; Assumptions and The neighboring points of and , , , and The corresponding speeds are , , , ; The time difference is: , , ; The speed difference is: , , ; when hour, ; when hour, ; in, For ships in The acceleration of the moment; Then, the kinematic model is constructed according to the input state variables of the ship. The kinematic model formula is as follows: The position update formula is as follows: ; in,( , )express The ship's position at the time, , )express The ship's position at the moment, express The speed of the ship at the moment, express The direction of the moment, represents the time increment; The speed update formula is as follows: ; in, express The speed of the moment; In order to optimize the trajectory interpolation effect of the model, two objective functions are constructed: one for position error and one for acceleration error. The final objective function is the weighted sum of the two parts. By minimizing the objective function, the prediction error of the model is reduced. The objective function is constructed as follows: ; ; ; in, represents the position error objective function, represents the acceleration error objective function, represents the overall objective function, Represents the weight coefficient of acceleration error, ( , ) represents the predicted ship trajectory, ( , ) represents the actual ship trajectory, and N represents the number of time steps; After obtaining the optimal control input, it is substituted into the kinematic model, that is, the position update formula and the velocity update formula to calculate the interpolation trajectory points.

5. The ship trajectory prediction method according to claim 1, characterized in that: In step 2, the formation process of the splicing vector of the input model is as follows: In the input layer, input the AIS data with batch size B, sequence length seqlen, and four attributes. The formula is as follows: ; Increase the dimensions of LAT and LON to 256, and increase the dimensions of SOG and COG to 128; ; Among them, LAT, LON, SOG and COG represent latitude, longitude, speed and heading respectively; the unique hot encodings of the four attributes are concatenated into a four-hot vector , and normalize it: , ; in, represents the concatenated vector, and the obtained concatenated vector is used as the input of the ship trajectory prediction model.

6. The ship trajectory prediction method according to claim 5, characterized in that: The embedding layer adopts a learnable position embedding layer; The resulting four-hot vector is added to the positional encoding as the input to the Transformer Block layer. The addition process is as follows: ; in, is the location code, latitude is the embedding dimension of the model, As the input to the Transformer Block layer, the position encoding uses a learnable position embedding.

7. The ship trajectory prediction method according to claim 1, characterized in that: In step 3, during the ship trajectory prediction model training process, a multi-granularity cross entropy loss function is used to calculate the difference between the probability distribution predicted by the model and the actual observed position. The formula is as follows: ; in, represents the probability distribution of the model output, represents the true label, represents the cross entropy loss function, which is used to measure the difference between the probability distribution of the model output and the true label; Based on the results of the above multi-granularity cross entropy loss function, the back propagation algorithm is used to update the parameters of the ship trajectory prediction model to reduce the error between the predicted distribution and the actual data, thereby completing the model training.

8. A ship trajectory prediction system, characterized in that: include: A preprocessing module is used to obtain public AIS historical ship data and preprocess the AIS historical ship data; Model building module, used to build a ship trajectory prediction model based on a double-layer LSTM model and an improved Transformer model; The input of the ship trajectory prediction model is the AIS data of four attributes. The unique hot encodings of the four attributes are concatenated into a four-hot vector and normalized. The concatenated vector is used as the input of the model. The ship trajectory prediction model includes an embedding layer, a Transformer Block layer, a first LSTM layer, a second LSTM layer, a linear transformation layer, and a normalization layer; the processing flow of the ship trajectory prediction model is as follows: First, the four-hot vector of the input model is added to the positional encoding as the input of the Transformer Block layer, and then processed by each Transformer block in the Transformer Block layer in turn to capture the global dependencies in the data; Each of the Transformer blocks adopts a multi-query attention mechanism, which modifies the key and value linear mapping matrix of the multi-head attention of each layer in the original Transformer model to be shared by all heads in the layer, that is: Each layer has only one K and one V matrix, while the Q matrix remains unchanged, and its number is still equal to the number of attention heads; The output features of the Transformer Block layer are passed through the first layer of LSTM to extract primary time features, and further passed through the second layer of LSTM to extract complex time-dependent features to improve the accuracy of long-term prediction; The output features of the second LSTM are sequentially transformed through the linear transformation layer and the normalization layer to output the predicted trajectory point sequence; As well as the model training and prediction module, it is used to train the constructed ship trajectory prediction model based on the preprocessed data set, and use the trained model to predict the ship trajectory and output the trajectory point time series for the future time period.

9. A computer device comprising a memory and one or more processors, wherein the memory stores executable code, characterized in that: When the processor executes the executable code, the steps of the ship trajectory prediction method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a program stored thereon, characterized in that: When the program is executed by a processor, the steps of the ship trajectory prediction method as described in any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Ultra-short-term power prediction model establishment method considering time-space characteristics of multiple offshore wind power units

    CN115587525A

  • Offshore ship trajectory real-time prediction method, system and equipment based on CNN-GRU and attention mechanism and medium

    CN116306790A