Ship loitering trajectory prediction method based on double-flow interaction

By constructing a dual-flow interactive prediction method, employing parallel micro-dynamic flow branches and macro-trend flow branches, and combining cross-attention and physical information constraints, the problem of forgetting micro-maneuvering features in ship trajectory prediction in existing technologies is solved, realizing the parallel extraction and accurate prediction of high-frequency micro-maneuvering features and long-term macro-trends.

CN122045718BActive Publication Date: 2026-07-03WUHAN UNIV OF TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
WUHAN UNIV OF TECH
Filing Date
2026-04-17
Publication Date
2026-07-03

AI Technical Summary

Technical Problem

In existing ship trajectory prediction methods, the serial unidirectional processing mechanism makes it easy for the high-frequency, instantaneous micro-maneuvering characteristics of ships during hovering to be smoothed or forgotten, resulting in significant lag and geometric distortion in the predicted trajectory at key turning points.

Method used

A ship loitering trajectory prediction method based on dual-stream interaction is constructed. It adopts parallel micro-dynamic stream branches and macro-trend stream branches, performs feature interaction fusion through cross-attention mechanism, introduces physical information constraints, uses gated spatiotemporal convolution and Transformer global self-attention mechanism to process features, and combines incremental scaling and real-time AIS data stream for dynamic updating and correction.

Benefits of technology

It effectively overcomes the information decay and smoothing effect in the feature transmission process of traditional models, and realizes the structural decoupling and parallel extraction of high-frequency micro-maneuver features and long-term macro-evolution trend in ship wandering trajectory, thereby improving the accuracy and real-time performance of predicted trajectory.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122045718B_ABST
    Figure CN122045718B_ABST
Patent Text Reader

Abstract

The application provides a ship lingering trajectory prediction method based on double-flow interaction, and relates to the technical field of water traffic engineering. The method steps include obtaining AIS data, preprocessing, and constructing a multi-dimensional time sequence sample; a double-flow parallel interaction prediction model is constructed, including a parallel micro-dynamic flow branch and a macro-trend flow branch, and the double-flow features are interactively fused through a cross-attention mechanism; based on the time sequence sample, the double-flow parallel interaction prediction model is trained by introducing physical information constraints, and the online prediction of the future trajectory of the ship is carried out, and the predicted trajectory is dynamically updated and corrected based on the real-time AIS data stream. The application uses a gated spatio-temporal convolution to accurately capture the micro instantaneous maneuvering characteristics, uses a Transformer global self-attention mechanism to process the macro long-time evolution trend, and realizes high-precision trajectory deduction in a complex lingering scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of water traffic engineering technology, and in particular to a method for predicting ship wandering trajectories based on dual-flow interaction. Background Technology

[0002] With the rapid development of the global shipping industry and the surge in water traffic, Automatic Identification Systems (AIS) have been widely used for real-time monitoring of vessel navigation status. Especially in scenarios such as port operations, engineering patrols, and fishing, vessels often exhibit high-density, non-linear, and complex circling behaviors in confined waters, such as regular back-and-forth movements and disorderly turning backs. These behaviors are accompanied by frequent sharp turns, sudden speed changes, and other micro-maneuvering characteristics. Furthermore, AIS data itself is susceptible to noise interference such as signal drift and packet loss, posing a severe challenge to the real-time performance and accuracy of trajectory prediction.

[0003] Currently, most mainstream ship trajectory prediction methods are based on data-driven deep learning models, especially recurrent neural networks with a serial architecture, such as LSTM, GRU, or combinations thereof. These models extract spatial features through convolutional layers and then perform temporal modeling through recurrent networks. The features undergo serialization and smoothing during this hierarchical transmission. However, this serial, unidirectional processing mechanism makes it easy for high-frequency, instantaneous micro-maneuvering features of ships during hesitant maneuvers to be smoothed or forgotten, resulting in significant lag and geometric distortion in the predicted trajectory at key turning points. Summary of the Invention

[0004] The purpose of this invention is to provide a ship lingering trajectory prediction method based on dual-flow interaction, in order to solve the problem mentioned in the background art that the existing ship trajectory prediction methods adopt a serial unidirectional processing mechanism, which makes it easy for the high-frequency and instantaneous micro-maneuvering characteristics of the ship during lingering to be smoothed or forgotten, resulting in significant lag and geometric distortion in the predicted trajectory at key turning points.

[0005] To achieve the above objectives, the present invention provides the following technical solution: a method for predicting ship loitering trajectories based on dual-flow interaction, comprising the following steps: acquiring raw AIS data of the target sea area and preprocessing it to construct a normalized time series sample containing multi-dimensional spatiotemporal features and physical enhancement features; constructing a dual-flow parallel interactive prediction model, wherein the dual-flow parallel interactive prediction model includes parallel micro-dynamic flow branches and macro-trend flow branches, and interactively fusing the dual-flow features through a cross-attention mechanism; training the dual-flow parallel interactive prediction model based on the time series sample and introducing physical information constraints; using the trained model to predict the future trajectory of ships online, and dynamically updating and correcting the predicted trajectory based on real-time AIS data stream.

[0006] Optionally, the preprocessing steps specifically include: detecting and removing outliers from the original AIS data, and reconstructing and resampling the missing data at fixed intervals using an interpolation algorithm; calculating the physical geometric features of the trajectory points based on the resampled trajectory data to construct a multidimensional spatiotemporal feature matrix, wherein the physical geometric features include discrete curvature, heading rate of change, and wave point identifiers; calculating the position increments at adjacent time points and amplifying the position increments using an incremental scaling mechanism; normalizing the incrementally scaled multidimensional spatiotemporal feature matrix and constructing model input samples using a sliding window method.

