Ship arrival time prediction method, system and device based on deep contrastive learning
Through a deep contrast learning method, using the ship's AIS, meteorological and maritime data for feature extraction and model training, the problem of inaccurate prediction of ship arrival time in the existing technology is solved, and higher accuracy and reliability are achieved .
Patent Information
- Application Number
- CN202411452608.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-17
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-10-17
AI Technical Summary
The existing ship arrival time prediction methods are affected by weather, sea conditions and other factors. Data quality and integrity issues lead to inaccurate prediction results and lack of high-reliability prediction solutions.
Using a deep contrast learning method, data cleaning and feature extraction are carried out by obtaining the ship's AIS data, meteorological data and sea transportation paths, and a model containing feature extractor, projection head and prediction layer is constructed, and comparison loss and mean square error are used for Two-stage training generates accurate arrival time prediction.
It improves the accuracy and reliability of ship arrival time prediction, can adapt to non-stationary time series and environmental changes, reduces the impact of data missing or errors on the prediction results, and provides more accurate navigation time prediction.
Smart Images

Figure CN118966483B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of shipping, and specifically relates to a ship arrival time prediction method based on deep contrast learning and a corresponding ship arrival time prediction system and device. Background Art
[0002] As global trade continues to deepen, shipping, as an important part of international trade, has a direct impact on the stability and cost of the global supply chain. The uncertainty of ship arrival time has always posed challenges to port operations, cargo scheduling and inventory management. Therefore, accurate prediction of ship arrival time is crucial to the shipping industry.
[0003] The existing method of predicting the arrival time of a ship is to calculate based on the real-time position and sailing speed of the ship. However, this prediction method is affected by factors such as weather and sea conditions. In addition, this type of ship arrival time prediction method is also highly dependent on the quality and integrity of the data. When the data is missing, wrong or inconsistent, it may cause a large deviation between the prediction result and the actual arrival time. Therefore, those skilled in the art are in urgent need of a ship arrival time prediction solution with higher reliability and more accurate prediction results. Summary of the invention
[0004] In order to solve the problem that it is difficult to accurately predict the arrival time of sea-going vessels in the prior art, the present invention provides a ship arrival time prediction method based on deep comparative learning and a corresponding ship arrival time prediction system and device.
[0005] The technical solution provided by the present invention is:
[0006] A method for predicting ship arrival time based on deep contrastive learning comprises the following steps:
[0007] S1: Obtain the process data corresponding to each voyage of the ship, including AIS data, meteorological data and shipping route.
[0008] Among them, AIS data includes the ship’s MMSI code, timestamp t , Speed V t ,course , Vessel position L t . Weather data including wind speed W t ,wind direction and rainfall B t The shipping route includes the starting port, arrival port and distance of the current voyage, as well as all ports or waypoints passed.
[0009] S2: Perform data cleaning, timestamp alignment and normalization on all process data contained in each voyage to obtain voyage spatiotemporal information containing various feature information D t : .in, It indicates the theoretical speed after correction according to wind speed and direction; W t Represents binary meteorological features.
[0010] The space-time information of all voyages included in the same voyage D t The sequence data constitutes a feature set.
[0011] S3: Collect a large number of real feature sets to form a sample data set, and select a number of positive sample pairs and negative sample pairs according to the MMSI code, meteorological characteristics and shipping routes corresponding to each feature set. The positive sample pairs and negative sample pairs constitute a pre-training set.
[0012] S4: Based on the contrastive learning framework, a ship arrival prediction model consisting of a feature extractor, a projection head, and a prediction layer is constructed. The feature extractor and the projection head are based on the input D t Extract feature vectors F c ; The prediction layer is based on the input F c Generate arrival time forecasts.
[0013] S5: Set contrast loss as the loss function, use the pre-training set to pre-train the feature extraction performance of the feature extractor and projection head in the ship arrival prediction model, and retain the pre-trained model parameters.
[0014] S6: Set the mean square error as the loss function, use the sample data set to train and verify the pre-trained complete ship arrival prediction model, and retain the model parameters of the network model that meets the prediction accuracy target.
[0015] S7: Input the spatiotemporal information of the current voyage into the trained ship arrival prediction model D t The ship arrival prediction model generates the predicted arrival time of the destination port based on the sequence data.
[0016] As a further improvement of the present invention, in step S2, the flight time and space information D t The generation process of the feature set is as follows:
[0017] S21: Perform data cleaning on each characteristic parameter in the collected process data, and delete duplicate data and abnormal data.
[0018] S22: Consider V t and right W t and Calculate the corrected theoretical speed .
[0019] S23: According to W t and B t The impact degree of ship navigation is binary processed and the discrete meteorological characteristics are generated. W t : W t =[ W t , B t ].
[0020] S24: According to time t Theoretical speed , Meteorological characteristics W t and ship position L t Timestamps are aligned and missing data of any feature parameters are supplemented by interpolation.
[0021] S25: concatenate the feature vectors from different data sources in the order of timestamps and merge them into a unified data structure to obtain the voyage time and space information D t , consisting of all the space-time information of the same voyage D t The sequence data constitutes a feature set.
[0022] As a further improvement of the present invention, in step S21, a box plot method is used to identify abnormal values contained in the process data of ship speed, wind speed and ship position, and delete them.
[0023] As a further improvement of the present invention, in step S22, the theoretical speed The correction method is as follows:
[0024] (1) Calculate the relative angle between wind direction and heading using the following formula: :
[0025]
[0026] (2) Based on relative angle The current navigation status Ut Divided into tailwind, headwind and crosswind:
[0027]
[0028] (3) Combined with navigation status U t The corrected theoretical speed is calculated by the following formula :
[0029]
[0030] In the above formula, k 1 and k 2 They respectively represent the influence coefficients of tailwind and headwind on the ship's sailing speed and satisfy: k 1 >1,0< k 2 <1.
[0031] As a further improvement of the present invention, in step S23, the expression for the binary processing of wind speed and rainfall is as follows:
[0032]
[0033] in, H w Indicates the wind speed threshold that can affect the navigation of ships; H B Indicates the rainfall threshold that can affect ship navigation.
[0034] As a further improvement of the present invention, in step S3, two sample data generated by the same type of ship on a similar navigation path and a voyage under the same meteorological conditions are selected to form a group positive sample pair. Two sample data generated by different types of ships on opposite navigation paths or voyages under different meteorological conditions are selected to form a group negative sample pair.
[0035] As a further improvement of the present invention, in step S4, the expression of the feature extractor is as follows:
[0036]
[0037] In the above formula, W c represents the convolution kernel; Z c is the output of the convolutional layer; Conv Represents the convolution operation; b c Represents the bias vector of the convolutional layer; LU represents the activation function; ARepresents the output of the activation function; P Represents the output of the pooling layer; F c represents the output of the feature extractor; MaxPool Represents a max pooling operation.
[0038] The expression of the projection head is as follows:
[0039]
[0040] In the above formula, Z p represents the output of the fully connected layer, W p represents the weight matrix of the fully connected layer, b p Represents the bias vector of the fully connected layer; H Represents the output of the activation function; F L Indicates the output of the projection head.
[0041] The prediction layer uses RNN or LSTM.
[0042] As a further improvement of the present invention, in step S5, the contrast loss function in the pre-training stage is L s as follows:
[0043]
[0044] In the above formula, S p is the similarity of the positive sample pair; For the i Similarity of group negative sample pairs; M Represents the number of negative sample pairs.
[0045] In step S6, the mean square error loss function used in the training phase is L MSE as follows:
[0046]
[0047] In the above formula, N Indicates the number of sample data in the training set; y i Indicates the true value of the arrival time; Indicates the predicted value of arrival time.
[0048] The present invention also includes a ship arrival time prediction system, which includes: a data acquisition module, a data processing module and a prediction module.
[0049] The data collection module collects AIS data, meteorological data and shipping routes corresponding to each ship's voyage in real time through ground base stations, meteorological satellites and the official database of the port administration.
[0050] The data processing module is used to use the ship arrival time prediction method based on deep contrast learning as mentioned above to clean, align and normalize the process data contained in each voyage collected by the data acquisition module, and obtain the voyage spatiotemporal information containing multiple feature information. D t .
[0051] The prediction module runs a ship arrival prediction model trained by the ship arrival time prediction method based on deep contrast learning as mentioned above; the prediction module is used to predict the current voyage of the specified ship according to the input D t Sequence data X , output the predicted arrival time for the specified destination port.
[0052] The present invention also includes a ship arrival time prediction device, which includes a memory, a processor, and a computer program stored in the memory and running in the processor. When the processor executes the computer program, the ship arrival time prediction method based on deep contrastive learning as described above is adopted to generate the predicted arrival time of any ship at a designated port according to the process data corresponding to the current voyage of the ship.
[0053] The technical solution provided by the present invention has the following beneficial effects:
[0054] The present invention uses CNN and RNN / LSTM networks to design a ship arrival time prediction model, and comprehensively collects AIS data, meteorological data and characteristic information of shipping routes during the ship's voyage to form sample data, and trains the network model so that the network model learns deep characteristic information and realizes accurate prediction of the ship's arrival time. In order to improve the learning effect of the network model, the present invention selects several groups of positive sample pairs and negative sample pairs from the sample data according to the navigation routes and sea conditions in different voyages, and then uses a comparative learning strategy to perform two-stage training on the ship arrival time prediction model, the former improves the feature extraction performance of the model, and the latter improves the prediction performance of the network model.
[0055] The present invention is based on deep contrast learning and can effectively capture the complex patterns and nonlinear relationships in ship navigation data. By learning the spatiotemporal characteristics and dynamic behaviors of ships, the understanding of navigation patterns can be improved, thereby improving the accuracy of predictions. The present invention does not rely on the continuity and regularity of historical data, and can adapt to non-stationary time series and sudden environmental changes, such as sudden weather changes or route adjustments, and quickly respond to these changes through real-time learning and adjustment of model parameters. The present invention has good robustness to outliers and noise data, and even in the case of missing, erroneous or inconsistent data, the impact of these factors on the prediction results can be reduced through the model's adaptive mechanism. The present invention fully considers meteorological conditions, AIS information and shipping network information, and provides more accurate sailing time predictions by fusing multi-source data. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] Figure 1 This is a flowchart of the steps of the method for predicting ship arrival time based on deep contrast learning provided in Example 1 of the present invention.
[0057] Figure 2 This is a network architecture diagram of the ship arrival prediction model constructed in Example 1 of the present invention.
[0058] Figure 3 Flow chart of the feature extraction part in the ship arrival prediction model of Example 1 of the present invention during the pre-training stage.
[0059] Figure 4 Flow chart of the prediction layer part in the ship arrival prediction model of Example 1 of the present invention during the training phase.
[0060] Figure 5 This is a functional module diagram of the ship arrival time prediction system provided in Example 2 of the present invention. DETAILED DESCRIPTION
[0061] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.
[0062] Example 1
[0063] This embodiment provides a method for predicting ship arrival time based on deep contrastive learning. The method uses a large amount of sequence data of feature information related to the ship's voyage to train a deep learning algorithm, and then uses a network model to predict the ship's arrival time.
[0064] In order to enable the network model to more fully learn the feature information in the limited sample data, this embodiment, on the one hand, preferably selects the feature information including AIS (Automatic Identification System) data, meteorological data and shipping routes as sample data; and selects several groups of positive sample pairs and negative sample pairs from the sample data according to the navigation route and sea condition information during the voyage. On the other hand, a ship arrival prediction model including a feature extractor, a projection head and RNN is constructed based on the contrastive learning framework; and the ship arrival prediction model is trained in two stages. In the first stage, this embodiment uses the feature extraction part in the pre-training model of positive sample pairs and negative sample pairs to make the similarity of the feature vectors of the positive sample pairs extracted by the model as high as possible, and the similarity of the feature vectors of the negative sample pairs as low as possible. In the second stage, the sample data set is directly used to train the entire network model by gradient descent, so that the prediction accuracy of the network model meets the requirements.
[0065] Specifically, Figure 1 As shown, the method for predicting ship arrival time based on deep contrast learning provided in this embodiment includes the following steps:
[0066] S1: Obtain the process data corresponding to each voyage of the ship, including AIS data, meteorological data and shipping route.
[0067] AIS data includes the ship's MMSI (Maritime Mobile Service Identity) code, time t , Speed V t ,course , Vessel position L t .
[0068] In this embodiment, the MMSI code is a nine-digit code sent by the ship's radio communication system on its radio channel that can uniquely identify various stations and group call stations. The MMSI code can be used to quickly find ship information and its company information, such as the ship's tonnage and type, etc.
[0069] Vessel position L t Usually composed of the latitude and longitude of the ship, the data format is as follows: L t =( Lon t , Lat t ),in, Lon t Indicates the longitude of the vessel's current position; Lat tThe latitude representing the ship's current position.
[0070] Weather data including wind speed W t ,wind direction and rainfall B t The heading in this embodiment The heading to the ground is based on the true north and rotates clockwise with increasing angles. It also takes the true north as the starting point and rotates clockwise, with the angle increasing continuously.
[0071] The shipping route includes the starting port, the arrival port and the distance of the current voyage, as well as all the ports or waypoints passed. The shipping route Route in this embodiment is represented by the following vector format:
[0072] Route =[ p 1 , p 2 ,… p i …, , p n ]
[0073] in, p i Indicates the first i ports or waypoints, i =1… n , n Indicates the total number of ports or waypoints in the current shipping route; p 1 Indicates the starting port, p n Indicates the port of arrival. In addition, the order of adjacent waypoints in the vector can also reflect the sailing direction of the ship in the waypoint interval.
[0074] Route length L M The calculation formula is as follows:
[0075]
[0076] Among them, d( p i , p i-1 ) is a waypoint p i-1 With waypoints p i The distance between.
[0077] S2: Preprocess all process data contained in each voyage, complete data cleaning, timestamp alignment and normalization, and obtain voyage spatiotemporal information containing various feature information D t : .in, It indicates the theoretical speed after correction according to wind speed and direction; W t Represents binary meteorological features.
[0078] In detail, in this embodiment, the flight time and space information D t The generation process is as follows:
[0079] S21: Perform data cleaning on each characteristic parameter in the collected process data, and delete duplicate data and abnormal data.
[0080] In the data cleaning process of this embodiment, the data is uniformly arranged, compared one by one, and the duplicate data is deleted. The missing values after the data deletion can be filled with the mean or deleted. For example, for the speed, heading, and longitude and latitude of the ship's position, the missing values can be supplemented by the mean filling method, and some data that cannot be supplemented by the mean can be directly deleted.
[0081] This embodiment uses a box plot method to identify outliers contained in the process data of ship speed, wind speed and ship position, and deletes them. A box plot is a statistical chart used to display the dispersion of a set of data. The biggest advantage of a box plot is that it is not affected by outliers, and can accurately and stably depict the discrete distribution of data, while also facilitating data cleaning. Taking speed data as an example, the process of using the box plot method to detect outliers in this embodiment is as follows:
[0082] (1) Arrange the speed data in the AIS data from small to large.
[0083] (2) Determine the lower quartile and upper quartile of the speed set and calculate the interquartile range:
[0084] The lower quartile of the speed set refers to the speed at the 25% position of the entire speed data sequence, which is set to V 1 ; The upper quartile of the speed set refers to the speed at 75% of the entire speed data sequence, set to V 3 The speed interquartile range (IQR) refers to the distribution range of the 50% of data in the middle of the data set. It is a robust statistic that is not affected by extreme values. The calculation formula is as follows:
[0085] IQR=V 3 - V 1
[0086] (3) Calculate the lower edge of the speed based on the lower quartile, upper quartile and interquartile range of the speed set V min and top edge V max :
[0087] V min = V 1 -1.5 × IQR
[0088] V max = V 3 +1.5×IQR
[0089] will be in the interval ( V min , V max ) are identified as abnormal data.
[0090] S22: Consider V t and right W t and Calculate the corrected theoretical speed .
[0091] The solution provided in this embodiment comprehensively considers the relationship between wind direction and heading, so that it can be better generalized to navigation prediction under different meteorological conditions. By analyzing the conditions of tailwind, headwind and crosswind during navigation, the model can adapt to different navigation conditions. In this embodiment, the reference of heading and wind direction is the same. At this time, the theoretical speed The correction method is as follows:
[0092] (1) Calculate the relative angle between wind direction and heading using the following formula: :
[0093]
[0094] (2) Based on relative angle Defines the wind type and current sailing status U t It is divided into tailwind, headwind and crosswind. This means the wind is blowing from behind the boat. means the wind is blowing from the front of the boat, and anything else means the wind is blowing from the side of the boat, so the sailing state is defined as follows:
[0095]
[0096] (3) Combined with navigation status U t The corrected theoretical speed is calculated by the following formula .
[0097] In this embodiment, an influence coefficient is defined k , which is used to quantify the effect of wind on the ship's navigation. Considering that tailwind has a gain on speed, headwind has a loss on speed, and crosswind has a limited effect on speed, we define k 1 and k 2 They respectively represent the influence coefficients of tailwind and headwind on the ship's sailing speed and satisfy: k 1 >1,0< k 2 <1.
[0098] On this basis, the corrected theoretical speed under different navigation conditions The calculation formula is as follows:
[0099]
[0100] S23: According to W t and B t The impact degree of ship navigation is binary processed and the discrete meteorological characteristics are generated. W t : W t =[ W t , B t ].
[0101] Wind speed and rainfall usually affect the navigation of ships only after they exceed the safety threshold. Therefore, in order to facilitate data processing, this embodiment performs binary processing on wind speed and rainfall according to whether they will affect the navigation of ships, and then obtains a meteorological feature. W t The binary processing expressions of wind speed and rainfall are as follows;
[0102]
[0103] in, H wIndicates the wind speed threshold that can affect the navigation of ships; H B Indicates the rainfall threshold that can affect ship navigation.
[0104] S24: According to time t Theoretical speed , Meteorological characteristics W t and ship position L t Timestamps are aligned and missing data of any feature parameters are supplemented by interpolation.
[0105] Timestamps are precise measurements of when a data point occurred, usually expressed as a date and time. In data analysis involving time series, timestamps are used to determine the order of data points, analyze trends, and calculate time intervals. Inconsistent or missing timestamps have potential impacts on data analysis, such as data misunderstanding, incorrect trend analysis, or inability to synchronize multi-source data. For timestamp extraction, if the dataset already contains a timestamp field, you can directly extract the timestamp information from the field. For log files or text data, use regular expressions or other string processing methods to parse timestamps. Convert timestamps to a uniform format.
[0106] In the data collected in this embodiment, different types of characteristic parameters have different data granularities. In order to be suitable for constituting the sequence data of characteristic parameters and input into the deep learning neural network, this embodiment performs time alignment on data from different sources. Taking the speed as an example, the difference algorithm to ensure that all characteristic parameters are synchronized in a unified time format is as follows:
[0107]
[0108] In the above formula, V new Represents the estimated value of the new speed point after interpolation; V old Represents the value of a known speed point, which is V new One data point ahead; V next The value of the speed point is known, which is V new A data point behind; t new The intermediate time point you want to estimate; t old Known data points V old The corresponding time point.
[0109] In this embodiment, through the above steps, each characteristic parameter is processed separately to obtain multiple data with the same granularity and the same timestamp, which is convenient for the data fusion step.
[0110] S25: concatenate the feature vectors from different data sources in the order of timestamps and merge them into a unified data structure to obtain the voyage time and space information D t , flight time and space information D t It is the new feature data obtained by aligning data from different sources and fusing them. This data can be provided to the neural network for use. D t The sequence data constitutes a feature set.
[0111] S3: Collect a large number of real feature sets to form a sample data set, and select a number of positive sample pairs and negative sample pairs according to the MMSI code, meteorological characteristics and shipping routes corresponding to each feature set. The positive sample pairs and negative sample pairs constitute a pre-training set.
[0112] In this embodiment, it is intended to improve the learning efficiency of the network model by contrastive learning, so it is necessary to select positive and negative sample pairs. The contrastive learning strategy adopted in this embodiment assumes that for the same type of ship, ships sailing on similar sailing paths and under similar weather conditions will have similar arrival times. On the contrary, under opposite sailing paths and under greatly different weather conditions, the arrival times of ships sailing on opposite sailing paths will be relatively different.
[0113] Based on this assumption, two sample data generated by the same type of ships on similar navigation paths and the same meteorological conditions are selected to form a set of positive sample pairs. Two sample data generated by different types of ships on opposite navigation paths or different meteorological conditions are selected to form a set of negative sample pairs.
[0114] The type of the ship in this embodiment can be obtained by querying the MMSI code. Generally speaking, ships with similar tonnage and the type of cargo they transport are considered to be of the same type. For example, LNG ships and container ships are generally considered to be of different types, while two container ships with a tonnage difference of less than 20% are generally considered to be of the same type.
[0115] In the solution of this embodiment, the method for evaluating whether the navigation paths are similar and whether the meteorological conditions are the same is as follows:
[0116] 1. Navigation path
[0117] According to the vector Route of the navigation path encoded in this embodiment, the ports or waypoints passed during the voyage and the navigation direction between any two waypoints can be determined. Therefore, the following evaluation rules can be set:
[0118] (1) If the overlap rate of waypoints on either side of two navigation paths is greater than 50% and the overlap rate of waypoint intervals on either side is greater than 50%, the two navigation paths are considered to be similar.
[0119] (2) When the overlap rate of waypoints on both sides of two navigation paths is not higher than 50% or the overlap rate of waypoint intervals on both sides is not higher than 50%, the two flight routes are deemed not to be similar paths.
[0120] For example, suppose there are two navigation paths R1 and R2, R1 = [1, 2, 3, 4, 5], R2 = [2, 1, 7, 3, 4]. Then both navigation paths include 5 waypoints, and the same waypoints they contain are 1, 2, 3, and 4. That is, for both navigation paths, the overlap rate of waypoints is 80%.
[0121] Both navigation paths include 4 waypoint intervals, and the same waypoint intervals are 1-2 interval and 3-4 interval. However, in the 1-2 interval, the navigation directions of the two navigation paths are opposite, so the two contain only one same waypoint interval, that is, for the two navigation paths, the overlap rate of the waypoint intervals is 25%.
[0122] Therefore, it can be determined that the navigation paths R1 and R2 are not similar paths.
[0123] 2. Weather conditions
[0124] In this embodiment, the meteorological conditions only include two elements, wind speed and rainfall, and the meteorological characteristics after binarization are W t Therefore, meteorological conditions can be divided into four types:
[0125] Type
[00] : refers to the situation of low wind speed and low rainfall, which has almost no impact on ship navigation.
[0126]
[01] Type: refers to the situation of low wind speed and high rainfall, which has an impact on the navigation of ships.
[0127]
[10] Type: refers to a situation of high wind speed and low rainfall, which has an impact on the navigation of ships.
[0128]
[11] Type: refers to conditions of high wind speed and high rainfall, which have a significant impact on ship navigation.
[0129] Under this condition, when the meteorological characteristics of the two flight paths are Wt If the overlap rate on either side exceeds 80%, the meteorological conditions of the two navigation paths are considered to be the same; otherwise, the meteorological conditions are considered to be different.
[0130] S4: Construct a framework based on contrastive learning Figure 2 The ship arrival prediction model shown in Figure 1 includes a feature extractor, a projection head, and an RNN. The feature extractor and the projection head are based on the input D t Extract feature vectors F c ;RNN according to the input F c Generate arrival time forecasts.
[0131] 1. Feature Extractor
[0132] The feature extractor of this embodiment uses CNN (Convolutional Neural Networks, Convolutional Neural Networks ) for feature extraction. Input data D It is the basis of model learning and contains various observations during the ship's navigation. These data are the starting point for feature extraction and provide raw information for subsequent convolution operations. W c When entering data D The convolutional layer extracts local features from the network. These local features capture the spatial correlation of the data. The convolutional layer can reduce the number of parameters in the fully connected layer while extracting useful features. After the convolutional layer, the feature extractor uses an activation function (such as the ReLU function) to enable the model to learn complex feature representations; it is used to increase the nonlinear expression ability of the network. Then a pooling operation (such as maximum pooling) is performed to reduce the spatial dimension of the features. Maximum pooling selects the maximum value within a region, which helps to highlight important features while reducing the amount of computation.
[0133] In summary, the output of the feature extractor in this embodiment is a high-level feature representation obtained after convolution, activation and pooling operations. These features capture the key attributes of the input data and provide rich information for subsequent deep learning tasks (such as classification, regression or contrastive learning).
[0134] In detail, assuming that the ship spatiotemporal data is ,in D represents the spatiotemporal data matrix of the ship, d is a feature dimension (e.g., latitude and longitude, time, speed, meteorological characteristics, etc.), N is the sample size (i.e. the number of data points).
[0135] Then, the processing of the convolutional layer in the feature extractor is as follows:
[0136]
[0137] in, Conv Represents the convolution operation; W c Represents the convolution kernel, which is used to slide on the input data to extract local features; b c Represents the bias vector of the convolutional layer; Z c It is the output of the convolutional layer and represents the result of the convolution operation.
[0138] The activation layer in the feature extractor is processed as follows:
[0139]
[0140] Among them, Re LU represents the activation function; A Represents the output of the activation function. When the input Z c When it is greater than 0, the output of the activation layer is Z c itself; when input Z c When it is less than 0, the output of the activation layer is 0.
[0141] The processing of the pooling layer in the feature extractor is as follows:
[0142]
[0143] in, P Represents the output of the pooling layer; MaxPool Represents the maximum pooling operation; F c Represents the output of the feature extractor, which is a high-level representation of the features.
[0144] 2. Projection Head
[0145] This embodiment uses a fully connected layer as a projection head. The fully connected layer maps the high-dimensional features of the feature extractor to a low-dimensional space, which helps to reduce the complexity of subsequent processing and extract more abstract feature representations. The fully connected layer can capture the complex relationship between input features. Then, by using a nonlinear activation function, nonlinear characteristics are introduced, allowing the model to learn more complex patterns. The fully connected layer of this embodiment uses the ReLU function, which helps to speed up training and reduce the problem of gradient disappearance. Finally, the output of the projection head is performed, and the output of the projection head is used to calculate the contrast loss and optimize the feature representation, so that the feature representations of similar samples are closer in the feature space, while the feature representations of dissimilar samples are farther away.
[0146] Specifically, the expression of the projection head in this embodiment is as follows:
[0147]
[0148] In the above formula, Z p represents the output of the fully connected layer, W p represents the weight matrix of the fully connected layer, b p Represents the bias vector of the fully connected layer; H Represents the output of the activation function; F L Indicates the output of the projection head.
[0149] 3. Prediction Layer
[0150] The prediction layer in this embodiment uses a standard RNN unit, the core idea of which is to combine the hidden state of the previous time step with the input of the current time step to generate the hidden state of the current time step. That is, remember the information it learned in the previous time step, which is stored in the hidden state h t-1 At the same time, the RNN unit will receive new information of the current time step, that is, input data, which is recorded as x t , the RNN unit uses the weight matrix W B and U B And the bias term b B , to combine "past information" and "present information". The combined information is converted into a new hidden state through an activation function h t .
[0151] The RNN unit is responsible for processing sequence data and capturing dynamic features in time series. Initialize the weight matrix of the RNN network W B and U B And the bias term b B The standard RNN unit at each time step t Update its hidden state using the following formula:
[0152]
[0153] In the above formula, the hidden state h t is the RNN at the current time step tThe representation is used to capture the information of the sequence to the current point. The input of the current time step x t The feature information after the feature extraction part of the corresponding path of the external input data received by the RNN at the current time step; the hidden layer weight matrix W B Used to connect the hidden states of the previous and next time steps. Input weight matrix U B Used to convert the input of the current time step x t The hidden state at the current time step h t Make the connection. Bias b B A constant offset is added to the hidden state calculation, providing additional flexibility. f It is used to introduce nonlinear characteristics so that RNN can learn more complex patterns. The activation function of this embodiment f The hyperbolic tangent function tanh is selected.
[0154] Finally, the prediction layer receives the hidden state from the last time step of the RNN h t , and then the hidden state is combined with the weight matrix of the output layer W O Multiply, map the hidden state features to the output space, and add a bias term b o , and get the final prediction result And output. The specific formula is as follows:
[0155]
[0156] It should be additionally emphasized that in other embodiments, in addition to the RNN network, the prediction layer may also use a long short-term memory network LSTM.
[0157] S5: Set contrast loss as the loss function, use the pre-training set to pre-train the feature extraction performance of the feature extractor and projection head in the ship arrival prediction model, and retain the pre-trained model parameters.
[0158] In this embodiment, the feature extraction part of the training model is trained using the contrast loss function. The training at this stage can make the feature representations of the input positive sample pairs closer in the feature space, and make the feature representations of the input negative sample pairs farther away.
[0159] The dot product is the product of the corresponding components of two vectors in the same dimension. It measures the consistency of the two vectors in direction. If the two vectors have the same direction, the dot product will be very large; if the directions are opposite, the dot product will be very small or negative. Therefore, the dot product is often used as a common similarity calculation method, which can be used to measure the similarity between two feature vectors.
[0160] In the contrastive learning of this embodiment, in order to make the dot product of the positive sample pair in the feature representation extracted by the model large and the dot product of the negative sample pair small, the similarity S of the two sample pairs is calculated using the following formula:
[0161]
[0162] In the above formula, F p+ Represents the feature representation of one sample in a positive sample pair; F p- Represents the feature representation of the other sample in a positive sample pair, or the feature representation of the sample compared with the anchor sample in a negative sample pair.
[0163] On this basis, the contrast loss function in the pre-training stage L s as follows:
[0164]
[0165] In the above formula, S p is the similarity of the positive sample pair; For the i Similarity of group negative sample pairs; M Represents the number of negative sample pairs.
[0166] like Figure 3 As shown in the figure, in the pre-training stage, by minimizing the contrast loss function, the feature representation learned by the model can make positive sample pairs more similar and negative sample pairs more dissimilar. Minimize the loss function and update the model parameters according to the gradient calculated by the loss function to reduce the loss.
[0167] S6: Set the mean square error as the loss function, use the sample data set to train and verify the pre-trained complete ship arrival prediction model, and retain the model parameters of the network model that meets the prediction accuracy target.
[0168] In the joint training process of feature extraction and RNN, the data obtained from contrastive learning needs to be converted into a format suitable for RNN processing, which involves converting static feature vectors into time series data and normalizing the data of various feature parameters.
[0169] Specifically, this embodiment scales the value of the feature parameter to a uniform range through normalization. Normalization only adjusts the numerical range of the feature to the same scale as other features and does not change its intrinsic importance. It ensures the fairness and stability of model training by adjusting the numerical range of the feature, rather than directly reducing or increasing the impact of a certain feature.
[0170] At speed V t Taking the characteristic parameter as an example, the normalized formula is:
[0171]
[0172] In the above formula, Indicates the minimum speed. Indicates the maximum speed; Indicates the normalized speed value.
[0173] The voyage temporal and spatial information input into the network model in this embodiment D t It has multiple characteristic parameters, and the normalized values are recorded as: , n t express D t The number of characteristic parameters in the RNN network, then the input vector at each time point t x t It can be expressed as:
[0174]
[0175] On this basis, using the normalized eigenvalues , which can be combined to include T A sequence of time points X :
[0176]
[0177] In the above formula, the number of rows T represents the length of the time series, and the number of columns n represents the number of features input into the network model at each time point.
[0178] The mean square error loss function used by the ship arrival prediction model in the training phase L MSE as follows:
[0179]
[0180] In the above formula, N Indicates the number of sample data in the training set; y i Indicates the true value of the arrival time; Indicates the predicted value of arrival time.
[0181] This embodiment uses gradient descent or its variants to update the weights and bias items of the network during the training phase. The process includes:
[0182] (1) Use the chain rule to calculate the gradient of the loss with respect to each parameter. The gradient of the loss function is calculated as follows:
[0183]
[0184] (2) After propagating to the output layer in the RNN, the loss function is relative to the output layer weights W O and the bias term b o The gradient is as follows:
[0185]
[0186] (3) Propagate to the RNN layer and calculate the loss function relative to the RNN hidden state h t The gradient is as follows:
[0187]
[0188] (4) Calculate the gradient of the activation function. For tan h Activation function, the gradient is:
[0189]
[0190] Where z is the input of the activation function and satisfies:
[0191]
[0192] like Figure 4 As shown, during the training process, the above process is repeated to iteratively optimize the network model until the performance of the network model on the validation set no longer improves or reaches a predetermined number of iterations.
[0193] S7: Input the spatiotemporal information of the current voyage into the trained ship arrival prediction model D t The ship arrival prediction model generates the predicted arrival time of the destination port based on the sequence data.
[0194] Example 2
[0195] On the basis of the scheme in Example 1, Figure 5 As shown, this embodiment further provides a ship arrival time prediction system, which includes: a data acquisition module, a data processing module and a prediction module.
[0196] The data collection module collects AIS data, meteorological data and shipping routes corresponding to each ship's voyage in real time through ground base stations, meteorological satellites and the official database of the port administration.
[0197] The data processing module is used to use the ship arrival time prediction method based on deep contrast learning as in Example 1 to perform data cleaning, timestamp alignment and normalization on the process data contained in each voyage collected by the data collection module to obtain the voyage spatiotemporal information containing multiple feature information. D t .
[0198] The prediction module runs a ship arrival prediction model trained by the ship arrival time prediction method based on deep contrast learning as in Example 1; the prediction module is used to predict the current voyage of the specified ship according to the input D t Sequence data X , output the predicted arrival time for the specified destination port.
[0199] Example 3
[0200] This embodiment provides a ship arrival time prediction device, which includes a memory, a processor, and a computer program stored in the memory and running in the processor. When the processor executes the computer program, the ship arrival time prediction method based on deep contrastive learning as in Example 1 is adopted to generate the predicted arrival time of any ship at a designated port according to the process data corresponding to the current voyage of the ship.
[0201] The ship arrival time prediction device provided in this embodiment is essentially a computer device for implementing the solutions in embodiments 1 and 2. The computer device can be an embedded device installed on each ship, or a back-end device independent of the ship, so as to obtain the navigation information of all ships and generate the predicted arrival time of each ship.
[0202] In practical applications, the computer device in this embodiment can adopt an intelligent terminal, a tablet computer, a laptop computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers) that can execute programs. The computer device pointed out in this embodiment at least includes but is not limited to: a memory and a processor that can be connected to each other through a system bus. Among them, the memory (i.e., a readable storage medium) includes a flash memory, a hard disk, a multimedia card, a card-type memory (for example, SD or DX memory, etc.), a random access memory (RAM), a static random access memory (SRAM), a read-only memory (ROM), an electrically erasable programmable read-only memory (EEPROM), a programmable read-only memory (PROM), a magnetic memory, a disk, an optical disk, etc. In some embodiments, the memory can be an internal storage unit of a computer device, such as a hard disk or memory of the computer device. In other embodiments, the memory can also be an external storage device of a computer device, such as a plug-in hard disk equipped on the computer device, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory may also include both the internal storage unit of the computer device and its external storage device. In this embodiment, the memory is usually used to store the operating system and various application software installed on the computer device. In addition, the memory may also be used to temporarily store various data that have been output or are to be output.
[0203] The processor may be a central processing unit (CPU), a graphics processing unit (GPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor is generally used to control the overall operation of a computer device. In this embodiment, the processor is used to run program codes stored in a memory or process data.
[0204] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.
Claims
1. A method for predicting ship arrival time based on deep contrastive learning, characterized in that: It includes the following steps: S1: Obtain the process data corresponding to each voyage of the ship, including AIS data, meteorological data and shipping route; Among them, AIS data includes the ship’s MMSI code, timestamp t , Speed V t ,course , Vessel position L t ; Weather data including wind speed W t ,wind direction and rainfall B t ; The shipping route includes the starting port, arrival port and distance of the current voyage, as well as all ports or waypoints passed; S2: Preprocess all process data contained in each voyage, complete data cleaning, timestamp alignment and normalization, and obtain voyage spatiotemporal information containing various feature information D t : ;in, It indicates the theoretical speed after correction according to wind speed and direction; W t Represents the binary meteorological characteristics; The space-time information of all voyages included in the same voyage D t The sequence data constitutes a feature set; S3: Collect a large number of real feature sets to form a sample data set, and select a number of positive sample pairs and negative sample pairs according to the MMSI code, meteorological characteristics and shipping routes corresponding to each feature set, and the positive sample pairs and negative sample pairs constitute a pre-training set; S4: Based on the contrastive learning framework, a ship arrival prediction model consisting of a feature extractor, a projection head and a prediction layer is constructed; the feature extractor and the projection head are based on the input D t Extract feature vectors F c ; The prediction layer is based on the input F c Generate arrival time prediction results; S5: setting contrast loss as a loss function, using the pre-training set to pre-train the feature extraction performance of the feature extractor and the projection head part in the ship arrival prediction model, and retaining the pre-trained model parameters; S6: setting mean square error as a loss function, using the sample data set to train and verify the complete pre-trained ship arrival prediction model, and retaining the model parameters of the network model that meets the prediction accuracy target; S7: Input the current voyage data into the trained ship arrival prediction model D t The ship arrival prediction model generates the predicted arrival time of the destination port based on the sequence data.
2. The method for predicting ship arrival time based on deep contrastive learning according to claim 1, characterized in that: In step S2, the voyage time and space information D t The generation process of the feature set is as follows: S21: performing data cleaning on each characteristic parameter in the collected process data, and deleting duplicate data and abnormal data; S22: Consider V t and right W t and Calculate the corrected theoretical speed ; S23: According to W t and B t The impact degree of ship navigation is binary processed and the discrete meteorological characteristics are generated. W t : W t =[ W t , B t ]; S24: According to time t Theoretical speed , Meteorological characteristics W t and ship position L t Perform timestamp alignment and supplement missing data of any feature parameters through interpolation; S25: concatenate the feature vectors from different data sources in the order of timestamps and merge them into a unified data structure to obtain the voyage time and space information D t , consisting of all the space-time information of the same voyage D t The sequence data constitutes a feature set.
3. The method for predicting ship arrival time based on deep contrastive learning according to claim 2, characterized in that: In step S21, a box plot method is used to identify abnormal values contained in the process data of ship speed, wind speed and ship position, and delete them.
4. The method for predicting ship arrival time based on deep contrastive learning according to claim 3, characterized in that: In step S22, the theoretical speed The correction method is as follows: (1) Calculate the relative angle between wind direction and heading using the following formula: : , (2) Based on relative angle The current navigation status U t Divided into tailwind, headwind and crosswind: , (3) Combined with navigation status U t The corrected theoretical speed is calculated by the following formula : , In the above formula, k 1 and k 2 They respectively represent the influence coefficients of tailwind and headwind on the ship's sailing speed and satisfy: k 1 >1,0< k 2 <1.
5. The method for predicting ship arrival time based on deep contrastive learning according to claim 4, characterized in that: In step S23, the binary processing expressions of wind speed and rainfall are as follows: , in, H w Indicates the wind speed threshold that can affect the navigation of ships; H B Indicates the rainfall threshold that can affect ship navigation.
6. The method for predicting ship arrival time based on deep contrastive learning according to claim 1, characterized in that: In step S3, two sample data generated by the same type of ships on similar navigation paths and voyages with the same meteorological conditions are selected to form a set of positive sample pairs; two sample data generated by different types of ships on opposite navigation paths or voyages with different meteorological conditions are selected to form a set of negative sample pairs.
7. The method for predicting ship arrival time based on deep contrastive learning according to claim 1, characterized in that: The expression of the feature extractor is as follows: , In the above formula, W c represents the convolution kernel; Z c is the output of the convolutional layer; Conv Represents the convolution operation; b c Represents the bias vector of the convolutional layer; LU represents the activation function; A Represents the output of the activation function; P Represents the output of the pooling layer; F c represents the output of the feature extractor; MaxPool Represents the maximum pooling operation; The expression of the projection head is as follows: , In the above formula, Z p represents the output of the fully connected layer, W p represents the weight matrix of the fully connected layer, b p Represents the bias vector of the fully connected layer; H Represents the output of the activation function; F L Represents the output of the projection head; The prediction layer uses RNN or LSTM.
8. The method for predicting ship arrival time based on deep contrastive learning according to claim 7, characterized in that: In step S5, the contrast loss function in the pre-training phase is L s as follows: , In the above formula, S p is the similarity of the positive sample pair; For the i Similarity of group negative sample pairs; M Represents the number of negative sample pairs; In step S6, the mean square error loss function used in the training phase is L MSE as follows: , In the above formula, N Indicates the number of sample data in the training set; y i Indicates the true value of the arrival time; Indicates the predicted value of arrival time.
9. A ship arrival time prediction system, characterized in that: It includes: The data collection module collects AIS data, meteorological data and shipping routes corresponding to each ship's voyage in real time through ground base stations, meteorological satellites and the official database of the port authority; A data processing module, which is used to use the ship arrival time prediction method based on deep contrast learning as described in any one of claims 1 to 8 to perform data cleaning, timestamp alignment and normalization on the process data contained in each voyage collected by the data collection module to obtain voyage spatiotemporal information containing multiple feature information D t ; A prediction module, wherein a ship arrival prediction model trained by the ship arrival time prediction method based on deep contrast learning as claimed in any one of claims 1 to 8 is run; the prediction module is used to predict the current voyage of the designated ship according to the input D t The predicted arrival time of the specified destination port is output.
10. A device for predicting ship arrival time, comprising a memory, a processor, and a computer program stored in the memory and running in the processor, characterized in that: When the processor executes the computer program, it adopts the ship arrival time prediction method based on deep contrast learning as described in any one of claims 1 to 8 to generate the predicted arrival time of any ship at a designated port based on the process data corresponding to the current voyage of the ship.