A ship trajectory prediction method based on local loitering activity scenario
By preprocessing AIS data and using hybrid neural network models, especially the combination of 1D-CNN, BiGRU and BiLSTM, the problem of low accuracy in ship trajectory prediction under complex marine environments is solved, achieving high-precision ship position prediction and adapting to complex trajectories with short-term mutations and long-term evolution.
Patent Information
- Application Number
- CN202511093260.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-06
- Publication Date
- 2025-11-04
- Estimated Expiration
- 2045-08-06
AI Technical Summary
Existing technologies have low accuracy in predicting ship trajectories in complex marine environments, especially for high-frequency motion, strong spatial constraints, and long-term continuous nonlinear wandering behavior. Traditional models are unable to effectively capture the dynamic changes and complex evolution patterns of these behaviors.
AIS data preprocessing and a hybrid neural network model are used, including a 1D-CNN convolutional neural network to extract high-dimensional spatial features, a BiGRU to capture short-term trajectory dependencies, a BiLSTM to mine long-term evolution patterns, and MSE and Adam optimization. Trajectory prediction is performed through rolling prediction and dynamic updates.
It significantly improves the accuracy of ship position prediction in complex loitering scenarios, with a short-term prediction average error as low as 0.7 kilometers. It can effectively capture the trajectory patterns of various loitering patterns, providing key technical support for maritime supervision and navigation safety.
Smart Images