[0007] Optionally, the step of constructing the multidimensional spatiotemporal feature matrix specifically includes: converting the latitude and longitude coordinates of the trajectory points into planar coordinates using Mercator projection; calculating the discrete curvature of each trajectory point based on the converted planar coordinates; performing wave point detection based on the discrete curvature by setting a minimum curvature threshold to identify key moments when the heading undergoes substantial changes; calculating the heading difference between adjacent moments as the heading change rate; and constructing a multidimensional spatiotemporal feature vector based on a combination of latitude and longitude, ground velocity, ground heading, heading change rate, discrete curvature, and wave point identifiers.

[0008] Optionally, the steps of constructing the dual-stream parallel interactive prediction model specifically include: inputting the time-series samples into a time-series embedding layer, performing causal convolutional mapping and high-dimensional position encoding, and outputting time-series samples with embedded features; processing the time-series samples with embedded features through a micro-dynamic flow branch, which is composed of stacked gated temporal convolutional networks, extracting high-frequency micro-dynamic features of ships through gating mechanisms and dilated convolutions, and outputting a micro-feature sequence; processing the time-series samples with embedded features through a macro-trend flow branch, which is composed of a Transformer encoder, modeling long-term macro-evolutionary trends through a global multi-head self-attention mechanism, and outputting a macro-feature sequence; performing dual-stream feature fusion through a cross-attention mechanism, using the macro-feature sequence as the query vector and the micro-feature sequence as the key-value vector, and performing semantic interaction and feature fusion through residual connections and layer normalization; and mapping the fused features through a fully connected layer to output the predicted position increment.

[0009] Optionally, the step of introducing physical information constraints to train the dual-stream parallel interactive prediction model specifically includes: constructing a composite loss function to train the dual-stream parallel interactive prediction model; the composite loss function includes a basic prediction error loss term and a physical inertia constraint loss term, the basic prediction error loss term measures the deviation between the predicted position increment and the actual position increment, and the physical inertia constraint loss term forces the prediction increments of adjacent time moments to maintain continuity, so as to conform to the motion inertia law of the ship.

[0010] Optionally, the step of using the trained model to predict the future trajectory of a ship online specifically includes: inputting the historical trajectory time series samples of the current time window into the trained model to obtain the predicted scaled position increment; performing inverse scaling on the predicted scaled position increment to obtain the position increment with true dimensions; adding the position increment with true dimensions to the normalized ship position at the current time, and performing inverse normalization to restore the predicted true latitude and longitude coordinates for the next time moment.

[0011] Optionally, the step of dynamically updating and correcting the predicted trajectory based on real-time AIS data stream specifically includes: continuously monitoring the ship's real-time AIS data stream; when new real AIS positioning data is received, replacing the latest corresponding data in the historical input window used for prediction with the real AIS positioning data; recalculating the position increment and curvature features within the window based on the updated historical window; and re-executing the trajectory prediction step based on the updated features to correct accumulated errors and generate a new predicted trajectory.

[0012] On the other hand, the present invention also provides a ship loitering trajectory prediction system based on dual-flow interaction, comprising: an acquisition module for acquiring raw AIS data of a target sea area and preprocessing it to construct a normalized time series sample containing multi-dimensional spatiotemporal features and physical enhancement features; a construction module for constructing a dual-flow parallel interactive prediction model, wherein the dual-flow parallel interactive prediction model includes parallel micro-dynamic flow branches and macro-trend flow branches, and the dual-flow features are interactively fused through a cross-attention mechanism; a training module for training the dual-flow parallel interactive prediction model based on the time series sample and introducing physical information constraints; and a prediction module for using the trained model to predict the future trajectory of ships online, and dynamically updating and correcting the predicted trajectory based on real-time AIS data stream.

[0013] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described ship wandering trajectory prediction method based on dual-stream interaction.

[0014] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described ship wandering trajectory prediction method based on dual-stream interaction.

[0015] Compared with the prior art, the beneficial effects of the present invention are:

[0016] This application constructs a dual-stream parallel interactive architecture that includes micro-dynamic flow branches and macro-trend flow branches. It utilizes gated spatiotemporal convolution to accurately capture micro-level instantaneous maneuvering features and employs the Transformer global self-attention mechanism to efficiently process macro-level long-term evolutionary trends. This achieves structural decoupling and parallel extraction of high-frequency micro-maneuvering features and long-term macro-evolutionary trends in ship loitering trajectories. Furthermore, it introduces a cross-attention mechanism to retrieve micro-level details from macro-level intents. This effectively overcomes the information attenuation and smoothing effects in the feature transmission process of traditional serial models and fundamentally solves the problem of lag in turning point prediction caused by feature passivation. Attached Figure Description

[0017] Figure 1 This is a schematic diagram of the method steps of the present invention.

[0018] Figure 2 This is a flowchart illustrating the technical route of the method of the present invention.

[0019] Figure 3 This is a schematic diagram illustrating the experimental results and evaluation indicators of this invention.

[0020] Figure 4 This is a schematic diagram of the system structure of the present invention.

[0021] In the diagram: 10 - Acquisition module, 20 - Construction module, 30 - Training module, 40 - Prediction module. Detailed Implementation

[0022] The present invention will now be clearly and completely described in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.

[0023] It should be noted that the terms "first," "second," etc., in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be used interchangeably where appropriate for the embodiments of this application described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0024] Those skilled in the art will understand that, unless explicitly stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in the specification of this application means the presence of features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.

[0025] It will be understood by those skilled in the art that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.

[0026] It should be understood that the sequence number and size of each step in this embodiment do not imply the order of execution. The execution order of each process is determined by its function and internal logic, and should not constitute any limitation on the implementation process of this application embodiment.

