Coastal ship AIS data-based two-order hybrid meeting identification method
By employing a two-order hybrid encounter recognition method, which utilizes weighted fusion of models such as random forest, bidirectional LSTM, and LightGBM, and combines DTW and UTM coordinate systems to process AIS data, the problem of high misclassification rate in coastal vessel encounter recognition is solved, achieving higher accuracy and stable classification results, and supporting collision avoidance decisions of intelligent navigation systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- MINJIANG UNIVERSITY
- Filing Date
- 2026-01-20
- Publication Date
- 2026-04-28
AI Technical Summary
In coastal vessel encounter identification, existing technologies rely on single classifiers based on static features that cannot effectively distinguish complex cross-encounter situations, resulting in high misjudgment rates and difficulty in handling fine-grained differences, especially in complex cross-encounter subclasses where errors are significant.
A two-order hybrid encounter recognition method based on coastal vessel AIS data is adopted. Coarse classification is performed by weighted fusion of random forest and bidirectional LSTM, and fine classification is performed by weighted fusion of LightGBM and attention LSTM. Data preprocessing is performed by combining DTW similarity matrix and UTM coordinate system to ensure data quality and feature extraction.
It improves the accuracy and stability of encounter recognition and classification, reduces the false positive rate, enhances the model's generalization ability and cross-sea adaptability, and provides more stable collision avoidance suggestions.
Smart Images

