A ship trajectory prediction method based on improved PBT

By combining the bidirectional long and short-term memory network and the Transformer model in the ship trajectory prediction, and using a loss function that considers heading and velocity factors, the problem of low prediction accuracy in the prior art is solved, and a ship trajectory prediction with higher accuracy and similarity is achieved.

CN118861532BActive Publication Date: 2025-03-18DALIAN MARITIME UNIVERSITY +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411128943.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-08-16
Publication Date
2025-03-18
Estimated Expiration
2044-08-16

AI Technical Summary

Technical Problem

In the prior art, in ship trajectory prediction, the prediction accuracy is low, and most models do not consider the ship's heading and velocity factors.

Method used

The ship trajectory prediction method based on bidirectional long and short-term memory network and Transformer model is used to establish a loss function, including mean square error, distance difference and heading difference, to train the model and obtain the predicted trajectory.

Benefits of technology

By considering the loss function of trajectory point position, distance and heading difference, the predicted ship trajectory is more in line with the actual motion state, improving the prediction accuracy and trajectory similarity.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118861532B_ABST
    Figure CN118861532B_ABST
Patent Text Reader

Abstract

The present invention discloses a ship trajectory prediction method based on improved P‑B‑T. By establishing a loss function including mean square error, the distance from a predicted ship trajectory point to a trajectory point at a previous moment, the distance from a real ship trajectory point to a trajectory point at a previous moment, and the heading difference between the real trajectory point and the predicted trajectory point, a ship trajectory prediction model based on a bidirectional long short-term memory network and a Transformer model is trained to obtain a trajectory vector after encoding time series data of the ship trajectory, so as to obtain the predicted trajectory of the ship and realize the prediction of the ship trajectory. Through the loss function established by the present invention, since the loss function not only considers the position factor of the trajectory point but also considers the ship heading and the speed factor of the ship, the predicted ship trajectory is more in line with the motion state of the actual movement of the ship, and the obtained prediction result is more conducive to improving the similarity between the entire predicted trajectory of the ship and the actual trajectory, thereby greatly improving the prediction accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of time series prediction technology, and in particular to a ship trajectory prediction method based on improved PBT. Background Art

[0002] Deep learning methods use deep neural network models to learn and predict trajectory data end-to-end without the need for manual feature extraction. Deep learning methods usually have stronger expressive power and can capture complex nonlinear relationships in data, and have become a mainstream research hotspot in the field of trajectory prediction.

[0003] Among them, the LSTM method (Long Short-Term Memory Network) is widely used in trajectory prediction because of its powerful time series modeling ability, ability to capture complex patterns, robustness to noise and irregular data, and flexible model structure. Its improved model BiLSTM can use information in both forward and backward directions at the same time, and the generated feature representation is richer and more comprehensive than the unidirectional LSTM. This comprehensive feature representation can better characterize the complexity of trajectory data, thereby improving prediction performance. At the same time, the Transformer model is also widely used in trajectory prediction, mainly due to its powerful self-attention mechanism and parallel processing capabilities. The defect of BiLSTM is that it is not sensitive enough to capture non-local and complex dependencies of time series; when processing very long sequences, it may encounter the problem of gradient vanishing or gradient explosion, and may have certain limitations when processing unknown data other than training data. The defect of Transformer is that it may not be efficient enough when processing local time series patterns. For trajectory prediction, both models have their own defects, and the prediction accuracy needs to be improved. At the same time, most deep learning trajectory predictions use artificially set hyperparameters, and the accuracy of the prediction results obtained still has room for improvement.

[0004] Most of the current trajectory prediction models use artificially defined model hyperparameters and only use mean square error or other single indicators as the model loss function. They are not designed for the specific problem of ship trajectory prediction and do not take into account the ship's heading and speed factors. Therefore, the prediction results are usually of low accuracy. Summary of the invention

[0005] The invention discloses a ship trajectory prediction method based on improved PBT to overcome the above technical problems.

[0006] In order to achieve the above object, the technical solution of the present invention is:

[0007] A ship trajectory prediction method based on improved PBT includes the following steps:

[0008] S1: Obtain the time series data of the ship trajectory, clean it, and pre-process the cleaned time series data by linear interpolation and normalization methods in turn to obtain the pre-processed time series data of the ship trajectory;

[0009] S2: Establishing a loss function of a ship trajectory prediction model based on a bidirectional long short-term memory network and a Transformer model; the loss function includes a mean square error, a distance difference between a predicted ship trajectory point and a previous moment trajectory point and a distance difference between a real ship trajectory point and a previous moment trajectory point, and a heading difference between a real trajectory point and a predicted trajectory point;

[0010] S3: according to the preprocessed time series data of the ship trajectory, adopting a ship trajectory prediction model based on a bidirectional long short-term memory network and a Transformer model, and based on the loss function, training the ship trajectory prediction model to obtain a trained ship trajectory prediction model;

[0011] S4: According to the trained ship trajectory prediction model, a trajectory vector is obtained after encoding the time series data of the ship trajectory to obtain the predicted trajectory of the ship, thereby realizing the prediction of the ship trajectory.