[0027] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0028] Please refer to Figure 1 , Figure 2 This invention discloses a method for predicting ship loitering trajectories based on dual-flow interaction, comprising the following steps: acquiring raw AIS data of the target sea area and preprocessing it to construct a normalized time-series sample containing multi-dimensional spatiotemporal features and physical enhancement features; constructing a dual-flow parallel interactive prediction model, wherein the dual-flow parallel interactive prediction model includes parallel micro-dynamic flow branches and macro-trend flow branches, and the dual-flow features are interactively fused through a cross-attention mechanism; training the dual-flow parallel interactive prediction model based on the time-series sample and introducing physical information constraints; using the trained model to predict the future trajectory of the ship online, and dynamically updating and correcting the predicted trajectory based on real-time AIS data stream.

[0029] Specifically, the raw AIS data for the target sea area is acquired. This AIS data includes the vessel's real-time position (latitude and longitude), speed over land, heading over land, turning rate, unique identifier (MMSI), vessel name, vessel type, size, water depth, destination, and estimated time of arrival. Because raw AIS data generally suffers from noise interference and uneven sampling, systematic preprocessing is required to construct normalized time-series samples containing multi-dimensional spatiotemporal features and physical enhancement features.

[0030] The preprocessed time-series samples are then fed into a subsequently constructed dual-flow parallel interactive prediction model. The core architecture of this model comprises two parallel feature extraction branches: a micro-dynamic flow branch and a macro-trend flow branch. The micro-dynamic flow branch, composed of a gated temporal convolutional network, is specifically designed to capture the instantaneous dynamic features of the ship under high-frequency sampling, such as sharp turns or sudden speed changes. The macro-trend flow branch, composed of a Transformer encoder, is specifically designed to model the evolution of navigation intentions over long time windows, such as overall circling patterns. Based on this, the model achieves interactive fusion of the two-flow features through a cross-attention mechanism. Specifically, it uses the macro-feature sequence as the query vector and the micro-feature sequence as the key-value vector, simulating the cognitive process of retrieving details based on intention. This allows the macro-intention to be reverse-located and recovered from the smoothed-out key micro-maneuver features. After the model is constructed, a training strategy incorporating physical information constraints is introduced to optimize the model based on the preprocessed time-series samples, ensuring that the prediction results conform to the physical laws of ship motion. Finally, the trained model is used to predict the future trajectory of the ship online, and a dynamic update mechanism based on real-time AIS data stream is introduced. Once the latest real AIS positioning data is received, the predicted trajectory is immediately corrected and reconstructed, so that high-precision real-time tracking of the ship's position can still be maintained when facing highly uncertain wandering scenarios such as disordered backtracking.

[0031] This application constructs a dual-stream parallel interactive architecture that includes micro-dynamic flow branches and macro-trend flow branches. It utilizes gated spatiotemporal convolution to accurately capture micro-level instantaneous maneuvering features and employs the Transformer global self-attention mechanism to efficiently process macro-level long-term evolutionary trends. This achieves structural decoupling and parallel extraction of high-frequency micro-maneuvering features and long-term macro-evolutionary trends in ship loitering trajectories. Furthermore, it introduces a cross-attention mechanism to retrieve micro-level details from macro-level intents. This effectively overcomes the information attenuation and smoothing effects in the feature transmission process of traditional serial models and fundamentally solves the problem of lag in turning point prediction caused by feature passivation.

[0032] In some embodiments, the preprocessing steps specifically include: outlier detection and removal of the original AIS data, and reconstruction and fixed-interval resampling of missing data using an interpolation algorithm; calculating the physical geometric features of trajectory points based on the resampled trajectory data to construct a multidimensional spatiotemporal feature matrix, wherein the physical geometric features include discrete curvature, heading rate of change, and wave point identifiers; calculating the position increments at adjacent time points and amplifying the position increments using an incremental scaling mechanism; normalizing the incrementally scaled multidimensional spatiotemporal feature matrix and constructing model input samples using a sliding window method.

[0033] Specifically, the massive amount of raw AIS data is first subjected to multi-level quality filtering to remove abnormal records with invalid MMSI, significant latitude and longitude drift, or speed and heading exceeding physical thresholds. To address the issue of uneven time intervals caused by signal loss in AIS data, a piecewise linear interpolation algorithm is used to fill in the missing geospatial values, and a fixed time interval is set to uniformly resample the cleaned trajectory sequence to ensure the continuity of the time series.

[0034] Subsequently, based on the resampled trajectory data, the physical geometric features of the trajectory points are calculated, including discrete curvature, rate of change of heading, and wave point identifiers, thereby constructing a multidimensional spatiotemporal feature matrix.

[0035] To overcome the problem of vanishing gradients during deep learning model training caused by extremely small ship displacement values ​​over short periods, this application employs an incremental scaling mechanism: calculating the position increment between adjacent time steps and amplifying this increment. Instead of directly predicting absolute coordinates, it calculates the position increment between adjacent time steps and amplifies its magnitude. For each time step... Location Its scaled incremental features The calculation formula is: ;in, The preset scaling factor (in this embodiment) ).

[0036] Finally, the multidimensional spatiotemporal feature matrix after incremental scaling is subjected to min-max scaling normalization to map all values ​​to the interval between 0 and 1. The sliding window technique is used to construct supervised learning samples, and the historical input window length L and prediction step size T are set to generate input-output pairs containing historical feature matrices and future time-point labels for subsequent model training.

[0037] This application introduces an incremental scaling mechanism in the preprocessing stage, amplifying the minute-level position increments between adjacent time points as the model prediction target. This effectively solves the technical problem of gradient vanishing or numerical instability during deep learning model training caused by excessively small short-term ship displacement values, significantly improving the convergence speed and numerical accuracy of model training. Simultaneously, through a series of preprocessing operations such as anomaly detection, interpolation reconstruction and resampling, physical geometric feature calculation, and sliding window sample construction, standardized time-series samples containing rich physical information are constructed. This lays a solid data foundation for the efficient training and accurate prediction of the subsequent dual-stream parallel interactive model, enhancing the model's robustness to AIS data noise and packet loss.

