Shift package-to-piece volume prediction method, device and computer equipment
By using pre-trained time series and linear models, combined with the attention mechanism, the number of parcels arriving at each shift at the transit station can be accurately predicted, solving the problem of improper resource allocation at the transit station and improving operational efficiency.
Patent Information
- Application Number
- CN202110411323.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-04-16
- Publication Date
- 2025-10-10
- Estimated Expiration
- 2041-04-16
AI Technical Summary
Existing technologies are unable to accurately predict the number of parcels arriving at the transfer station for each shift on a future day, resulting in improper resource allocation and reduced transfer station operating efficiency.
Using pre-trained time series models and linear models, we obtain the historical package arrival data of the target logistics node, determine the historical reference date, and use the attention mechanism and linear fitting to predict the package arrival volume on the predicted day.
It achieves accurate prediction of the number of parcels at logistics nodes, improves the operating efficiency of transfer yards, and can flexibly adapt to the scheduling arrangements of different logistics nodes.
Smart Images

Figure CN115222082B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of logistics technology, and in particular to a method, device, computer equipment, and storage medium for predicting the number of packages to be delivered during a shift. Background Art
[0002] A transit station is a crucial node for sorting, collecting, and distributing express shipments. Its primary operational feature is that it doesn't engage in specific product production. Instead, it concentrates, exchanges, and transfers shipments collected from other distribution centers, shifting the flow of shipments from decentralized to centralized and then decentralized across the network. In practice, shipments from other connected distribution centers are gathered at the transit station at a specific timeframe and then exchanged.
[0003] With the rapid development of the logistics industry, the number of parcels arriving at transit stations has been increasing year by year. People often try to predict the number of parcels arriving at transit stations, so as to pre-arrange manpower, vehicles, and other resources for each shift and improve the overall efficiency of the transit stations. However, related technologies often cannot predict the number of parcels arriving at a target transit station for each shift on a specific day. This makes it difficult to accurately arrange manpower, vehicles, and other resources for each shift, which is not conducive to improving the efficiency of the target transit station.
[0004] Therefore, there is a problem in the related art that the operation efficiency of the transfer station is low. Summary of the Invention
[0005] Based on this, it is necessary to provide a method, device, computer equipment and storage medium for predicting the number of parcels per shift that can improve the operating efficiency of the transfer station in response to the above technical problems.
[0006] A method for predicting the number of packages delivered per shift, comprising:
[0007] For the target logistics node, obtain the parcel arrival data of the N historical days before the predicted day; the parcel arrival data includes the actual parcel arrival volume of each shift of the target logistics node on each of the historical days;
[0008] Inputting the parcel arrival data of the shifts for the N historical days into a pre-trained reference day prediction model; the pre-trained reference day prediction model is used to determine a historical reference day for the day to be predicted from the N historical days; the similarity between the characteristics of the factors affecting the arrival volume of the historical reference day and the characteristics of the factors affecting the arrival volume of the day to be predicted is greater than a preset threshold; the characteristics of the factors affecting the arrival volume are characteristics corresponding to factors that affect the parcel arrival volume of each shift at the target logistics node;
[0009] The daily package arrival volume of the historical reference day is input into the pre-trained shift arrival volume prediction model; the pre-trained shift arrival volume prediction model is used to fit the daily package arrival volume to obtain the predicted package arrival volume of each shift of the target logistics node on the day to be predicted.
[0010] In one embodiment, the pre-trained reference day prediction model is a pre-trained time series model, and the pre-trained time series model includes an encoding layer. Inputting the package-to-piece data of the N historical days into the pre-trained reference day prediction model includes:
[0011] The package arrival data of the N historical days are input into the pre-trained time series model. The package arrival data of the N historical days are encoded through the encoding layer of the pre-trained time series model to obtain a target encoding vector; the target encoding vector is used to represent the historical reference day of the day to be predicted and the daily package arrival volume of the historical reference day.
[0012] In one embodiment, the pre-trained time series model further includes an attention mechanism layer. The encoding layer of the pre-trained time series model encodes the package-to-piece data of the N historical days to obtain a target encoding vector, including:
[0013] The package arrival data of the N historical days are encoded by the encoding layer of the pre-trained time series model to obtain initial encoding vectors; each initial encoding vector is used to represent the corresponding historical day and the daily package arrival volume of the historical day;
[0014] Obtaining an attention weight corresponding to each of the initial encoding vectors through the attention mechanism layer of the pre-trained time series model; the attention weight is used to represent the similarity between the characteristics of the factors affecting the arrival volume of the corresponding historical day and the characteristics of the factors affecting the arrival volume of the day to be predicted;
[0015] Based on the attention weight, the initial encoding vector is weighted to obtain the target encoding vector.
[0016] In one embodiment, the pre-trained reference day prediction model is a pre-trained linear model, and the inputting of the daily package quantity of the historical reference day into the pre-trained shift quantity prediction model includes:
[0017] The target coding vector is input into the pre-trained linear model, and the target coding vector is linearly fitted by the pre-trained linear model to obtain the predicted number of packages for each shift on the day to be predicted.
[0018] In one embodiment, the method further comprises:
[0019] Acquire training sample data; the training sample data includes the actual package arrival volume of each shift of the target logistics node on the label day and the package arrival data of the shifts on N historical days before the label day;
[0020] Based on the actual package arrival volume of each shift on the label day and the package arrival data of the shifts on N historical days before the label day, the time series model to be trained and the linear model to be trained are trained;
[0021] When the trained time series model and the trained linear model meet the preset training conditions, the pre-trained time series model and the pre-trained linear model are obtained.
[0022] In one embodiment, the training of the time series model to be trained and the linear model to be trained based on the actual package arrival volume of each shift on the label day and the package arrival data of the shifts on N historical days before the label day includes:
[0023] Inputting the package arrival data of the shifts for N historical days before the label date into the time series model to be trained, and encoding the package arrival data of the shifts for N historical days before the label date through the encoder in the time series model to be trained to obtain a sample encoding vector; the sample encoding vector is used to represent the historical reference date of the label date and the daily package arrival volume of the historical reference date;
[0024] Inputting the sample code vector into the linear model to be trained, performing linear fitting processing on the sample code vector through the linear model to be trained, and obtaining the predicted number of packages received for each shift on the label day;
[0025] Based on the difference between the predicted number of packages delivered for each shift on the labeling day and the actual number of packages delivered for each shift on the labeling day, updating the model parameters of the time series model to be trained and the linear model to be trained;
[0026] Retrain the time series model and the linear model after the model parameters are updated until the trained time series model and the trained linear model meet the preset training conditions.
[0027] In one embodiment, updating the model parameters of the time series model to be trained and the linear model to be trained based on the difference between the predicted package arrival volume of each shift on the labeling day and the actual package arrival volume of each shift on the labeling day includes:
[0028] Based on the difference, calculating the gradient of each node parameter in the time series model to be trained and the linear model to be trained by the chain rule;
[0029] Based on the gradient, each node parameter is modified to obtain a time series model and a linear model after the model parameters are updated.
[0030] A device for predicting the number of packages delivered during a shift, the device comprising:
[0031] An acquisition module is used to obtain, for a target logistics node, the parcel arrival data of the shifts for N historical days prior to the predicted date; the parcel arrival data includes the actual parcel arrival volume of each shift of the target logistics node on each of the historical days;
[0032] A reference day determination module is configured to input the parcel arrival data for the shifts of the N historical days into a pre-trained reference day prediction model; the pre-trained reference day prediction model is configured to determine a historical reference day for the day to be predicted from the N historical days; the similarity between the characteristics of the factors influencing the arrival volume of the historical reference day and the characteristics of the factors influencing the arrival volume of the day to be predicted is greater than a preset threshold; the characteristics of the factors influencing the arrival volume are characteristics corresponding to factors that affect the parcel arrival volume of each shift at the target logistics node;
[0033] The package quantity determination module is used to input the daily package quantity of the historical reference day into the pre-trained shift quantity prediction model; the pre-trained shift quantity prediction model is used to fit the daily package quantity to obtain the predicted package quantity of each shift of the target logistics node on the day to be predicted.
[0034] A computer device includes a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the above method when executing the computer program.
[0035] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.
[0036] The above-mentioned method, device and computer equipment for predicting the quantity of package arrivals by shift obtain the package arrival data of the N historical days before the day to be predicted for the target logistics node; the package arrival data of the shift includes the actual package arrival quantity of each shift of the target logistics node on each historical day; the package arrival data of the N historical days are input into a pre-trained reference day prediction model; the pre-trained reference day prediction model is used to determine the historical reference day of the day to be predicted among the N historical days; the similarity between the characteristics of the factors affecting the quantity of package arrivals on the historical reference day and the characteristics of the factors affecting the quantity of package arrivals on the day to be predicted is greater than a preset threshold; the characteristics of the factors affecting the quantity of package arrivals are the characteristics corresponding to the factors affecting the quantity of package arrivals of each shift of the target logistics node; the daily package arrival quantity of the historical reference day is input into the pre-trained shift arrival quantity prediction model; the pre-trained shift arrival quantity prediction model is used to fit the daily package arrival quantity to obtain the predicted quantity of package arrivals of each shift of the target logistics node on the day to be predicted. In this way, the prediction granularity of the package-to-piece volume at a logistics node can be accurately predicted to each different shift of the day, and it can flexibly adapt to the scheduling of different logistics nodes, making it easier for people to accurately arrange manpower, vehicles and other resources for each shift for the logistics node in advance, thereby improving the operating efficiency of the target transfer station. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] Figure 1 A flowchart of a method for predicting the number of packages per shift in one embodiment is shown;
[0038] Figure 2 A structural framework of a package-to-piece quantity prediction model in one embodiment;
[0039] Figure 3 A technical framework diagram of a method for predicting the number of packages per shift in one embodiment;
[0040] Figure 4 A flowchart of a method for predicting the number of packages arriving in a mid-shift according to another embodiment is shown;
[0041] Figure 5 This is a structural block diagram of a device for predicting the number of packages delivered per shift in one embodiment;
[0042] Figure 6 FIG. 1 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solutions and advantages of this application more clear, the following further describes this application in detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain this application and are not intended to limit this application.
[0044] In one embodiment, Figure 1As shown, a method for predicting the number of packages delivered during a shift is provided. The method is described using the application of the method to a server as an example, and includes the following steps:
[0045] Step S110 , for the target logistics node, obtain the shift package arrival data of N historical days before the predicted day; the shift package arrival data includes the actual package arrival volume of each shift of the target logistics node on each historical day.
[0046] Among them, logistics nodes can refer to transfer yards, transfer stations, distribution yards, transfer centers, etc.
[0047] The target logistics node may be a logistics node for which the number of packages arriving for each shift within the predicted day needs to be predicted. For example, the target logistics node may be the number of packages arriving for each shift at a transfer station within the next day.
[0048] Wherein, N is a positive integer. In practical applications, the N historical days before the to-be-predicted day may be historical days within two months before the to-be-predicted day.
[0049] In a specific implementation, the server can respond to a prediction request initiated by the terminal for the package arrival quantity of the target logistics node on the predicted day, and obtain the actual package arrival quantity of each shift on the N historical days before the predicted day.
[0050] It should be noted that factors influencing the arrival volume of transfer depot shifts have been summarized based on business experience and historical data analysis. 1) Historical arrival volume: By analyzing the autocorrelation function of the arrival volume of a specific transfer depot shift, it can be concluded that the arrival volume of a shift is often correlated with the arrival volume of the closest shifts in the past. 2) Historical base period (i.e., historical reference date): By analyzing the relationship between the historical base period volume of each shift at the transfer depot and the current volume, an appropriate base period is selected.
[0051] Taking April 2, 2020 as an example, the server can obtain the package arrival data of the target transfer station A in the historical days two months before April 2, that is, the package arrival data of the target transfer station A from February 2 to April 1.
[0052] Step S120 , inputting the package-to-piece data of N historical days into a pre-trained reference day prediction model; the pre-trained reference day prediction model is used to determine a historical reference day for the day to be predicted from the N historical days.
[0053] Among them, the similarity between the characteristics of the factors affecting the arrival volume of the historical reference day and the characteristics of the factors affecting the arrival volume of the day to be predicted is greater than a preset threshold.
[0054] Among them, the characteristics of factors affecting the arrival volume are the characteristics corresponding to the factors that affect the arrival volume of packages at each shift of the target logistics node.
[0055] The historical reference date may refer to a natural day used to provide a reference for the daily parcel arrival volume. In practical applications, the historical reference date may also be referred to as a historical base period, a historical similarity date, etc.
[0056] The pre-trained reference day prediction model may refer to a pre-trained transformer model (a machine learning model).
[0057] In a specific implementation, after obtaining the actual package arrival volume for each shift on the N historical days preceding the predicted day, the server can use these actual package arrival volumes for each shift on the N historical days preceding the predicted day as input features to the pre-trained reference day prediction model to obtain a target vector. This feature vector is used to represent the historical reference day among the N historical days and the daily package arrival volume on that historical reference day.
[0058] Continuing with the previous example, the server inputs the package arrival data for the target transfer station A from February 2nd to April 1st into the pre-trained reference day prediction model. The pre-trained reference day prediction model then outputs a target vector Y. This feature vector Y is used to represent a historical reference day (e.g., March 26th) where the similarity between the characteristics of the factors influencing the arrival volume from February 2nd to April 1st and the characteristics of the factors influencing the arrival volume on the predicted day exceeds a preset threshold, as well as the daily package arrival volume on that historical reference day.
[0059] Step S130: Input the daily package arrival volume of the historical reference day into the pre-trained shift arrival volume prediction model; the pre-trained shift arrival volume prediction model is used to fit the daily package arrival volume to obtain the predicted package arrival volume of each shift at the target logistics node on the day to be predicted.
[0060] In the specific implementation, after the server determines the historical reference day of the day to be predicted, the server can input the daily package arrival volume of the historical reference day into the pre-trained shift arrival volume prediction model; the pre-trained shift arrival volume prediction model can perform linear fitting on the daily package arrival volume to obtain the predicted package arrival volume of each shift of the target logistics node on the day to be predicted.
[0061] Continuing with the previous example, the server inputs the feature vector Y into the pre-trained model for predicting the number of packages delivered per shift. The pre-trained model performs linear fitting on the feature vector Y and outputs the predicted number of packages delivered for each shift on April 2, 2020, in the form of a time series.
[0062] In the method for predicting the parcel delivery quantity of each shift of the target logistics node, the parcel delivery quantity data of each shift of N historical days before the day to be predicted is obtained for the target logistics node; the parcel delivery quantity data of each shift includes the actual parcel delivery quantity of each shift of the target logistics node on each historical day; the parcel delivery quantity data of the N historical days is input into a pre-trained reference day prediction model; the pre-trained reference day prediction model is used to determine a historical reference day of the day to be predicted from the N historical days; the similarity between the delivery quantity influencing factor features of the historical reference day and the delivery quantity influencing factor features of the day to be predicted is greater than a preset threshold; the delivery quantity influencing factor features are features corresponding to factors influencing the parcel delivery quantity of each shift of the target logistics node; the daily parcel delivery quantity of the historical reference day is input into a pre-trained shift delivery quantity prediction model; the pre-trained shift delivery quantity prediction model is used to fit the daily parcel delivery quantity to obtain the predicted parcel delivery quantity of each shift of the target logistics node on the day to be predicted. In this way, the prediction granularity of the parcel delivery quantity of the logistics node can be accurately determined for each different shift of the day, and it can be flexibly adapted to the scheduling of different logistics nodes, so as to facilitate people to accurately arrange resources such as manpower and vehicles in each shift of the logistics node in advance, thereby improving the operation efficiency of the target transfer field.
[0063] In another embodiment, the pre-trained reference day prediction model is a pre-trained time series model, and the pre-trained time series model includes an encoding layer. In the process of inputting the parcel delivery quantity data of the N historical days into the pre-trained reference day prediction model, the parcel delivery quantity data of the N historical days is input into the pre-trained time series model, the parcel delivery quantity data of the N historical days is encoded by the encoding layer of the pre-trained time series model to obtain a target encoding vector, and the target encoding vector is used to represent the historical reference day of the day to be predicted and the daily parcel delivery quantity of the historical reference day.
[0064] In the actual application, the encoding layer can be an encoder in a transformer model (a kind of time series model).
[0065] In the specific implementation, in the process of inputting the parcel delivery quantity data of the N historical days into the pre-trained reference day prediction model, the server can input the parcel delivery quantity data of the N historical days into the pre-trained time series model, encode the parcel delivery quantity data of the N historical days by the encoding layer of the pre-trained time series model to obtain a target encoding vector representing the historical reference day of the day to be predicted and the daily parcel delivery quantity of the historical reference day, and then determine the target historical day with the similarity between the delivery quantity influencing factor features and the delivery quantity influencing factor features of the day to be predicted greater than the preset threshold as the historical reference day from the first N historical days of the day to be predicted.
[0066] The technical solution of this embodiment is to input the package arrival data of N historical days into a pre-trained time series model, and to encode the package arrival data of N historical days through the encoding layer of the pre-trained time series model to obtain a target encoding vector for representing the historical reference day of the day to be predicted and the daily package arrival quantity of the historical reference day, thereby determining a target historical day among the N historical days before the day to be predicted, whose similarity between the characteristics of the factors affecting the arrival quantity and the characteristics of the factors affecting the arrival quantity of the day to be predicted is greater than a preset threshold, as the historical reference day, to achieve the selection of the historical base period.
[0067] In another embodiment, the pre-trained time series model further includes an attention mechanism layer, and the package arrival data of N historical days are encoded through the encoding layer of the pre-trained time series model to obtain a target encoding vector, including: encoding the package arrival data of N historical days through the encoding layer of the pre-trained time series model to obtain an initial encoding vector; each initial encoding vector is used to represent the corresponding historical day and the daily package arrival volume of the historical day; the attention weight corresponding to each initial encoding vector is obtained through the attention mechanism layer of the pre-trained time series model; the attention weight is used to represent the similarity between the characteristics of the factors affecting the arrival volume of the corresponding historical day and the characteristics of the factors affecting the arrival volume of the day to be predicted; based on the attention weight, the initial encoding vector is weighted to obtain a target encoding vector.
[0068] The pre-trained time series model also includes an attention mechanism layer. In practical applications, this attention mechanism layer may refer to a network layer that uses the attention mechanism. In practical applications, this attention mechanism layer may include, but is not limited to, a self-attention layer, a multi-head attention layer, and the like.
[0069] In a specific implementation, after encoding the package arrival data for N historical days using the encoding layer of a pre-trained time series model to obtain the target encoding vector, the server can also encode the package arrival data for N historical days using the encoding layer of the pre-trained time series model to obtain the initial encoding vector. Each initial encoding vector represents the corresponding historical day and the daily package arrival volume for that historical day. The server then uses the attention mechanism layer of the pre-trained time series model to obtain the attention weight corresponding to each initial encoding vector. The attention weight represents the similarity between the characteristics of the factors influencing the arrival volume of the corresponding historical day and the characteristics of the factors influencing the arrival volume of the day to be predicted. The attention weight is positively correlated with the similarity between the characteristics of the factors influencing the arrival volume of the corresponding historical day and the characteristics of the factors influencing the arrival volume of the day to be predicted. Specifically, the higher the similarity between the characteristics of the factors influencing the arrival volume of the historical day and the characteristics of the factors influencing the arrival volume of the day to be predicted, the higher the attention weight corresponding to the initial encoding vector for that historical day. Then, the server performs weighted processing on the corresponding initial coding vectors based on the attention weights of each initial coding vector to obtain the weighted initial coding vector as the target coding vector, thereby determining the target historical day as the historical reference day, in which the similarity between the characteristics of the factors affecting the quantity of parcels arriving in the N historical days before the day to be predicted and the characteristics of the factors affecting the quantity of parcels arriving on the day to be predicted is greater than a preset threshold.
[0070] The technical solution of this embodiment is to encode the parcel arrival data of N historical days through the encoding layer of a pre-trained time series model to obtain initial encoding vectors; each initial encoding vector is used to represent the corresponding historical day and the daily parcel arrival volume on the historical day; the attention weight corresponding to each initial encoding vector is obtained through the attention mechanism layer of the pre-trained time series model; the attention weight is used to represent the similarity between the characteristics of the factors affecting the arrival volume of the corresponding historical day and the characteristics of the factors affecting the arrival volume of the day to be predicted; based on the attention weight, the initial encoding vectors are weighted to obtain a target encoding vector; thus, by adopting the attention mechanism, high attention weights are assigned to initial encoding vectors whose characteristics of the factors affecting the arrival volume have a high similarity with the characteristics of the factors affecting the arrival volume of the day to be predicted, and the initial encoding vectors are weighted using this method, so that the obtained target encoding vector can accurately represent the historical reference day in which the similarity between the characteristics of the factors affecting the arrival volume and the characteristics of the factors affecting the arrival volume of the day to be predicted is greater than a preset threshold among the N historical days preceding the day to be predicted.
[0071] In another embodiment, the daily package quantity on the historical reference day is input into a pre-trained shift quantity prediction model, including: inputting the target coding vector into a pre-trained linear model, and performing linear fitting processing on the target coding vector through the pre-trained linear model to obtain the predicted package quantity for each shift on the day to be predicted.
[0072] The pre-trained reference day prediction model is a pre-trained linear model. In practical applications, the pre-trained reference day prediction model can be a fully connected layer.
[0073] In a specific implementation, when the server inputs the daily package-to-piece quantity of the historical reference day into the pre-trained shift-to-piece quantity prediction model, the server can input the target encoding vector output by the encoding layer (encoder) of the pre-trained time series model into the pre-trained linear model. Through the pre-trained linear model, the target encoding vector is linearly fitted to output the target package-to-piece quantity vector for each shift on the day to be predicted. The target package-to-piece quantity vector is used to represent the predicted package-to-piece quantity for each shift on the day to be predicted.
[0074] In practical applications, the pre-trained reference day prediction model and the pre-trained shift-to-piece quantity prediction model can be integrated into a package-to-piece quantity prediction model, which is easier for those skilled in the art to understand. Figure 2 A structural framework of a package-to-item quantity prediction model is provided. The model includes a multi-head attention layer, a first summation and normalization layer, a first fully connected layer, a second summation and normalization layer, and a second fully connected layer.
[0075] The technical solution of this embodiment implements linear fitting of the target coding vector by inputting the target coding vector into a pre-trained linear model, thereby quickly predicting the number of packages arriving for each shift on the day to be predicted.
[0076] In another embodiment, the method further includes: obtaining training sample data; the training sample data includes the actual package arrival volume of each shift of the target logistics node on the labeling day and the package arrival data of the shifts on N historical days before the labeling day; based on the actual package arrival volume of each shift on the labeling day and the package arrival data of the shifts on N historical days before the labeling day, the time series model to be trained and the linear model to be trained are trained; when the trained time series model and the trained linear model meet the preset training conditions, the pre-trained time series model and the pre-trained linear model are obtained.
[0077] In specific implementations, the server obtains training sample data, including the actual package arrival volume for each shift at the target logistics node on the labeled day, as well as the package arrival data for shifts on N historical days prior to the labeled day, and performs feature construction. The model input vector x is constructed, and the model output vector y is constructed, with a total of one dimension. The server then selects the package volume for two months, with the daily package volume occupying one dimension, and places it in the x value. Finally, the server places the actual package arrival volume for each shift on the labeled day in the y value.
[0078] It should be noted that in order to make the influence weight of each dimension on the result consistent, the information of each dimension is normalized so that it is between 0 and 1.
[0079] 1) Training set construction: In practical applications, the server can construct a training set. The server can sort the historical shifts by time and take the first 80% as the training set.
[0080] 2) Learning rate configuration: For each training cycle, the learning rate is adjusted to 90% of the previous cycle. A training cycle refers to the time it takes for the model to traverse all training data.
[0081] 3) Early stopping: To prevent overfitting, the model terminates training early when the loss function value no longer decreases.
[0082] Taking March 2nd of a certain year as an example, the server can obtain the actual package arrival volume of each shift at transfer station A on March 2nd to construct the model output vector y as the sample label y, and obtain the package arrival data of the historical days two months before March 2nd, that is, obtain the package arrival data of the shift at transfer station A from January 2nd to March 1st, and use the daily package arrival volume as a dimension to construct the model input vector x as the sample feature x corresponding to the sample label y. Then, the server inputs the package arrival data of the shift at transfer station A from January 2nd to March 1st as the sample feature x to the time series model to be trained. The encoder in the time series model to be trained encodes the package arrival data of the shift from January 2nd to March 1st to obtain a sample encoding vector. The sample encoding vector is used to represent the historical reference day of the label day and the daily package arrival volume of the historical reference day.
[0083] The server then inputs the sample coding vector into the linear model to be trained, and performs linear fitting on the sample coding vector through the linear model to be trained to obtain the predicted package arrival volume for each shift on March 2.
[0084] Finally, the server can determine the model loss of the time series model to be trained and the time series model to be trained based on the difference between the predicted package arrival volume of each shift on March 2 and the actual package arrival volume of each shift on March 2, and update the model parameters of the time series model to be trained and the linear model to be trained based on the model loss; retrain the time series model and the linear model after the model parameters are updated until the trained time series model and the trained linear model meet the preset training conditions. For example, if the loss function value of the model no longer decreases, it is determined that the trained time series model and the trained linear model meet the preset training conditions, and the training is terminated early.
[0085] The technical solution of this embodiment is to obtain the actual package arrival volume of each shift of the target logistics node on the labeling day and the package arrival data of the shifts in the N historical days before the labeling day, and train the time series model to be trained and the linear model to be trained based on the actual package arrival volume of each shift on the labeling day and the package arrival data of the shifts in the N historical days before the labeling day, until the trained time series model and the trained linear model meet the preset training conditions, so that the pre-trained time series model can determine the historical reference day of the to-be-predicted day from the N historical days before the to-be-predicted day, and the pre-trained shift arrival volume prediction model can fit the daily package arrival volume of the historical reference day, so as to accurately obtain the predicted package arrival volume of each shift of the target logistics node on the to-be-predicted day.
[0086] In another embodiment, based on the difference between the predicted package arrival volume of each shift on the labeling day and the actual package arrival volume of each shift on the labeling day, the model parameters of the time series model to be trained and the linear model to be trained are updated, including: based on the difference, calculating the gradient of each node parameter in the time series model to be trained and the linear model to be trained by the chain rule; based on the gradient, modifying each node parameter to obtain the time series model and linear model with updated model parameters.
[0087] In a specific implementation, when the server updates the model parameters of the time series model to be trained and the linear model to be trained based on the difference between the predicted package arrival volume of each shift on the labeling day and the actual package arrival volume of each shift on the labeling day, the server can calculate the gradient of each node parameter in the time series model to be trained and the linear model to be trained by the chain rule based on the difference; then, the server can modify each node parameter based on the gradient to obtain the time series model and linear model after the model parameters are updated.
[0088] The server can use a loss function to calculate the error between the time series model and the linear model to be trained. In practice, the server can use the loss function value to represent the difference between the predicted package arrival volume for each shift on the labeling day and the actual package arrival volume for each shift on the labeling day.
[0089] The loss function may be the MSE (mean square error) loss function. The formula is:
[0090]
[0091] Where; N represents the number of training samples; y i represents the predicted value of the i-th sample; y i Represents the true value of the i-th sample.
[0092] Then, the chain rule is used to calculate the gradient of each node parameter in the neural network and modify the parameters of each node. The parameter modification formula is:
[0093]
[0094] Among them, θ t+1 represents the modified parameter value, θ t represents the parameter value before modification, λ represents the learning rate, represents the parameter θ t gradient.
[0095] If the loss function value is greater than or equal to the loss function value of the previous training, the training stops, and the server determines that the trained time series model and the trained linear model meet the preset training conditions.
[0096] To facilitate understanding by those skilled in the art, Figure 3 A technical framework diagram for a method for predicting the number of parcels arriving per shift is also provided. The server pre-trains a transformer model and uses the transformer model's encoder to select a historical base period for the labeled day from the N historical days preceding the labeled day. The server then uses the linear model to perform a linear fit on the daily parcel arrival volume corresponding to the historical base period of the labeled day, obtaining the predicted parcel arrival volume for each shift on the labeled day. Based on the difference between the predicted parcel arrival volume for each shift on the labeled day and the actual parcel arrival volume for each shift on the labeled day, the server uses a preset loss function and the chain rule to calculate the gradient of each node parameter in the model. Based on the gradient, each node parameter is modified until the model's loss function value meets the preset conditions.
[0097] The technical solution of this embodiment calculates the gradient of each node parameter in the time series model to be trained and the linear model to be trained by the chain rule based on the difference between the predicted package arrival volume of each shift on the labeling day and the actual package arrival volume of each shift on the labeling day; based on the gradient, each node parameter is modified to obtain the time series model and linear model with updated model parameters; in this way, the model parameters can be effectively updated based on the actual prediction performance of the trained time series model and the trained linear model, thereby improving the efficiency of adjusting the model parameters of the time series model to be trained and the linear model to be trained.
[0098] In another embodiment, Figure 4 As shown, a method for predicting the number of packages to pieces during a shift is provided, including the following steps:
[0099] Step S410: For the target logistics node, obtain the shift package arrival data of N historical days before the predicted day; the shift package arrival data includes the actual package arrival volume of each shift of the target logistics node on each of the historical days.
[0100] Step S420: Input the package-to-piece data of the N historical days into a pre-trained time series model. The package-to-piece data of the N historical days are encoded through the encoding layer of the pre-trained time series model to obtain initial encoding vectors; each of the initial encoding vectors is used to represent the corresponding historical day and the daily package-to-piece volume of the historical day.
[0101] In step S430, the attention weight corresponding to each of the initial coding vectors is obtained through the attention mechanism layer of the pre-trained time series model; the attention weight is used to represent the similarity between the characteristics of the factors affecting the arrival volume of the corresponding historical day and the characteristics of the factors affecting the arrival volume of the day to be predicted.
[0102] Step S440: Based on the attention weight, the initial coding vector is weighted to obtain a target coding vector; the target coding vector is used to represent the historical reference day of the day to be predicted and the daily package arrival volume of the historical reference day; the similarity between the characteristics of the factors affecting the arrival volume of the historical reference day and the characteristics of the factors affecting the arrival volume of the day to be predicted is greater than a preset threshold; the characteristics of the factors affecting the arrival volume are the characteristics corresponding to the factors that affect the package arrival volume of each shift of the target logistics node.
[0103] Step S450: Input the target code vector into a pre-trained linear model, perform linear fitting on the target code vector through the pre-trained linear model, and obtain the predicted number of packages arriving for each shift on the day to be predicted.
[0104] It should be noted that the specific limitations of the above steps can refer to the specific limitations of the above method for predicting the number of packages per shift.
[0105] It should be understood that although Figure 1 、 Figure 3 and Figure 4 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. In addition, Figure 1 、 Figure 3 and Figure 4At least part of the steps may include multiple steps or multiple stages. These steps or stages are not necessarily performed at the same time, but can be performed at different times. The order of execution of these steps or stages is not necessarily one by one, but can be performed in turn or alternately with other steps or at least part of the steps or stages in other steps.
[0106] In one embodiment, Figure 5 As shown, a device for predicting the number of packages to be delivered during a shift is provided, comprising:
[0107] An acquisition module 510 is configured to acquire, for a target logistics node, the parcel arrival data for each shift for N historical days prior to the predicted date; the parcel arrival data for each shift includes the actual parcel arrival volume for each shift of the target logistics node on each of the historical days;
[0108] Reference day determination module 520 is configured to input the package arrival data for the N historical days into a pre-trained reference day prediction model; the pre-trained reference day prediction model is configured to determine a historical reference day for the predicted day from the N historical days; the similarity between the characteristics of the factors influencing the arrival volume of the historical reference day and the characteristics of the factors influencing the arrival volume of the predicted day is greater than a preset threshold; the characteristics of the factors influencing the arrival volume are characteristics corresponding to factors that affect the package arrival volume of each shift at the target logistics node;
[0109] The package quantity determination module 530 is used to input the daily package quantity of the historical reference day into the pre-trained shift quantity prediction model; the pre-trained shift quantity prediction model is used to fit the daily package quantity to obtain the predicted package quantity of each shift of the target logistics node on the day to be predicted.
[0110] In one embodiment, the pre-trained reference day prediction model is a pre-trained time series model, which includes a coding layer. The reference day determination module 520 is specifically used to input the package-to-piece data of the N historical days into the pre-trained time series model, and encode the package-to-piece data of the N historical days through the coding layer of the pre-trained time series model to obtain a target coding vector; the target coding vector is used to represent the historical reference day of the day to be predicted and the daily package-to-piece quantity of the historical reference day.
[0111] In one embodiment, the pre-trained time series model also includes an attention mechanism layer, and the reference day determination module 520 is specifically used to encode the package arrival data of the N historical days through the encoding layer of the pre-trained time series model to obtain an initial encoding vector; each of the initial encoding vectors is used to represent the corresponding historical day and the daily package arrival volume of the historical day; the attention weight corresponding to each initial encoding vector is obtained through the attention mechanism layer of the pre-trained time series model; the attention weight is used to represent the similarity between the characteristics of the factors affecting the arrival volume of the corresponding historical day and the characteristics of the factors affecting the arrival volume of the day to be predicted; based on the attention weight, the initial encoding vector is weighted to obtain the target encoding vector.
[0112] In one embodiment, the pre-trained reference day prediction model is a pre-trained linear model, and the package quantity determination module 530 is specifically used to input the target coding vector into the pre-trained linear model, and perform linear fitting processing on the target coding vector through the pre-trained linear model to obtain the predicted package quantity of each shift on the day to be predicted.
[0113] In one embodiment, the device for predicting the quantity of packages to be delivered per shift further includes: a sample acquisition module for acquiring training sample data; the training sample data includes the actual quantity of packages to be delivered per shift of the target logistics node on the labeling day and the package-to-delivery data of the shifts for N historical days before the labeling day; a training module for training the time series model to be trained and the linear model to be trained based on the actual quantity of packages to be delivered per shift on the labeling day and the package-to-delivery data of the shifts for N historical days before the labeling day; and a determination module for obtaining the pre-trained time series model and the pre-trained linear model when the trained time series model and the trained linear model meet preset training conditions.
[0114] In one embodiment, the training module is specifically configured to input the package arrival data of the shifts for N historical days before the labeling day into the time series model to be trained, and encode the package arrival data of the shifts for N historical days before the labeling day through the encoder in the time series model to be trained to obtain a sample encoding vector; the sample encoding vector is used to represent the historical reference day of the labeling day and the daily package arrival quantity on the historical reference day; the sample encoding vector is input into the linear model to be trained, and the sample encoding vector is linearly fitted by the linear model to be trained to obtain the predicted package arrival quantity of each shift on the labeling day; based on the difference between the predicted package arrival quantity of each shift on the labeling day and the actual package arrival quantity of each shift on the labeling day, the model parameters of the time series model to be trained and the linear model to be trained are updated; and the time series model and the linear model after the updated model parameters are retrained until the trained time series model and the trained linear model meet the preset training conditions.
[0115] In one embodiment, the training module is specifically used to calculate the gradient of each node parameter in the time series model to be trained and the linear model to be trained based on the difference by the chain rule; based on the gradient, each node parameter is modified to obtain the time series model and linear model after the model parameters are updated.
[0116] The specific definitions of the device for predicting the number of packages delivered to a particular shift can be found in the definitions of the method for predicting the number of packages delivered to a particular shift, and will not be further elaborated here. Each module in the aforementioned device for predicting the number of packages delivered to a particular shift can be implemented in whole or in part via software, hardware, or a combination thereof. Each of these modules can be embedded in or independent of a processor in a computer device in hardware form, or stored in a computer device memory in software form, so that the processor can call and execute the corresponding operations of each of these modules.
[0117] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6As shown. The computer device includes a processor, a memory, and a network interface connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The database of the computer device is used to store predicted data on the number of packages to pieces per shift. The network interface of the computer device is used to communicate with an external terminal via a network connection. When the computer program is executed by the processor, it implements a method for predicting the number of packages to pieces per shift.
[0118] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than shown in the figure, or combine certain components, or have a different component arrangement.
[0119] In one embodiment, a computer device is provided, including a memory and a processor. The memory stores a computer program. When executed by the processor, the computer program causes the processor to perform the steps of predicting the number of parcels per shift. The steps of predicting the number of parcels per shift can be the steps of predicting the number of parcels per shift in each of the above embodiments.
[0120] In one embodiment, a computer-readable storage medium is provided, storing a computer program. When executed by a processor, the computer program causes the processor to perform the steps of predicting the number of parcels per shift. The steps of predicting the number of parcels per shift can be the steps of predicting the number of parcels per shift in each of the above embodiments.
[0121] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include at least one of non-volatile and volatile memory. Non-volatile memory may include read-only memory (ROM), magnetic tape, floppy disk, flash memory or optical memory, etc. Volatile memory may include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM).
[0122] The technical features of the above embodiments can be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0123] The above-described embodiments merely represent several implementation methods of the present application. While the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of the present invention. It should be noted that a person skilled in the art could make various modifications and improvements without departing from the spirit of the present application, all of which fall within the scope of protection of the present application. Therefore, the scope of protection of the present patent application shall be determined by the appended claims.
Claims
1. A method for predicting the number of packages delivered during a shift, characterized in that: include: For the target logistics node, obtain the parcel arrival data of the shifts for N historical days before the predicted day; the parcel arrival data includes the actual parcel arrival volume of each shift of the target logistics node on each of the historical days; The parcel arrival data of the shifts of the N historical days are input into the pre-trained reference day prediction model; the pre-trained reference day prediction model is used to determine the historical reference day of the to-be-predicted day among the N historical days; the similarity between the arrival quantity influencing factor characteristics of the historical reference day and the arrival quantity influencing factor characteristics of the to-be-predicted day is greater than a preset threshold; the arrival quantity influencing factor characteristics are the characteristics corresponding to the factors that affect the arrival quantity of the parcels of each shift of the target logistics node; the pre-trained reference day prediction model is a pre-trained time series model; the parcel arrival data of the shifts of the N historical days are processed through the encoding layer of the pre-trained time series model. Encoding is performed to obtain initial encoding vectors; each initial encoding vector is used to represent the corresponding historical day and the daily package arrival volume on the historical day; an attention weight corresponding to each initial encoding vector is obtained through the attention mechanism layer of the pre-trained time series model; the attention weight is used to represent the similarity between the characteristics of the factors affecting the arrival volume of the corresponding historical day and the characteristics of the factors affecting the arrival volume of the day to be predicted; based on the attention weight, the initial encoding vectors are weighted to obtain the target encoding vector; the target encoding vector is used to represent the historical reference day of the day to be predicted and the daily package arrival volume on the historical reference day; The target coding vector is input into a pre-trained model for predicting the quantity of packages to be delivered per shift, which is a pre-trained linear model. The target coding vector is linearly fitted by the pre-trained linear model to obtain the predicted quantity of packages to be delivered per shift of the target logistics node on the day to be predicted.
2. The method according to claim 1, characterized in that The method further comprises: Acquire training sample data; the training sample data includes the actual package arrival volume of each shift of the target logistics node on the label day and the package arrival data of the shifts on N historical days before the label day; Based on the actual package arrival volume of each shift on the label day and the package arrival data of the shifts on N historical days before the label day, the time series model to be trained and the linear model to be trained are trained; When the trained time series model and the trained linear model meet the preset training conditions, the pre-trained time series model and the pre-trained linear model are obtained.
3. The method according to claim 2, characterized in that The training of the time series model to be trained and the linear model to be trained based on the actual package arrival volume of each shift on the label day and the package arrival data of the shifts on N historical days before the label day includes: Inputting the package arrival data of the shifts for N historical days before the label date into the time series model to be trained, and encoding the package arrival data of the shifts for N historical days before the label date through the encoder in the time series model to be trained to obtain a sample encoding vector; the sample encoding vector is used to represent the historical reference date of the label date and the daily package arrival volume of the historical reference date; Inputting the sample code vector into the linear model to be trained, performing linear fitting processing on the sample code vector through the linear model to be trained, and obtaining the predicted number of packages received for each shift on the label day; Based on the difference between the predicted number of packages delivered for each shift on the labeling day and the actual number of packages delivered for each shift on the labeling day, the model parameters of the time series model to be trained and the linear model to be trained are updated; Retrain the time series model and the linear model after the model parameters are updated until the trained time series model and the trained linear model meet the preset training conditions.
4. The method according to claim 3, characterized in that The updating of the model parameters of the time series model to be trained and the linear model to be trained based on the difference between the predicted package arrival volume of each shift on the label day and the actual package arrival volume of each shift on the label day includes: Based on the difference, calculating the gradient of each node parameter in the time series model to be trained and the linear model to be trained by the chain rule; Based on the gradient, each node parameter is modified to obtain a time series model and a linear model after the model parameters are updated.
5. A device for predicting the number of packages arriving during a shift, characterized in that: The device comprises: An acquisition module is used to obtain, for a target logistics node, the parcel arrival data of the shifts for N historical days prior to the predicted date; the parcel arrival data includes the actual parcel arrival volume of each shift of the target logistics node on each of the historical days; The reference day determination module is used to input the arrival data of the shift packages of the N historical days into the pre-trained reference day prediction model; the pre-trained reference day prediction model is used to determine the historical reference day of the to-be-predicted day among the N historical days; the similarity between the arrival quantity influencing factor characteristics of the historical reference day and the arrival quantity influencing factor characteristics of the to-be-predicted day is greater than a preset threshold; the arrival quantity influencing factor characteristics are the characteristics corresponding to the factors that affect the arrival quantity of the packages of each shift of the target logistics node; the pre-trained reference day prediction model is a pre-trained time series model; the arrival quantity of the shift packages of the N historical days is predicted by the encoding layer of the pre-trained time series model. The package data is encoded to obtain an initial encoding vector; each initial encoding vector is used to represent the corresponding historical day and the daily package arrival volume on the historical day; an attention weight corresponding to each initial encoding vector is obtained through the attention mechanism layer of the pre-trained time series model; the attention weight is used to represent the similarity between the characteristics of the factors affecting the arrival volume of the corresponding historical day and the characteristics of the factors affecting the arrival volume of the day to be predicted; based on the attention weight, the initial encoding vector is weighted to obtain the target encoding vector; the target encoding vector is used to represent the historical reference day of the day to be predicted and the daily package arrival volume of the historical reference day; The package quantity determination module is used to input the target coding vector into a pre-trained shift package quantity prediction model, which is a pre-trained linear model; through the pre-trained linear model, the target coding vector is linearly fitted to obtain the predicted package quantity of each shift of the target logistics node on the day to be predicted.
6. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 4 are implemented.
7. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 4 are implemented.
Citation Information
Patent Citations
Method and equipment for processing and predicting time sequence containing sample points
CN103294729A
Time sequence data prediction method and device and computer storage medium
CN109978208A
Electric power system short-term load prediction method based on GEP parameter optimization XGBoost
CN111340273A