[0012] Furthermore, in S3, the loss function is established as follows:

[0013] LOSS=MSE+△distance+△course

[0014] △y=y t -y t-1

[0015] △x=x t -x t-1

[0016]

[0017]

[0018] △distance=|distance1-distance2

[0019]

[0020] △course=min(course-course'|,2π-|course-course')

[0021] Where: LOSS represents the loss function; MSE represents the mean square error, that is, the sum of the squares of the difference between the true value and the predicted value; △distance represents the distance difference; △course represents the course difference; Represents the horizontal coordinate of the predicted point at time t; The ordinate of the predicted point at time t; x t Represents the horizontal coordinate of the real point at time t; y t represents the ordinate of the real point at time t; △y represents the real ordinate difference; △x represents the real abscissa difference; △y′ represents the predicted ordinate difference; △x′ represents the predicted abscissa difference; distance1 represents the distance from the predicted trajectory point to the real trajectory point at the previous moment; distance2 represents the distance from the real trajectory point to the real trajectory point at the previous moment; course represents the heading of the real trajectory point; course' represents the heading of the predicted trajectory point; △course represents the heading difference between the real trajectory point and the predicted trajectory point; |·| represents the absolute value operation;

[0022]

[0023] Where: MSE represents the mean square error, that is, the sum of the squares of the differences between the true value and the predicted value; t represents the time; T represents the total number of time; u t represents the true value at time t, Represents the predicted value at time t.

[0024] Furthermore, in S4, the method for obtaining the trajectory vector after encoding the time series data of the ship trajectory is as follows:

[0025] S41: According to the preprocessed time series data of the ship trajectory, the hidden state sequence of the time step is obtained, that is, the new latent vector H after splicing t ;

[0026] S42: According to the hidden state sequence H of the time step t , obtain the trajectory vector after encoding the time series data of the ship trajectory.

[0027] Furthermore, in S41, the hidden state sequence of the time step is obtained, that is, the new latent vector H after splicing t The method is as follows:

[0028]

[0029] Where: Represents the new latent vector at time t; represents the positive time direction latent vector at time t-1; represents the hidden vector in the opposite time direction at time t-1; P t The feature vector representing the input at time t is the data of the ship trajectory point at time t; H t represents the new latent vector after concatenation; LSTM(·) represents the input function of the LSTM layer.

[0030] Furthermore, in S42, the formula used to obtain the trajectory vector after encoding the time series data of the ship trajectory is as follows:

[0031]

[0032] Where: e t Indicates H t and The concatenated vector is the trajectory vector after encoding the time series data of the ship trajectory; H t Represents the new latent vector after concatenation; Represents the position vector provided by the Transformer.

[0033] Beneficial effect: A ship trajectory prediction method based on improved PBT of the present invention trains a ship trajectory prediction model based on a bidirectional long short-term memory network and a Transformer model by establishing a loss function including the mean square error, the distance from the predicted trajectory point of the ship to the trajectory point at the previous moment, the distance from the actual trajectory point of the ship to the trajectory point at the previous moment, and the heading difference between the actual trajectory point and the predicted trajectory point, so as to obtain a trajectory vector after encoding the time series data of the ship trajectory, so as to obtain the predicted trajectory of the ship and realize the prediction of the ship trajectory; through the loss function established by the present invention, since the loss function not only considers the trajectory point position factor but also the ship heading and the ship speed factor, the predicted ship trajectory is more in line with the actual motion state of the ship, and the obtained prediction result is more conducive to improving the similarity between the entire predicted trajectory of the ship and the actual trajectory, thereby greatly improving the prediction accuracy. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0035] Figure 1 This is a flow chart of the ship trajectory prediction method of the present invention;

[0036] Figure 2 Schematic diagram of the structure of the PSO-BiLSTM-Transformer model in an embodiment of the present invention;

[0037] Figure 3 A technical roadmap for implementing ship trajectory prediction in an embodiment of the present invention;

[0038] Figure 4 Schematic diagram of a sliding time window in an embodiment of the present invention;

[0039] Figure 5a This is a schematic diagram of a ship trajectory before interpolation in an embodiment of the present invention;

[0040] Figure 5b This is a schematic diagram of a ship trajectory after interpolation in an embodiment of the present invention;

[0041] Figure 5c This is a schematic diagram of a ship's speed before interpolation in an embodiment of the present invention;

[0042] Figure 5d This is a schematic diagram of a ship's speed after interpolation in an embodiment of the present invention;

[0043] Figure 5e This is a schematic diagram of a ship's heading before interpolation in an embodiment of the present invention;

[0044] Figure 5f This is a schematic diagram of a ship's heading after interpolation in an embodiment of the present invention;

[0045] Figure 6 Design an explanation diagram for the model loss function in an embodiment of the present invention;

[0046] Figure 7 It is a convergence diagram of the optimal fitness function of the particle swarm algorithm in the embodiment of the present invention;

[0047] Figure 8a ADE comparison diagram of the error indicator in the embodiment of the present invention;

[0048] Figure 8b is a comparison diagram of the error indicator FDE in an embodiment of the present invention;