Figure CN120596854B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of intelligent maritime supervision, and particularly relates to a ship trajectory prediction method based on a local loitering activity scene. BACKGROUND
[0002] The continuous deepening of the global trade system has driven the shipping industry into a rapid development stage. At the same time, the exponential growth of water traffic has significantly increased the risk of maritime safety, and hidden dangers such as ship collision and illegal navigation not only cause significant economic losses, but also pose a continuous threat to the maritime safety system. Against this background, establishing a continuous dynamic monitoring mechanism for ships has become a core challenge for maritime supervision. As a key communication and navigation system for ship-shore cooperation, the Automatic Identification System (AIS) has shown important application value in maritime traffic research. The system transmits multi-dimensional data such as ship identification (name, ship type) and spatio-temporal state parameters (geographic coordinates, speed over ground SOG, course over ground COG), providing basic data support for ship behavior modeling and supervision decision-making.
[0003] It is worth noting that due to the combined effects of complex marine electromagnetic environment, equipment failure, signal shielding, and abnormal manual operation, AIS data often exhibits intermittent failure and information discontinuity. In addition, the special nature of maritime operations results in high-density reciprocating motion of ships within limited waters, generating nonlinear trajectory patterns, further exacerbating the technical challenges of continuous tracking.
[0004] Recent studies have shown that deep learning technology based on AIS big data can effectively model the linear trajectory characteristics of inter-port transportation and achieve satisfactory prediction accuracy in conventional shipping scenarios. However, maritime work ships (including engineering ships, research ships, and rescue ships) exhibit distinct motion patterns due to their operational characteristics, and their trajectories exhibit high-frequency motion, strong spatial constraints, and long-duration characteristics, forming high-density discrete point clusters with discontinuous mutations in space-time distribution. The dynamic mutation and complex evolution of such nonlinear trajectories expose the significant performance limitations of traditional prediction models, becoming a key technical bottleneck for intelligent maritime traffic supervision. In the field of ship motion pattern recognition, this nonlinear activity is referred to as loitering behavior, which is defined as long-time reciprocating motion with regular changes in heading within a specific area, exhibiting time duration, spatial aggregation, and motion dimensionality characteristics. SUMMARY
[0005] In view of the deficiencies in the background art, the purpose of the present application is to provide a ship trajectory prediction method based on local wandering activity scene, which is used to solve the problems of low accuracy and difficulty in ship trajectory prediction under complex wandering scene activity; the technical method mainly includes AIS original data extraction and preprocessing; constructing a hybrid neural network prediction model, and inputting data into the model for training and optimization; ship trajectory prediction and dynamic updating; the present application can significantly improve the accuracy of ship position prediction in future complex wandering scene, and provides important technical support for maritime supervision and navigation safety.
[0006] The technical scheme adopted by the present application is:
[0007] A ship trajectory prediction method based on local wandering activity scene, comprising the following steps:
[0008] S1. Obtain AIS data, and preprocess the data, which includes abnormal data detection and cleaning, trajectory reconstruction, feature engineering, time series segmentation, and division into a training set, a validation set and a test set;
[0009] S2. Construct a hybrid neural network prediction model: extract high-dimensional spatial features with a convolutional neural network 1D-CNN, capture short-term trajectory dependence with BiGRU, mine long-term evolution rules with BiLSTM, and output results with a fully connected layer;
[0010] S3. Train the hybrid neural network prediction model, input the training set into the hybrid neural network prediction model, and train and optimize it through MSE and Adam;
[0011] S4. Input the test set into the trained hybrid neural network prediction model, evaluate the accuracy through MSE, MAE, RMSE, SMAPE and AED, use rolling prediction for dynamic updating, calculate the actual distance error with the Haversine formula, and test the performance of the hybrid neural network prediction model;
[0012] S5. Use the trained hybrid neural network prediction model for trajectory prediction and dynamic updating.
[0013] Preferably, in step S1, the AIS data is obtained, the data is preprocessed, and the data is divided into a training set, a validation set and a test set, and the specific process is as follows:
[0014] AIS data is obtained, and wandering trajectories are selected from the obtained AIS data for relevant preprocessing:
[0015] First, abnormal detection and removal are performed, including multi-level filtering, syntax verification, domain constraint and motion verification;
[0016] Secondly, trajectory reconstruction is performed; when AIS trajectory data has missing latitude and longitude, the missing geospatial values are interpolated using piecewise linear function, and uniform time resampling is performed at intervals of one minute, as shown in equation (1):
[0017] (1)
[0018] wherein is the interpolated geospatial value, is the known geospatial coordinate at time t, is the time t, is the known geospatial coordinate at time t, is the known geospatial coordinate at time t;
[0019] Subsequently, feature engineering is performed around the wandering behavior characteristics of the wandering trajectory, and geospatial filtering is performed in the target experimental sea area to obtain a dataset containing four basic motion attributes , as shown in equation (2):
[0020] (2)
[0021] wherein is the trajectory point feature vector at time t, is the latitude of the ship at time t, is the longitude of the ship at time t, is the speed of the ship at time t, is the heading of the ship at time t, is the total time of the trajectory point; To clearly describe the wandering pattern of the wandering trajectory, a first-order turning angle difference is used as a behavior index, and is incorporated into the data attribute as an enhanced feature, as shown in equation (3):
[0022] (3) wherein
[0023] is the heading at time t; Each trajectory point is represented by a five-dimensional enhanced feature vector
[0024] ; the enhanced feature vector is then normalized by minimum-maximum scaling, as shown in equation (4):
[0025] (4)
[0026] (4)
[0027] wherein, denotes the feature mask vector, ensuring the scaled value is ; denotes the normalized feature value; denotes element-wise multiplication; denotes the feature vector; denotes the minimum value of the feature in the time series; denotes the maximum value of the feature in the time series;
[0028] Then, time series segmentation is performed; a sliding window method is used to construct the input-output pair (X, Y), as shown in equation (5):
[0029] (5)
[0030] wherein, is the historical context window, is the prediction horizon, and N is the total trajectory length; the sliding step is fixed at 1 timestamp to maximize the time resolution; is the input-output pair (X, Y) dataset; is the input; is the output;
[0031] Finally, the processed dataset is divided into training, validation, and test sets in the ratio of 8:1:1.
[0032] Preferably, in step S2, a hybrid neural network prediction model is constructed, and the specific steps are as follows:
[0033] ① The training set is input into the convolutional neural network 1D-CNN for high-dimensional spatial feature extraction; a one-dimensional convolution kernel is used to calculate the training set data, which is dot producted with the convolution kernel and passed through a nonlinear activation function to obtain the output high-dimensional feature data , as shown in equation (6):
[0034] (6)
[0035] wherein denotes the output high-dimensional feature data, is the input training set data, is the weight of the convolution kernel, which transforms the input feature dimension to a 128-dimensional high-dimensional vector; b is the bias term of the convolution kernel, is a nonlinear activation function;
[0036] wherein, The definition formula of the activation function is shown in equation (7):
[0037] (7)
[0038] In the formula is the output result of the activation function, is the larger value;
[0039] ②The high-dimensional feature data is imported into the BiGRU neural network model, and the short-term trajectory dependence is captured through the bidirectional time processing mechanism. The BiGRU neural network model is composed of two single-direction GRU units in opposite directions. One single-direction GRU unit is composed of a reset gate and an update gate . The specific calculation process is described as follows:
[0040] The reset gate determines how to combine the new input data information with the previous memory. When the reset gate is closed, the GRU unit effectively forgets the previous calculation and returns to the state when the first input sequence is read. The formula is shown in equation (8):
[0041] (8)
[0042] The update gate decides the activation state of the GRU unit and the degree of update content. The formula is shown in equation (9):
[0043] (9)
[0044] Next, the reset gate is applied to the vector, and the obtained result is multiplied by to form a splicing vector with . Then, the result is converted into a vector with element values between -1 and 1 through the tanh function, so as to obtain the candidate hidden state value . Then, the update gate is combined with the previous hidden state vector and the candidate hidden state value to obtain the hidden state vector at the time t. The formula is shown in equations (10) and (11):
[0045] (10)
[0046] (11)
[0047] In equations (8)-(11), , , This represents the bias term for the corresponding gate. , , This represents the weight term for the corresponding gate. This indicates element-wise multiplication. Here, is the sigmoid activation function, and tanh is the hyperbolic tangent function. Let be the hidden state vector from the previous time step. The convolutional features at the current time step;
[0048] Based on the characteristic of the BiGRU neural network model that simultaneously considers both forward and backward time series information, the forward output... It is the current input The state of the previous moment Determined, reverse output It is the current input and the state at the next moment The determination is made; the calculation formulas are shown in equations (12)-(14):
[0049] (12)
[0050] (13)
[0051] (14)
[0052] in, Represents timestamp Forward / reverse hidden states, This indicates that the forward GRU cell gated cyclic cell is being calculated. This indicates backward GRU cell gated cyclic cell computation. This represents the vector concatenation operator. This is the output of the BiGRU neural network model;
[0053] ③ Output results after processing The system encapsulates the ship's real-time motion dynamics and its historical context information. These features are then passed to downstream BiLSTM layers to extract the long-term evolution patterns implicit in the trajectory. Building upon the short-term modeling of BiGRU, the input gate, forget gate, and output gate of iLSTM selectively retain key historical states, while mitigating the vanishing / exploding gradient phenomenon in long sequence training. Its bidirectional design is consistent with BiGRU, handling both forward and backward sequence context. The specific computation process is described below:
[0054] Forgotten Gate The amount of information controlled by the memory unit at the previous moment, i.e., to decide which information to remember or forget, the calculation formula is shown in equation (15):
[0055] (15)
[0056] Input gate The amount of information controlled by the memory unit update, i.e., to decide which information is important to remember; is the candidate vector generated by the tanh layer, and will be fused with the memory unit state at the previous moment to update the current state, the calculation formula is shown in equations (16)-(18):
[0057] (16)
[0058] (17)
[0059] (18)
[0060] Output gate The amount of information controlled by the output to the next hidden state, i.e., to decide which information to pass; the output value is passed to the hidden state of the next unit , the calculation formula is shown in equations (19)-(20):
[0061] (19)
[0062] (20)
[0063] In equations (15)-(20), , , , respectively represent the weight matrix of the forget gate, the input gate, the candidate vector, and the output gate, , , , represent the corresponding bias term, denotes element-wise multiplication (Hadamard product), is the Sigmoid activation function, and tanh is the hyperbolic tangent function, denotes the BiGRU output result at the current moment, denotes the current memory unit state;
[0064] Similarly, the above formula is the one-way LSTM model formula, and the BiLSTM calculation formula is shown in equations (21)-(23):
[0065] (21)
[0066] (22)
[0067] (23)
[0068] wherein, denotes the vector concatenation operator, denotes the hidden state to represent short-term contextual information, denotes the memory cell state to encode long-term memory, denotes the BiLSTM layer output result, denotes the memory cell state of the forward LSTM at time t, denotes the hidden state vector of the forward LSTM at time t, denotes the forward LSTM computation function, denotes the memory cell state of the forward LSTM at the previous time t-1, denotes the hidden state vector of the forward LSTM at time t-1, denotes the memory cell state of the backward LSTM at time t, denotes the memory cell state of the backward LSTM at the previous time t-1, denotes the hidden state vector of the backward LSTM at time t, denotes the hidden state vector of the backward LSTM at time t-1, denotes the backward LSTM computation function;
[0069] The processed output result encapsulates multi-scale temporal dynamic information, which is then transmitted to the fully connected layer for the output of the final result, and the calculation formula is shown in equation (24):
[0070] (24)
[0071] wherein, and represent the weights and biases of the fully connected layer, respectively, denotes the output result of the fully connected layer.
[0072] Preferably, in the step S3, the specific steps of training the hybrid neural network prediction model are as follows:
[0073] The mean square error is used to optimize the large deviation of the predicted trajectory, the learning rate is dynamically adjusted by the Adam optimizer, and the Dropout is introduced to suppress overfitting; the input validation set is used for testing during the training process, and the validation set loss is monitored to use the early stopping mechanism to save the optimal weights;
[0074] The formula for optimizing the predicted trajectory is shown in equation (25):
[0075] (25)
[0076] wherein, for the mean square error, for the true label of the th sample, for the model prediction value of the th sample.
[0077] Preferably, in step S4, the test set is input into the trained hybrid neural network prediction model, the accuracy is evaluated by MSE, MAE, RMSE, SMAPE and AED, dynamic updating is performed by rolling prediction, and the actual distance error is calculated by the Haversine formula. The specific steps are as follows:
[0078] The test set is input into the trained hybrid neural network prediction model to obtain the prediction result of the test set, and the prediction result is compared with the true value. Five evaluation indexes, including mean square error, mean absolute error, root mean square error, symmetric average absolute percentage error and average Euclidean distance, are used to evaluate the accuracy of the prediction, and the performance of the hybrid neural network prediction model is also tested.
[0079] The MSE formula is shown in equation (25), and the specific formulas of other indexes are shown in equations (26)-(29):
[0080] (26)
[0081] (27)
[0082] (28)
[0083] (29)
[0084] wherein, is the sequence number of the input trajectory, is the number of samples of the data, is the true value of the th data, is the prediction value of the th data, is the mean absolute error, is the root mean square error, is the symmetric average absolute percentage error, is the average Euclidean distance.
[0085] In addition, in order to better evaluate the prediction performance of the model in actual application, the rolling prediction method is used for dynamic updating. In order to more intuitively represent the error between the model prediction data and the actual data, the Haversine formula is used to calculate the actual distance between the predicted trajectory point and the actual trajectory point, and the calculation formula is shown in equation (30):
[0086] (30)
[0087] wherein, is the actual distance between two points; is the average radius of the earth; and are the geographic coordinates of the actual and predicted points, respectively, in radians; and are the latitude and longitude differences between the predicted and actual points, respectively.
[0088] Compared with the prior art, the present application proposes a ship trajectory prediction method based on a local wandering activity scenario, which has the following advantages:
[0089] The present application aims to solve the problem of ship trajectory prediction in complex wandering scenarios, and achieves high-precision prediction through multi-module cooperation: AIS data preprocessing is filtered through multiple layers, interpolated and reconstructed, feature engineering and sequence segmentation to ensure the quality and structure of the input data; hybrid neural network fuses 1D-CNN to extract local spatial features, BiGRU to capture short-term dynamics, and BiLSTM to mine long-term evolution rules, multi-scale feature fusion to solve the problem of insufficient nonlinear modeling; during training, MSE loss and Adam optimization are used, combined with Dropout and early stopping mechanism to improve the robustness of the model; the prediction stage supports single-step and rolling multi-step prediction, combined with real-time data to dynamically calibrate errors. Experiments show that its prediction accuracy in complex wandering scenarios is significantly better than that of traditional models, with an average error of as low as 0.7 kilometers in short-term prediction, which can effectively capture the trajectory rules of various wandering forms, providing key technical support for maritime supervision and navigation safety, especially in local spatiotemporal information capture and generalization ability, and has strong adaptability to complex trajectory prediction coupled with short-term mutation and long-term evolution. BRIEF DESCRIPTION OF DRAWINGS
[0090] Figure 1 is the overall flowchart of the ship trajectory prediction method based on the local wandering activity scenario of the present application;
[0091] Figure 2 is the BiGRU model structure diagram proposed by the present application;
[0092] Figure 3 is the BiLSTM model structure diagram proposed by the present application;
[0093] Figure 4 is the optimal parameter setting diagram of the hybrid neural network prediction model experiment;
[0094] Figure 5 is the experimental results and evaluation index diagram of the hybrid neural network prediction model;
[0095] Figure 6A box plot of trajectory prediction errors of the hybrid neural network prediction model proposed in the application and other models. DETAILED DESCRIPTION
[0096] The technical solutions in the embodiments of the application will be further described in detail below with reference to the drawings in the embodiments of the application. It should be noted that the described embodiments are only some of the embodiments of the application, not all the embodiments. Based on the embodiments in the application, all other embodiments obtained by those skilled in the art without creative work fall within the scope of protection of the application.
[0097] In order to make the application purposes, technical solutions and advantages of the application more clear, the embodiments of the application will be further described in detail below with reference to the drawings of the specification: In order to more clearly understand the above-mentioned purposes, features and advantages of the application, the advantages of the application will be further described by comparing embodiments with reference to the drawings and specific embodiments.
[0098] The application proposes a ship trajectory prediction method based on local loitering activity scene, as shown in the overall flowchart, the steps of the method are described in detail: Figure 1
[0099] S1. Obtain AIS data, and pre-process the data, the pre-processing includes abnormal data detection and cleaning, trajectory reconstruction, feature engineering, time series segmentation, and division into a training set, a validation set and a test set;
[0100] Specifically, in step S1, AIS data is obtained, the data is selected and pre-processed, and is divided into a training set, a validation set and a test set, and the specific process is as follows:
[0101] AIS data is obtained, and loitering trajectories are selected from the obtained AIS data, and the loitering trajectory data is pre-processed:
[0102] Firstly, abnormal detection and removal are performed, including maritime mobile service identity (MMSI), geographic space coordinates (longitude, latitude), SOG and COG, and multi-level filtered AIS original records: syntax verification: remove data with MMSI not being 9 digits; domain constraint: retain latitude φ∈[-180°, 180°], longitude λ∈[-90°, 90°], SOG∈[0, 30 knots], COG∈[0°, 360°]; motion verification: eliminate points with instantaneous speed exceeding 30 knots (derived from consecutive positions) and turning angle exceeding 135° (calculated by vector cross product);
[0103] Secondly, trajectory reconstruction is performed; when AIS trajectory data is missing in longitude and latitude due to signal loss, etc., the missing geographic space values are interpolated using a piecewise linear function, and the trajectory is reconstructed by connecting the interpolated points and the original points. The missing geographic coordinates in the trajectory reconstruction are filled in and the time consistency is ensured by evenly time resampling with one-minute interval, as shown in formula (1).
[0104] (1)
[0105] wherein is the interpolated geographic spatial value, is the known geographic spatial coordinate (longitude or latitude) at time t, is the time t, is the known geographic spatial coordinate (longitude or latitude) at time t; Subsequently, the feature engineering operation is performed on the loitering behavior characteristics of the loitering trajectory, and the loitering behavior characteristics are enhanced by the geographic space filtering in the target experimental sea area
[0106] The dataset containing four basic motion attributes standardizes the basic feature dimension of the trajectory data, as shown in formula (2):
[0107] (2)
[0108] wherein is the trajectory point feature vector at time t, is the latitude of the ship at time t, is the longitude of the ship at time t, is the speed at time t, is the heading at time t, is the total time of the trajectory point; In order to clearly describe the loitering mode of the loitering trajectory, the first-order turning angle difference is used as a behavior index, and the data attribute is integrated as an enhanced feature to enhance the loitering behavior characteristics, as shown in formula (3):
[0109] (3) wherein
[0110] is the heading at time t; Each trajectory point is represented by a five-dimensional enhanced feature vector
[0111] ; the enhanced feature vector is then normalized by the minimum-maximum scaling, as shown in formula (4):
[0112]
[0113] (4)
[0114] wherein, denotes the feature mask vector, ensuring the scaled value is ; denotes the normalized feature value; denotes element-wise multiplication; denotes the feature vector; denotes the minimum value of the feature in the time series; denotes the maximum value of the feature in the time series;
[0115] Then, time series segmentation is performed; a sliding window method is used to construct input-output pairs (X, Y), as shown in equation (5):
[0116] (5)
[0117] wherein, is the historical context window, is the prediction horizon, and N is the total trajectory length; the sliding step is fixed at 1 timestamp to maximize the time resolution; is the input-output pair (X, Y) dataset; is the input; is the output;
[0118] Finally, the processed dataset is divided into training, validation, and test sets in a ratio of 8:1:1.
[0119] S2. Constructing a hybrid neural network prediction model: extracting high-dimensional spatial features with a convolutional neural network 1D-CNN, capturing short-term trajectory dependencies with BiGRU, mining long-term evolution rules with BiLSTM, and outputting results with a fully connected layer;
[0120] Specifically, in step S2, a hybrid neural network prediction model is constructed, and the specific steps are as follows:
[0121] ① 1D-CNN is a variant of CNN, which is used as the main spatial feature extractor and is specifically designed to process sequence trajectory data through convolution operations; the training set is input into the convolutional neural network 1D-CNN for high-dimensional spatial feature extraction, effectively capturing short-range spatial dependencies and transient patterns in navigation trajectories, thereby enhancing the potential spatial representation of input data; the convolution layer, as the core component of CNN, uses a one-dimensional convolution kernel (size 3, step 1, padding 1, channel number 128) to calculate the training set data, performs dot product operations with the convolution kernel, and passes the output through a nonlinear activation function to obtain the output high-dimensional feature data , as shown in equation (6):
[0122] (6)
[0123] wherein ( is the time step, and 128 is the feature dimension) represents the output of the high-dimensional feature data, is the input training set data, is the weight of the convolution kernel, which transforms the dimension of the input feature into a high-dimensional vector of 128 dimensions; is the bias term of the convolution kernel, is a nonlinear activation function, which effectively suppresses negative interference, alleviates the gradient vanishing problem, and improves the convergence efficiency of the model;
[0124] wherein, The definition formula of the activation function is shown in formula (7):
[0125] (7)
[0126] wherein is the output result of the activation function, is the larger value;
[0127] ②The high-dimensional feature data is imported into the BiGRU neural network model, which uses its precise gating structure (including reset gate and update gate) to capture short-term trajectory dependency relationships, dynamically regulates information flow while preserving key recent states. The BiGRU neural network model is composed of two single-direction GRU units in opposite directions. The forward GRU moves from the beginning to the end of the sequence, and its hidden state is determined by the current input and the previous state. The reverse GRU moves from the end to the beginning of the sequence, and its hidden state is determined by the current input and the next state. The bidirectional structure can analyze the forward (time sequence) and backward (review) sequence context at the same time, thereby enhancing the model's ability to detect transient motion changes (such as high-frequency position / velocity fluctuations) in ship lingering behavior. A single-direction GRU unit is composed of a reset gate and an update gate The specific calculation process is described as follows:
[0128] The reset gate determines how to combine new input data information with previous memory. When the reset gate is closed, the GRU unit effectively forgets the previous calculation and returns to the state when the first input sequence is read, thereby achieving the purpose of resetting. The formula is shown in formula (8):
[0129] (8)
[0130] The update gate The activation state of the GRU unit and the degree of update content are determined, and the formula is shown in equation (9):
[0131] (9)
[0132] Next, the reset gate is applied to the vector, and the result is multiplied by to form a spliced vector with , and then the result is converted to a vector with element values between -1 and 1 through the tanh function, thereby obtaining the candidate hidden state value , combined with the update gate , the hidden state vector at the previous moment is weighted and fused with the candidate hidden state value , thereby obtaining the hidden state vector at the moment, the formula is shown in equations (10) and (11):
[0133] (10)
[0134] (11)
[0135] In equations (8)-(11), , , denote the bias term of the corresponding gate, , , denote the weight term of the corresponding gate, denotes element-wise multiplication (Hadamard product), is the Sigmoid activation function, and tanh is the hyperbolic tangent function, is the hidden state vector at the previous moment, is the convolution feature at the current moment;
[0136] The above one-way GRU unit only records information in one direction, while the BiGRU neural network model considers both forward and backward time series information, further improving the ability to capture short-term dynamic changes; the forward output is determined by the current input and the state at the previous moment, and the reverse output is determined by the current input and the state at the next moment; the BiGRU structure diagram is shown in Figure 2 , and the calculation formula is shown in equations (12)-(14):
[0137] (12)
[0138] (13)
[0139] (14)
[0140] in, Represents timestamp Forward / reverse hidden states, This indicates that the forward GRU cell gated cyclic cell is being calculated. This indicates backward GRU cell gated cyclic cell computation. This represents the vector concatenation operator. This is the output of the BiGRU neural network model;
[0141] ③ Output results after processing The system encapsulates the ship's real-time motion dynamics and its historical context information. These features are then passed to downstream BiLSTM layers to extract the long-term evolution patterns hidden in the trajectory. Building upon the short-term modeling of BiGRU, the BiLSTM network addresses the long-term dependency problem through its precise memory gating architecture. The input, forget, and output gates of BiLSTM selectively retain key historical states while mitigating the vanishing / exploding gradient phenomenon in long-sequence training. Its bidirectional design, consistent with BiGRU, simultaneously processes both forward and backward sequence contexts, comprehensively analyzing the multi-stage heading change patterns in the ship's lingering behavior. This bidirectional flow analysis enables the network to decode continuous trajectory patterns spanning long periods (such as periodic reciprocating motion and multi-stage heading evolution) that traditional unidirectional architectures cannot capture. Specifically, the BiLSTM structure diagram is as follows: Figure 3 As shown, the calculation process is described in detail below:
[0142] Forgotten Gate The amount of information used by the memory units in the previous moment is controlled, that is, it determines which information to remember or forget, and the calculation is shown in equation (15):
[0143] (15)
[0144] Input gate Controlling the amount of information updated in memory units, that is, deciding which information is more important and needs to be memorized; It is a candidate vector generated by the tanh layer, and it will be compared with the state of the memory unit at the previous time step. The current state is updated by merging, and the calculation formulas are shown in equations (16)-(18):
[0145] (16)
[0146] (17)
[0147] (18)
[0148] Output gate controls the amount of information output to the next hidden state, i.e., determines the information to be passed; the output value is passed to the hidden state of the next cell , the calculation formula is shown in formula (19)-(20):
[0149] (19)
[0150] (20)
[0151] In formula (15)-(20), , , , respectively represent the weight matrix of the forget gate, the input gate, the candidate vector, and the output gate, , , , represent the corresponding bias terms, denotes element-wise multiplication (Hadamard product), is a Sigmoid activation function, and tanh is a hyperbolic tangent function, denotes the BiGRU output result at the current moment, denotes the current memory cell state;
[0152] Similarly, the above formula is a unidirectional LSTM model formula, and the BiLSTM calculation formula is shown in formula (21)-(23):
[0153] (21)
[0154] (22)
[0155] (23)
[0156] wherein, denotes a vector concatenation operator, denotes a hidden state to represent short-term context information, denotes a memory cell state to encode long-term memory, denotes a BiLSTM layer output result, denotes the memory cell state of the forward LSTM at moment, denotes the memory cell state of the forward LSTM at the hidden state vector at time t, denotes a forward LSTM computation function, denotes the memory cell state of the forward LSTM at the previous time step, denotes the memory cell state of the forward LSTM at the previous time step, denotes a backward LSTM computation function;
[0157] the processed output result encapsulates multi-scale temporal dynamic information, which is then transmitted to a fully connected layer for output of a final result, and the calculation formula is shown in equation (24):
[0158] (24)
[0159] wherein, and represent the weights and bias of the fully connected layer, respectively, represent the output result of the fully connected layer;
[0160] S3. Train the hybrid neural network prediction model, input the training set into the hybrid neural network prediction model, and train and optimize through MSE and Adam;
[0161] Specifically, in the step S3), the specific steps of training the hybrid neural network prediction model are as follows:
[0162] The mean square error (MSE) is used to strengthen the optimization of the large deviation of the predicted trajectory, the learning rate is dynamically adjusted through the Adam optimizer, and the Dropout is introduced to suppress overfitting; a verification set is input during the training process for testing, and the verification set loss is monitored to use the early stopping mechanism to save the optimal weights;
[0163] Relying on GPU parallel computing to accelerate the training, ensure the efficient convergence of the model, and the formula for optimizing the predicted trajectory is shown in equation (25):
[0164] (25)
[0165] wherein, is the mean square error, is the true label of the i-th sample, is the model prediction value of the i-th sample.
[0166] S4. The test set is input into the trained hybrid neural network prediction model to evaluate accuracy by MSE, MAE, RMSE, SMAPE, and AED, and to dynamically update by rolling prediction, and to test the performance of the hybrid neural network prediction model by calculating the actual distance error by the Haversine formula;
[0167] Specifically, in step S4), the test set is input into the trained hybrid neural network prediction model to obtain a prediction result, and the specific steps are as follows:
[0168] The test set is input into the trained hybrid neural network prediction model to obtain a prediction result, and the prediction result is compared with the true value. Five evaluation indexes are used to evaluate the accuracy of the prediction, and the performance of the hybrid neural network prediction model is also tested. The five evaluation indexes are introduced as follows:
[0169] Mean Squared Error (MSE): measures the average squared difference between predicted and actual values, sensitive to large errors;
[0170] Mean Absolute Error (MAE): calculates the average absolute error, simple and robust to outliers;
[0171] Root Mean Squared Error (RMSE): square root of the mean squared error, reflects the error in the original data unit, and emphasizes the influence of large errors;
[0172] Symmetric Mean Absolute Percentage Error (SMAPE): normalized relative error, ensures the symmetry of overestimation and underestimation;
[0173] Average Euclidean Distance (AED): calculates the average Euclidean distance between predicted and actual trajectory points, suitable for spatial error analysis;
[0174] The MSE formula is shown in equation (25), and the specific formulas of other indexes are shown in equations (26)-(29):
[0175] (26)
[0176] (27)
[0177] (28)
[0178] (29)
[0179] wherein, is the sequence number of the input trajectory, is the number of data samples, is the true value of the th data, is the predicted value of the th data, is the mean absolute error, is the root mean square error, is the symmetric mean absolute percentage error, is the mean Euclidean distance;
[0180] In addition, in order to better evaluate the prediction performance of the model in practical application, a rolling prediction method is adopted for dynamic updating; rolling prediction is a dynamic strategy in which each prediction result is used as input for the next prediction step, thereby enabling multi-step prediction across consecutive time intervals; this method more realistically simulates real-world scenarios, as the model continuously updates its input and makes sequential predictions over time; in order to more intuitively represent the error between the model's predicted data and the actual data, the Haversine formula is used to calculate the actual distance between the predicted trajectory points and the actual trajectory points, as shown in formula (30):
[0181] (30)
[0182] wherein, is the actual distance between two points (unit: kilometers); is the average radius of the Earth (unit: kilometers); and are the geographic coordinates (latitude, longitude) of the actual point and the predicted point, respectively, in radians; and are the latitude difference and the longitude difference between the predicted point and the actual point, respectively.
[0183] S5. Using the trained hybrid neural network prediction model for trajectory prediction and dynamic updating.
[0184] Experimental simulation verification and analysis of the present application:
[0185] For the proposed ship trajectory prediction method based on local loitering activity scenarios, an experiment was designed and operated to verify the effectiveness and stability of the method; the present application uses AIS data from Sagami Bay, Japan (latitude 34.9 to 35.3 degrees north, longitude 139.2 to 139.6 degrees east); this area is a marine area characterized by high-density ship interactions and diverse operational modes, with frequent observations of ship loitering behavior involving fishing boats, patrol boats, yachts, and other types of ships; by extracting 178 trajectories with loitering characteristics from 439,338 original AIS record samples, the data set was obtained through the aforementioned preprocessing steps, with a downsampling time setting of 2 minutes; due to empirical verification, a proportionally allocated hierarchical data set division was used: 80% of the training subset (n=142 trajectories), 10% of the validation (n=18), and 10% of the test (n=18). This division method ensures robust model evaluation while maintaining spatiotemporal continuity within the subsets;
[0186] In the training process, to avoid oscillation in the training process and achieve the best effect, the batch size is set to 32, the initial learning rate is set to 0.0001; the Adam optimizer is adopted, which can adaptively adjust the learning rate of each parameter, has stability and rapid convergence, so that the model gradually approaches the optimal solution; in the training process, the core task is to minimize the loss function by continuously adjusting the model parameters, thereby improving the prediction accuracy; the MSE is selected as the loss function because it is sensitive to large deviations and can impose stricter penalties on outliers and large deviations, especially suitable for the modeling requirements of ship lingering trajectories in this study; in addition, to effectively suppress overfitting, the early stopping mechanism is introduced: after each training cycle, the performance of the model on the validation set is monitored, and if the validation loss does not decrease for 5 consecutive rounds, the training is terminated and the model weight with the smallest loss is saved, ensuring that the training process ends under optimal conditions; in addition, through multiple experimental experiences, the optimal parameter settings of the model structure are obtained as follows Figure 4 ;
[0187] The five evaluation indicators used are shown in equations (25-29), which aim to measure the deviation between the actual value and the predicted value; the smaller the value of each indicator, the higher the prediction accuracy; all reported experimental results are the average values of all trajectories in the test set, Figure 5 The experimental results are shown in Table 1; from the prediction results, the proposed method achieves the minimum value (highlighted in bold) on all evaluation indicators, indicating its overall advantage over other methods; although some classic models (such as BiGRU and CNN-BiLSTM) perform well on some indicators, they show significant advantages in both individual indicators and overall performance; in particular, its SMAPE and AED values (0.0053 and 0.0034, respectively) have high sensitivity to small errors and can effectively suppress error fluctuations, showing strong ability in handling fine-grained prediction tasks; in addition, compared with the original model, the model containing the CNN layer shows significant improvement, reflecting the importance of CNN-based feature extraction;
[0188] In addition, the dynamic update experiment based on rolling prediction selects 18 ship trajectory data in the test set for rolling prediction, including 7 regular reciprocating trajectories, 5 random surrounding trajectories, 5 disordered turning trajectories, and 1 lasso trajectory; for each trajectory, the experiment randomly selects input data and inputs the model for rolling prediction; after each prediction, the output result of the model will be used as the input of the next prediction, until the whole trajectory prediction process is completed, and the error is calculated by formula (30); in order to ensure the reliability of the experimental results, the experiment is repeated 50 times, and each time the starting point and time window are randomly selected for prediction; finally, the prediction errors of all experimental trajectories are summarized to calculate the average error, so as to evaluate the prediction performance of the model; in addition, in order to intuitively show the error distribution of the model under different prediction steps, the application draws the box plot of ship trajectory prediction error, as shown in FIG. 8. Figure 6
[0189] Although the preferred embodiments of the present application have been described, those skilled in the art can make additional changes and modifications to the embodiments once they know the basic inventive concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications falling within the scope of the present application.
[0190] Obviously, those skilled in the art can make various modifications and variations to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalent technologies, the present application also intends to include these modifications and variations.
Claims
1. A ship trajectory prediction method based on a local loitering activity scenario, characterized by, Comprise the following steps: S1. Obtain AIS data, preprocess the data, including anomaly detection and cleaning, trajectory reconstruction, feature engineering, time series segmentation, and division into training set, validation set and test set; Obtain AIS data, select wandering trajectory from the obtained AIS data, and perform relevant preprocessing: First, perform anomaly detection and removal, including multi-level filtering, syntax verification, domain constraint, and motion verification; Secondly, trajectory reconstruction is carried out; when the AIS trajectory data has missing latitude and longitude, the missing geospatial values are interpolated using a piecewise linear function, and the AIS trajectory data is uniformly time resampled at intervals of 1 minute, as shown in formula (1): minute intervals, as shown in formula (1): (1) wherein is the interpolated geospatial value, is is the geospatial coordinate known at time t, is the time t, is is the geospatial coordinate known at time t; Subsequently, feature engineering operation is performed on the wandering behavior features around the wandering trajectory, and the target experimental sea area Geospatial filtering is performed to obtain a dataset containing 4 basic motion attributes , as shown in formula (2): (2) wherein is the first is the time of the trajectory point feature vector, is the latitude of the ship at the time is the latitude of the ship at the time is the longitude of the ship at the time is the longitude of the ship at the time is the speed of the ship at the time is the speed of the ship at the time is the heading of the ship at the time is the heading of the ship at the time is the total time of the trajectory point; To make clear the wandering pattern of the wandering trajectory, the first-order corner difference As a discriminative behavior indicator, the data attribute is integrated as an enhanced feature, and the formula is shown in equation (3): (3) In the formula is heading at the moment Each trajectory point takes a five-dimensional augmented feature vector denotes; augmented feature vector is then normalized by min-max scaling, as shown in equation (4): (4) wherein, denotes a feature mask vector, ensuring that the scaled value is ; denotes a normalized feature value; denotes element-wise multiplication; denotes a feature vector; denotes the minimum value of a feature in a time series; denotes the maximum value of a feature in a time series; Then, time series segmentation is performed; a sliding window method is used to construct input-output pairs The formula is shown in equation (5): (5) wherein, is the history context window, is the predicted horizon, is the total trajectory length; the sliding step is fixed to 1 timestamp to maximize the temporal resolution; is the input-output pair dataset; is the input; is the output; Finally, divide the processed data set into training set, validation set and test set according to the proportion 8:1:1; S2. Construct a hybrid neural network prediction model: extract high-dimensional spatial features with a convolutional neural network 1D-CNN, capture short-term trajectory dependencies with BiGRU, and mine long-term evolution rules with BiLSTM, and output results with a fully connected layer; S3. Train the hybrid neural network prediction model, input the training set into the hybrid neural network prediction model, and train and optimize it through MSE and Adam; S4. Input the test set into the trained hybrid neural network prediction model, evaluate the accuracy through MSE, MAE, RMSE, SMAPE, and AED, dynamically update it using rolling prediction, calculate the actual distance error using the Haversine formula, and test the performance of the hybrid neural network prediction model; S5. Use the trained hybrid neural network prediction model to predict and dynamically update the trajectory.
2. The ship trajectory prediction method based on local loitering activity context according to claim 1, characterized in that, In step S2, the hybrid neural network prediction model is constructed, and the specific steps are as follows: ①The training set is input into the convolutional neural network 1D-CNN for high-dimensional space feature extraction, a one-dimensional convolution kernel is used to calculate the training set data, the one-dimensional convolution kernel is subjected to point multiplication operation with the training set data, and the output high-dimensional feature data is obtained through a nonlinear activation function , as shown in formula (6): (6) In the formula represents the output of the high-dimensional feature data, is the input training set data, is the weight of the convolution kernel, which transforms the dimension of the input feature into a 128-dimensional high-dimensional vector; is the bias term of the convolution kernel, is a nonlinear activation function; wherein, The activation function is defined as follows: (7) In the formula is The output result of the activation function, is the larger value; ②The high-dimensional feature data is imported into the BiGRU neural network model, and the short-term trajectory dependency is captured through a bidirectional time processing mechanism. The BiGRU neural network model is composed of two opposite unidirectional units. One unidirectional unit is composed of a reset gate and an update gate, and the specific calculation process is described as follows: reset gate determine how to combine the new input data information with the previous memory when the reset gate is closed, The unit effectively forgets the previous computation and returns to the state when the first input sequence is read, as shown in equation (8): (8) Updating gate Decide The activation state of the unit and the degree of updating content, formula as shown in equation (9): (9) Next, the reset gate is applied to the input vector, and the result is multiplied by a sigmoid function to form a gating vector whose elements are between 0 and 1 . The result is then passed through a tanh function to convert the result to a vector whose elements are between -1 and 1, thereby obtaining a candidate hidden state value . Next, the update gate is applied to the previous time hidden state vector and the candidate hidden state value , and a weighted fusion is performed thereon, thereby obtaining the hidden state vector at the current time , as shown in equations (10) and (11) below: (10) (11) In formulas (8)-(11), , , denotes a bias term for the corresponding gate, , , denotes a weight term for the corresponding gate, denotes element-wise multiplication, is a Sigmoid activation function, and tanh is a hyperbolic tangent function, is a hidden state vector at the previous time step, is a convolutional feature at the current time step; Based on the BiGRU neural network model, the characteristics of the forward and reverse time series information are considered simultaneously, the forward output is determined by the current input and the state at the previous moment, and the reverse output is determined by the current input and the state at the next moment; the calculation formula is as follows: (12) (13) (14) wherein, denotes a forward / backward hidden state denotes a forward / backward hidden state denotes a forward cell-gated recurrent unit computation denotes a backward cell-gated recurrent unit computation denotes a vector concatenation operator is a BiGRU neural network model output result; iii. The output result after processing The instantaneous motion dynamics of the encapsulated ship and its historical context information; these features are then passed to the downstream BiLSTM layer for extracting the long-term evolution rules implied in the trajectory, and on the basis of the BiGRU short-term modeling, the input gate, the forget gate, and the output gate of the iLSTM selectively retain the key historical state, while relieving the gradient vanishing / explosion phenomenon in long sequence training; its bidirectional design is consistent with the BiGRU, which simultaneously processes the forward and backward sequence context, and the calculation process is described as follows: forgetting gate The amount of use of the memory cell information at the previous time, that is, which information to remember or forget, is determined by calculating as shown in Equation (15). (15) Input gate The information quantity of the control memory cell update, that is, to determine which information is important and needs to be remembered; The candidate vector generated by the tanh layer, and the memory cell state Fusion to update the current state, the calculation formula is as follows: (16) (17) (18) Output gate Controlling the amount of information output to the next hidden state, i.e., deciding what information to pass; the output value is passed to the hidden state of the next cell The calculation formula is as follows: (19) (20) In formulas (15)-(20), , , , respectively represent the weight matrix of the forget gate, the input gate, the candidate vector, and the output gate, , , , represent the corresponding bias terms, represents element-wise multiplication, is a Sigmoid activation function, and tanh is a hyperbolic tangent function, represents the BiGRU output result at the current moment, represents the current memory cell state; Similarly, the above formula is a one-way LSTM model formula, and the BiLSTM calculation is formalized as: (21) (22) (23) in, This represents the vector concatenation operator. Hidden states are used to represent short-term contextual information. Indicate the state of memory units to encode long-term memory. This represents the output of the BiLSTM layer. Indicating a forward LSTM in The state of the memory unit at any given moment. Indicating a forward LSTM in The hidden state vector at time step 1. This indicates that the forward LSTM computes the function. This indicates that the positive LSTM was in the previous time step. The state of the memory unit, This indicates that the positive LSTM was in the previous time step. The hidden state vector at time step 1. Indicates the inverse LSTM computation function; Processed output result The multi-scale temporal dynamic information is encapsulated and then transmitted to the full connection layer for output of the final result, which is calculated as follows: (24) wherein, and represent the weights and biases of the fully connected layer, respectively, represent the output of the fully connected layer.
3. The ship trajectory prediction method based on local loitering activity context of claim 1, wherein, In step S3, the specific steps of training the hybrid neural network prediction model are as follows: Optimize the prediction trajectory by using mean square error to suppress large deviations, dynamically adjust the learning rate through the Adam optimizer, and introduce Dropout to suppress overfitting; During training, input the validation set for testing and monitor the validation set loss to use early stopping mechanism to save the optimal weight; The formula for optimizing the prediction trajectory is as follows: (25) In the formula is the mean square error, is the true label of the th sample, is the model prediction value of the th sample.
4. The ship trajectory prediction method based on local loitering activity context of claim 1, wherein, In step S4, input the test set into the trained hybrid neural network prediction model, evaluate the accuracy through MSE, MAE, RMSE, SMAPE, and AED, dynamically update it using rolling prediction, and calculate the actual distance error using the Haversine formula, the specific steps are as follows: Input the test set into the trained hybrid neural network prediction model to obtain the prediction results of the test set, compare the prediction results with the true values, and use five evaluation indexes of mean square error, mean absolute error, root mean square error, symmetric average absolute percentage error, and average Euclidean distance to evaluate the accuracy of the prediction, which is also used to test the performance of the hybrid neural network prediction model; The MSE formula is shown in (25), and the specific formulas of other indexes are as follows: (26) (27) (28) (29) wherein, is a sequence number of input trajectories, is a sample number of data, is a true value of the th data, is a predicted value of the th data, is a mean absolute error, is a root mean square error, is a symmetric mean absolute percentage error, is a mean Euclidean distance; To better evaluate the prediction performance of the model in actual application, the rolling prediction method is used for dynamic updating; To more intuitively represent the error between the predicted data and the actual data of the model, the Haversine formula is used to calculate the actual distance between the predicted trajectory point and the actual trajectory point, and the calculation formula is shown in (30): (30) wherein, is the actual distance between two points; is the average radius of the Earth; and are the geographical coordinates of the actual and predicted points, respectively, in radians; and are the latitude and longitude differences between the predicted and actual points, respectively.
Citation Information
Patent Citations
Pedestrian trajectory prediction method, system and device based on dynamic scene multi-information fusion and storage medium
CN120147948A