[0038] In some embodiments, the step of constructing a multidimensional spatiotemporal feature matrix specifically includes: converting the latitude and longitude coordinates of the trajectory points into planar coordinates using Mercator projection; calculating the discrete curvature of each trajectory point based on the converted planar coordinates; performing wave point detection based on the discrete curvature by setting a minimum curvature threshold to identify key moments when the heading undergoes substantial abrupt changes; calculating the heading difference between adjacent moments as the heading change rate; and constructing a multidimensional spatiotemporal feature vector based on a combination of latitude and longitude, ground velocity, ground heading, heading change rate, discrete curvature, and wave point identifiers.

[0039] Specifically, to enhance the model's ability to perceive turning and speed changes during hesitant behavior, this invention introduces geometric features with clear physical meaning on top of the basic features. Specifically, firstly, the latitude and longitude are converted into planar coordinates using Mercator projection, and then the trajectory points are calculated. Discrete curvature Curvature is a key indicator describing the degree of curvature of a curve. For a discrete sequence of ship trajectory points, its local curvature can effectively capture the instantaneous rate of change of heading. (Trajectory points) curvature Through its adjacent front and rear points , The geometric relationships formed are calculated using the following formula: ;in, For vectors and The angle between them Let be the Euclidean distance between the two points. The curvature set can be obtained by traversing the sequence of points on the trajectory. A larger curvature value is typically used for emergency turns or sudden changes in direction, accurately depicting the trajectory. The local curvature of a point.

[0040] Building upon this, to further highlight key turning points in the wandering trajectory, this invention performs wave point detection based on curvature calculation. If the trajectory points... curvature At the same time, the curvature is greater than that of its preceding point. and the curvature of the last point Furthermore, the curvature value exceeds the set minimum curvature threshold. Then the point is marked as a wave point. (IsWave). The criteria for determining the wave point are: By introducing threshold conditions It can effectively filter out false points generated by minor jitters, ensuring that the identified points can represent the critical moments when the course changes substantially.

[0041] In addition, the first-order heading difference is calculated. The instantaneous turning amplitude is quantified. Finally, a feature vector containing seven attributes is constructed by combining the above features. , ;in, , They are latitude and longitude, For ground speed, For ground heading, For the rate of change of heading, For curvature, The polka dot symbol is used.

[0042] This application converts latitude and longitude into planar coordinates using Mercator projection, and on this basis, accurately calculates discrete curvature, performs wave point detection through a minimum curvature threshold to identify key moments of abrupt changes in heading, and calculates the rate of change of heading, constructing a physically enhanced feature vector containing seven-dimensional attributes. This feature extraction method enables the model to explicitly perceive the local curvature morphology and steering abruptness of the ship's trajectory, transforming the geometric information originally implicit in the original coordinates into directly learnable feature inputs. This significantly enhances the model's ability to capture high-frequency micro-maneuvering features such as sharp turns and U-turns during hesitant behavior, providing a more discriminative dynamic representation of micro-dynamic flow branches.

[0043] In some embodiments, the step of constructing a dual-stream parallel interactive prediction model specifically includes: inputting the time-series samples into a time-series embedding layer, performing causal convolutional mapping and high-dimensional position encoding, and outputting time-series samples with embedded features; processing the time-series samples with embedded features through a micro-dynamic flow branch, which is composed of stacked gated temporal convolutional networks, extracting high-frequency micro-dynamic features of ships through gating mechanisms and dilated convolutions, and outputting a micro-feature sequence; processing the time-series samples with embedded features through a macro-trend flow branch, which is composed of a Transformer encoder, modeling long-term macro-evolutionary trends through a global multi-head self-attention mechanism, and outputting a macro-feature sequence; performing dual-stream feature fusion through a cross-attention mechanism, using the macro-feature sequence as the query vector and the micro-feature sequence as the key-value vector, and performing semantic interaction and feature fusion through residual connections and layer normalization; and mapping the fused features through a fully connected layer to output the predicted position increment.

[0044] Specifically, after data preprocessing, the ship trajectory is modeled using a dual-stream parallel interactive network model. This model mainly consists of a temporal embedding layer, a micro-dynamic flow branch, a macro-trend flow branch, an interactive fusion layer, and a physical constraint training module.