[0049] Figure 8c It is a comparison diagram of the error indicator MSE in the embodiment of the present invention;

[0050] Figure 8d It is a comparison diagram of error indicator MAE in an embodiment of the present invention;

[0051] Fig. 9 This is a trajectory prediction comparison diagram in an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0053] This embodiment introduces a ship trajectory prediction method based on improved PBT, in particular, a ship trajectory prediction method based on PSO-BiLSTM-Transformer, such as Figure 1 As shown, the following steps are included:

[0054] S1: Obtain the time series data of the ship trajectory, clean it, and pre-process the cleaned time series data by linear interpolation and normalization methods in turn to obtain the pre-processed time series data of the ship trajectory. Finally, the longitude and latitude of the ship in the time series data of the ship trajectory are converted into coordinates on the plane coordinate system using Mercator projection, in meters, to facilitate subsequent distance calculations;

[0055] Specifically, due to the problems of errors, discontinuity and loss in the transmission of AIS data, in order to ensure the accuracy of subsequent trajectory prediction, the original AIS data is cleaned, mainly processing the four types of data in the AIS data, namely position, speed, heading and time. For speed and heading data, the parameter threshold is controlled according to the basic law of ship motion, and data beyond the reasonable range is eliminated. For time and position data, repeated and obviously wrong repeated time points and position points are eliminated.

[0056] After cleaning the time series data of the ship trajectory, for some missing data, 10s is selected as the time step to perform linear interpolation on the ship trajectory. The linear interpolation formula is as shown in formula (1), where X1 and X2 represent the longitude coordinates of two adjacent trajectory points, and Y1 and Y2 represent the latitude coordinates of two adjacent trajectory points. are the latitude and longitude coordinates of the interpolated trajectory points.

[0057]

[0058] in,

[0059]

[0060] Where: X1, X2 represent the longitude coordinates of two adjacent trajectory points; Y1, Y2 represent the latitude coordinates of two adjacent trajectory points; are the latitude and longitude coordinates of the interpolated trajectory points.

[0061] Since the frequency of AIS data is not constant, this embodiment selects 10s as the time step. Since the time step is short and the ship speed is slow, the ship motion within 10s can be approximated as uniform linear motion, so linear interpolation can be applied to trajectory interpolation. Figure 5 is a comparison before and after interpolation. Figure 5a , Figure 5c , Figure 5e These are the trajectory, speed, and heading data before interpolation. It can be seen that these three data are uneven and missing before interpolation. Figure 5b , Figure 5d , Figure 5f The figures are after interpolation of trajectory, speed and heading. It can be seen that the missing data are filled after interpolation, making the data points more uniform and real. The interpolated data input into the model is more conducive to improving the accuracy of trajectory prediction.

[0062] Since the longitude and latitude of the ship are coordinates on a sphere, they cannot be used to calculate the distance of the ship. Therefore, the longitude and latitude of the ship should be transformed into plane coordinates by Mercator projection. The projection formula is as follows:

[0063] Determine the reference sphere as the WGS84 ellipsoid, with the parameters of the major semi-axis b = 6378137.0, f = 1 / 298.257223563, e 2 =1-(1-f) 2 =0.00669437999014.

[0064]

[0065] T′=tan 2 (φ)

[0066]

[0067] Among them, λ0 is the central meridian, λ is the longitude, φ is the latitude, x is the horizontal coordinate converted from the longitude, y is the vertical coordinate converted from the latitude; b is the major axis; e is the first eccentricity; f is the flattening; k0 is the expansion scale factor; N is the equatorial radius curvature; T′ represents the square tangent function of latitude, which is an auxiliary variable; C represents the cosine square of latitude multiplied by the square of the first eccentricity of the reference ellipsoid, which is an auxiliary variable; M is the arc length from the equator to a certain latitude.

[0068] Then the time series data of the ship trajectory after linear interpolation and planarization is normalized. Normalizing the AIS data can make the range of each feature (including the horizontal coordinate, vertical coordinate, speed, and heading) between [0,1]. Normalization scales the data to the same range, making the comparison between different features easier and more reasonable. Normalization can also avoid numerical instability problems caused by excessively large or small values ​​during the calculation process. In a neural network, if the input data range is large, it may cause the weight update to be too large or too small, affecting the training effect. The minimum-maximum normalization method is as follows:

[0069]

[0070] Where: X max and X min are the maximum and minimum values ​​in the sample data respectively, X0 is the original value, and X' is the normalized value.

[0071] Specifically, in this embodiment, the time series data of the j-th ship trajectory is expressed as Among them, Traj j represents the jth trajectory, t represents the time; T represents the total number of time, which is also the total number of trajectory points in the time series data of the ship trajectory, and also the total number of timestamps; where P t ={sog t ,cog t ,y t ,x t ,},t=1,…,T,P t The tth track point in the time series data of the ship's track is also the data at time t, sog t represents the speed at time t in the time series data of the ship's trajectory; cog t represents the heading of the tth track point at time t in the time series data of the ship's track; t The ordinate at time t in the time series data of the ship's trajectory; x t The horizontal coordinate at time t in the time series data of the ship's trajectory; specifically, the trajectory point contains four features: SOG represents speed, COG represents heading, X represents horizontal coordinate, and Y represents vertical coordinate.