Figure CN121938231A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of ship navigation safety early warning technology, and in particular to a two-stage hybrid encounter identification method based on coastal ship AIS data. Background Technology
[0002] When two or more vessels are navigating in coastal waters, their routes or tracks may intersect or approach, creating a situation where they can influence each other. This is a common scenario in maritime navigation, requiring crews to strictly adhere to collision avoidance rules to ensure safety. In coastal areas, vessel encounters require particularly careful handling, necessitating regular lookout, continuous monitoring of the surrounding environment using radar, AIS, and other equipment, and advance assessment of collision risks. Current methods extract static geometric features within a time window, such as DCPA, TCPA, instantaneous / average phase difference, and speed ratio, to train RF or XGboost / LightGBM to recognize encounter situations (intersection, overtaking, head-on collisions), directly providing three categories of labels and partially adopting COLREGs suggestions.
[0003] Many studies typically use a single classifier to perform one-time multi-classification of samples, including "crossover," "overtaking," and "head-on" scenarios, due to its simplicity, short training time, and low cost. Classifying complex encounter situations into three coarse labels easily overlooks fine-grained differences, preventing error localization. However, modeling solely with static features such as DCPA, TCPA, heading difference, and speed ratio cannot represent the complete dynamic process, resulting in insufficient separability of encounter situations, especially in complex crossover subclasses where the misclassification rate further increases. Specifically, when two ships have similar geometric relationships at the same time point but different evolution trajectories, it is difficult to perform fine-grained classification called "crossover" because their static feature vectors are almost identical. Summary of the Invention
[0004] The purpose of this invention is to provide a two-order hybrid encounter identification method based on coastal vessel AIS data, which can improve the encounter identification accuracy and classification stability, and enhance the discrimination stability of boundary samples.
[0005] To achieve the above objectives, the present invention provides the following technical solution: a two-order hybrid encounter identification method based on coastal vessel AIS data, the method comprising the following steps: Step 1: Extract AIS data from coastal vessels; Step 2: Decode, clean, segment, and preprocess the AIS messages using PCHIP interpolation; Step 3: Set a time window, convert the ship's latitude and longitude coordinates to the transverse Mercator projection plane coordinate system within the time window, and obtain the Euclidean spatial distance between ships based on the projected plane coordinates; Step 4: Filter candidate encounter samples using the DTW similarity matrix and extract encounter data; Step 5: Based on parameters such as relative heading, speed ratio, DCPA and TCPA, the encounter samples are labeled according to rules to form a coarse classification of crossing, overtaking, and facing each other. Then, they are further classified into five different types of crossing labels: crossing-port side, crossing-starboard side at a large angle, crossing-starboard side at a small angle, overtaking, and facing each other. Step 6: Establish a two-stage hybrid recognition model. In the first stage, random forest and bidirectional LSTM are used for fine classification. In the second stage, LightGBM and attention LSTM are used for weighted fusion for cross-fine classification to obtain the encounter situation of the two ships. Step 7: Use COLEWGs to automatically label the yield obligation on the recognition results and visualize the encounter trajectory.
[0006] Furthermore, step 2 is further specified as follows: Step 2.1: Use the pyais module to parse the raw AIS data, retain dynamic information, extract static information, and finally store the data in the database, including time information, MMSI identifier, position coordinates (precision and latitude), speed and navigation status; Step 2.2: Traverse all trajectory points, segment the trajectory data of different ships according to the MMSI identifier, determine whether they are the same ship, and then determine whether they are the same trajectory according to the time difference between the data and the distance between the two points. Save the trajectory with more than 50 trajectory points; then preliminarily separate the different trajectory data of the same ship according to the AIS data reception time interval, then filter out the latitude and longitude drift points according to the ship speed and sailing distance, discard the latitude and longitude drift points, and obtain the correct different trajectory data of the same ship. Finally, separate the trajectory according to the distance between two adjacent points. Step 2.3: Region-specific numerical control filtering standards are used to remove outlier data for different areas. Then, for incomplete trajectories, the piecewise cubic Hermitian interpolation (PCHIP) method is used to reconstruct the complete ship trajectory. The core formula of PCHIP is as follows: ; In PCHIP interpolation, the meanings of the symbols are as follows: For the first One original data point; The interval length; For interval The slope of the secant line on the line; It is an interval The slope of the piecewise cubic polynomial in the interval The above is represented as: ; For data points PCHIP in each interval Construct a cubic polynomial above, where, This represents the function value of the polynomial at the nodes; For nodes The first derivative at (calculated by PCHIP rule); The coefficient of the quadratic term; The coefficient of the cubic term; , These represent the nodes respectively. , The estimated first derivative value is obtained at the location; Indicates the length of the interval The square of; To ensure data continuity, the ship's heading angle is processed for continuity; a threshold constraint is applied to the speed; and the time standardization formula is as follows: ; ; ; ; in The operation eliminates 360° jumps; This operation prevents the generation of unreasonable trajectory points. ; Convert timestamps to relative seconds to improve numerical stability; in, Indicates the original heading angle; To eliminate continuous heading angles after a 360° jump; The heading angle after interpolation and remapping; This is the relative time (in seconds) relative to the start time of the trajectory; The final speed after passing the minimum speed threshold constraint; t represents the current timestamp; Represents the minimum timestamp; Convert the time difference object to a floating-point number in seconds; This represents the velocity value calculated using an interpolation method; This indicates the physically reasonable minimum speed.
[0007] Furthermore, step 3 specifically involves: dividing the extraction process of ship encounter data into daily time segments, using daily AIS data as the basic processing unit to extract encounter scenarios, and then using the transverse Mercator (UTM) coordinate system for calculation. The projection formula is as follows: ; ; wherein, is the scale factor; is the radius of curvature of the prime vertical; is the square of the tangent of the latitude; is the correction factor; is the longitude difference from the central meridian; is the meridian arc length, represents the meridian arc length constant corresponding to the central meridian in the UTM projection; Then, according to the converted UTM coordinates, calculate the minimum spatial distance between the two ship tracks. If the calculated distance is less than the threshold of 30 meters, it is determined that there is a possibility of collision. The formula for the spatial distance is as follows: ; Furthermore, the specific steps of step 4 are as follows: During the encounter extraction process, there is a situation where similar tracks of the same ship are misjudged as encounters. The DTW algorithm is used to filter out such redundant cases. The core formula of the algorithm is as follows: ; Filter the encounter tracks again by calculating DTW. Finally, save the tracks that meet the conditions, number the encounters during the extraction process, and finally identify different encounters through the encounter numbers; wherein, is the first time series; is the second time series; is a time warping path used to align the elements in the sequences and one by one; is to find the path that minimizes the cumulative distance among all the warping paths that satisfy the boundary conditions, monotonicity, and continuity; is the th element in the sequence ; is the th element in, represents the local distance metric between two elements; represents the number of alignment points (i.e., the DTW path length) in the warping path . It should be noted that this has a different meaning from the index symbol used to represent intervals or data points in the PCHIP interpolation mentioned above.
[0008] Furthermore, the specific steps of step 5 are as follows: Step 5.1: The extracted ship encounter data is divided into three basic types: face-to-face encounter, overtaking, and cross encounter. The coarse classification is mainly based on the relative heading difference, and the marking rules are as follows: The DCPA (Discretionary Directional Approach) is used to determine whether a vessel encounter occurs. For a circle with a heading difference of 0°-360°, a head-on encounter occurs when the heading difference is within the range of 5°-355°. A head-on encounter occurs when the heading difference is within the range of 112.5°-247.5°, and overtaking involves passing maneuvering. Therefore, the speed of the overtaking vessel must be greater than the speed of the overtaken vessel for an overtaking encounter to occur; otherwise, it does not constitute an encounter. When the heading difference between the two vessels is within the ranges of 5°-112.5° and 247.5°-354°, it is a cross encounter. For overtaking scenarios, the speed difference between the vessels needs to be verified. It is stipulated that the speed of the overtaking vessel must be greater than the speed of the overtaken vessel by 0.2 knots for it to be identified as an overtaking scenario. For encounters that do not belong to the above three categories, i.e., irregular encounters, they are marked as "unknown" and discarded. Only encounter data belonging to the above three categories are studied. Step 5.2: Further classify the cross-encounter scenarios based on relative headings: when the relative headings are between 247.5° and 354°, it is determined to be a close encounter on the port side; when the relative headings are between 6.5° and 67.5°, it is determined to be a small-angle encounter on the starboard side; when the relative headings are between 67.5° and 112.5°, it is determined to be a large-angle encounter on the starboard side.
[0009] Furthermore, step 6 is further specified as follows: Step 6.1: Construct multiple feature combinations to capture high-order interaction features, while eliminating features with less influence. Random Forest (RF) is selected to capture geometric differences between ships using feature combinations. The random seed is fixed at random_state=42. The number of decision trees n_estimators is explored within the range of {100, 200, 300}, while the maximum tree depth max_depth is set to {none, 10} to control overfitting and feature interaction depth. Triple cross-validation is used, with the macro average F1 score f1_macro as the optimization objective. During dynamic feature extraction, a bidirectional LSTM is trained simultaneously. Input features include relative distance, relative speed, relative bearing, angular velocity, and distance change rate. The forward layer of the LSTM decodes historical operations, and the backward layer captures future cues. At the same time, a forget gate filters out erroneous data points caused by positioning drift. A weighted fusion is used to integrate the RF and Bi-LSTM models. The specific formula is as follows: ; in, This represents the class probability vector output by the final fusion model. This represents the weights assigned to the RF model; This represents the class probability vector output by the random forest model for the current sample; This is the class probability vector output by the bidirectional LSTM model for the current sample.
[0010] Step 6.2: In the static features of the fine classification, new indicators are introduced, such as starboard crossing angle, heading change difference, initial heading difference, relative bearing of the crossing point, and speed-heading combination features. The fine classification model of LightGBM and Attention LSTM uses the LightGBM algorithm to help distinguish between port and starboard crossing types. Through gradient one-sided sampling Goss and EFB technology of binding specific features, the parameter range of LightGBM is set as follows: number of trees n_estimators=[100,200,300], maximum depth max_depth=[4,5,6], learning rate learning_rate=[0.03,0.05,0.07], row sampling rate subsample=[0.6,0.8,1.0], column sampling rate colsample_bytree=[0.6,0.8,1.0]. Simultaneously, an attention-enhanced LSTM is introduced as a component of the fine-grained classification model. The Bahdanau attention mechanism is used to automatically learn time-step weights, assigning higher weights to the most critical temporal steps. A weighted fusion mechanism is also employed to combine the LightGBM model with the attention-enhanced LSTM, as shown in the following formula: ; in, This represents the class probability vector output by the LightGBM fine-grained classification model; This is the class probability vector output by the attention-enhanced LSTM fine-grained classification model; This is the final sub-classification probability output vector obtained by weighted fusion of the two models; This represents the weights assigned to the LightGBM model.
[0011] The beneficial effects of this invention are: 1. Improved encounter recognition accuracy and classification stability: This invention employs a two-stage hybrid encounter recognition architecture. In the first stage, coarse classification is achieved through weighted fusion of RF and bidirectional BiLSTM. In the second stage, fine classification is achieved through weighted fusion of LightGBM and attention LSTM. The architecture utilizes the temporal memory unit of LSTM to capture dynamic evolution patterns, compensating for the inability of traditional static geometric features to reflect temporal dependencies. The static branch of RF and LightGBM provides geometric constraints, while the dynamic branch of LSTM provides temporal evolution features. The fusion of these two achieves integrated spatiotemporal recognition. Compared to a single model, the classification accuracy is significantly improved, and the false positive rate is reduced.
[0012] 2. Improve the consistency and reliability of input data (solve the problem of insufficient data quality control): This invention establishes a complete data cleaning and screening process, including AIS message parsing, outlier removal, PCHIP interpolation, coordinate transformation, and DTW similarity filtering, which significantly improves the continuity of sample trajectories, effectively eliminates false encounters, and ensures that features and labels are consistent, reducing random errors in training and testing, stabilizing model input data, and ensuring the accuracy of recognition.
[0013] 3. Enhance model generalization ability and cross-sea adaptability (solve the problem of model fragility): This invention adopts a dual-branch structure of tree model and time series model to achieve complementarity, avoids the dependence of a single model on specific feature distribution, and enables the model to maintain a high recognition rate under different sea areas, sampling frequencies and other conditions; at the same time, it effectively improves the model stability and cross-sea capability, and reduces the cost of retraining.
[0014] 4. Improved stability of boundary sample discrimination: This invention employs a probability-weighted fusion and consistency constraint strategy in the model output layer, using a Softmax probability-weighted averaging method to form a smooth final classification result. This layer uses static thresholds as weighted fusion results, making the outputs of the same trajectory more consistent under different sampling rates, while improving the smoothness of the model's prediction results and significantly enhancing stability. Furthermore, by combining the recognition result domain CLOREGs, yield obligations are automatically labeled, providing navigators with reliable collision avoidance suggestions. Attached Figure Description
[0015] Figure 1 This is a flowchart of the identification method of the present invention; Figure 2 For the process of extraction, a flowchart is provided. Figure 3 A classification diagram of five types of encounter situations; Figure 4 This is a diagram of the architecture of a two-order hybrid encounter recognition model. Figure 5 Flowchart for building an LSTM model; Figure 6 This is a trajectory distribution diagram for a port-side crossover encounter in a meeting situation; Figure 7 This is a trajectory distribution diagram for a port-side crossover encounter in a meeting situation; Figure 8 This is a trajectory distribution diagram for a large-angle crossover encounter on the starboard side during a meeting situation; Figure 9 This is a trajectory distribution diagram for a large-angle crossover encounter on the starboard side during a meeting situation; Figure 10 This is a trajectory distribution diagram for a head-on encounter situation; Figure 11This is a trajectory distribution diagram for a head-on encounter situation; Figure 12 This is a trajectory distribution diagram for an encounter situation involving overtaking and meeting. Figure 13 This is a trajectory distribution diagram for an encounter situation involving overtaking and meeting. Figure 14 This is a trajectory distribution diagram for a small-angle encounter on the starboard side during a meeting situation; Figure 15 This is a trajectory distribution diagram for a small-angle encounter on the starboard side during a meeting situation. Detailed Implementation
[0016] The invention will now be further described with reference to the accompanying drawings.
[0017] Please see Figures 1 to 15 The present invention provides an embodiment: a two-order hybrid encounter identification method based on coastal vessel AIS data, the method comprising the following steps: Step 1: Extract AIS data from coastal vessels; Step 2: Decode, clean, segment, and preprocess the AIS messages using PCHIP interpolation; Step 3: Set a time window, convert the ship's latitude and longitude coordinates to the transverse Mercator projection plane coordinate system within the time window, and obtain the Euclidean spatial distance between ships based on the projected plane coordinates; Step 4: Filter candidate encounter samples using the DTW similarity matrix and extract encounter data; Step 5: Based on parameters such as relative heading, speed ratio, DCPA and TCPA, the encounter samples are labeled according to rules to form a coarse classification of crossing, overtaking, and facing each other. Then, they are further classified into five different types of crossing labels: crossing-port side, crossing-starboard side at a large angle, crossing-starboard side at a small angle, overtaking, and facing each other. Step 6: Establish a two-stage hybrid recognition model. In the first stage, random forest and bidirectional LSTM are used for fine classification. In the second stage, LightGBM and attention LSTM are used for weighted fusion for cross-fine classification to obtain the encounter situation of the two ships. Step 7: Use COLEWGs to automatically label the yield obligation on the recognition results and visualize the encounter trajectory.
[0018] Please continue reading. Figure 1 As shown, in one embodiment of the present invention, step 2 is further specifically described as follows: Step 2.1: Use the pyais module to parse the raw AIS data, retain dynamic information, extract static information, and finally store the data in the database, including time information, MMSI identifier, position coordinates (precision and latitude), speed and navigation status; the pyais module is a decoding tool for parsing raw AIS messages, used to parse NMEA format AIS messages into structured field data.
[0019] Step 2.2: Traverse all trajectory points, segment the trajectory data of different ships according to the MMSI identifier, determine whether they are the same ship, and then determine whether they are the same trajectory according to the time difference between the data and the distance between the two points. Save the trajectory with more than 50 trajectory points; then preliminarily separate the different trajectory data of the same ship according to the AIS data reception time interval, then filter out the latitude and longitude drift points according to the ship speed and sailing distance, discard the latitude and longitude drift points, and obtain the correct different trajectory data of the same ship. Finally, separate the trajectory according to the distance between two adjacent points. Step 2.3: Region-specific numerical control filtering standards are used to remove outlier data for different areas. Then, for incomplete trajectories, the piecewise cubic Hermitian interpolation (PCHIP) method is used to reconstruct the complete ship trajectory. The core formula of PCHIP is as follows: ; In PCHIP interpolation, the meanings of the symbols are as follows: For the first One original data point; The interval length; For interval The slope of the secant line on the line; It is an interval The slope of the piecewise cubic polynomial in the interval The above is represented as: ; For data points PCHIP in each interval Construct a cubic polynomial above, where, This represents the function value of the polynomial at the nodes; For nodes The first derivative at (calculated by PCHIP rule); The coefficient of the quadratic term; The coefficient of the cubic term; , These represent the nodes respectively. , The estimated first derivative value is obtained at the location; Indicates the length of the interval The square of; Meanwhile, to ensure data continuity, the ship's course angle is processed for continuity; the speed is constrained by a threshold; the formula for time normalization is as follows: ; ; ; ; where The operation eliminates the 360° jump; The operation prevents the generation of unreasonable trajectory points, ; Convert the timestamp to relative seconds to improve numerical stability; where, represents the original course angle; is the continuous course angle after eliminating the 360° jump; is the interpolated and remapped course angle; is the relative time (seconds) relative to the start time of the trajectory; is the final speed after being constrained by the minimum speed threshold; t represents the current timestamp; represents the minimum timestamp; Convert the time difference object to a floating point number in seconds; represents the speed value calculated by the interpolation method; represents the set physically reasonable minimum ship speed.
[0020] Please continue to refer to Figure 2 As shown, in an embodiment of the present invention, step 3 is further specifically as follows: The process of extracting ship encounter data is segmented by day, and the encounter scenarios are extracted with the daily AIS data as the basic processing unit, and then the transverse Mercator (UTM) coordinate system is used for calculation. The projection formula is as follows: ; ; where, is the scale factor; is the radius of curvature of the prime vertical; is the square of the tangent of the latitude; is the correction factor; is the longitude difference from the central meridian; is the meridian arc length, represents the meridian arc length constant corresponding to the central meridian in the UTM projection; Then, based on the converted UTM coordinates, the minimum spatial distance between the two ship tracks is calculated. If the calculated distance is less than the threshold of 30 meters, it is determined that there is a possibility of a collision. The formula for calculating the spatial distance is as follows: ; Please continue reading. Figure 2 As shown, in one embodiment of the present invention, step 4 is further specifically as follows: During the encounter extraction process, there may be cases where similar trajectories of the same vessel are mistakenly identified as encounters. The DTW algorithm is used to filter out such redundant cases. The core formula of the algorithm is as follows: ; The encounter trajectories are further filtered by calculating DTW (Deep Time Wave), and the trajectories that meet the conditions are finally saved. During the extraction process, encounters are numbered, and different encounters are finally identified by their encounter numbers. This is the first time series; This is the second time series; This is a time-warped path used to transform the sequence and Align the elements in the text one by one; For all regular paths that satisfy boundary conditions, monotonicity, and continuity In the process, find the path that minimizes the cumulative distance; For sequence The Middle One element; for The Middle One element, This represents a local distance metric between two elements. Represents a regular path The number of alignment points (i.e., DTW path length) in the data should be noted. The meaning of the index symbol used to represent intervals or data points is different from that used in PCHIP interpolation mentioned earlier.
[0021] Please continue reading. Figure 3 As shown, in one embodiment of the present invention, step 5 is further specifically described as follows: Step 5.1: The extracted ship encounter data is divided into three basic types: face-to-face encounter, overtaking, and cross encounter. The coarse classification is mainly based on the relative heading difference, and the marking rules are as follows: The DCPA (Discretionary Directional Approach) is used to determine whether a vessel encounter occurs. For a circle with a heading difference of 0°-360°, a head-on encounter occurs when the heading difference is within the range of 5°-355°. A head-on encounter occurs when the heading difference is within the range of 112.5°-247.5°, and overtaking involves passing maneuvering. Therefore, the speed of the overtaking vessel must be greater than the speed of the overtaken vessel for an overtaking encounter to occur; otherwise, it does not constitute an encounter. When the heading difference between the two vessels is within the ranges of 5°-112.5° and 247.5°-354°, it is a cross encounter. For overtaking scenarios, the speed difference between the vessels needs to be verified. It is stipulated that the speed of the overtaking vessel must be greater than the speed of the overtaken vessel by 0.2 knots for it to be identified as an overtaking scenario. For encounters that do not belong to the above three categories, i.e., irregular encounters, they are marked as "unknown" and discarded. Only encounter data belonging to the above three categories are studied. Step 5.2: Further classify the cross-encounter scenarios based on relative headings: when the relative headings are between 247.5° and 354°, it is determined to be a close encounter on the port side; when the relative headings are between 6.5° and 67.5°, it is determined to be a small-angle encounter on the starboard side; when the relative headings are between 67.5° and 112.5°, it is determined to be a large-angle encounter on the starboard side.
[0022] Please continue reading. Figure 4 As shown, in one embodiment of the present invention, step 6 is further specifically described as follows: Step 6.1: Construct multiple feature combinations to capture high-order interaction features, while eliminating features with less influence. Random Forest (RF) is selected to capture geometric differences between ships using feature combinations. The random seed is fixed at random_state=42. The number of decision trees n_estimators is explored within the range of {100, 200, 300}, while the maximum tree depth max_depth is set to {none, 10} to control overfitting and feature interaction depth. Triple cross-validation is used, with the macro average F1 score f1_macro as the optimization objective. During dynamic feature extraction, a bidirectional LSTM is trained simultaneously. Input features include relative distance, relative speed, relative bearing, angular velocity, and distance change rate. The forward layer of the LSTM decodes historical operations, and the backward layer captures future cues. At the same time, a forget gate filters out erroneous data points caused by positioning drift. A weighted fusion is used to integrate the RF and Bi-LSTM models. The specific formula is as follows: ; in, This represents the class probability vector output by the final fusion model. This represents the weights assigned to the RF model. This represents the class probability vector output by the random forest model for the current sample; This is the class probability vector output by the bidirectional LSTM model for the current sample; Step 6.2: In the static features of the fine classification, new indicators are introduced, such as starboard crossing angle, heading change difference, initial heading difference, relative bearing of the crossing point, and speed-heading combination features. The fine classification model of LightGBM and Attention LSTM uses the LightGBM algorithm to help distinguish between port and starboard crossing types. Through gradient one-sided sampling Goss and EFB technology of binding specific features, the parameter range of LightGBM is set as follows: number of trees n_estimators=[100,200,300], maximum depth max_depth=[4,5,6], learning rate learning_rate=[0.03,0.05,0.07], row sampling rate subsample=[0.6,0.8,1.0], column sampling rate colsample_bytree=[0.6,0.8,1.0]. Simultaneously, an attention-enhanced LSTM is introduced as a component of the fine-grained classification model. The Bahdanau attention mechanism is used to automatically learn time-step weights, assigning higher weights to the most critical temporal steps. A weighted fusion mechanism is also employed to combine the LightGBM model with the attention-enhanced LSTM, as shown in the following formula: ; in, This represents the class probability vector output by the LightGBM fine-grained classification model; This is the class probability vector output by the attention-enhanced LSTM fine-grained classification model; This is the final sub-classification probability output vector obtained by weighted fusion of the two models; This represents the weights assigned to the LightGBM model. Specific Implementation
[0023] This invention provides a two-order hybrid encounter identification method based on AIS data, which accurately classifies data under different encounter situations and automatically marks yield obligations using COLREGs, providing effective collision avoidance decision support for intelligent navigation systems.
[0024] The technical solution of this invention is illustrated in the flowchart below. Figure 1 As shown; A two-order hybrid encounter recognition method based on AIS data, the method comprising the following steps: Step 1: Extract AIS data; Step 2: Decode, clean, segment, and preprocess the AIS messages using PCHIP interpolation; Step 3: Set the time window and calculate the spatial distance in the horizontal Mercator coordinate system; Step 4: Combine DTW similarity matrix filtering to extract encounter data; Step 5: Based on parameters such as relative heading, speed ratio, DCPA and TCPA, the encounter samples are labeled according to rules to form a coarse classification of cross, overtaking, and facing. Then, they are further classified into five different types of cross labels: cross-port, cross-starboard at a large angle, cross-starboard at a small angle, overtaking, and facing. Step 6: Establish a two-stage hybrid recognition model. In the first stage, random forest and bidirectional LSTM are used for fine classification. In the second stage, LightGBM and attention LSTM are used for weighted fusion for cross-fine classification to obtain the encounter situation of the two ships. Step 7: Use COLEWGs to automatically label the yield obligation on the recognition results and visualize the encounter trajectory.
[0025] Furthermore, step 2 is further specified as follows: Step 2.1: Use the pyais module to parse the raw AIS data. Since the research content is about encounters, only dynamic information is retained and static information is extracted. The data finally stored in the database includes time information, MMSI identifier, position coordinates (precision and latitude), speed and navigation status. Step 2.2: Segment the trajectory data of different ships based on the MMSI identifier after traversing all trajectory points. First, determine if they belong to the same ship. Then, determine if they belong to the same trajectory based on the time difference between data points and the distance between two points. Since too few trajectory points will result in incomplete trajectories, save trajectories with more than 50 trajectory points. Next, preliminarily separate different trajectory data of the same ship based on the AIS data reception time interval. Then, filter out latitude and longitude drift points based on ship speed and sailing distance, discarding latitude and longitude drift points to obtain the correct different trajectory data of the same ship. Finally, separate the trajectory based on the distance between adjacent points.
[0026] Step 2.3: Region-specific numerical control filtering standards are used to remove outlier data for different areas. Then, for incomplete trajectories, the piecewise cubic Hermitian interpolation (PCHIP) method is used to reconstruct the complete ship trajectory. The core formula of PCHIP is as follows: ; in, For data points PCHIP in each interval A cubic polynomial constructed on the above; It is an interval The slope; , .
[0027] To ensure data continuity, the ship's heading angle is processed for continuity; a threshold constraint is applied to the speed; and the time standardization formula is as follows: ; ; ; ; where the operation eliminates 360° jumps; the operation prevents the generation of unreasonable trajectory points, ; Convert the timestamp to relative seconds to improve numerical stability.
[0028] Furthermore, step 3 is specifically as follows: The flowchart for encounter process extraction is as shown in Figure 2 ; Divide the encounter extraction process into daily periods, and then use the Universal Transverse Mercator (UTM) coordinate system for calculation. The projection formula is as follows: ; ; where, is the scale factor; is the radius of curvature of the prime vertical; is the square of the tangent of the latitude; is the correction factor; is the longitude difference from the central meridian; is the length of the meridian arc.
[0029] Then, according to the converted UTM coordinates, calculate the minimum spatial distance between the two ship tracks. If the calculated distance is less than the 30-meter threshold, it is determined that a collision has occurred. The spatial distance calculation formula is as follows: ; Step 4 is further specifically as follows: During the encounter extraction process, there may be a situation where similar tracks of the same ship are misjudged as encounters. Use the DTW algorithm to filter out such redundant cases. The core formula of the algorithm is as follows: ; Filter the encounter tracks again by calculating DTW, and finally save the tracks that meet the conditions. Number the encounter pairs during the extraction process, and finally identify different encounters through the encounter numbers.
[0030] Step 5 is further specifically as follows: The classification diagram of five types of encounter situations is as shown in Figure 3 ; Step 5.1: The extracted ship encounter data is divided into three basic types: face-to-face encounter, overtaking, and cross encounter. The coarse classification is mainly based on the relative heading difference, and the marking rules are as follows: Determining whether a vessel encounter is imminent based on DCPA; For a circle with a heading difference of 0°-360°, a head-on encounter occurs when the heading difference is between 5°-355°; an overtaking encounter occurs when the heading difference is between 112.5°-247.5°, and overtaking involves passing maneuvering, so the speed of the overtaking vessel must be greater than the speed of the overtaken vessel for an overtaking encounter to occur; otherwise, an encounter does not occur; a cross encounter occurs when the heading difference between the two vessels is between 5°-112.5° and between 247.5°-354°. For overtaking scenarios, the speed difference between vessels needs to be verified. It is stipulated that the speed of the overtaking vessel must be greater than 0.2 knots of the speed of the overtaken vessel in order to be identified as an overtaking scenario. For encounters that do not belong to the above three categories, i.e., irregular encounters, they are marked as "unknown" and removed. Only the encounter data that belong to the above three categories are studied.
[0031] Step 5.2: Further classify the encounter scenarios based on relative headings: when the relative heading is between 247.5° and 354°, it is classified as a close encounter on the port side, corresponding to area E; when the relative heading is between 6.5° and 67.5°, it is classified as a small-angle encounter on the starboard side, corresponding to area B; when the relative heading is between 67.5° and 112.5°, it is classified as a large-angle encounter on the starboard side, corresponding to area C. Through this two-stage classification method, the encounter scenarios are ultimately divided into five distinct categories.
[0032] Step 5.3: Finally, 3691 pairs of ship encounter trajectory data were extracted. The number of samples in each category is shown in Table 1. After data balancing, 315 samples were selected for each coarse-grained level and 179 samples were selected for each fine-grained level, as shown in Table 2. Table 1 Sample Count for Each Category Encounter Scene quantity Crossing 1786 Head-on 535 Overtaking 315 Port side crossing 1353 Large-angle crossing on the starboard side 179 Small-angle crossing on the starboard side 254 Table 2 Number of samples selected for each category Encounter Scene quantity Overtaking 315 Head-on 315 Port side crossing 179 Large-angle crossing on the starboard side 179 Small-angle crossing on the starboard side 179 Step 6 further specifies: The architecture diagram of the two-order hybrid encounter recognition model is as follows: Figure 4As shown, the architecture of the two-stage hybrid encounter recognition model is illustrated. This model divides the classification task into two stages: the first stage is the coarse classification stage, which is a weighted fusion of RF and bidirectional LSTM to output the result: the encounter scene is divided into three types: intersection, overtaking, and head-on; the second stage is the fine classification stage, which is a weighted fusion of LightGBM (gradient boosting tree) and attention LSTM to input the result: all intersection encounter scenes are finely classified into intersection-port, intersection-starboard large angle, and intersection-starboard small angle.
[0033] Step 6.1: Construct multiple feature combinations to capture high-order interaction features, while eliminating features with low impact (importance < 0.02). Random Forest (RF) is used to capture geometric differences between ships using feature combinations. The random seed is fixed at (random_state = 42). The number of decision trees (n_estimators) is explored within the range of {100, 200, 300}, while the maximum tree depth (max_depth) is set to {none, 10} to control overfitting and feature interaction depth. Triple-fold cross-validation is used, with the macro-average F1 score (f1_macro) as the optimization objective. On the other hand, a bidirectional LSTM is trained simultaneously during dynamic feature extraction. Input features include relative distance, relative speed, relative bearing, angular velocity, and distance change rate. The LSTM's forward layer decodes historical operations, and the backward layer captures future cues. Simultaneously, a forget gate filters out erroneous data points caused by positioning drift. The model construction process is as follows: Figure 5 As shown; Finally, a weighted fusion method is used to integrate the RF and Bi-LSTM models, as shown in the following formula: ; in, This represents the probability output vector for each category. This represents the weights assigned to the RF model.
[0034] Step 6.2: In the detailed static features, new indicators are introduced, such as starboard crossing angle, heading change difference, initial heading difference, relative bearing of the crossing point, and speed-heading combination features. The model uses the LightGBM algorithm to help distinguish between port and starboard crossing types. Through gradient one-sided sampling (Goss) and feature binding by specific features (EFB) technology, the parameter range of LightGBM is set as follows: number of trees n_estimators=[100,200,300], maximum depth max_depth=[4,5,6], learning rate learning_rate=[0.03,0.05,0.07], row sampling rate subsample=[0.6,0.8,1.0], column sampling rate colsample_bytree=[0.6,0.8,1.0]. Simultaneously, an attention-enhanced LSTM is introduced as a component of the fine-grained classification model. The model structure is shown in the figure. The Bahdanau attention mechanism is set to automatically learn the time step weights, assigning higher weights to the most critical time steps. Similarly, a weighted fusion mechanism is used to combine the LightGBM model with the attention-enhanced LSTM. The specific formula is as follows: in, This represents the probability output vector for each category. This represents the weights assigned to the LightGBM model.
[0035] Step 7 is further specified as follows: To verify the accuracy of the developed two-order hybrid method in identifying encounter types, as shown in Table 3 and referring to the collision avoidance criteria specified by COLREGs, as shown in Table 4, the verification data and predicted data were visualized. Furthermore, the encounter trajectory of ships was visualized by labeling avoidance responsibilities. Based on the visualization results, as shown... Figures 6-15 As shown, the model demonstrates its superior performance in collision recognition, reducing the risk of collisions caused by misjudging encounters and thus improving maritime navigation safety.
[0036] Table 3 COLREGs specifies collision avoidance rules
[0037] Table 4. Display of Validation Data and Predicted Data
[0038] The present invention has the following working principle: In the first step, a coarse classification of encounters (crossing, overtaking, facing) is achieved by using RF and BiLSTM weighted fusion. In the second step, for the "crossing" class samples in the coarse classification, a fine classification is performed by using LightGBM and AttentionLSTM weighted fusion (crossing-port, crossing-starboard large angle, crossing-starboard small angle). This hierarchical architecture significantly improves the separability and stability of the model and solves the problems of easy confusion and high sample misclassification rate in one-step multi-classification.
[0039] The dual-branch weighted fusion mechanism of static geometric features and dynamic temporal features: In each stage of the model, the present invention adopts a "static + dynamic" dual-branch structure. The static branch (RF and LightGBM) handles geometric quantities, and the dynamic branch (BiLSTM and Attention LSTM) handles temporal features. The outputs of the two branches are fused by weight, making the classification results more robust under complex sea conditions.
[0040] An end-to-end data quality control chain based on PCHIP interpolation, projection distance, and DTW filtering: This invention designs a complete quality control process in the AIS data preprocessing stage. First, PCHIP interpolation is used to repair trajectory gaps; second, latitude and longitude are projected to the UTM coordinate system; and finally, DTW similarity matrix is used to eliminate spurious encounter samples. This quality control chain effectively improves the quality of input data and provides stable samples for model training.
[0041] Introduction of attention mechanism in dynamic feature recognition of encounters: An attention-enhanced LSTM network is introduced in the fine classification stage. The attention focusing module adopts the constructed Bahdanau attention mechanism, which automatically focuses on key steps before and after CPA through the time weight allocation mechanism, improving the model's sensitivity to differences in cross angle. This introduction effectively suppresses redundant information interference when processing long sequence inputs.
[0042] The above description is only a preferred embodiment of the present invention and should not be construed as a limitation of this application. All equivalent changes and modifications made in accordance with the scope of the patent application of the present invention should be covered by the present invention.
Claims
1. A two-order hybrid encounter identification method based on coastal vessel AIS data, characterized in that: The method includes the following steps: Step 1: Extract AIS data from coastal vessels; Step 2: Decode, clean, segment, and preprocess the AIS messages using PCHIP interpolation; Step 3: Set a time window, convert the ship's latitude and longitude coordinates to the transverse Mercator projection plane coordinate system within the time window, and obtain the Euclidean spatial distance between ships based on the projected plane coordinates; Step 4: Filter candidate encounter samples using the DTW similarity matrix and extract encounter data; Step 5: Based on parameters such as relative heading, speed ratio, DCPA and TCPA, the encounter samples are labeled according to rules to form a coarse classification of crossing, overtaking, and facing each other. Then, they are further classified into five different types of crossing labels: crossing-port side, crossing-starboard side at a large angle, crossing-starboard side at a small angle, overtaking, and facing each other. Step 6: Establish a two-stage hybrid recognition model. In the first stage, random forest and bidirectional LSTM are used for fine classification. In the second stage, LightGBM and attention LSTM are used for weighted fusion for cross-fine classification to obtain the encounter situation of the two ships. Step 7: Use COLEWGs to automatically label the yield obligation on the recognition results and visualize the encounter trajectory.
2. The two-order hybrid encounter identification method based on coastal vessel AIS data according to claim 1, characterized in that: Step 2 is further specified as follows: Step 2.1: Use the pyais module to parse the raw AIS data, retain dynamic information, extract static information, and finally store the data in the database, including time information, MMSI identifier, position coordinates (precision and latitude), speed and navigation status; Step 2.2: Traverse all trajectory points, segment the trajectory data of different ships according to the MMSI identifier, determine whether they are the same ship, and then determine whether they are the same trajectory according to the time difference between the data and the distance between the two points. Save the trajectory with more than 50 trajectory points; then preliminarily separate the different trajectory data of the same ship according to the AIS data reception time interval, then filter out the latitude and longitude drift points according to the ship speed and sailing distance, discard the latitude and longitude drift points, and obtain the correct different trajectory data of the same ship. Finally, separate the trajectory according to the distance between two adjacent points. Step 2.3: Region-specific numerical control filtering standards are used to remove outlier data for different areas. Then, for incomplete trajectories, the piecewise cubic Hermitian interpolation (PCHIP) method is used to reconstruct the complete ship trajectory. The core formula of PCHIP is as follows: ; In PCHIP interpolation, the meanings of the symbols are as follows: For the first One original data point; The interval length; For interval The slope of the secant line on the secant line; It is an interval The slope of the piecewise cubic polynomial in the interval Represented as ; For data points PCHIP in each interval Construct a cubic polynomial above, where, The function value of the polynomial at the node; For nodes The first derivative at (calculated by PCHIP rule); The coefficient of the quadratic term; The coefficient of the cubic term; , These represent the nodes respectively. , The estimated first derivative value is obtained at the location; Indicates the length of the interval The square of; To ensure data continuity, the ship's heading angle is processed for continuity; a threshold constraint is applied to the speed; and the time standardization formula is as follows: ; ; ; ; The operation eliminates 360° jumps; This operation prevents the generation of unreasonable trajectory points. ; Convert timestamps to relative seconds to improve numerical stability; in, Indicates the original heading angle; To eliminate continuous heading angles after a 360° jump; The heading angle after interpolation and remapping; This is the relative time (in seconds) relative to the start time of the trajectory; The final speed after passing the minimum speed threshold constraint; t represents the current timestamp; Represents the minimum timestamp; Convert the time difference object to a floating-point number in seconds; This represents the velocity value calculated using an interpolation method; This indicates the physically reasonable minimum speed.
3. The two-order hybrid encounter identification method based on coastal vessel AIS data according to claim 1, characterized in that: Step 3 is further specified as follows: the extraction process of ship encounter data is divided into daily time segments, and the encounter scene is extracted using daily AIS data as the basic processing unit. Then, the transverse Mercator (UTM) coordinate system is used for calculation, and the projection formula is as follows: ; ; Among them, is the scale factor; is the radius of curvature of the prime vertical; is the square of the tangent of the latitude; is the correction factor; is the longitude difference from the central meridian; is the arc length of the meridian, represents the meridian arc length constant corresponding to the central meridian in the UTM projection; Then, based on the converted UTM coordinates, the minimum spatial distance between the two ship tracks is calculated. If the calculated distance is less than the threshold of 30 meters, it is determined that there is a possibility of a collision. The formula for calculating the spatial distance is as follows: .
4. The two-stage hybrid encounter identification method based on coastal vessel AIS data according to claim 1, characterized in that: Step 4 is further specified as follows: During the encounter extraction process, there may be cases where similar trajectories of the same vessel are mistakenly identified as encounters. The DTW algorithm is used to filter out such redundant cases. The core formula of the algorithm is as follows: ; The encounter trajectories are further filtered by calculating DTW (Deep Time Wave), and the trajectories that meet the conditions are finally saved. During the extraction process, encounters are numbered, and different encounters are finally identified by the encounter number. This is the first time series; This is the second time series; This is a time-warped path used to transform the sequence and Align the elements in the text one by one; For all regular paths that satisfy boundary conditions, monotonicity, and continuity In the process, find the path that minimizes the cumulative distance; For sequence The Middle One element; for The Middle One element, This represents a local distance metric between two elements. Represents a regular path The number of alignment points (i.e., DTW path length) in the data should be noted. The meaning of the index symbol used to represent intervals or data points is different from that used in PCHIP interpolation mentioned earlier.
5. The two-stage hybrid encounter identification method based on coastal vessel AIS data according to claim 1, characterized in that: Step 5 is further specified as follows: Step 5.1: The extracted ship encounter data is divided into three basic types: face-to-face encounter, overtaking, and cross encounter. The coarse classification is mainly based on the relative heading difference, and the marking rules are as follows: The DCPA (Discretionary Directional Approach) is used to determine whether a vessel encounter occurs. For a circle with a heading difference of 0°-360°, a head-on encounter occurs when the heading difference is within the range of 5°-355°. A head-on encounter occurs when the heading difference is within the range of 112.5°-247.5°, and overtaking involves passing maneuvering. Therefore, the speed of the overtaking vessel must be greater than the speed of the overtaken vessel for an overtaking encounter to occur; otherwise, it does not constitute an encounter. When the heading difference between the two vessels is within the ranges of 5°-112.5° and 247.5°-354°, it is a cross encounter. For overtaking scenarios, the speed difference between the vessels needs to be verified. It is stipulated that the speed of the overtaking vessel must be greater than the speed of the overtaken vessel by 0.2 knots for it to be identified as an overtaking scenario. For encounters that do not belong to the above three categories, i.e., irregular encounters, they are marked as "unknown" and discarded. Only encounter data belonging to the above three categories are studied. Step 5.2: Further classify the cross-encounter scenarios based on relative headings: when the relative headings are between 247.5° and 354°, it is determined to be a close encounter on the port side; when the relative headings are between 6.5° and 67.5°, it is determined to be a small-angle encounter on the starboard side; when the relative headings are between 67.5° and 112.5°, it is determined to be a large-angle encounter on the starboard side.
6. The two-order hybrid encounter identification method based on coastal vessel AIS data according to claim 1, characterized in that: Step 6 is further specified as follows: Step 6.1: Construct multiple feature combinations to capture high-order interaction features, while eliminating features with less influence. Random Forest (RF) is selected to capture geometric differences between ships using feature combinations. The random seed is fixed at random_state=42. The number of decision trees n_estimators is explored within the range of {100, 200, 300}, while the maximum tree depth max_depth is set to {none, 10} to control overfitting and feature interaction depth. Triple cross-validation is used, with the macro average F1 score f1_macro as the optimization objective. During dynamic feature extraction, a bidirectional LSTM is trained simultaneously. Input features include relative distance, relative speed, relative bearing, angular velocity, and distance change rate. The forward layer of the LSTM decodes historical operations, and the backward layer captures future cues. At the same time, a forget gate filters out erroneous data points caused by positioning drift. A weighted fusion is used to integrate the RF and Bi-LSTM models. The specific formula is as follows: ; in, This represents the class probability vector output by the final fusion model; This represents the weights assigned to the RF model; This represents the class probability vector output by the random forest model for the current sample; This is the class probability vector output by the bidirectional LSTM model for the current sample; Step 6.2: In the static features of the fine classification, new indicators are introduced, such as starboard crossing angle, heading change difference, initial heading difference, relative bearing of the crossing point, and speed-heading combination features. The fine classification model of LightGBM and Attention LSTM uses the LightGBM algorithm to help distinguish between port and starboard crossing types. Through gradient one-sided sampling Goss and EFB technology of binding specific features, the parameter range of LightGBM is set as follows: number of trees n_estimators=[100,200,300], maximum depth max_depth=[4,5,6], learning rate learning_rate=[0.03,0.05,0.07], row sampling rate subsample=[0.6,0.8,1.0], column sampling rate colsample_bytree=[0.6,0.8,1.0]. Simultaneously, an attention-enhanced LSTM is introduced as a component of the fine-grained classification model. The Bahdanau attention mechanism is used to automatically learn time-step weights, assigning higher weights to the most critical temporal steps. A weighted fusion mechanism is also employed to combine the LightGBM model with the attention-enhanced LSTM, as shown in the following formula: ; in, This represents the class probability vector output by the LightGBM fine-grained classification model; This is the class probability vector output by the attention-enhanced LSTM fine-grained classification model; This is the final sub-classification probability output vector obtained by weighted fusion of the two models; The table represents the weights assigned to the LightGBM model.