[0045] First, temporal embedding and position encoding are performed on the preprocessed normalized trajectory sequence. (in For batch size, For time step, The input (with the feature dimension as the input) is fed into the temporal embedding layer. In order to preserve the temporal information of the sequence and increase the feature dimension, this application uses causal convolution to map the low-dimensional input into high-dimensional hidden layer features, and superimposes sinusoidal positional encoding.

[0046] Causal convolution ensures that in The convolution operation at time step depends only on The time and previous inputs are used to prevent future information leaks. Location coding. The calculation formula is: ;in, Indicates the time step position. Indicates the feature dimension index. Let be the dimension of the model's hidden layers. The output after embedding is denoted as . .

[0047] Furthermore, a micro-dynamic flow branch is constructed to accurately capture high-frequency micro-abrupt changes (such as sharp turns and sudden speed changes) in the ship's circling behavior. This branch abandons the traditional recurrent neural network and adopts a stacked gated temporal convolutional network.

[0048] This branch consists of multiple gated TCN blocks cascaded together, each containing two parallel causal dilated convolutions: one as a feature filter using the Tanh activation function, and the other as a gate using the Sigmoid activation function. Through dilated convolutions with exponentially increasing dilation rates (d=1,2,4), the model exponentially expands the local receptive field while maintaining computational efficiency.

[0049] For the Layer input Output of the Gated TCN block The calculation formula is: ;in, This indicates a causal dilated convolution operation. and These are the convolution kernel weights for the filter and the gate, respectively. This indicates element-wise multiplication. This is the Sigmoid function. This gating mechanism adaptively controls the information flow, allowing key mutation features to pass through while suppressing irrelevant noise. The final micro-feature sequence output by this branch is denoted as... .

[0050] Furthermore, a macro-trend flow branch is constructed to capture the macro-evolutionary trend of ships over a long time span. This branch employs a Transformer encoder module and utilizes a global multi-head self-attention mechanism to directly establish global dependencies between any two time steps in the sequence, overcoming the problem of information forgetting in long sequences.

[0051] Input features After LayerNorm normalization, the data enters the attention layer, where the query, key, and value matrices are calculated, and global features are computed using scaled dot product attention. The calculation formula is as follows: ;in, This represents the dimension of the attention head. Subsequently, the features are processed through a feedforward neural network and residual connections to generate a macroscopic feature sequence. .

[0052] Furthermore, regarding feature interaction and fusion, in order to effectively combine macroscopic navigation intentions with microscopic maneuver details during the prediction process and to address the problem of details being easily obscured in long sequence modeling, this application designs a cross-attention mechanism with vertical semantic interaction. This mechanism is not a simple feature concatenation or dimension alignment, but rather simulates the cognitive process of humans when maneuvering a ship, that is, planning specific maneuvering actions based on the current navigation intention.

[0053] Specifically, this step first extracts the deep output of the macroscopic trend flow to construct a query vector Q, representing the ship's high-level motion intention at the current moment, such as maintaining a clockwise turning posture. Simultaneously, it extracts the deep output of the microscopic dynamic flow to construct a key-value vector K / V, representing the ship's underlying dynamic support within the historical window, such as a series of continuous bow angular velocities. The subsequent interaction process calculates the correlation between the macroscopic intention and the microscopic dynamic sequence, retrieving key maneuver moments supporting the current intention, and extracting the corresponding dynamic features for weighted fusion. This mechanism ensures that when generating long-sequence trajectories, the model can capture key microscopic maneuver memories based on the macroscopic intention, thereby accurately reconstructing the physical details at turning points while maintaining the overall smoothness of the trajectory. Through this interaction, the model can retrieve supporting evidence from microscopic details from the perspective of macroscopic intention. The fused feature update formula is: Finally, the model extracts micro-branches. and the macro branches after fusion The features from the last time step are concatenated and mapped through a fully connected layer to obtain the predicted position increment for the next time step. .

[0054] This application constructs a dual-stream parallel interactive prediction model consisting of a temporal embedding layer, a micro-dynamic flow branch, a macro-trend flow branch, a cross-attention fusion layer, and a fully connected output layer. This model achieves multi-scale feature extraction and deep fusion of ship wandering trajectories. The micro-dynamic flow branch employs a stacked gated temporal convolutional network, which adaptively filters noise through a gating mechanism and expands the receptive field using dilated convolutions to accurately lock key instantaneous maneuver features. The macro-trend flow branch uses a Transformer encoder, which directly establishes the dependency relationship between any time step in the sequence through a global multi-head self-attention mechanism, overcoming the problem of information forgetting in long sequences. In particular, the cross-attention mechanism fuses macro-features as queries and micro-features as keys, and introduces residual connections and layer normalization to simulate the cognitive process of "retrieving details with intent," achieving lossless complementarity between macro-evolutionary trends and micro-maneuver details. This ensures the coherence of the predicted trajectory in its overall shape and the accuracy in local details from an architectural perspective.

[0055] In some embodiments, the step of introducing physical information constraints to train the dual-stream parallel interactive prediction model specifically includes: constructing a composite loss function to train the dual-stream parallel interactive prediction model; the composite loss function includes a basic prediction error loss term and a physical inertia constraint loss term, the basic prediction error loss term measures the deviation between the predicted position increment and the actual position increment, and the physical inertia constraint loss term forces the prediction increments of adjacent time moments to maintain continuity, so as to conform to the motion inertia law of the ship.

[0056] Specifically, to suppress the "momentary" or "jagged jitter" phenomena that may occur in purely data-driven models, this application constructs a composite loss function that includes physical smoothing constraints. This loss function consists of two parts: the first part is the basic prediction error, which measures the deviation between the predicted increment and the actual increment; the second part is the physical inertia constraint term, which enforces the current predicted increment... The actual increment compared to the previous moment Maintaining a certain degree of continuity conforms to the motion inertia laws of a large-mass rigid body like a ship.

[0057] Total loss function The calculation formula is: ; ;in, The physical smoothing weighting coefficient is set to 0.1 in this embodiment. This represents the smoothing L1 norm or squared norm, used to balance the relative importance of the two loss functions. During training, the AdamW optimizer minimizes this composite loss function, enabling iterative updates of the model parameters. This allows the model to learn trajectory generation capabilities that conform to the physical laws of ship motion while pursuing prediction accuracy.

[0058] This application constructs a composite loss function that includes a basic prediction error loss term and a physical inertia constraint loss term, explicitly embedding the prior physical knowledge of ship motion inertia into the traditional data-driven optimization objective. The physical inertia constraint loss term forces the current prediction increment to maintain continuity with the previous actual increment, effectively suppressing trajectory artifacts that violate kinematic laws, such as sawtooth jitter, sharp angle reversal, or instantaneous position shift, which are easily generated by pure data-driven models when facing sparse data or noise interference. This physical information constraint mechanism enables the model to learn the trajectory generation capability that conforms to the motion characteristics of a large-mass rigid body while pursuing prediction accuracy, significantly improving the credibility and acceptability of the prediction results in the actual maritime regulatory environment.

[0059] In some embodiments, the step of using the trained model to predict the future trajectory of a ship online specifically includes: inputting historical trajectory time series samples of the current time window into the trained model to obtain the predicted scaled position increment; performing inverse scaling on the predicted scaled position increment to obtain the position increment in true dimensions; adding the position increment in true dimensions to the normalized ship position at the current time, and performing inverse normalization to restore the predicted true latitude and longitude coordinates for the next time moment.

[0060] Specifically, in the online prediction phase, the test set or the historical trajectory sequence received in real time (length is...) is first... The input is fed into the trained dual-stream parallel interactive prediction model. Because the model employs an incremental scaling strategy during training, its direct output is the scaled position increment. To obtain the accurate geographic latitude and longitude for the next moment, the system needs to perform inverse scaling and location restoration operations.

[0061] Assuming the current time The normalized ship position is The preset scaling factor is Then the predicted normalized position at the next time step The calculation formula is: Subsequently, the extreme values ​​recorded in the preprocessing stage were used ( , The prediction results are then inversely normalized to obtain the final true latitude and longitude coordinates. As shown in the following formula: ;in, This indicates element-wise multiplication. This mechanism, based on "incremental prediction + restoration," effectively avoids the problem of deep networks ignoring small numerical fluctuations when directly predicting absolute coordinates, thus significantly improving prediction accuracy.

[0062] To address the need for predicting the navigation intentions of vessels over long periods in maritime regulatory work, this application employs a rolling prediction strategy. Under this strategy, the system outputs the next predicted time point from the model. Treating this as known information, iteratively add it to the end of the input sequence, while removing the oldest time step from the input sequence. This allows for the creation of an updated input window. The formula is: The updated window is then input into the dual-stream parallel interactive prediction model, and this process is repeated to continuously generate future multi-step trajectories. Thanks to the Transformer global attention and physical inertia constraints introduced in the training phase of this invention, the model can maintain its memory of the hovering geometry for a long time during the rolling prediction process, effectively suppressing the error accumulation and divergence problem that is common in traditional recursive networks during multi-step inference.

[0063] This application designs an online prediction process that includes inverse scaling and inverse normalization operations. This process accurately restores the scaled position increments output by the model to real geographic latitude and longitude coordinates, ensuring consistency between the prediction results and the original AIS data dimensions. Simultaneously, a rolling prediction strategy is employed to iteratively input single-step prediction results into the model, enabling continuous extrapolation of future multi-step trajectories. This meets the maritime regulatory need for predicting the long-term navigation intentions of vessels. Furthermore, this prediction mechanism, combined with Transformer global attention and physical inertia constraints introduced during the training phase, maintains a long-term memory of the wandering geometry during rolling prediction, effectively suppressing the error accumulation and divergence problem common in traditional recursive networks during multi-step extrapolation, thus ensuring the stability and reliability of long-term predictions.

[0064] In some embodiments, the step of dynamically updating and correcting the predicted trajectory based on real-time AIS data stream specifically includes: continuously monitoring the ship's real-time AIS data stream; when new real AIS positioning data is received, replacing the latest corresponding data in the historical input window used for prediction with the real AIS positioning data; recalculating the position increment and curvature features within the window based on the updated historical window; and re-executing the trajectory prediction step based on the updated features to correct accumulated errors and generate a new predicted trajectory.

[0065] Specifically, in actual operation, to eliminate uncertainties caused by environmental disturbances (such as wind, waves, and currents) and the accumulated errors of rolling predictions, this application introduces a dynamic update mechanism. The system continuously monitors the ship's real-time AIS data stream. When new real AIS positioning data is received... Upon that, the system immediately initiates the calibration procedure: First, using a real... The model replaces the predicted values ​​at the corresponding time steps in the input window to ensure that it always bases its inference on the most accurate historical information. Secondly, based on the updated real historical window, it recalculates the latest position increment and curvature features within the window to ensure feature consistency. Finally, based on the corrected and updated features, it re-executes the trajectory prediction step, initiating a new round of trajectory extrapolation. This closed-loop feedback mechanism, which always bases its inference on the most accurate historical information, enables the model to correct deviations in real time and dynamically adapt to changes in ship motion patterns when faced with highly uncertain wandering behaviors such as disordered backtracking or random looping. This achieves high-precision real-time tracking and situational awareness of the ship's position.

[0066] This application introduces a dynamic update and correction mechanism based on real-time AIS data stream, constructing a closed-loop processing flow of prediction-feedback-correction. The system continuously monitors real-time AIS data, and once new real-time positioning data is received, it immediately replaces the corresponding predicted value in the input window and recalculates features and initiates inference, realizing online correction of environmental disturbances, sudden changes in navigation intentions, and cumulative errors in rolling predictions. This dynamic update mechanism enables the model to continuously self-correct and adapt to new motion patterns when facing highly uncertain wandering behaviors such as disordered backtracking and random loops, avoiding the error divergence problem caused by the inability of static prediction models to obtain real-time feedback. It provides highly timely and adaptable technical support for maritime traffic management, ship collision avoidance early warning, and abnormal behavior monitoring.

[0067] Please refer to Figure 3 To fully validate the effectiveness and robustness of the proposed dual-flow interaction prediction model, the experiment selected the sea area between 34.9°–35.3°N and 139.2°–139.6°E as the study area. This sea area has dense traffic flow and complex operational patterns, encompassing various types of vessels including yachts, fishing boats, and patrol boats, making it an ideal scenario for observing vessel loitering behavior. The research team screened and extracted 178 trajectory segments with obvious loitering characteristics from a total of 439,338 original AIS data points, and resampled the data at 2-minute intervals. In terms of dataset construction, a stratified sampling strategy was adopted, dividing the data into training, validation, and test sets in an 8:1:1 ratio. This partitioning mechanism preserves the spatiotemporal coherence within each subset and provides a reliable foundation for evaluating the model's generalization ability.

[0068] During the model parameter optimization phase, aiming to eliminate training oscillations and pursue optimal convergence, the batch size was set to 512, and the initial learning rate was configured to 0.001. The AdamW optimizer was chosen as the optimization algorithm, leveraging its adaptive gradient adjustment characteristic to balance optimization stability and convergence speed. To accurately quantify prediction errors, the mean squared error was used as the loss function, which significantly penalizes large deviations, particularly meeting the high-precision requirements of modeling outliers in this study. Furthermore, to effectively mitigate overfitting risks, an early stopping mechanism was introduced: during training iterations, the validation set performance was continuously monitored. If the validation loss did not decrease for 10 consecutive epochs, the system automatically stopped training and rolled back to save the model weights with the lowest loss, thus ensuring the final model achieved optimal performance.

[0069] Experimental results are as follows Figure 3As shown, the proposed GTCN and Transformer (Model M) two-stream parallel interactive model achieved the best prediction performance among all comparative models. Specifically, the model achieved the lowest mean squared error (MSE) of 3.95 × 10⁻⁶, which is approximately 13.4% lower than the classic cascaded CNN-BiGRU-BiLSTM model and approximately 17.2% lower than the single-stream Transformer model. In terms of the most practically meaningful kilometer-level mean absolute error, the model achieved an extremely high accuracy of 0.0556 km, significantly outperforming traditional RNN-type combined models. This result fully demonstrates the state-of-the-art (SOTA) performance of the proposed model in comprehensively handling ship trajectory prediction tasks, proving the effectiveness of combining microscopic convolution with macroscopic attention.

[0070] By comparing experimental data from the two-stream parallel model, the serial model, and the single-stream model, the superiority of the two-stream interactive architecture can be clearly verified. First, although the serial model performs reasonably well, its performance is still lower than that of the parallel model of this invention. This confirms that the hierarchical transfer of features in the serial architecture leads to the attenuation of microscopic detail information, while the parallel architecture can ensure the lossless extraction of both microscopic and macroscopic features.

[0071] Secondly, all two-stream models generally outperform their corresponding single-stream models. In particular, the MSE further decreases after fusing GTCN and Transformer through cross-attention. This strongly demonstrates that the cross-attention mechanism successfully achieves complementarity between long-term and short-term features, solving the problem that single models cannot simultaneously address local mutations and global trends.

[0072] Regarding micro-branching: Comparing Model M with the parallel model Model L of TCN and Transformer, the former outperforms the latter in all metrics. This demonstrates that introducing a gating mechanism into TCN can more effectively filter environmental noise in massive AIS data and accurately pinpoint key maneuvering features.

[0073] Regarding the macro-level branch: Comparing Model M with the parallel models Model O of GTCN and Informer, Model M significantly outperforms Model O (MSE is reduced by approximately 18.7%). This indicates that, on a dataset of this specific scale for ship trajectory prediction, the global self-attention mechanism of Transformer can capture the geometric evolution of trajectories more subtly than the sparse attention of Informer. This finding provides solid data support for our study's decision to abandon Informer and choose Transformer instead.

[0074] Please refer to Figure 4On the other hand, the present invention also provides a ship loitering trajectory prediction system based on dual-flow interaction, comprising: an acquisition module 10, used to acquire raw AIS data of the target sea area, and preprocess it to construct a normalized time series sample containing multi-dimensional spatiotemporal features and physical enhancement features; a construction module 20, used to construct a dual-flow parallel interactive prediction model, wherein the dual-flow parallel interactive prediction model includes parallel micro-dynamic flow branches and macro-trend flow branches, and the dual-flow features are interactively fused through a cross-attention mechanism; a training module 30, used to train the dual-flow parallel interactive prediction model based on the time series sample and introducing physical information constraints; and a prediction module 40, used to use the trained model to predict the future trajectory of ships online, and dynamically update and correct the predicted trajectory based on real-time AIS data stream.

[0075] On the other hand, the present invention also provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the steps of the above-described ship wandering trajectory prediction method based on dual-stream interaction.

[0076] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the steps of the above-described ship wandering trajectory prediction method based on dual-stream interaction.

[0077] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause an electronic device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0078] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above methods. Any references to memory, storage, database, or other media used in the embodiments provided by this invention can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and RAMbus dynamic RAM (RDRAM), etc.

[0079] The above are merely embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent modifications made based on the content of the present invention's specification and drawings, or direct or indirect applications in related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A ship loitering trajectory prediction method based on double-flow interaction, characterized by the steps of include: The raw AIS data of the target sea area is acquired and preprocessed to construct a normalized time series sample containing multi-dimensional spatiotemporal features and physical enhancement features. A dual-stream parallel interactive prediction model is constructed, which includes parallel micro-dynamic flow branches and macro-trend flow branches, and interactively fuses the features of the two streams through a cross-attention mechanism. The steps for constructing the dual-stream parallel interactive prediction model specifically include: The time-series samples are input into the time-series embedding layer, where causal convolutional mapping and high-dimensional position encoding are performed, and the time-series samples with embedded features are output. The time-series samples after embedding the features are processed by a micro-dynamic flow branch, which is composed of stacked gated temporal convolutional networks. The high-frequency micro-dynamic features of the ship are extracted through gating mechanism and dilated convolution, and the micro-feature sequence is output. The time-series samples after embedding features are processed by a macro trend flow branch, which is composed of a Transformer encoder. The macro trend flow branch models the long-term macro evolution trend through a global multi-head self-attention mechanism and outputs a macro feature sequence. Dual-stream feature fusion is performed through a cross-attention mechanism, with macroscopic feature sequences as query vectors and microscopic feature sequences as key vectors. Semantic interaction and feature fusion are achieved through residual connections and layer normalization. The fused features are mapped using a fully connected layer to output the predicted location increment; Based on the time-series samples, physical information constraints are introduced to train the dual-stream parallel interaction prediction model; The trained model is used to predict the future trajectory of ships online, and the predicted trajectory is dynamically updated and corrected based on real-time AIS data stream; The steps for dynamically updating and correcting the predicted trajectory based on real-time AIS data stream specifically include: Continuously monitor the ship's real-time AIS data stream; When new real AIS location data is received, the latest corresponding data in the historical input window used for prediction is replaced with the real AIS location data. Based on the updated historical window, the position increment and curvature features within the window are recalculated. Based on the updated features, the trajectory prediction step is re-executed to correct accumulated errors and generate new predicted trajectories.

2. The two-stream interaction based ship loitering trajectory prediction method according to claim 1, characterized in that, The preprocessing steps specifically include: Outlier detection and removal are performed on the original AIS data, and interpolation algorithms are used to reconstruct missing data and resample at fixed intervals. Based on the resampled trajectory data, the physical geometric features of the trajectory points are calculated to construct a multidimensional spatiotemporal feature matrix, wherein the physical geometric features include discrete curvature, heading rate of change, and wave point identifiers. Calculate the position increment between adjacent time points, and amplify the position increment using an incremental scaling mechanism; The multidimensional spatiotemporal feature matrix after incremental scaling is normalized, and the sliding window method is used to construct the model input samples.

3. The two-stream interaction based ship loitering trajectory prediction method according to claim 2, characterized in that, The steps for constructing the multidimensional spatiotemporal feature matrix specifically include: The latitude and longitude coordinates of the trajectory points are converted into planar coordinates using Mercator projection. Based on the transformed planar coordinates, calculate the discrete curvature of each trajectory point; Based on the discrete curvature, wave point detection is performed by setting a minimum curvature threshold to identify critical moments when the course undergoes substantial changes. Calculate the heading difference between adjacent time points as the heading change rate; A multidimensional spatiotemporal feature vector is constructed based on a combination of latitude and longitude, ground velocity, ground heading, rate of change of heading, discrete curvature, and wave point identifiers.

4. The dual-stream interaction-based ship loitering trajectory prediction method according to claim 1, characterized in that, The steps of introducing physical information constraints to train the dual-stream parallel interaction prediction model specifically include: A composite loss function is constructed to train the dual-stream parallel interactive prediction model; The composite loss function includes a basic prediction error loss term and a physical inertia constraint loss term. The basic prediction error loss term measures the deviation between the predicted position increment and the actual position increment, while the physical inertia constraint loss term forces the prediction increments of adjacent time moments to maintain continuity, so as to conform to the motion inertia law of the ship.

5. The dual-stream interaction-based ship loitering trajectory prediction method according to claim 1, wherein, The steps for online prediction of future ship trajectories using the trained model specifically include: Input the historical trajectory time series samples of the current time window into the trained model to obtain the predicted scaled position increment; The predicted scaled position increment is inversely scaled to obtain the position increment with true dimensions. The position increment of the true dimension is added to the normalized ship position at the current moment, and then denormalized to obtain the predicted true latitude and longitude coordinates for the next moment.

6. A ship loitering trajectory prediction system based on two-stream interaction, characterized in that, include: The acquisition module is used to acquire raw AIS data of the target sea area, perform preprocessing, and construct normalized time series samples containing multi-dimensional spatiotemporal features and physical enhancement features. A construction module is used to build a dual-stream parallel interactive prediction model, which includes parallel micro-dynamic flow branches and macro-trend flow branches, and performs interactive fusion of dual-stream features through a cross-attention mechanism; The steps for constructing the dual-stream parallel interactive prediction model specifically include: The time-series samples are input into the time-series embedding layer, where causal convolutional mapping and high-dimensional position encoding are performed, and the time-series samples with embedded features are output. The time-series samples after embedding the features are processed by a micro-dynamic flow branch, which is composed of stacked gated temporal convolutional networks. The high-frequency micro-dynamic features of the ship are extracted through gating mechanism and dilated convolution, and the micro-feature sequence is output. The time-series samples after embedding features are processed by a macro trend flow branch, which is composed of a Transformer encoder. The macro trend flow branch models the long-term macro evolution trend through a global multi-head self-attention mechanism and outputs a macro feature sequence. Dual-stream feature fusion is performed through a cross-attention mechanism, with macroscopic feature sequences as query vectors and microscopic feature sequences as key vectors. Semantic interaction and feature fusion are achieved through residual connections and layer normalization. The fused features are mapped through a fully connected layer to output the predicted position increment; the training module is used to train the dual-stream parallel interactive prediction model based on the time-series samples and by introducing physical information constraints. The prediction module is used to make online predictions of the future trajectory of ships using the trained model, and to dynamically update and correct the predicted trajectory based on real-time AIS data stream. The steps for dynamically updating and correcting the predicted trajectory based on real-time AIS data stream specifically include: Continuously monitor the ship's real-time AIS data stream; When new real AIS location data is received, the latest corresponding data in the historical input window used for prediction is replaced with the real AIS location data. Based on the updated historical window, the position increment and curvature features within the window are recalculated. Based on the updated features, the trajectory prediction step is re-executed to correct accumulated errors and generate new predicted trajectories. 7.An electronic device comprising a memory and a processor, the memory storing a computer program, wherein, When the processor executes the computer program, it implements the steps of the ship wandering trajectory prediction method based on dual-stream interaction as described in any one of claims 1 to 5.

8. A non-transitory computer-readable storage medium having stored thereon a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the ship wandering trajectory prediction method based on dual-stream interaction as described in any one of claims 1 to 5.