[0072] S2: Establishing a loss function of a ship trajectory prediction model based on a bidirectional long short-term memory network and a Transformer model; the loss function includes a mean square error, a distance difference between a ship's predicted trajectory point and a trajectory point at the previous moment, a distance between a ship's actual trajectory point and a trajectory point at the previous moment, and a heading difference between an actual trajectory point and a predicted trajectory point;

[0073] S3: According to the preprocessed time series data of the ship trajectory and the loss function, based on the PSO algorithm, a ship trajectory prediction model based on a bidirectional long short-term memory network and a Transformer model is adopted to train the ship trajectory prediction model to obtain a trained ship trajectory prediction model;

[0074] Preferably, the loss function in this embodiment consists of three parts, one part is MSE (i.e., mean square error, used to find the mean of the square of the error between the true value and the predicted value), the second part is designed based on the consistency between the predicted speed and the true speed of the ship, so the distance distance1 from the predicted trajectory point of the ship to the true trajectory point of the previous moment should be as close as possible to the distance distance2 from the true trajectory point to the true trajectory point of the previous moment to maintain the consistency of speed, and is set to the distance difference △distance between the two. The third part is also based on the characteristics of ship trajectory similarity judgment-the heading difference between the predicted trajectory point of the ship and the actual trajectory point should be approximately equal. Therefore, the final loss function is set as follows:

[0075] LOSS=MSE+△distance+△course

[0076] △y=y t -y t-1

[0077] △x=x t -x t-1

[0078]

[0079] △distance=|distance1-distance2

[0080]

[0081] △course=min(course-course'|,2π-|course-course')

[0082] Where: LOSS represents the loss function; MSE represents the mean square error; △distance represents the distance difference; △course represents the course difference; Represents the horizontal coordinate of the predicted trajectory point at time t; Represents the ordinate of the predicted trajectory point at time t; x t Represents the horizontal coordinate of the actual trajectory point at time t; y trepresents the ordinate of the real trajectory point at time t; △y represents the real ordinate difference; △x represents the real abscissa difference; △y′ represents the predicted ordinate difference; △x′ represents the predicted abscissa difference; distance1 represents the distance from the predicted trajectory point to the real trajectory point at the previous moment; distance2 represents the distance from the real trajectory point to the real trajectory point at the previous moment; course represents the heading of the real trajectory point; course' represents the heading of the predicted trajectory point; △course represents the heading difference between the real trajectory point and the predicted trajectory point.

[0083] The specific principle of establishing the loss function is explained as follows Figure 6 , P t represents the actual track point of the ship at time t, P t ′(1) represents the predicted trajectory point 1 at time t, P t ′(2) represents the predicted trajectory point 2 at time t, P t-1 represents the actual track point of the ship at time t-1, with the m-axis and n-axis as the coordinate axes of the track. Assume that P′ t (1) and P′ t (2) Distance P t The distance between the two points is equal, so the two points are located at the radius of P t On the circle with the center as the center (green circle), passing through point P t Draw a straight line parallel to the m-axis (red line w). Assume P t ′(1) and P t ′(2) are two points symmetrical about the line, so the mean square error of the two trajectory points is consistent. At this time, if only MSE (mean square error) is used in the loss function, the two predicted trajectory points are equally good. Assuming the trajectory length d(P t ′(1)P t-1 )=d(P t P t-1 )>d(P t ′(2)P t-1 ), if the predicted speed and the actual speed should be consistent according to the ship's motion characteristics, then P′ t (1) The point should be better than P′ t (2) Considering that the predicted heading should be as consistent as possible with the actual heading, then P′ t (2) The point should be better than P′ t (1) Point. Therefore, in this embodiment, these two antagonistic indicators are also used as part of the loss function, and multi-objective optimization is performed to find the optimal value, which is the predicted trajectory point.

[0084] After completing the basic modeling, the particle swarm algorithm is used to optimize the model hyperparameters to make up for the defects of manually setting hyperparameters. The model hyperparameters include the number of LSTM layers, the number of heads of multi-head attention in transformer, the size of hidden variables, the number of training rounds, the batch size, the learning rate, etc. The MSE, an evaluation index of the error size, is used as the fitness function of the particle swarm algorithm.

[0085] Particle Swarm Optimization (PSO) is an optimization algorithm based on swarm intelligence, inspired by the collective behavior of biological groups such as bird flocks or fish schools. The PSO algorithm simulates the behavior of individuals in the group and continuously updates their positions and velocities to find the optimal solution to the problem.

[0086] The basic idea of ​​the PSO algorithm is to optimize the position and speed of individuals through continuous iteration so that the group approaches the optimal solution to the problem. In PSO, individuals are usually called particles, and each particle has its own position and speed. Particles adjust their movement direction and speed based on their own experience and the information of the group in the hope of finding the optimal solution to the problem.

[0087] In the model hyperparameter optimization of this embodiment, the position and velocity of the particle are both four-dimensional vectors (including longitude, latitude, speed, and heading), and the position vector representation and velocity vector representation are as follows:

