Inventory demand forecasting method, device and electronic equipment
By optimizing parameters related to cargo inventory costs in the time series prediction model, the problem of inaccurate prediction of demand in the existing model in inventory management is solved, and more efficient inventory management and cost control are achieved.
Patent Information
- Application Number
- CN202411976215.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-04-08
AI Technical Summary
Existing time series prediction models are difficult to accurately predict cargo demand in inventory management, resulting in increased costs, excessive or insufficient forecasts will trigger unbalanced business costs.
By optimizing the parameters of the time series prediction model, the optimization parameters related to the predicted demand are used to optimize the cost of goods inventory, thereby improving prediction accuracy.
The optimized time series prediction model can more accurately predict cargo demand, reduce the risk of increased costs, and improve the efficiency of inventory management.
Smart Images

Figure CN119784296A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device and electronic equipment for predicting inventory demand. Background Art
[0002] Inventory management often relies on time series forecasting models to make decisions. In inventory management, time series forecasting models can be used to predict the order quantity of goods to balance factors such as customer satisfaction, the cost of holding excess inventory (holding cost), the opportunity cost of out-of-stock goods (out-of-stock cost), and keeping the supply chain running smoothly.
[0003] Since the time series forecasting model is used to determine the order quantity of goods, the prediction quality of the time series forecasting model will greatly affect the downstream business performance indicators. For example, the order quantity of goods will cause the inventory to generate corresponding business costs, and the business costs of over-forecasting and under-forecasting are often unbalanced. For example, the cost of losing sales opportunities may exceed the cost of holding additional inventory, which may cause the order quantity predicted by the model to increase costs. Summary of the invention
[0004] In view of this, the present application provides a method, device and electronic device for predicting inventory demand, as follows:
[0005] A method for predicting inventory demand, comprising:
[0006] Obtaining input data, the input data comprising: sales volume of goods corresponding to multiple historical time points;
[0007] The input data is processed using a time series forecasting model to obtain output data; the output data includes: the demand for goods corresponding to multiple future time points;
[0008] The time series forecasting model is optimized based on optimization parameters, and the optimization parameters are related to the cost of goods inventory generated by the predicted demand output by the time series forecasting model.
[0009] In the above method, preferably, the optimization parameter includes at least one of the following: a relative root mean square corresponding to at least one cost component, and a total cost corresponding to at least one cost component;
[0010] Among them, different cost components represent the costs incurred by the predicted demand on the goods inventory in different dimensions.
[0011] In the above method, preferably, the optimization parameters are obtained by:
[0012] Obtaining a predicted order quantity and a predicted net inventory quantity corresponding to a reference time point according to the predicted demand quantities corresponding to multiple predicted time points output by the time series prediction model;
[0013] The predicted order quantity represents the quantity of goods purchased at the reference time point, and the predicted net inventory quantity represents the actual inventory quantity of goods corresponding to the reference time point;
[0014] According to the predicted order quantity and the predicted net inventory quantity, obtaining a plurality of cost components corresponding to the reference time point;
[0015] The optimization parameters are obtained according to the multiple cost components.
[0016] The above method preferably obtains the predicted order quantity corresponding to the reference time point according to the predicted demand quantities corresponding to the multiple predicted time points output by the time series prediction model, including:
[0017] According to the predicted demand corresponding to the multiple predicted time points output by the time series prediction model, a first predicted total demand corresponding to the ordering cycle starting from the reference time point and a second predicted total demand corresponding to the ordering cycle starting from the time point before the reference time point are obtained; the ordering cycle includes at least one time point;
[0018] The predicted order quantity corresponding to the reference time point is obtained based at least on the first predicted total demand, the second predicted total demand, the standard deviation corresponding to the reference time point, the standard deviation corresponding to the time point before the reference time point and the actual demand corresponding to the reference time point.
[0019] The above method preferably obtains the predicted net inventory corresponding to the reference time point according to the predicted demand corresponding to the multiple predicted time points output by the time series prediction model, including:
[0020] According to the predicted demand corresponding to the multiple predicted time points output by the time series prediction model, a third predicted total demand corresponding to the ordering cycle starting from the target time point is obtained; the target time point is before the reference time point, and there is an ordering cycle between the target time point and the reference time point, and the ordering cycle includes at least one time point;
[0021] The predicted net inventory corresponding to the reference time point is obtained based at least on the third predicted total demand, the standard deviation corresponding to the target time point and the actual demand corresponding to each time point between the target time point and the reference time point.
[0022] In the above method, preferably, the standard deviation corresponding to the reference time point is obtained by:
[0023] Creating a first tensor according to the historical sales volume of at least one goods sales point at each historical time point, wherein the rows of the first tensor represent the goods sales points, and the columns of the first tensor represent the historical time points;
[0024] For the first tensor along the dimension corresponding to the time point, construct a sliding window with a size of a first number to obtain a second tensor, where the first number is the number of time points included in the ordering period;
[0025] constructing a four-dimensional binary mask according to the second tensor, wherein a fourth dimension of the binary mask corresponds to the reference time point;
[0026] Obtain a four-dimensional average error matrix according to the average error corresponding to each matrix element in the second tensor;
[0027] The standard deviation corresponding to the reference time point is obtained according to the average error matrix and the binary mask.
[0028] The above method preferably obtains the standard deviation corresponding to the reference time point according to the average error matrix and the binary mask, including:
[0029] Multiplying the average error matrix by the binary mask to obtain a product matrix;
[0030] Processing the matrix elements of the second dimension and the third dimension in the product matrix to obtain a first value;
[0031] Processing the matrix elements of the second dimension and the third dimension in the binary mask to obtain a second value;
[0032] A standard deviation corresponding to the reference time point is obtained according to the first value and the second value.
[0033] In the above method, preferably, the cost component includes: at least one of a holding cost component, a stock-out cost component and an order difference cost component;
[0034] Wherein, according to the predicted order quantity and the predicted net inventory quantity, a plurality of cost components corresponding to the reference time point are obtained, including at least one of the following:
[0035] Processing the predicted net inventory using a preset unit holding cost value to obtain the holding cost component;
[0036] Processing the predicted net inventory using a preset unit stock-out cost value to obtain the stock-out cost component;
[0037] The predicted order quantity is processed using a preset unit order differential cost value to obtain the order differential cost component.
[0038] A device for predicting inventory demand, comprising:
[0039] A data acquisition unit, used to acquire input data, wherein the input data includes: the sales volume of goods corresponding to multiple historical time points;
[0040] A data processing unit is used to process the input data using a time series prediction model to obtain output data; the output data includes: the demand for goods corresponding to multiple future time points;
[0041] The time series forecasting model is optimized based on optimization parameters, and the optimization parameters are related to the cost of goods inventory generated by the predicted demand output by the time series forecasting model.
[0042] An electronic device, comprising:
[0043] A memory, used to store a computer program and data generated by the execution of the computer program;
[0044] A processor is used to execute the computer program to achieve: obtaining input data, the input data including: the sales volume of goods corresponding to multiple historical time points; using a time series prediction model, processing the input data to obtain output data; the output data including: the demand volume of goods corresponding to multiple future time points;
[0045] The time series forecasting model is optimized based on optimization parameters, and the optimization parameters are related to the cost of goods inventory generated by the predicted demand output by the time series forecasting model.
[0046] A computer-readable storage medium having a computer program / instruction stored thereon, wherein the computer program / instruction, when executed by a processor, implements the steps of any one of the above-mentioned methods for predicting inventory demand.
[0047] A computer program product includes a computer program / instruction, which, when executed by a processor, implements the steps of any one of the above-mentioned methods for predicting inventory demand.
[0048] It can be seen from the above technical solutions that in the inventory demand prediction method, device and electronic device provided by the present application, for a time series prediction model capable of predicting the demand for goods, the optimization parameters related to the cost incurred by the predicted demand for goods inventory can be used to optimize the model. Therefore, the cost incurred by the demand for goods on the goods inventory in the present application is taken into account in the model optimization, which enables the optimized time series prediction model to more accurately predict the demand for goods, thereby improving the accuracy of the predicted demand for goods. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0050] Figure 1 A flowchart of a method for predicting inventory demand provided in an embodiment of the present application;
[0051] Figure 2 This is an example diagram of time points in the embodiments of the present application;
[0052] Figure 3 A partial flow chart of a method for predicting inventory demand provided in an embodiment of the present application;
[0053] Figure 4 Another partial flow chart of a method for predicting inventory demand provided in an embodiment of the present application;
[0054] Figure 5 This is an example diagram of an ordering cycle in an embodiment of the present application;
[0055] Figure 6 Another partial flow chart of a method for predicting inventory demand provided in an embodiment of the present application;
[0056] Figure 7 A flowchart of another part of a method for predicting inventory demand provided in an embodiment of the present application;
[0057] Figure 8 This is an example diagram of time points in the embodiments of the present application;
[0058] Fig. 9 A schematic diagram of the structure of an inventory demand prediction device provided in an embodiment of the present application;
[0059] Fig.10 Another structural schematic diagram of an inventory demand prediction device provided in an embodiment of the present application;
[0060] Fig.11 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application;
[0061] Fig.12 This application is applicable to the flowchart of implementing inventory demand forecasting in the notebook inventory management scenario. DETAILED DESCRIPTION
[0062] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0063] refer to Figure 1 As shown, it is a flowchart of an implementation method of a method for predicting inventory demand provided in an embodiment of the present application, which can be applied to electronic devices capable of data processing, such as computers or servers. The technical solution in this embodiment is mainly used to improve the accuracy of the time series prediction model in predicting the demand for goods.
[0064] Specifically, the method in this embodiment may include the following steps:
[0065] Step 101: Obtain input data, where the input data includes: sales volumes of goods corresponding to multiple historical time points.
[0066] Among them, the historical time point refers to the time point before the current moment, such as Figure 2 as shown in .
[0067] Specifically, the goods sales volume refers to: the sales volume of goods by at least one goods sales point. For example, there may be N goods sales points, and the goods sales volume includes: the historical sales volume of goods by each goods sales point at a historical time point.
[0068] In this embodiment, the historical sales volume of goods at each goods sales point at each historical time point can be read from the sales record table in the historical database to obtain the goods sales volume corresponding to each historical time point.
[0069] Step 102: Using the time series prediction model, the input data is processed to obtain output data.
[0070] The time series prediction model can be a model based on the long short-term memory network LSTM (Long Short-Term Memory), and the output data includes: the demand for goods corresponding to multiple future time points, and the demand for goods can also be the order quantity of goods, that is, the purchase quantity of goods. The future time point refers to the time point after the current moment, such as Figure 2 In this embodiment, the input data can be input into the time series prediction model, so that the time series prediction model outputs the demand for goods corresponding to multiple future time points.
[0071] It should be noted that the time series forecasting model is optimized based on optimization parameters, and the optimization parameters are related to the cost of goods inventory generated by the predicted demand output by the time series forecasting model.
[0072] The predicted demand can be understood as the demand for goods at the predicted time point output by the time series prediction model during the training process. That is to say, in this embodiment, during the training of the time series prediction model, the predicted demand corresponding to the predicted time point can be used to predict the cost of goods inventory, and the optimization parameters can be generated according to the predicted cost, and then the time series prediction model can be optimized according to the optimization parameters to obtain a time series prediction model that can accurately predict the demand for goods.
[0073] It can be seen from the above technical solution that in a method for predicting inventory demand provided in an embodiment of the present application, for a time series prediction model capable of predicting the demand for goods, the optimization parameters related to the cost incurred by the predicted demand for goods inventory can be used to optimize the model. Therefore, the cost incurred by the demand for goods for goods inventory in the present application is taken into account in the model optimization, which enables the optimized time series prediction model to more accurately predict the demand for goods, thereby improving the accuracy of the predicted demand for goods.
[0074] In one implementation, the optimization parameters may include at least one of the following: a relative root mean square corresponding to at least one cost component, and a total cost corresponding to at least one cost component.
[0075] Among them, different cost components represent the costs incurred by the forecast demand on the goods inventory in different dimensions. Cost component refers to the component of the forecast demand on the goods inventory in the corresponding dimension, and there can be multiple cost components.
[0076] For example, the cost component may include at least one of a holding cost component, a stock-out cost component, and an order variance cost component.
[0077] Among them, the holding cost component can be expressed as C hIt means that the holding cost component can be understood as: when the quantity of goods in stock exceeds the actual market demand, the storage cost, capital occupation cost, goods depreciation and goods loss will be incurred. Among them, the storage cost can include warehouse rent, management staff salary, maintenance cost, etc.; the capital occupation cost can include the cost incurred when the enterprise funds are occupied and cannot be used for other investments.
[0078] The out-of-stock cost component can be expressed as C s It means that the out-of-stock cost component can be understood as: the cost amount incurred when inventory cannot be sold due to out-of-stock.
[0079] The order difference cost component can be expressed as C v It indicates that the order difference cost component can be understood as: the cost amount caused by fluctuations in the goods supply chain.
[0080] Based on this, during the training process of the time series prediction model, in this embodiment, the above cost components can be calculated based on the predicted demand corresponding to the time series prediction model at multiple prediction time points, and then the corresponding optimization parameters can be calculated based on these cost components, so as to use the optimization parameters to optimize the time series prediction model.
[0081] In one implementation, the optimization parameters can be obtained by: Figure 3 As shown in:
[0082] Step 301: According to the predicted demand corresponding to multiple prediction time points output by the time series prediction model, the predicted order quantity and predicted net inventory corresponding to the reference time point are obtained.
[0083] The predicted order quantity represents the quantity of goods purchased at the reference time point, and the predicted net inventory represents the actual inventory of goods corresponding to the reference time point. t It represents the quantity of goods that need to be purchased at the reference time point t; the predicted net inventory can be used t It represents the actual inventory quantity of goods in the inventory at the reference time point t.
[0084] It should be noted that the reference time point refers to the time point when the goods need to be ordered.
[0085] Step 302: Obtain multiple cost components corresponding to a reference time point according to the predicted order quantity and the predicted net inventory quantity.
[0086] Specifically, in this embodiment, the cost component corresponding to the reference time point can be obtained through the algorithm or formula corresponding to each cost component.
[0087] In one implementation, in step 302 , the predicted net inventory may be processed using a preset unit holding cost value to obtain a holding cost component.
[0088] For example, in this embodiment, the holding cost component C can be calculated by formula (1): h :
[0089]
[0090] Among them, c h It is a constant greater than or equal to 0. The specific value can be set according to business requirements. Represents the average value of the positive part of the predicted net inventory from time point 0 to time point t.
[0091] In one implementation, in step 302 , the predicted net inventory can be processed using a preset unit out-of-stock cost value to obtain an out-of-stock cost component.
[0092] For example, in this embodiment, the out-of-stock cost component C can be calculated by formula (2): s :
[0093]
[0094] Among them, c s It is a constant greater than or equal to 0. The specific value can be set according to business requirements. It represents the average value of the negative part of the predicted net inventory from time point 0 to time point t, that is, when the net inventory is lower than 0, the average value of its absolute value is calculated.
[0095] In one implementation, in step 302, the predicted order quantity is processed using a preset unit order differential cost value to obtain an order differential cost component.
[0096] For example, in this embodiment, the order difference cost component C can be calculated by formula (3): v :
[0097] C v =c v Var t (o t ) (3)
[0098] Among them, c v It is a constant greater than or equal to 0. The specific value can be set according to business needs. v Var t (o t ) is the variance of the predicted order quantities, which can be calculated by averaging the squared differences between the predicted order quantities and the mean quantity.
[0099] Step 303: Obtain optimization parameters according to multiple cost components.
[0100] The optimization parameters may include: the total cost of the cost components, and the relative root mean square of the cost components.
[0101] For example, in step 303, the holding cost component, the out-of-stock cost component and the order difference cost component are added to obtain the total cost, which can be expressed by TC, as shown in formula (4):
[0102] TC=C h +C s +C v (4)
[0103] For example, in step 303, the relative root mean square between the holding cost component, the out-of-stock cost component and the order difference cost component is calculated. The relative root mean square can be expressed by RRMS, such as formula (5):
[0104]
[0105] Where rel is defined as shown in formula (6):
[0106]
[0107] where σ is the sigmoid function. rel(x) is a unitless quantity because the unit costs cancel out in the numerator and denominator.
[0108] Based on this, in this embodiment, the optimization parameters TC and RRMS can be judged against corresponding thresholds respectively, and then the model parameters of the time series prediction model can be adjusted according to the judgment results to achieve model optimization.
[0109] In one implementation, the predicted order volume corresponding to the reference time point can be obtained in step 301 in the following manner: Figure 4 As shown in:
[0110] Step 401: Based on the predicted demand corresponding to multiple predicted time points output by the time series prediction model, obtain a first predicted total demand corresponding to an ordering cycle starting from a reference time point and a second predicted total demand corresponding to an ordering cycle starting from a time point before the reference time point.
[0111] The ordering cycle refers to the period from placing an order to a goods provider to the delivery of the goods to the goods provider, and the ordering cycle can be represented by L. The ordering cycle contains at least one time point, such as Figure 5 As shown in , the ordering cycle starting from the reference time point includes multiple time points, and the ordering cycle starting from the time point before the reference time point also includes multiple time points.
[0112] Specifically, in this embodiment, the predicted demand corresponding to each time point in the ordering cycle starting from the reference time point is added together to obtain a first predicted total demand; and the predicted demand corresponding to each time point in the ordering cycle starting from the time point before the reference time point is added together to obtain a second predicted total demand.
[0113] Step 402: Obtain the predicted order quantity corresponding to the reference time point based on at least the first predicted total demand, the second predicted total demand, the standard deviation corresponding to the reference time point, the standard deviation corresponding to the time point before the reference time point, and the actual demand corresponding to the reference time point.
[0114] For example, in step 402, the predicted order quantity can be obtained by formula (7):
[0115]
[0116] Among them, L is the ordering period, which includes multiple time points; is the first predicted total demand corresponding to the ordering period L starting from the reference time point t; is the second predicted total demand corresponding to the ordering cycle L starting from the time point t-1 before the reference time point t; s Target service level; -1 (α s ) is the target service level α s The inverse CDF of the normal distribution evaluated under can be calculated using the scipy.stats.norm.ppf() function; σ e,t is the standard deviation corresponding to the reference time point t; σ e,t-1 is the standard deviation corresponding to the previous time point t-1 of the reference time point t; d t is the actual demand corresponding to the reference time point t.
[0117] In one implementation, the standard deviation corresponding to the reference time point can be achieved in the following manner, such as Figure 6 As shown in:
[0118] Step 601: Create a first tensor according to the historical sales volume corresponding to at least one commodity sales point at each historical time point.
[0119] The rows of the first tensor represent the sales points of the goods, and the columns of the first tensor represent the historical time points. Figure 7 As shown in , there are N sales points for goods, that is, the first tensor has N rows, and there are T historical time points, that is, the first tensor has T rows. The first tensor is a two-dimensional vector, and the first tensor can be represented by M, where M is N×T.
[0120] It should be noted that the historical sales volume corresponding to the goods sales point at each historical time point can be obtained from the sales record table. Based on this, a first tensor is created according to these historical sales volumes in step 601. The matrix elements in the first tensor are: the historical sales volume of the goods sales point corresponding to the row at the historical time point corresponding to the corresponding column.
[0121] Step 602: construct a sliding window of a first size for the first tensor along the dimension corresponding to the time point to obtain a second tensor.
[0122] The first quantity is the quantity of time points included in the ordering cycle. Figure 7 In the sliding window, the first number of time points is the number of time points included in the ordering period L. According to the sliding window, a second tensor is obtained. The second tensor is a three-dimensional vector. The second tensor can be represented by M′, which is N×T×L.
[0123] Step 603: construct a four-dimensional binary mask according to the second tensor.
[0124] The fourth dimension of the binary mask corresponds to the reference time point.
[0125] Specifically, the second tensor in step 603 can be repeated multiple times to obtain an intermediate tensor M", the fourth dimension of the intermediate tensor M" corresponds to the reference time point. Based on this, the size between the time point of the fourth dimension and the time point of the third dimension is judged, and the matrix elements whose time points of the fourth dimension are smaller than the time points of the third dimension are set to 0, and the others are set to 1 to obtain a four-dimensional binary mask.
[0126] Step 604: Obtain a four-dimensional average error matrix according to the average error corresponding to each matrix element in the second tensor.
[0127] For example, in step 604, the average error E of each matrix element in the second tensor M′(N×T×L), that is, the three-dimensional average error of each matrix element, can be calculated first, and this can be repeated T times to obtain the four-dimensional average error E′, where E′ is N×T×L×T.
[0128] Step 605: Obtain the standard deviation corresponding to the reference time point according to the average error matrix and the binary mask.
[0129] In this embodiment, the average error matrix and the binary mask may be subjected to matrix calculation to obtain the standard deviation corresponding to the reference time point.
[0130] Specifically, step 605 can be implemented in the following manner:
[0131] First, the average error matrix is multiplied by the binary mask to obtain a product matrix; then, the matrix elements of the second and third dimensions in the product matrix are processed, for example, the matrix elements of the second and third dimensions in the product matrix are added to obtain a first value; and, the matrix elements of the second and third dimensions in the binary mask are processed, for example, the matrix elements of the second and third dimensions in the binary mask are added to obtain a second value; finally, based on the first and second values, the standard deviation corresponding to the reference time point is obtained, for example, the first and second values are divided and then the square root is taken to obtain the standard deviation.
[0132] It should be noted that, in this embodiment, the standard deviation corresponding to the time point before the reference time point can be obtained in the above manner.
[0133] In one implementation, the predicted net inventory corresponding to the reference time point can be obtained in step 301 in the following manner: Figure 7 As shown in:
[0134] Step 701: According to the predicted demand quantities at multiple predicted time points output by the time series prediction model, a third predicted total demand quantity corresponding to the ordering cycle starting from the target time point is obtained.
[0135] The target time point is before the reference time point, and there is an ordering period between the target time point and the reference time point, and the ordering period includes at least one time point, such as Figure 8 As shown in , the target time point is a time point before the reference time point and separated by L time points.
[0136] For example, in step 701, the predicted demand corresponding to each time point in the ordering cycle starting from the target time point may be added up to obtain a third predicted total demand.
[0137] Step 702: Obtain the predicted net inventory corresponding to the reference time point based on at least the third predicted total demand, the standard deviation corresponding to the target time point, and the actual demand corresponding to each time point between the target time point and the reference time point.
[0138] For example, in step 702, the predicted net inventory can be obtained by formula (8):
[0139]
[0140] in, is the third predicted total demand corresponding to the ordering period L starting from the target time point tL; e,t-L is the standard deviation corresponding to the target time point tL; d kis the actual demand corresponding to each time point k from the next time point of the target time point to the benchmark time point.
[0141] refer to Fig. 9 , is a schematic diagram of the structure of a device for predicting inventory demand provided in an embodiment of the present application, and the device may include the following units:
[0142] The data acquisition unit 901 is used to acquire input data, wherein the input data includes: the sales volume of goods corresponding to multiple historical time points;
[0143] The data processing unit 902 is used to process the input data using a time series prediction model to obtain output data; the output data includes: the demand for goods corresponding to multiple future time points;
[0144] The time series forecasting model is optimized based on optimization parameters, and the optimization parameters are related to the cost of goods inventory generated by the predicted demand output by the time series forecasting model.
[0145] It can be seen from the above technical solution that in an inventory demand prediction device provided by the present application, for a time series prediction model capable of predicting the demand for goods, the optimization parameters related to the cost incurred by the predicted demand for goods inventory can be used to optimize the model. Therefore, the cost incurred by the demand for goods on the goods inventory in the present application is taken into account in the model optimization, which enables the optimized time series prediction model to more accurately predict the demand for goods, thereby improving the accuracy of the predicted demand for goods.
[0146] In one implementation, the optimization parameters include at least one of the following: a relative root mean square corresponding to at least one cost component, and a total cost corresponding to at least one cost component; wherein different cost components represent the costs incurred by the predicted demand on the goods inventory in different dimensions.
[0147] In one implementation, the device in this embodiment may further include the following units: Fig.10 As shown in:
[0148] The parameter obtaining unit 903 is used to obtain the optimization parameters in the following manner:
[0149] According to the predicted demand corresponding to multiple predicted time points output by the time series forecasting model, the predicted order quantity and the predicted net inventory corresponding to the reference time point are obtained; wherein the predicted order quantity represents the quantity of goods purchased at the reference time point, and the predicted net inventory represents the actual inventory of goods corresponding to the reference time point; according to the predicted order quantity and the predicted net inventory, multiple cost components corresponding to the reference time point are obtained; according to the multiple cost components, the optimization parameters are obtained.
[0150] In one implementation, when the parameter acquisition unit 903 obtains the predicted order quantity corresponding to a reference time point based on the predicted demand quantities corresponding to multiple predicted time points output by the time series prediction model, it is specifically used to: obtain a first predicted total demand amount corresponding to an ordering cycle with the reference time point as the starting point and a second predicted total demand amount corresponding to an ordering cycle with the previous time point as the starting point based on the predicted demand quantities corresponding to multiple predicted time points output by the time series prediction model; the ordering cycle includes at least one time point; and obtain the predicted order quantity corresponding to the reference time point based on at least the first predicted total demand amount, the second predicted total demand amount, the standard deviation corresponding to the reference time point, the standard deviation corresponding to the previous time point and the actual demand corresponding to the reference time point.
[0151] In one implementation, when the parameter acquisition unit 903 obtains the predicted net inventory corresponding to the reference time point based on the predicted demand corresponding to multiple prediction time points output by the time series prediction model, it is specifically used to: obtain a third predicted total demand corresponding to an ordering cycle with a target time point as the starting point based on the predicted demand corresponding to multiple prediction time points output by the time series prediction model; the target time point is before the reference time point, and the target time point is separated from the reference time point by an ordering cycle, and the ordering cycle includes at least one time point; obtain the predicted net inventory corresponding to the reference time point based on at least the third predicted total demand, the standard deviation corresponding to the target time point and the actual demand corresponding to each time point between the target time point and the reference time point.
[0152] In one implementation, the parameter obtaining unit 903 is further configured to obtain the standard deviation corresponding to the reference time point by:
[0153] A first tensor is created according to the historical sales volume corresponding to at least one goods sales point at each historical time point, wherein the rows of the first tensor represent the goods sales points, and the columns of the first tensor represent the historical time points; a sliding window with a size of a first number is constructed for the first tensor along the dimension corresponding to the time point to obtain a second tensor, wherein the first number is the number of time points included in the ordering cycle; a four-dimensional binary mask is constructed according to the second tensor, wherein the fourth dimension of the binary mask corresponds to the reference time point; a four-dimensional average error matrix is obtained according to the average error corresponding to each matrix element in the second tensor; and a standard deviation corresponding to the reference time point is obtained according to the average error matrix and the binary mask.
[0154] In one implementation, when the parameter acquisition unit 903 obtains the standard deviation corresponding to the reference time point based on the average error matrix and the binary mask, it is specifically used to: multiply the average error matrix by the binary mask to obtain a product matrix; process the matrix elements of the second dimension and the third dimension in the product matrix to obtain a first value; process the matrix elements of the second dimension and the third dimension in the binary mask to obtain a second value; and obtain the standard deviation corresponding to the reference time point based on the first value and the second value.
[0155] In one implementation, the cost component includes: at least one of a holding cost component, a stock-out cost component, and an order variance cost component;
[0156] Among them, when the parameter acquisition unit 903 obtains multiple cost components corresponding to the benchmark time point based on the predicted order quantity and the predicted net inventory, it is specifically used to: use the preset unit holding cost value to process the predicted net inventory to obtain the holding cost component; use the preset unit out-of-stock cost value to process the predicted net inventory to obtain the out-of-stock cost component; use the preset unit order difference cost value to process the predicted order quantity to obtain the order difference cost component.
[0157] It should be noted that the specific implementation method of each unit in this embodiment can refer to the corresponding content in the previous text and will not be described in detail here.
[0158] refer to Fig.11 , is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application, and the electronic device may include the following structure:
[0159] Memory 1101, used to store computer programs and data generated by the execution of the computer programs;
[0160] The processor 1102 is configured to execute the computer program to: obtain input data, the input data including: the sales volume of goods corresponding to multiple historical time points; process the input data using a time series prediction model to obtain output data; the output data including: the demand volume of goods corresponding to multiple future time points;
[0161] The time series forecasting model is optimized based on optimization parameters, and the optimization parameters are related to the cost of goods inventory generated by the predicted demand output by the time series forecasting model.
[0162] It can be seen from the above technical solution that in an electronic device provided by the present application, for a time series prediction model capable of predicting the demand for goods, the optimization parameters related to the cost incurred by the predicted demand for goods inventory can be used to optimize the model. Therefore, the cost incurred by the demand for goods on the goods inventory in the present application is taken into account in the model optimization, which can enable the optimized time series prediction model to more accurately predict the demand for goods, thereby improving the accuracy of the predicted demand for goods.
[0163] Taking the inventory management scenario of a notebook as an example, this application predicts the demand for L time steps in the ordering cycle. The relevant formula of the inventory status is a closed form, which can avoid the instability of back propagation, reduce the computational complexity, and reduce memory usage. Moreover, this application can directly predict the inventory quantity that needs to be ordered based on business indicators such as TC and RRMS, and there is no need to decide the final result based on business indicators.
[0164] The following is an example of the technical solution of this application:
[0165] First, for each time series, i.e., a sequence of multiple time points, a rolling simulation method is used in this application to simulate the inventory status at each time point. Considering the actual demand d at each time point t=1, 2, ..., T t A time series, at each time point, the order o t It will arrive within the lead time L days. The order is given by formula (9):
[0166]
[0167] in, is the forecasted lead time demand for the next L time steps (i.e., time points), ss t is the amount of safety stock that adds a buffer to ensure that orders meet demand, ip t is the total inventory, which represents the inventory in the warehouse and the inventory on the way. is the historical demand data, according to d tSum and forecast lead time requirements Given by formula (10) and formula (11):
[0168]
[0169] in, It is the demand forecast for the time point t+k given the data before the given time point t. The forecast model in this application can be any type of time series prediction model, LSTM is one of them. The calculation of safety stock is shown in formula (12):
[0170] ss t =φ -1 (α s )σ e (12)
[0171] Among them, σ e Is the standard deviation of the forecast error. It measures the size of the forecast error. The larger the standard deviation, the lower the forecast accuracy, and more safety stock is needed. The standard deviation calculation is performed on the predicted demand and actual demand. -1 (α s ) is the target service level α s The inverse CDF of the normal distribution evaluated under , where the service level refers to the probability of meeting customer demand, which is used to measure the ability of the inventory system to meet customer demand. The higher the service level, the better it can meet customer needs, but it may also be accompanied by higher costs. The target service level is an indicator set by the enterprise and the service level it expects to achieve. Assuming the error is normally distributed, with α s The safety stock plus the lead time demand forecast should be able to cover the actual demand.
[0172] The total inventory ip t It is done by taking the previous inventory position and placing the order o of the previous time step t-1 Add and subtract the current demand d t To obtain, as shown in formula (13):
[0173] ip t =ip t-1 +o t-1 -d t (13)
[0174] Assume that ip0 is 0 and o0 is 0. Since the order needs a lead time of L to arrive, the total inventory can be decomposed into: the actual amount of inventory is called the net inventory i t , and semi-finished products at different stages of the production process, called work-in-progress inventory ω t , as shown in formula (14) and formula (15):
[0175] ip t =i t +ω t (14)
[0176] i t =i t-1 +o t-L -d t (15)
[0177] The following is an explanation of the business indicators (also called evaluation indicators, i.e. the optimization parameters mentioned above):
[0178] First, total cost (TC) is defined as the cost of holding excess inventory (holding cost C h ), the opportunity cost of out-of-stock (the cost of out-of-stock C s ) and the cost of supply chain fluctuations (order difference cost C v ), such as formula (1), formula (2) and formula (3). Based on this, TC is C h , C s and C v The sum of .
[0179] Specifically, c h is the unit holding cost, c s is the unit stockout cost, c v is the unit order differential cost. c h 、c s 、c v Can be set based on experience.
[0180] Second, for settings where the cost tradeoff may be unknown, the relative root mean square (RRMS) is introduced, such as equations (5) and (6).
[0181] It should be noted that for typical forecasting metrics (such as mean square error MSE (Mean Square Error), symmetric mean absolute percentage error sMAPE (Symmetric Mean Absolute Percentage Error), etc.), differentiable calculations are relatively simple. These indicators can usually be decomposed into calculating a differentiable quantity (such as the squared difference between the predicted value and the actual value) at each time point and taking the average value for all time points. However, calculating inventory performance (such as total cost TC, RRMS) is not so direct because there are continuous inventory variables that must be tracked over time (such as net inventory, orders), which cannot be simply calculated once and need to be continuously tracked and updated throughout the planning period. Therefore, the present application can derive a series of calculations that can simulate the inventory management system and be calculated in a differentiable manner.
[0182] Among them, if a simple recursive iterative method is used, for each time point t, the inventory status is updated using the formula in the previous article according to the current inventory quantity, orders, etc., the calculation is very inefficient and is easily affected by the accumulation of calculation errors. Especially for long time series, this iterative dependency chain will lead to the problem of gradient vanishing or gradient exploding, making the model difficult to train. Gradient vanishing means that as the number of back propagation layers increases, the gradient becomes smaller and smaller, so that it is almost zero when it reaches the early layers, making the model unable to effectively update the weights of these early layers. In contrast, gradient explosion means that the gradient becomes very large, making model training unstable.
[0183] By using the initial conditions to expand the recursive formula, the inventory at any time t can be written in closed form (a closed form means that a mathematical expression can directly output the value of the function without the need for iteration or recursion to calculate step by step). Then, the application can directly calculate the order volume at any time point t without simulating the entire time series to calculate each time point one by one. The derivation process is shown in formula (16):
[0184]
[0185] Based on this, we get o as shown in formula (7): t .
[0186] Among them, the net inventory at time point t can be the derivation process of formula (17):
[0187]
[0188] Assuming that all quantities with a value of -1 at time point t are equal to 0, i0 can be expressed as formula (18):
[0189] i0=i -1 +o -L -d0=-d0 (18)
[0190] Based on this, t It can be simplified as formula (8).
[0191] Target service levelΦ -1 (α s ) is a constant and easy to calculate. Since the forecast is made at each time point over a period of time, the standard deviation of the forecast error σ e,t It is more complicated. In Python, you can use the scipy.stats.norm.ppf() function to calculate it.
[0192] The following is to calculate the standard deviation σ e,t The process:
[0193] 1. Create an N×T tensor M, where M[:,t] = t. N is the number of time series.
[0194] 2. Build a sliding window of size L along the time dimension. This will create a tensor M′ with size N×T×L.
[0195] 3. Repeat the tensor T times in the new (fourth) dimension, taking the threshold to create a binary mask for each t∈{1,2,…,T}, corresponding to whether the time occurred. That is, M″[i,t,l,t′] is 1{M′[i,t,l,t′]≤t′}.
[0196] It should be noted that the purpose of repeating the tensor M′ T times to create a new four-dimensional tensor M″ in this application is to construct a binary mask, which can be used in subsequent calculations to distinguish whether predictions at different time points should be taken into account, specifically to mark whether the predicted time point t+l has been reached or exceeded at a given time point t′. It is 1 only when t+l is less than or equal to t′, otherwise it is 0. Using this mask, it is possible to ensure that future information is not used when calculating errors, and the use of masks can efficiently perform conditional selection operations in TensorFlow or Pytorch, improve computing efficiency, and the selection and calculation process is differentiable.
[0197] 4. Calculate the square error E of each element of the N×T×L prediction. Repeat T times to get E′(N×T×L×T). Specifically, for the prediction made by the model at each time point t Calculate the error (subtraction) between it and the true demand d[i,t,l], and then calculate the square of the error to get the error tensor E. Then copy it T times to match the shape of M″ to get E′.
[0198] 5. Multiply the repeated error E' element-wise by the binary mask (both should be N×T×L×T). Sum along the second and third dimensions (of size T and L), and divide by the sum of the binary masks along the second and third dimensions. This gives the mean squared forecast error for each time series at each time point. Take the square root to get the standard deviation.
[0199] It should be noted that the present application multiplies E′ and M″ by element-wise multiplication to eliminate the impact of prediction time points that have not yet arrived. The positions where the element value in M″ is 1 are valid square errors (i.e., predictions corresponding to time points that have already occurred), while the positions where the value is 0 indicate that these predictions should not be considered (i.e., predictions corresponding to future time points). The second and third dimensions (i.e., the time dimension T and the prediction window dimension L) are then summed. This summation operation actually calculates the sum of the squares of the valid prediction errors at each time point t′ and each time series i. Then divide it by the sum of the second and third dimensions (i.e., the number of valid predictions at this time point t′ and time series i) to obtain the average square error. Finally, take the square root of the average square error to obtain the standard deviation of the prediction error for each time t′ and time series i.
[0200] Among them, this application gives the inventory state variable o t and i t , the evaluation mean can be calculated on these variables. That is, the optimized standard deviation is used to calculate o t and i t , and then calculate o t and i t Substitute formula (1) into formula (3), calculate the three costs, and then calculate TC and RRMS. Holding costs and out-of-stock costs can be calculated by t and -i t ReLU activation is applied and the average is calculated over the time points. The variance of the orders can be calculated by averaging the squared differences between orders and the average number of orders. Finally, the total cost (TC) and relative root mean squares (RRMs) combine these three components in a differentiable way (sum or subtract and divide by a constant, the sum of squares).
[0201] Based on this, inventory demand forecasting can be achieved in this application through the following process: Fig.12 As shown in:
[0202] Step 1201: Collect historical data related to inventory forecasting.
[0203] Among them, historical data includes product sales, inventory, promotional activities, etc. The collected data is cleaned, converted and standardized.
[0204] Step 1202: Build a time series prediction model. Any differentiable model, such as LSTI, can be used.
[0205] Step 1203: Use new evaluation indicators such as TC and / or RRMS to train and optimize the model.
[0206] Step 1204: Use the trained model to predict future inventory demand.
[0207] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0208] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0209] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0210] The above description of the disclosed embodiments enables those skilled in the art to implement or use the present application. Various modifications to these embodiments will be apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application will not be limited to the embodiments shown herein, but will conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for predicting inventory demand, comprising: Obtaining input data, the input data comprising: sales volume of goods corresponding to multiple historical time points; The input data is processed using a time series forecasting model to obtain output data; the output data includes: the demand for goods corresponding to multiple future time points; The time series forecasting model is optimized based on optimization parameters, and the optimization parameters are related to the cost of goods inventory generated by the predicted demand output by the time series forecasting model.
2. The method according to claim 1, wherein the optimization parameter comprises at least one of the following: a relative root mean square corresponding to at least one cost component, and a total cost corresponding to at least one cost component; in, The different cost components represent the costs incurred by the predicted demand on the inventory of goods in different dimensions.
3. According to the method of claim 1 or 2, the optimization parameters are obtained by: Obtaining a predicted order quantity and a predicted net inventory quantity corresponding to a reference time point according to the predicted demand quantities corresponding to multiple predicted time points output by the time series prediction model; in, The predicted order quantity represents the quantity of goods purchased at the reference time point, and the predicted net inventory quantity represents the actual inventory quantity of goods corresponding to the reference time point; According to the predicted order quantity and the predicted net inventory quantity, obtaining a plurality of cost components corresponding to the reference time point; The optimization parameters are obtained according to the multiple cost components.
4. The method according to claim 3, obtaining the predicted order quantity corresponding to the reference time point according to the predicted demand quantity corresponding to the multiple predicted time points output by the time series prediction model, comprises: According to the predicted demand corresponding to the multiple predicted time points output by the time series prediction model, a first predicted total demand corresponding to the ordering cycle starting from the reference time point and a second predicted total demand corresponding to the ordering cycle starting from the time point before the reference time point are obtained; the ordering cycle includes at least one time point; The predicted order quantity corresponding to the reference time point is obtained based at least on the first predicted total demand, the second predicted total demand, the standard deviation corresponding to the reference time point, the standard deviation corresponding to the time point before the reference time point and the actual demand corresponding to the reference time point.
5. The method according to claim 3, obtaining the predicted net inventory corresponding to the reference time point according to the predicted demand corresponding to the multiple predicted time points output by the time series prediction model, comprises: Obtaining a third predicted total demand corresponding to an ordering cycle starting at a target time point according to the predicted demand corresponding to a plurality of predicted time points output by the time series prediction model; The target time point is before the reference time point, and there is a subscription period between the target time point and the reference time point, wherein the subscription period includes at least one time point; The predicted net inventory corresponding to the reference time point is obtained based at least on the third predicted total demand, the standard deviation corresponding to the target time point and the actual demand corresponding to each time point between the target time point and the reference time point.
6. The method according to claim 4, wherein the standard deviation corresponding to the reference time point is obtained by: Creating a first tensor according to the historical sales volume of at least one goods sales point at each historical time point, wherein the rows of the first tensor represent the goods sales points, and the columns of the first tensor represent the historical time points; For the first tensor along the dimension corresponding to the time point, construct a sliding window with a size of a first number to obtain a second tensor, where the first number is the number of time points included in the ordering period; constructing a four-dimensional binary mask according to the second tensor, wherein a fourth dimension of the binary mask corresponds to the reference time point; Obtain a four-dimensional average error matrix according to the average error corresponding to each matrix element in the second tensor; The standard deviation corresponding to the reference time point is obtained according to the average error matrix and the binary mask.
7. The method according to claim 6, obtaining the standard deviation corresponding to the reference time point according to the average error matrix and the binary mask, comprising: Multiplying the average error matrix by the binary mask to obtain a product matrix; Processing the matrix elements of the second dimension and the third dimension in the product matrix to obtain a first value; Processing the matrix elements of the second dimension and the third dimension in the binary mask to obtain a second value; A standard deviation corresponding to the reference time point is obtained according to the first value and the second value.
8. The method of claim 3, wherein the cost components include: at least one of a holding cost component, a stock-out cost component, and an order variance cost component; Wherein, according to the predicted order quantity and the predicted net inventory quantity, a plurality of cost components corresponding to the reference time point are obtained, including at least one of the following: Processing the predicted net inventory using a preset unit holding cost value to obtain the holding cost component; Processing the predicted net inventory using a preset unit stock-out cost value to obtain the stock-out cost component; The predicted order quantity is processed using a preset unit order differential cost value to obtain the order differential cost component.
9. A device for predicting inventory demand, comprising: A data acquisition unit, used to acquire input data, wherein the input data includes: the sales volume of goods corresponding to multiple historical time points; A data processing unit, used to process the input data using a time series forecasting model to obtain output data; the output data includes: the demand for goods corresponding to multiple future time points; The time series forecasting model is optimized based on optimization parameters, and the optimization parameters are related to the cost of goods inventory generated by the predicted demand output by the time series forecasting model.
10. An electronic device comprising: A memory, used to store a computer program and data generated by the execution of the computer program; A processor is used to execute the computer program to achieve: obtaining input data, the input data including: the sales volume of goods corresponding to multiple historical time points; using a time series prediction model, processing the input data to obtain output data; the output data including: the demand volume of goods corresponding to multiple future time points; The time series forecasting model is optimized based on optimization parameters, and the optimization parameters are related to the cost of goods inventory generated by the predicted demand output by the time series forecasting model.
Citation Information
Cited By
Intelligent supply chain demand prediction and inventory optimization system
CN120181754A