[0088] x q =(x q1 ,x q2 ,x q3 ,x q4 )

[0089] v q =(v q1 ,v q2 ,v q3 ,v q4 )

[0090] The particle q velocity update formula is as follows:

[0091] v q (t+1)=ωv q (t)+c1r1(p q (t)-x q (t))+c2r2(g(t)-x q (t))

[0092] Among them, ω is the inertia weight, c1 and c2 are learning factors, r1 and r2 are random number vectors in the range of [0,1], and p q(t) is the individual optimal position of particle q at time t, g(t) is the global optimal position of the entire population at time t, and x q (t) is the position of particle q at time t. q represents the position vector of particle q; x q1 represents the longitude of particle q; x q2 represents the latitude of particle q; x q3 represents the speed of particle q; x q4 represents the heading of particle q; v q represents the velocity vector of the particle; v q1 represents the change in the longitude of particle q; v q2 represents the change in the latitude of particle q; v q3 represents the change in the speed of particle q; v q4 represents the change in the heading of particle q; v q (t) represents the velocity of the particle at time t;

[0093] The position update formula of particle q is as follows:

[0094] x q (t+1)=x q (t)+v q (t+1)

[0095] The problem in this embodiment is to use the hyperparameters to be optimized in the model as the position of the particles. The MSE, an evaluation index of the size of the model error, is used as the fitness function of PSO. The smaller the MSE, the better the model effect. The PSO algorithm will continue to search for particles that make the fitness function smaller, even if the hyperparameter combination with smaller model error reaches a certain algorithm termination condition, then stop searching, and use the optimal hyperparameter combination obtained at this time as the hyperparameter of the BiLSTM-Transformer model.

[0096] After the PSO-BiLSTM-Transformer model is established, the model is trained with processed data, and then the trained model is used to predict the trajectory. Finally, four evaluation indicators are used to evaluate the model prediction error, among which MAE is the sum of the absolute values ​​of the difference between the true value and the predicted value, and MSE is the sum of the squares of the difference between the true value and the predicted value. It is used to evaluate the accuracy of the model in prediction. The smaller the values ​​of MAE and MSE, the more accurate the prediction of the model and the better the prediction effect. It can be used to compare and evaluate the performance of different models. MAE has better robustness to outliers. ADE can measure the average distance between two trajectories, and FDE represents the distance difference between the predicted last point and the true last point, which can reasonably evaluate the accumulation of model errors.

[0097]

[0098] Where: MAE represents the sum of the absolute values ​​of the difference between the true value and the predicted value; MSE represents the mean square error, that is, the sum of the squares of the difference between the true value and the predicted value; ADE represents the average distance between the trajectory points in the true trajectory and the predicted trajectory; FDE represents the distance difference between the position of the last predicted trajectory point and the position of the last true trajectory point; t represents the time; T represents the total number of times; u t represents the true value at time t, Represents the predicted value at time t. Represents the horizontal coordinate of the predicted point at time t; The ordinate of the predicted point at time t; x t Represents the horizontal coordinate of the real point at time t; y t Represents the ordinate of the real point at time t.

[0099] Figure 7 The optimal fitness change diagram of the particle swarm algorithm in this embodiment is shown. The optimal fitness gradually decreases with the increase of the number of iterations, and the hyperparameters corresponding to the last optimal fitness are selected as the hyperparameters of the BiLSTM-Transformer model.

[0100] Figure 8a-8d The error index comparison chart in this embodiment is shown. It includes four error indicators: MAE, MSE, ADE, and FDE. Each figure shows the comparison of five models. The PSO-BiLSTM-Transformer model is referred to as PBT, the BiLSTM-Transformer is referred to as BT, and the LSTM-Transformer is referred to as LT. The error comparison of each model can be more intuitively seen from the figure. The PBT model proposed in this embodiment has the smallest indicators and is better.

[0101] Specifically, the improved ship trajectory prediction model of this embodiment is as follows: Figure 2As shown in the figure, the model structure diagram of the improved PSO-BiLSTM-Transformer is shown. First, in the hyperparameter optimization stage, the PSO algorithm is used to optimize the hyperparameters of the BiLSTM-Transformer model, including the three important hyperparameters of the number of BiLSTM layers, batch size, and learning rate; then the model is trained, and the trajectory feature data including speed, heading, longitude, and latitude are input into the BiLSTM layer, and the feature time series information of the input sequence is extracted. Then, the hidden state sequence of the BiLSTM model is used as the input of the Transformer encoder. In the Transformer encoder, the hidden state sequence will be encoded through a multi-layer self-attention mechanism to capture the global dependencies in the input sequence and generate feature representations for prediction. Finally, the feature representation generated by the Transformer encoder is input into the decoder, and the decoder is used to predict the value of the future time step. This combination can make full use of the bidirectional modeling ability of BiLSTM for time series data and the ability of Transformer to capture the global dependencies of the sequence, thereby improving the accuracy and robustness of trajectory prediction.

[0102] Specifically, the method used to train the ship trajectory prediction model is a conventional technology in the field and will not be described in detail here.

[0103] S4: According to the trained ship trajectory prediction model, a trajectory vector is obtained after encoding the time series data of the ship trajectory to obtain the predicted trajectory of the ship, thereby realizing the prediction of the ship trajectory.

[0104] S41: According to the preprocessed time series data of the ship trajectory, the preprocessed time series data of the ship trajectory is input into the BiLSTM layer to obtain the hidden state sequence of the time step, that is, the concatenated new hidden vector H t ;

[0105] S42: According to the hidden state sequence H of the time step t , the hidden state sequence H of the time step t Input to Transformer to obtain the trajectory vector after encoding the time series data of the ship trajectory;

[0106] Specifically, given the trajectory information of the jth trajectory for a period of time in the past, we can predict the trajectory point information at the next moment. By sliding the time window, we input the data into the model in sequence to predict the trajectory point at the next moment. The prediction process of the trajectory point is equivalent to obtaining a mapping relationship f between some trajectory points and the trajectory points at the next moment. Assuming the time window size is △t, the calculation formula is as follows.

[0107]

[0108] in: represents the trajectory point at the tth moment on the jth ship trajectory; Δt represents the known time step; represents the mapping relationship function; j represents the index number of the ship trajectory; Represents the trajectory point at the next moment of the predicted time t;

[0109] Figure 4 The figure shows a schematic diagram of a sliding time window. Given the trajectory information of a certain time period of a certain trajectory, the trajectory point information of the next moment is predicted. Then, through the sliding time window method, the data is input into the model one by one for prediction.

[0110] Specifically, the bidirectional long short-term memory network (Bi-directional Long Short-Term Memory, BiLSTM) in this embodiment is an improved recursive neural network (RNN) for processing and predicting sequence data. It combines the advantages of long short-term memory network (LSTM) and bidirectional RNN. BiLSTM is composed of LSTM in two directions. The forward LSTM (Forward LSTM) accepts information from the beginning to the end of the input sequence and processes it in the order of time steps to learn the time dependencies in the sequence. The backward LSTM (Backward LSTM) accepts information from the end to the beginning of the input sequence and processes it in the reverse order of the time steps to learn the reverse time dependencies in the sequence. BiLSTM will comprehensively consider the hidden state information of the forward and backward directions to obtain a more comprehensive sequence representation. This bidirectional structure enables BiLSTM to better capture the long-term correlation in the sequence data and better predict trajectories. The BiLSTM model is a bidirectional architecture composed of two independent LSTM networks. When solving, the hidden vector in the positive time direction is calculated. Generate new latent vector and the opposite time direction latent vector Generate new latent vector and Concatenate into a new latent vector H t :

[0111]

[0112] In the formula: In the formula: Represents the new latent vector at time t; represents the positive time direction latent vector at time t-1; represents the hidden vector in the opposite time direction at time t-1; P t The feature vector representing the input at time t is the data of the ship trajectory point at time t; H trepresents the new latent vector after concatenation; LSTM(·) represents the input function of the LSTM layer;

[0113] Specifically, the Transformer model in this embodiment consists of two parts: an encoder and a decoder, each of which consists of multiple stacked layers. Each encoder layer consists of two main components: a multi-head self-attention mechanism and a feed-forward neural network. The decoder layer is similar to the encoder layer, but additionally includes a multi-head attention layer for encoder-decoder attention, allowing the decoder to access the output of the encoder when generating output. First, the input sequence is processed by the data embedding layer and the position encoding is added to generate the position embedding vector input encoder, which is converted into a vector representation mapped to a high-dimensional space by a multi-head attention module and a fully connected module, so that the model can memorize and obtain the features of the context vector for subsequent processing. The decoder receives the output of the encoder and the output of the decoder of the previous time step to generate an attention context vector to guide the model to decide the final output of the current time step. In short, the encoder module mainly creates the representation of the input, and the decoder module is responsible for the output result.

[0114] The Transformer encoder of this embodiment does not have a clear sequential perception capability and needs to obtain the previous and next information of the trajectory sequence through position encoding. For each position in the sequence, the position encoder generates a vector of fixed size, where each dimension corresponds to a sine or cosine function of different frequencies. The encoding vectors of different positions have different angles in space, so that the relative position relationship between them can be expressed. The formula for position encoding is as follows:

[0115]

[0116] Among them, pos represents the position index, h represents the dimension index, and d model Represents the dimension of the model; PE (pos,2h) Indicates positional encoding;

[0117] Specifically, the core module of the encoder and decoder is a multi-head attention mechanism, which can linearly transform the input matrix to generate different query matrices Query, key matrices Key and value matrices Value for independent attention calculations, and weightedly concatenate the output of each head in the final fused representation to obtain a global self-attention feature map. Because it has multiple heads, it can fuse the features of different heads, better process long sequence data and more effectively focus on global information. The calculation process of the self-attention mechanism is as follows:

[0118]

[0119] Where Q = W Q I,K=W K I,V=W V I

[0120] Where: Attention(.) represents the self-attention size of the vector; softmax(·) represents the activation function; Q represents the query vector; K represents the key vector; V represents the value vector; K T represents the transpose of K; d k represents the dimension of the key vector K; I represents the encoder input after the embedding layer and position encoding; W Q , W K , W V The weight matrices are continuously updated during the training process. Their function is to assign an attention weight to each input, and to increase the computational weight of the data with a large attention weight in network training. For each input, each head will generate an attention matrix, and the attention matrices of the h heads are concatenated with the weight matrix W trained with the network. O By multiplying them together, we can obtain the attention matrix that contains all the head information.

[0121]

[0122] Multihead(Q,K,V)=Concat(head1,…,head m )W O (12)

[0123] Where: Multihead(Q,K,V) represents the multi-head attention size of the vector; Concat(·) represents vector concatenation; Both represent weight matrices; m′ represents the number of heads in the multi-head attention mechanism; head a represents the attention size of the a-th head; a represents the a-th head; W O represents the weight matrix that concatenates the attention matrices of m' heads;

[0124] The ship trajectory prediction model of this embodiment uses both BiLSTM and Transformer as encoders. The time series data of the input ship trajectory first enters the BiLSTM layer for processing to generate a hidden state sequence of time steps, that is, a new latent vector H after splicing. t These hidden states capture the time-dependent characteristics of the input sequence. Then the hidden state sequence H t , and the position vector provided by Transformer Combined, the time series is encoded, and the trajectory vector is finally represented as e t , e t The features are input into the transformer model, and the transformer further processes these features using the self-attention mechanism. Finally, the decoder linear layer is used to convert the output of the transformer encoder into the final prediction result and generate the final output sequence to obtain the predicted trajectory points.

[0125]

[0126] Where: e t Indicates H t and The concatenated vector is the trajectory vector after encoding the time series data of the ship trajectory; H t Represents the new latent vector after concatenation; Represents the position vector provided by Transformer;

[0127] Table 1 shows the initial values ​​of the model hyperparameters of this embodiment. Among them, n_layers represents the number of layers of LSTM, n_head represents the number of heads of multi-head attention in transformer, hidden_size represents the size of hidden variables, num_epochs represents the number of training rounds, batchsize represents the number of sample points input each time, i.e., batch size, and learning_rate represents the learning rate. In order to reduce the time complexity of the optimization algorithm, this paper only selects three hyperparameters to be optimized, namely n_layers, batchsize, and learning_rate.

[0128] Table 1 Initial values ​​of model hyperparameters

[0129]

[0130] Table 2 shows the initial values ​​of the particle swarm algorithm parameters of this embodiment.

[0131] Table 2 Initial values ​​of particle swarm algorithm parameters

[0132]

[0133] Table 3 shows the comparison results of the model evaluation indicators in this implementation. From the comparison chart of the evaluation indicators of different models for the same trajectory prediction, it can be seen that the four error evaluation indicators of the PSO-BiLSTM-Transformer model in this embodiment are all the smallest, and the prediction results are closest to the true value.

[0134] Table 3 Comparison of model evaluation indicators

[0135]

[0136] Specifically, Figure 3 The above is the technical roadmap of this embodiment. The first stage is the data preparation stage, in which suitable training sets and test sets are screened out. Since the AIS data has individual noise points and uncertain frequency sizes, the AIS data is cleaned and interpolated. 10s is selected as the time step, and linear interpolation is used for interpolation. Finally, the data is normalized using five models: LSTM, BiLSTM, and LSTM-Transformer to eliminate the influence of dimensional results. The second stage is the comparative experiment stage, which includes nsformer, BiLSTM-Transformer, and PSO-BiLSTM-Transformer. The last stage uses MSE, MAE, ADE, and FD to evaluate the trajectory prediction of different models.

[0137] Fig. 9 The comparison chart of trajectory prediction results of different models is shown. It includes the true trajectory and the predicted trajectories of other different prediction models. From the enlarged view of the trajectory, it can be seen that the predicted trajectory of the PSO-BiLSTM-Transformer model is closest to the true trajectory, and the predicted trajectory of the unoptimized LSTM model is farthest from the true trajectory. Consistent with the order corresponding to the model evaluation indicators, the PSO-BiLSTM-Transformer model has the best prediction effect.

[0138] Specifically, compared with the traditional LSTM, the use of BiLSTM can consider both past and future information, so it can better understand the contextual information in the trajectory data, and can provide more comprehensive and accurate predictions in the trajectory prediction task, especially when processing long sequences and complex data relationships. Therefore, BiLSTM is selected as one of the structures for time series processing of the model in this embodiment; Transformer has a self-attention mechanism, which may have better parallelism, global attention ability, position encoding effect, adaptability and stability in the trajectory prediction task, so it may be more suitable for processing trajectory data in some cases, so Transformer is selected as one of the structures for time series processing of the model in this embodiment. Therefore, this embodiment combines BiLSTM with Transformer as an encoder, a linear layer as a decoder, and selects a particle swarm algorithm for model hyperparameter optimization. The PSO-BiLSTM-Transformer model can combine the advantages of BiLSTM and Transformer while selecting better hyperparameters, and can pay more attention to key position information in the trajectory while understanding the global information in the trajectory, thereby improving the prediction accuracy. At the same time, the loss function of this model is customized to make the predicted ship trajectory more consistent with the actual motion state of the ship, and to make the prediction result more conducive to improving the similarity between the entire predicted trajectory of the ship and the actual trajectory, rather than just the similarity of the position of a single trajectory point at the same time. The experiment predicted the trajectory of Qingdao Port and conducted a comparative experiment of various models. The experimental results verified that the effect of this model is better than the unoptimized model.

[0139] The BiLSTM-Transformer proposed in this embodiment combines the advantages of BiLSTM and Transformer, and can achieve a better balance between capturing local time dependencies and long-term global dependencies. In general, the combination of BiLSTM and Transformer can combine the advantages of both and solve some of the defects of these two models when performing trajectory prediction separately, showing stronger time series modeling capabilities, higher computing efficiency, better complex dependency capture capabilities, and stronger generalization capabilities.

[0140] The improved PBT model adopted in this embodiment applies the particle swarm model to optimize the hyperparameters of the BiLSTM and Transformer models, and customizes the model loss function. The loss function not only considers the trajectory point position factor but also the ship heading and ship speed factors, so that the predicted ship trajectory is more similar to the real trajectory and more in line with the actual motion state of the ship.

[0141] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A ship trajectory prediction method based on improved PBT, characterized in that: The steps include: S1: Obtain the time series data of the ship trajectory, clean it, and pre-process the cleaned time series data by linear interpolation and normalization methods in turn to obtain the pre-processed time series data of the ship trajectory; S2: Establishing a loss function of a ship trajectory prediction model based on a bidirectional long short-term memory network and a Transformer model; the loss function includes a mean square error, a distance difference between a predicted ship trajectory point and a previous moment trajectory point and a distance difference between a real ship trajectory point and a previous moment trajectory point, and a heading difference between a real trajectory point and a predicted trajectory point; S3: according to the preprocessed time series data of the ship trajectory, adopting a ship trajectory prediction model based on a bidirectional long short-term memory network and a Transformer model, and based on the loss function, training the ship trajectory prediction model to obtain a trained ship trajectory prediction model; In S3, the loss function is established as follows: LOSS=MSE+△distance+△course △and=and t -and t-1 △x=x t -x t-1 △distance=|distance1-distance2| △course=min(|course-course'|,2π-|course-course'|) Where: LOSS represents the loss function; MSE represents the mean square error, that is, the sum of the squares of the difference between the true value and the predicted value; △distance represents the distance difference; △course indicates the heading difference; Represents the horizontal coordinate of the predicted point at time t; The ordinate of the predicted point at time t; x t Represents the horizontal coordinate of the real point at time t; y t represents the ordinate of the real point at time t; △y represents the real ordinate difference; △x represents the real abscissa difference; △y′ represents the predicted ordinate difference; △x′ represents the predicted abscissa difference; distance1 represents the distance from the predicted trajectory point to the real trajectory point at the previous moment; distance2 represents the distance from the real trajectory point to the real trajectory point at the previous moment; course represents the heading of the real trajectory point; course' represents the heading of the predicted trajectory point; △course represents the heading difference between the real trajectory point and the predicted trajectory point; |·| represents the absolute value operation; Where: MSE represents the mean square error, that is, the sum of the squares of the differences between the true value and the predicted value; t represents the time; T represents the total number of time; u t represents the true value at time t, represents the predicted value at time t; S4: According to the trained ship trajectory prediction model, a trajectory vector is obtained after encoding the time series data of the ship trajectory to obtain the predicted trajectory of the ship, thereby realizing the prediction of the ship trajectory.

2. A ship trajectory prediction method based on improved PBT according to claim 1, characterized in that: In S4, the method used to obtain the trajectory vector after encoding the time series data of the ship trajectory is as follows: S41: According to the preprocessed time series data of the ship trajectory, the hidden state sequence of the time step is obtained, that is, the new latent vector H after splicing t ; S42: According to the hidden state sequence H of the time step t , obtain the trajectory vector after encoding the time series data of the ship trajectory.

3. A ship trajectory prediction method based on improved PBT according to claim 2, characterized in that: In S41, the hidden state sequence of the time step is obtained, that is, the new latent vector H after splicing t The method is as follows: Where: Represents the new latent vector at time t; represents the positive time direction latent vector at time t-1; represents the hidden vector in the opposite time direction at time t-1; P t The feature vector representing the input at time t is the data of the ship trajectory point at time t; H t represents the new latent vector after concatenation; LSTM(·) represents the input function of the LSTM layer.

4. A ship trajectory prediction method based on improved PBT according to claim 2, characterized in that: In S42, the formula used to obtain the trajectory vector after encoding the time series data of the ship trajectory is as follows: Where: e t Indicates H t and The concatenated vector is the trajectory vector after encoding the time series data of the ship trajectory; H t Represents the new latent vector after concatenation; Represents the position vector provided by the Transformer.

Citation Information

Patent Citations

  • Track prediction method and device based on binary coded representation and multi-classification

    CN115310677A

  • Method for predicting sailing trajectory of automatic ship identification system

    CN117131371A