Material demand prediction method and device, electronic equipment and storage medium
By pre-setting a demand forecasting model, based on historical data and material attribute covariates, and simulating the conditional probability distribution of demand, the difficulty of material demand forecasting in unplanned project management is solved, and the forecasting accuracy and inventory management efficiency are improved.
Patent Information
- Application Number
- CN202511758099.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-27
- Publication Date
- 2026-01-20
AI Technical Summary
In unplanned project management, material demand forecasting is difficult, human experience standards are inconsistent, and maintenance plans change frequently, making it difficult to adjust demand plans and affecting the accuracy of material requirements and inventory management.
A pre-defined demand forecasting model is adopted. Based on historical demand and material attribute covariates, the model simulates the conditional probability distribution of demand through multi-head self-attention transformation and negative binomial distribution prediction. The model parameters are adjusted through random sampling and gradient optimization to predict future demand.
It improves the accuracy of material demand forecasting and the efficiency of inventory management, reduces the difficulty of demand forecasting, and is suitable for sudden changes in demand in unplanned project management.
Smart Images

Figure CN121365779A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of inventory management, and particularly relates to a material demand prediction method and device, an electronic device and a storage medium. BACKGROUND
[0002] In non-planned project management, a demand plan is formulated in advance based on maintenance plans by using artificial experience. However, the maintenance plan of non-planned project management is sudden, and the maintenance plan will change frequently. After the demand plan is formulated, it is difficult to feed back the change of the maintenance plan to the maintenance field, so that the demand plan cannot be adjusted according to the maintenance plan. Moreover, the standard relied on by artificial experience varies from person to person, so that the difficulty of formulating the demand plan is further increased. Since the demand plan is essentially to predict the material demand of the maintenance plan in advance, how to reduce the difficulty of material demand prediction has become a problem to be solved. SUMMARY
[0003] The main purpose of the embodiments of the present application is to provide a material demand prediction method and device, an electronic device and a storage medium, which aims to reduce the difficulty of material demand prediction.
[0004] To achieve the above-mentioned purpose, a first aspect of the embodiments of the present application provides a material demand prediction method, which comprises: obtaining a historical demand quantity of a material in a historical period, a historical material attribute covariate and a target material attribute covariate in a plurality of continuous target periods, and a reference demand quantity; predicting, by a preset demand prediction model, a demand conditional probability distribution of the material in a first target period based on the historical demand quantity, the historical material attribute covariate and the target material attribute covariate of the first target period, and randomly sampling the demand conditional probability distribution to obtain an initial demand quantity of the material in the first target period and a demand probability of the initial demand quantity; starting from a second target period, for each target period, predicting, by the preset demand prediction model, an initial demand quantity and a demand probability of a current target period based on the historical demand quantity, the historical material attribute covariate, the target material attribute covariate from the first target period to the current target period, the initial demand quantity of each target period from the first target period to the previous target period, until the initial demand quantity and the demand probability of each target period are obtained; adjusting model parameters of the preset demand prediction model according to the initial demand quantity, the demand probability of each target period and the reference demand quantity to obtain a target prediction model; The target prediction model is used to predict a target demand quantity of the target material in a future period based on a reference historical demand quantity of the target material in a reference historical period, a reference historical material attribute covariate, and a reference material attribute covariate in the future period.
[0005] In some embodiments, the model parameters of the preset demand prediction model are adjusted according to the initial demand quantity, the demand probability and the reference demand quantity of each target period to obtain a target prediction model, including: A joint probability is calculated according to the demand probability of each target period. The initial demand quantity of each target period is screened according to the joint probability to obtain a predicted demand quantity of each target period. A target loss value is determined according to the reference demand quantity and the corresponding predicted demand quantity of each target period. The model parameters of the preset demand prediction model are adjusted according to the target loss value to obtain the target prediction model.
[0006] In some embodiments, the demand conditional probability distribution of the material in the first target period is predicted based on the historical demand quantity, the historical material attribute covariate and the target material attribute covariate of the first target period, including: The historical demand quantity, the historical material attribute covariate and the target material attribute covariate of the first target period are subjected to multi-head self-attention transformation to obtain demand attention features. The demand attention features are subjected to feature decoding to obtain demand decoding features. The demand decoding features are subjected to negative binomial distribution prediction to obtain the demand conditional probability distribution.
[0007] In some embodiments, the historical demand quantity, the historical material attribute covariate and the target material attribute covariate of the first target period are subjected to multi-head self-attention transformation to obtain demand attention features, including: The historical demand quantity, the historical material attribute covariate and the target material attribute covariate of the first target period are subjected to vectorization processing to obtain demand embedding vectors. Query vectors, key vectors and value vectors are determined according to the demand embedding vectors. The query vectors, the key vectors and the value vectors are subjected to multi-head attention calculation to obtain the demand attention features.
[0008] In some embodiments, the model parameters of the preset demand prediction model are adjusted according to the target loss value to obtain the target prediction model, including: The gradient of the target loss value with respect to the model parameters is calculated. determining an update step for the model parameters; updating the model parameters according to the update step and the gradient, to obtain the target prediction model.
[0009] In some embodiments, after the model parameters of the preset demand prediction model are adjusted according to the initial demand quantity of each target period, the demand probability and the reference demand quantity, to obtain a target prediction model, the material demand prediction method further comprises: initializing an inventory cycle, a safety inventory level and an order level; determining a future period according to the inventory cycle, and obtaining a reference historical demand quantity of a target material in a reference historical period, a reference historical material attribute covariate and a reference material attribute covariate in the future period; predicting a target demand quantity of the target material in the future period based on the reference historical demand quantity, the reference historical material attribute covariate and the reference material attribute covariate through the target prediction model; determining an inventory level of the future period according to the safety inventory level, the order level and a preset service level constraint condition; determining a target inventory cost according to the target demand quantity, the inventory level and the safety inventory level; adjusting the inventory cycle, the safety inventory level and the order level according to the target inventory cost, to obtain an inventory strategy.
[0010] In some embodiments, the determination of the target inventory cost according to the target demand quantity, the inventory level and the safety inventory level comprises: determining a first inventory cost according to a preset unit order procurement cost, the target demand quantity, the inventory level and the safety inventory level; determining a second inventory cost according to a preset unit inventory holding cost, the target demand quantity and the inventory level; determining a third inventory cost according to a preset unit delay penalty cost, the target demand quantity and the inventory level; determining the target inventory cost according to the first inventory cost, the second inventory cost and the third inventory cost.
[0011] To achieve the above object, a second aspect of the embodiment of the present application provides a material demand prediction device, which comprises: an acquisition module, configured to acquire a historical demand quantity of a material in a historical period, a historical material attribute covariate and a target material attribute covariate in a plurality of continuous target periods, and a reference demand quantity; The first prediction module is configured to predict a demand conditional probability distribution of the material in the first target period based on the historical demand quantity, the historical material attribute covariates, and the target material attribute covariates of the first target period by using a preset demand prediction model, and to obtain an initial demand quantity of the material in the first target period and a demand probability of the initial demand quantity by randomly sampling the demand conditional probability distribution. The second prediction module is configured to, starting from the second target period, for each target period, predict an initial demand quantity and a demand probability of the current target period by using the preset demand prediction model based on the historical demand quantity, the historical material attribute covariates, the target material attribute covariates of the first target period to the current target period, and the initial demand quantity of each target period from the first target period to the previous target period, until the initial demand quantity and the demand probability of each target period are obtained. The training module is configured to adjust model parameters of the preset demand prediction model according to the initial demand quantity, the demand probability, and the reference demand quantity of each target period, to obtain a target prediction model. The target prediction model is configured to predict a target demand quantity of a target material in a future period based on a reference historical demand quantity and a reference historical material attribute covariate of the target material in a reference historical period and a reference material attribute covariate of the target material in the future period.
[0012] To achieve the above object, a third aspect of embodiments of the present application provides an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the method of the first aspect when executing the computer program.
[0013] To achieve the above object, a fourth aspect of embodiments of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method of the first aspect.
[0014] The material demand prediction method, the material demand prediction device, the electronic equipment and the computer readable storage medium provided by the embodiments of the present application can automatically predict the material demand by obtaining the historical demand quantity of the material in the historical period, the historical material attribute covariate and the target material attribute covariate in the plurality of continuous target periods and the reference demand quantity, based on these material data information. In order to solve the problem that the demand prediction standards are inconsistent for artificial experience, the preset demand prediction model is used for automatic demand prediction, so as to reduce the difficulty of material demand prediction. By using the preset demand prediction model, the demand condition probability distribution of the material in the first target period is predicted based on the historical demand quantity, the historical material attribute covariate and the target material attribute covariate of the first target period, so that the complex time sequence mode hidden in the material data information can be captured by the probability distribution prediction, thereby simulating the change process of the demand plan with the maintenance plan. The demand quantity will be affected by various random factors in the maintenance plan. In order to simulate these random factors and make the model better applicable to the demand prediction of non-planned project management, the demand condition probability distribution is randomly sampled to obtain the initial demand quantity of the material in the first target period and the demand probability of the initial demand quantity. The demand quantity of each time constitutes a time sequence, and the initial demand quantity of the current target period in the time sequence will be affected by the initial demand quantity and the target material attribute covariate of the last target period. In order to determine the initial demand quantity of each target period, the second target period is taken as the starting point, the preset demand prediction model is used to predict the initial demand quantity and the demand probability of the current target period based on the historical demand quantity, the historical material attribute covariate, the target material attribute covariate of each period from the first target period to the current target period, and the initial demand quantity of each period from the first target period to the last target period, until the initial demand quantity and the demand probability of each target period are obtained, so as to capture the complexity and variability of the time sequence. The model parameters of the preset demand prediction model are adjusted according to the initial demand quantity, the demand probability and the reference demand quantity of each target period, so as to optimize the demand prediction model and obtain a target prediction model, thereby reducing the difficulty of material demand prediction based on the target prediction model. BRIEF DESCRIPTION OF DRAWINGS
[0015] Figure 1 is a flowchart of the material demand prediction method provided by the embodiments of the present application; Figure 2 is a flowchart of step S120 in Figure 1 Figure 3 is a flowchart of step S210 in Figure 2 Figure 4 is a flowchart of step S140 in Figure 1 Figure 5 is a flowchart of step S140 in Figure 4 the flowchart of step S440 in FIG. 4; Figure 6 is another flowchart of the material demand prediction method provided by the embodiments of the present application; Figure 7 is Figure 6 the flowchart of step S650 in FIG. 6; Figure 8 is a structural schematic diagram of the material demand prediction device provided by the embodiments of the present application; Figure 9 is a hardware structural schematic diagram of the electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION
[0016] In order to make the objects, technical solutions and advantages of the present application clearer, the present application is further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.
[0017] It should be noted that although the functional modules are divided in the device schematic diagram, and the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a manner different from the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification and claims and the above drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.
[0018] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.
[0019] From the perspective of the demand side, the types of project management include planned project management and unplanned project management. Planned project management includes maintenance plans such as overhauls, which are relatively fixed. For example, an overhaul plan is usually published 13 months in advance, and once published, a demand plan is started and triggers procurement activities. The work orders of unplanned project management often fluctuate, resulting in inaccuracy and variability of demand planning. Without special standards, demand prediction refers to the spontaneous nature of non-project management demand prediction.
[0020] In unplanned project management, a demand plan is made in advance based on maintenance plan by manual experience. However, the maintenance plan of unplanned project management is emergent, and the maintenance plan changes frequently. After the demand plan is made, it is difficult to feed back the change of the maintenance plan to the maintenance field, so that the demand plan cannot be adjusted according to the maintenance plan. Moreover, the standard based on manual experience is different for different people, so that the difficulty of making the demand plan is further increased. Since the demand plan is essentially to predict the material demand of the maintenance plan in advance, how to reduce the difficulty of material demand prediction has become a problem to be solved.
[0021] Based on this, the embodiment of the application provides a material demand prediction method, a material demand prediction device, an electronic device and a computer readable storage medium, which aims to reduce the difficulty of material demand prediction.
[0022] The material demand prediction method, the material demand prediction device, the electronic device and the computer readable storage medium provided by the embodiment of the application are specifically explained by the following embodiments. First, the material demand prediction method in the embodiment of the application is described.
[0023] The material demand prediction method provided by the embodiment of the application relates to the technical field of inventory management. The material demand prediction method provided by the embodiment of the application can be applied in a terminal, can be applied in a server end, and can also be software running in a terminal or a server end. In some embodiments, the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, etc.; the server end can be configured as an independent physical server, can be configured as a server cluster or a distributed system composed of multiple physical servers, can also be configured as a cloud server providing basic cloud computing services such as cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and big data and artificial intelligence platform; and the software can be an application for realizing the material demand prediction method, but is not limited to the above forms.
[0024] The application is operable in a multitude of general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application can be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, and the like, that perform particular tasks or implement particular abstract data types. The application can also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules can be located in local and remote computer storage media including memory storage devices.
[0025] Figure 1 is an optional flowchart of a material demand prediction method provided by an embodiment of the application, Figure 1 The method in the method can include but is not limited to including steps S110 to S140.
[0026] Step S110, obtaining historical demand quantity of a material in a historical period, historical material attribute covariates, and target material attribute covariates in a plurality of continuous target periods and reference demand quantity; Step S120, predicting a demand conditional probability distribution of the material in the first target period based on the historical demand quantity, the historical material attribute covariates, and the target material attribute covariates in the first target period by a preset demand prediction model, and performing random sampling on the demand conditional probability distribution to obtain an initial demand quantity of the material in the first target period and a demand probability of the initial demand quantity; Step S130, taking the second target period as a starting point, for each target period, predicting an initial demand quantity and a demand probability of the current target period based on the historical demand quantity, the historical material attribute covariates, the target material attribute covariates from the first target period to the current target period, and the initial demand quantity of each target period from the first target period to the previous target period by the preset demand prediction model, until the initial demand quantity and the demand probability of each target period are obtained; Step S140, adjusting model parameters of the preset demand prediction model according to the initial demand quantity, the demand probability, and the reference demand quantity of each target period to obtain a target prediction model; The target prediction model is used to predict a target demand quantity of a target material in a future period based on a reference historical demand quantity of the target material in a reference historical period, reference historical material attribute covariates, and reference material attribute covariates in the future period.
[0027] In step S110 of some embodiments, the material refers to various raw materials, semi-finished products, finished products and the like used in the production process. Nuclear power plants are an important part of the power grid, and their stable operation is of great significance to the safety of power plants. During the operation of the nuclear power plant, the material can be a device spare part, which can be used to replace the aging and worn-out device parts to ensure the stable operation of the nuclear power plant. The historical period is a period before the target period, and the target period is a period for which the material demand prediction is to be performed. The historical demand quantity is the demand quantity for the material in the historical period, the reference demand quantity is the true demand quantity for the material in the target period, the historical material attribute covariate is the material attribute covariate for the material in the historical period, and the target material attribute covariate is the material attribute covariate for the material in the target period. The material attribute covariate is used to describe the attribute characteristics of the material, including static covariates and dynamic covariates. The static covariate is metadata used to represent the entity characteristics of the material, including material demand planning type, batch type, rescheduling point, maximum inventory level, fixed batch, consumable label, importance rating, average receiving quantity, and average receiving interval. The dynamic covariate is a dynamic characteristic that changes over time, such as the purchase quantity, warehouse data, and inventory data for each material in the historical period or the target period.
[0028] If the number of device spare parts is N, N is a positive integer greater than or equal to 1, in order to predict the demand quantity of N different types of device spare parts of the nuclear power plant in the target period, the spare part data of the nuclear power operation system in the historical period and the target period can be collected to obtain a data set , wherein is the spare part data of the i-th device spare part. The data set can be divided into a training set, a validation set, and a test set for model training, hyperparameter adjustment, and performance evaluation. The spare part data includes the i-th device spare part in 1 to The historical demand quantity, the historical material attribute covariate, and the target material attribute covariate, the reference demand quantity in to multiple consecutive target periods. The historical demand quantity, the material attribute covariate of multiple periods form a time series, and the historical demand quantity of multiple periods is represented as , which is a univariate demand quantity time series, represents the historical demand quantity of the i-th device spare part in the historical period j. The material attribute covariate includes m material attribute characteristics of the device spare part, which includes m columns of covariates from period 1 to period , and the material attribute covariate from period 1 to period . It should be noted that for the sudden maintenance operation of the nuclear power plant, in order to realize the unplanned demand prediction of the material, the historical demand quantity is the demand quantity of the unplanned demand type in the historical period.
[0029] Considering the uncertainty of unplanned demand, historical demand will be used. Historical material attribute covariates Covariates of target material properties for the first target time period As input to a pre-defined demand forecasting model, the conditional probability distribution of material demand in the first target time period is predicted to simulate the randomness of unplanned demand based on this distribution. The conditional probability distribution is the probability distribution of material demand in the target time period given historical demand, historical material attribute covariates, and target material attribute covariates. It includes all possible values of material demand in the target time period and the probability of each possible value. To simulate unplanned demand scenarios such as sudden maintenance operations or equipment failures at nuclear power plants and to quantify demand uncertainty, the conditional probability distribution is randomly sampled to obtain at least one initial demand for the material in the first target time period and the probability of that initial demand. The initial demand is the material demand in the target time period, and the probability is the probability of the initial demand value.
[0030] To improve the convergence speed and stability of the pre-defined demand prediction model, the input data needs to be normalized, converting it into a standard normal distribution with a mean of 0 and a standard deviation of 1. This eliminates the influence of unit dimensions and improves the model's learning efficiency. The normalization formula is defined as: , Where Z is the normalized parameter; X is the input parameter, which can be the demand or material attribute covariate; The mean parameter is determined based on the type of the input parameter. If the input parameter is the demand quantity, the mean parameter is the mean of the demand quantity. If the input parameter is a material attribute covariate, the mean parameter is the mean of the material attribute covariate. The variance parameter is determined based on the type of the input parameter. If the input parameter is the demand quantity, the variance parameter is the variance of the demand quantity. If the input parameter is a material attribute covariate, the variance parameter is the variance of the material attribute covariate.
[0031] The preset demand forecasting model adopts the Transformer model, including an encoder, a decoder, and a negative binomial distribution head, which is located at the top of the decoder. The length of the encoder input sequence can be set to 24, the length of the decoder input sequence can be set to 24, the learning rate can be set to 0.001, and the number of hidden layer neurons can be set to 512. Based on the encoder-decoder architecture, the Transformer model encodes and decodes the time series of demand and the material attribute features associated with that time series, generating a demand conditional probability distribution. The calculation process of the demand conditional probability distribution output by the preset demand forecasting model is described in detail below.
[0032] Referring to Figure 2 In some embodiments, step S120 can include, but is not limited to, steps S210 to S230: In step S210, the historical demand quantity, the historical material attribute covariate and the target material attribute covariate of the first target period are subjected to multi-head self-attention transformation to obtain demand attention features. In step S220, the demand attention features are subjected to feature decoding to obtain demand decoding features. In step S230, the demand decoding features are subjected to negative binomial distribution prediction to obtain a demand conditional probability distribution.
[0033] In step S210 of some embodiments, the encoder is provided with at least one encoding block, each encoding block is provided with a multi-head self-attention mechanism, and the historical demand quantity of the historical period, the historical material attribute covariate and the target material attribute covariate of the first target period are subjected to multi-head self-attention transformation based on the multi-head self-attention mechanism to capture important features that play a key role in unplanned demand prediction, thereby obtaining demand attention features.
[0034] In step S220 of some embodiments, the decoder is provided with at least one decoding block and an output layer, each decoding block is provided with a multi-head self-attention mechanism, a feedforward neural network and an encoder-decoder attention mechanism, and the output layer includes a linear layer and a softmax layer. The demand attention features are subjected to feature decoding by the decoder to obtain demand decoding features.
[0035] In step S230 of some embodiments, after the demand plan is formulated, changes in the maintenance plan are difficult to feed back to the maintenance field, resulting in the demand plan being unable to be adjusted according to the maintenance plan, and further resulting in the procurement plan being unable to be adjusted according to the actual demand, and finally forming the phenomenon of over-procurement or delayed spare parts supply. The time pattern is complex and needs to be interpretable, and it is still challenging to predict future demand trends and uncertainties through a probability time series. In the related art, the material demand quantity of the future period is predicted by fitting a probability distribution, but it is limited by the time distribution change and the model capability. These methods usually assume static distribution or simple patterns, resulting in reduced prediction accuracy and error accumulation. In order to reduce the difficulty of unplanned demand prediction and improve the accuracy of demand prediction, the embodiments of the present application determine the probability distribution based on the model prediction mode, and use the probability distribution to characterize the changes in the maintenance plan before the demand plan is formulated, thereby effectively predicting the future demand with complex prior knowledge and reasonable assumptions about the data distribution.
[0036] The negative binomial distribution head is based on the demand decoding feature to predict the negative binomial distribution, converts the traditional deterministic prediction into a probability distribution prediction, and obtains the demand conditional probability distribution. The demand conditional probability distribution is a discrete probability distribution with a mean of and a dispersion parameter of . The mean can be obtained by weighting each possible value of the demand in the discrete probability distribution and the probability of the corresponding possible value. For example, the possible values of the demand are x1, x2 and x3, and the probabilities of each possible value are y1, y2 and y3, respectively. Then is the multiplication operation. The variance can be obtained according to the mean and the dispersion parameter, and the variance is represented as: , where Var is the variance, is the mean, and is the dispersion parameter.
[0037] The predicted demand for material i satisfies the demand conditional probability distribution, i.e. , where NB represents the negative binomial distribution. This design makes the model not directly output the specific value of the demand, but learns the distribution characteristics of the data.
[0038] The demand conditional probability distribution can be obtained by learning the demand uncertainty and the pattern distribution changing over time through the Transformer framework in steps S210 to S230, so as to simulate the demand uncertainty of the unplanned demand based on the demand conditional probability distribution, make the predicted demand more suitable for the non-planned project management scene, and thus improve the accuracy of demand prediction.
[0039] Please refer to Figure 3 In some embodiments, step S210 can include but is not limited to steps S310 to S330: Step S310: vectorizing the historical demand, the historical material attribute covariate and the target material attribute covariate of the first target period to obtain a demand embedding vector; Step S320: determining a query vector, a key vector and a value vector according to the demand embedding vector; Step S330: performing multi-head attention calculation on the query vector, the key vector and the value vector to obtain a demand attention feature.
[0040] In step S310 of some embodiments, in order to preserve the overall context information of each period and make full use of the correlation between different features of the same period, for each historical period, the historical demand quantity and the historical material attribute covariates of the same historical period are spliced. The spliced data sequence is spliced with the target material attribute covariates of the first target period again, and the data sequence spliced again is vectorized to obtain a demand embedding vector.
[0041] In step S320 of some embodiments, a position encoding is added to the demand embedding vector to obtain an initial input representation. The initial input representation is linearly transformed by a learnable weight matrix to obtain a query vector, a key vector and a value vector, wherein the query vector is a query representation of the current input, the key vector is used to calculate attention features, and the value vector is used to provide actual feature information. The query vector, the key vector and the value vector are respectively represented as: , , , wherein, Q is the query vector; K is the key vector; V is the value vector; X is the initial input representation; , and are learnable weight matrices.
[0042] In step S330 of some embodiments, the multi-head attention mechanism includes a plurality of attention heads, each of which is provided with a learnable weight parameter for the query vector, the key vector and the value vector, and is used to learn different subspace features. For each attention head, the query vector is linearly transformed according to the weight parameter set by the attention head for the query vector to obtain a query feature, the key vector is linearly transformed according to the weight parameter set by the attention head for the key vector to obtain a key feature, and the value vector is linearly transformed according to the weight parameter set by the attention head for the value vector to obtain a value feature. The query feature, the key feature and the value feature are respectively defined as: , , , wherein h represents the hth attention head; Qh is the query feature of the hth attention head; Kh is the key feature of the hth attention head; Vh is the value feature of the hth attention head; Wq is the weight parameter of the query vector Q; Wk is the weight parameter of the key vector K; Wv is the weight parameter of the value vector V.
[0043] Attention is calculated based on the query features, corresponding key features, and corresponding value features of each attention head, resulting in sub-attention features for each attention head. These sub-attention features are then concatenated to obtain the demand attention features. This process, employing an attention mechanism and scaled dot product operations, aims to improve the accuracy of demand prediction. The formula for attention calculation is as follows: , in, The sub-attention feature of the h-th attention head; Attention represents attention computation; T represents the transpose operation; The feature dimension of the key feature.
[0044] The model's deep structure can capture complex temporal patterns, and its multi-head attention mechanism allows different attention heads to focus on various temporal features such as periodic changes, short-term fluctuations, long-term trends, and seasonal variations. Furthermore, the parallel training mechanism of the encoder-decoder and the encoding of supplementary data effectively improve training efficiency.
[0045] Through the above steps S310 to S330, demand attention features containing rich semantic information can be captured, so as to predict the demand for materials for unplanned needs based on the demand attention features.
[0046] In step S130 of some embodiments, this application embodiment fits the probability density function of the demand for the target time period using a preset demand prediction model. Starting from the second target time period, for each target time period, referring to steps S210 to S230, the historical demand of material i in the historical time period is calculated. Historical material attribute covariates From the first target period Target material attribute covariates for each target time period up to the current target time period t From the first target period Initial demand for each target time period up to the previous target time period t-1 As input to the preset demand forecasting model, the conditional probability distribution of demand for material i in the current target time period t is obtained. This conditional probability distribution is then randomly sampled to obtain the initial demand quantity and demand probability of material i in the current target time period t. Step S130 is repeated until the initial demand quantity and demand probability for each target time period are obtained.
[0047] The conditional probability distribution of demand for material i in the target time period t is expressed as: , in, This represents the conditional probability distribution of demand. For pre-defined demand forecasting models; The model parameters are used to preset the demand forecasting model.
[0048] Please see Figure 4 In some embodiments, step S140 may also include, but is not limited to, steps S410 to S440: Step S410: Calculate the joint probability based on the demand probability for each target time period; Step S420: Filter the initial demand for each target time period based on the joint probability to obtain the predicted demand for each target time period. Step S430: Determine the target loss value based on the reference demand and the corresponding predicted demand for each target time period; Step S440: Adjust the model parameters of the preset demand prediction model according to the target loss value to obtain the target prediction model.
[0049] In step S410 of some embodiments, the demand probability of the initial demand for materials for each target time period is multiplied to obtain the joint probability. The joint probability is expressed as: , in, Let i be the joint probability for material i; Let be the conditional probability distribution of demand for material i for the target time period t; The multiplication symbol is shown.
[0050] In step S420 of some embodiments, the initial demand of material i in each target time period can have multiple possible values. Therefore, the initial demand in each target time period can constitute different demand time series, and the joint probability will also have multiple possible values. In order to obtain from to The optimal demand time series is formed by the initial demand for each target period. The initial demand for each target period with the highest joint probability is selected as the predicted demand for each target period.
[0051] In step S430 of some embodiments, a sub-loss is calculated based on the loss function between the reference demand for each material in each target time period and the predicted demand for the corresponding target time period. The sub-losses of each material in each target time period are then summed to obtain the target loss value. The loss function can be a mean squared error loss function, a negative log-likelihood function, etc. The negative log-likelihood function is expressed as: , in, The output value of the negative log-likelihood function; Here are the model parameters; n is the quantity of materials. represents the reference demand amount of the i-th material in the j-th target period; represents the predicted demand amount of the i-th material in the j-th target period.
[0052] In step S440 of some embodiments, the target loss value is minimized, the model parameters of the preset demand prediction model are updated, and a target prediction model is obtained.
[0053] It should be noted that standard PyTorch loops can be used for training, and the Accelerate library can be used to automatically place models, optimizers, and data loaders on appropriate devices.
[0054] Through the above steps S410 to S440, a target prediction model with better probability distribution prediction performance can be obtained, so as to fit the most accurate time-varying demand condition probability distribution based on the target prediction model, thereby improving the accuracy of non-planned demand prediction.
[0055] The embodiments of the present application iteratively train the probability time series Transformer network model according to the loss function based on the training set, and determine the best weight and bias parameters of the model using the gradient descent algorithm. The validation set is input into the trained probability time series Transformer network, and the best hyperparameters of the model are optimized according to the error of the validation set, and the prediction model is retrained based on the best hyperparameters.
[0056] Please refer to Figure 5 In some embodiments, step S440 can include but is not limited to steps S510 to S530: Step S510, calculating the gradient of the target loss value with respect to the model parameters; Step S520, determining the update step of the model parameters; Step S530, updating the model parameters according to the update step and the gradient to obtain the target prediction model.
[0057] In step S510 of some embodiments, the derivative of the target loss value with respect to the model parameters is calculated to obtain the gradient. The gradient represents the rate of change of the loss function with respect to the model parameters.
[0058] In step S520 of some embodiments, the update step of the model parameters is set, and the update step, i.e., the learning rate, is used to control the step size of each update. The update step is usually a small positive number.
[0059] In step S530 of some embodiments, the model parameters are updated according to the update step and the gradient until the target loss value reaches the minimum value, and a target prediction model is obtained. The model is trained by a data-driven method to realize dynamic prediction of the demand for spare parts of the nuclear power plant equipment, so as to prepare goods in advance, improve the reliability of the equipment, and ensure the continuous safe and efficient operation of the nuclear power station. The formula for updating the model parameters is defined as: , wherein, is the model parameter of the tthiteration round; is the update step; is the gradient.
[0060] The steps S510 to S530 gradually adjust the model parameters along the gradient direction of the function by iteration, and gradually approach the optimal solution, thereby improving the convergence speed and stability of the model.
[0061] To ensure the stable operation of the nuclear power station, the inventory of the equipment spare parts needs to be in a safe state. When the inventory quantity is insufficient, the demand for equipment spare parts and the timely elimination of defects of the nuclear power station cannot be guaranteed, and when the inventory quantity is too much, too much storage space will be occupied, so the inventory needs to be optimized. The demand uncertainty is related to the inventory optimization target in the embodiments of the present application to meet the service level target.
[0062] Please refer to Figure 6 In some embodiments, after step S140, the material demand prediction method can further include but is not limited to steps S610 to S660: Step S610, initializing the inventory cycle, the safety inventory level and the order level; Step S620, determining a future period according to the inventory cycle, obtaining the reference historical demand quantity of the target material, the reference historical material attribute covariate and the reference material attribute covariate of the target material in the reference historical period, and the reference material attribute covariate in the future period; Step S630, predicting the target demand quantity of the target material in the future period based on the reference historical demand quantity, the reference historical material attribute covariate and the reference material attribute covariate by the target prediction model; Step S640, determining the inventory level of the future period according to the safety inventory level, the order level and the preset service level constraint condition; Step S650, determining the target inventory cost according to the target demand quantity, the inventory level and the safety inventory level; Step S660, adjusting the inventory cycle, the safety inventory level and the order level according to the target inventory cost to obtain an inventory strategy.
[0063] In step S610 of some embodiments, the inventory strategy is composed of an inventory cycle, a safety stock level and an order level, the inventory cycle is a time interval between two adjacent inventory replenishments, such as one month, the safety stock level is an inventory quantity at which the inventory of the material is in a safe state, and the order level is an inventory quantity that the inventory of the material needs to reach.
[0064] In step S620 of some embodiments, a preset time length is obtained, the preset time length is a time length that starts counting from the current period as a starting point, and the preset time length is divided into a plurality of future periods according to the inventory cycle. If the preset time length is , and the inventory cycle is R, the number of periods of the future periods is represented as: , wherein, is the number of periods.
[0065] If the current period is , the plurality of future periods can be represented as .
[0066] The reference historical demand quantity, the reference historical material attribute covariate of the target material in the reference historical period, and the reference material attribute covariate in the future period are obtained, the target material is a material to be demand predicted, and the target material can be the same as or different from the material type in the model training phase. In order to improve the accuracy of the material demand prediction, the target material is generally selected to be the same as the material type in the training phase. The reference historical period is a period before the current period, the reference historical demand quantity and the reference historical material attribute covariate are the demand quantity and the material attribute covariate of the target material in the reference historical period, respectively, and the reference material attribute covariate is the material attribute covariate of the target material in the future period.
[0067] In step S630 of some embodiments, referring to steps S120-S130, a demand conditional probability distribution of the target material in the first future time period is predicted based on the reference historical demand quantity, the reference historical material attribute covariates, and the reference material attribute covariates of the first future time period by the target prediction model, and a target demand quantity of the target material in the first future time period and a demand probability of the target demand quantity are obtained by random sampling of the demand conditional probability distribution. Starting from the second future time period, a demand conditional probability distribution of the current future time period is predicted based on the reference historical demand quantity, the reference historical material attribute covariates, the reference material attribute covariates of each time period from the first future time period to the current future time period, the target demand quantity of each time period from the first future time period to the last future time period before the current future time period, and the target prediction model, and a target demand quantity of the current future time period and a demand probability are obtained by random sampling of the demand conditional probability distribution of the current future time period. The above steps are repeated until the target demand quantity of each future time period and the demand probability are obtained. It should be noted that the target demand quantity of each future time period constitutes a demand time series, and multiple demand time series can be obtained by random sampling.
[0068] In step S640 of some embodiments, the service level constraint condition is that the inventory level of the future time period is greater than or equal to the safety stock level. The application embodiments do not consider the backlog of excess demand, and the unmet excess demand in the current time period is not counted in the next time period. The unmet demand will be lost but will generate costs. The starting inventory of each future time period is set to 0. For each future time period, it is determined whether the starting inventory meets the service level constraint condition. If the condition is met, the starting inventory is used as the inventory level of the future time period. If the constraint condition is not met, the starting inventory is supplemented to the order level to obtain the inventory level of the future time period.
[0069] In step S650 of some embodiments, in order to measure the cost generated by the change of the inventory state, a target inventory cost is calculated according to the target demand quantity and the inventory level of each future time period, the safety stock level, so as to optimize the inventory strategy based on the target inventory cost.
[0070] In step S660 of some embodiments, the target inventory cost is minimized, and the inventory cycle, the safety stock level, and the order level are adjusted to obtain the inventory strategy.
[0071] Through the above steps S610-S660, the optimal inventory strategy can be obtained to reduce the waste of storage resources.
[0072] Please refer to Figure 7 In some embodiments, step S650 can include but is not limited to steps S710-S740: Step S710, determining a first inventory cost according to a preset unit order procurement cost, a target demand, an inventory level and a safety inventory level; Step S720, determining a second inventory cost according to a preset unit inventory holding cost, the target demand and the inventory level; Step S730, determining a third inventory cost according to a preset unit delay penalty cost, the target demand and the inventory level; Step S740, determining a target inventory cost according to the first inventory cost, the second inventory cost and the third inventory cost.
[0073] In step S710 of some embodiments, the unit order procurement cost is the resource consumed by procuring a unit of material, and the inventory level and the target demand are both integers greater than 0. For each future period, subtract the target demand and the safety inventory level from the inventory level, take the maximum of 0 and the difference as the procurement quantity, multiply the unit order procurement cost by the procurement quantity, and obtain the first inventory cost of the future period.
[0074] In step S720 of some embodiments, the unit inventory holding cost is the resource consumed by storing a unit of material in the warehouse. For each future period, subtract the target demand from the inventory level, take the maximum of 0 and the difference as the holding quantity, multiply the unit inventory holding cost by the holding quantity, and obtain the second inventory cost of the future period.
[0075] In step S730 of some embodiments, the unit delay penalty cost is the penalty cost generated when the inventory cannot meet the demand. For each future period, subtract the inventory level from the target demand, take the maximum of 0 and the difference as the shortage quantity, multiply the unit delay penalty cost by the shortage quantity, and obtain the third inventory cost of the future period.
[0076] In step S740 of some embodiments, sum the first inventory cost, the second inventory cost and the third inventory cost of each future period to determine the target inventory cost.
[0077] The target inventory cost is expressed as: , Where TC is the target inventory cost; r represents the rth future period; is the number of future periods; R is the inventory cycle; s is the safety inventory level; S is the order level; c is the unit order procurement cost; h is the unit inventory holding cost; b is the unit delay penalty cost; is the inventory level of the rth future period; is the target demand of the rth future period; + represents taking the non-negative value, and is expressed as , x is an input parameter.
[0078] It should be noted that the embodiment of the present application sets a stock-out tolerance to determine a reasonable inventory level. The stock-out tolerance is a constant value, which is used to reflect the tolerance for the inventory level failing to meet the target demand. That is, the probability that the difference between the inventory level and the target demand is greater than or equal to 0 is greater than or equal to the stock-out tolerance, i.e. , wherein, is the probability of the rth future period; is the stock-out tolerance.
[0079] The inventory optimization model can be converted into a linear model with constraints by constraint transformation, and a solver is used to solve the target inventory cost. The linear model with constraints includes an objective function and constraint conditions, and the objective function is expressed as: , The constraint conditions are expressed as: , , , , , , , , , , wherein, TC is the target inventory cost; K is a fixed ordering cost; c is a unit variable cost; h is a unit holding cost; p is a unit stock-out cost; is a binary variable, which indicates whether replenishment is made in period r, and takes the value of 1 if replenishment is made, otherwise 0; is the replenishment quantity in period r; is the inventory level at the beginning of period r; is the inventory level after replenishment; is the value of the target demand in period r; is the demand probability of the target demand; M is a larger constant value; s is a safety stock level; S is an order level; ED is an expected demand, which is the weighted sum of the target demand and the demand probability in period r; represents a positive integer space.
[0080] Through the steps S710 to S740, the target inventory cost can be obtained, so as to optimize the inventory strategy based on the target inventory cost, establish a reasonable inventory level, and cope with the uncertainty of demand and supply, thereby ensuring the stable operation of the nuclear power plant.
[0081] Referring to Figure 8 The embodiment of the present application also provides a material demand prediction device, which can implement the above-mentioned material demand prediction method. The material demand prediction device comprises: The acquisition module 810 is configured to acquire the historical demand quantity of the material in the historical period, the historical material attribute covariate, and the target material attribute covariate and the reference demand quantity in the plurality of continuous target periods. The first prediction module 820 is configured to predict, by using a preset demand prediction model, a demand conditional probability distribution of the material in the first target period based on the historical demand quantity, the historical material attribute covariate, and the target material attribute covariate of the first target period, and to obtain an initial demand quantity of the material in the first target period and a demand probability of the initial demand quantity by randomly sampling the demand conditional probability distribution. The second prediction module 830 is configured to, starting from the second target period, for each target period, predict, by using the preset demand prediction model, an initial demand quantity and a demand probability of the current target period based on the historical demand quantity, the historical material attribute covariate, the target material attribute covariate from the first target period to the current target period, and the initial demand quantity of each target period from the first target period to the previous target period, until the initial demand quantity and the demand probability of each target period are obtained. The training module 840 is configured to adjust model parameters of the preset demand prediction model according to the initial demand quantity, the demand probability, and the reference demand quantity of each target period, to obtain a target prediction model. The target prediction model is configured to predict a target demand quantity of a target material in a future period based on a reference historical demand quantity and a reference historical material attribute covariate of the target material in a reference historical period and a reference material attribute covariate of the target material in the future period.
[0082] The specific implementation of the material demand prediction device is basically the same as that of the above-mentioned material demand prediction method, and will not be described here again.
[0083] The embodiment of the present application also provides an electronic device, which comprises a memory and a processor. The memory stores a computer program, and the processor implements the above-mentioned material demand prediction method when executing the computer program. The electronic device can be any intelligent terminal, such as a tablet computer or a vehicle-mounted computer.
[0084] Referring to Figure 9 , Figure 9The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes: The processor 910 can be implemented in a manner of a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, and is configured to execute a related program to implement the technical solutions provided by the embodiments of the present application. The memory 920 can be implemented in a form of a ROM (ReadOnly Memory), a static storage device, a dynamic storage device, or a RAM (Random Access Memory), and the like. The memory 920 can store an operating system and other application programs, and when the technical solutions provided by the embodiments of the present application are implemented by software or firmware, the related program codes are stored in the memory 920 and are called and executed by the processor 910 to implement the material demand prediction method of the embodiments of the present application. The input / output interface 930 is configured to implement information input and output. The communication interface 940 is configured to implement the communication interaction between the device and other devices, and can realize the communication through a wired manner (for example, a USB, a network cable, or the like) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, or the like). The bus 950 is configured to transmit information between various components (for example, the processor 910, the memory 920, the input / output interface 930, and the communication interface 940) of the device. The processor 910, the memory 920, the input / output interface 930, and the communication interface 940 are connected to each other through the bus 950 to realize the communication connection between the devices.
[0085] The embodiments of the present application further provide a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the above-mentioned material demand prediction method.
[0086] The memory is a non-transitory computer readable storage medium, and can be used to store a non-transitory software program and a non-transitory computer executable program. In addition, the memory can include a high-speed random access memory, and can further include a non-transitory memory, for example, at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory remotely arranged relative to the processor, and the remote memory can be connected to the processor through a network. Examples of the above-mentioned network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.
[0087] The embodiments described in the specification are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of technology and the appearance of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.
[0088] Those skilled in the art can understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and can include more or fewer steps than shown in the figures, or combine certain steps, or different steps.
[0089] The device embodiments described above are merely illustrative, and the units described as separate components can or can not be physically separated, i.e., can be located in one place, or can be distributed on multiple network units. Part or all of the modules can be selected according to actual needs to achieve the purpose of the embodiments of the present application.
[0090] Those skilled in the art can understand that all or some of the steps in the above disclosed method, the functional modules / units in the system and the device can be implemented as software, firmware, hardware and their appropriate combinations.
[0091] The terms "first", "second", "third", "fourth" and the like (if any) in the specification of the present application and the above-described drawings are used to distinguish similar objects, and do not necessarily have to be used to describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not have to be limited to those steps or units clearly listed, but can include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0092] It should be understood that, in the application, "at least one" refers to one or more, and "multiple" refers to two or more. "And / or" is used to describe the association relationship of the associated objects, which means that there can be three relationships, for example, "A and / or B" can represent three cases of only A, only B, and A and B existing at the same time, wherein A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects before and after it. "At least one of the following" or similar expressions means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c can represent a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, and c can be single or multiple.
[0093] In several embodiments provided in the application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only illustrative, for example, the division of the above units is only a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. The coupling or direct coupling or communication connection between the displayed or discussed each other can be through some interface, indirect coupling or communication connection between devices or units, which can be electrical, mechanical or other forms.
[0094] The units described above as separate components can or can not be physically separated, and the components shown as units can or can not be physical units, that is, they can be located in one place, or can be distributed on multiple network units. Part or all of the units can be selected according to actual needs to achieve the purpose of the embodiment scheme.
[0095] In addition, each functional unit in each embodiment of the application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.
[0096] The integrated unit, if implemented in the form of a software function unit and sold or used as an independent product, can be stored in a computer readable storage medium. Based on such understanding, the technical solutions of the present application, essentially or in other words, the part that contributes to the prior art or the whole or part of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes multiple instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the various embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program storage media.
[0097] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, and are not limited to the scope of the embodiments of the present application. Any modifications, equivalent replacements and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the embodiments of the present application.
Claims
1. A material demand forecasting method, characterized in that, The method includes: Obtain the historical demand for materials in historical time periods, historical material attribute covariates, and target material attribute covariates and reference demand in multiple consecutive target time periods; By using a pre-set demand forecasting model, based on the historical demand, the historical material attribute covariates, and the target material attribute covariates for the first target period, the demand conditional probability distribution of the material in the first target period is predicted, and the demand conditional probability distribution is randomly sampled to obtain the initial demand of the material in the first target period and the demand probability of the initial demand. Starting from the second target time period, for each target time period, the preset demand prediction model is used to predict the initial demand and demand probability of the current target time period based on the historical demand, the historical material attribute covariates, the target material attribute covariates of each target time period from the first target time period to the current target time period, and the initial demand of each target time period from the first target time period to the previous target time period, until the initial demand and demand probability of each target time period are obtained. The model parameters of the preset demand prediction model are adjusted according to the initial demand, demand probability and reference demand for each target time period to obtain the target prediction model. The target prediction model is used to predict the target demand of the target material in the future period based on the reference historical demand of the target material in the reference historical period, the reference historical material attribute covariates, and the reference material attribute covariates in the future period.
2. The method according to claim 1, characterized in that, The step of adjusting the model parameters of the preset demand prediction model based on the initial demand, demand probability, and reference demand for each target time period to obtain the target prediction model includes: Calculate the joint probability based on the demand probability for each target time period; The initial demand for each target time period is filtered based on the joint probability to obtain the predicted demand for each target time period. The target loss value is determined based on the reference demand for each target time period and the corresponding predicted demand. The model parameters of the preset demand prediction model are adjusted according to the target loss value to obtain the target prediction model.
3. The method according to claim 1, characterized in that, The step of predicting the conditional probability distribution of demand for the material in the first target period based on the historical demand, the historical material attribute covariates, and the target material attribute covariates for the first target period includes: A multi-head self-attention transformation is performed on the historical demand, the historical material attribute covariate, and the target material attribute covariate for the first target time period to obtain demand attention features; The demand attention features are decoded to obtain the demand decoding features; The negative binomial distribution prediction is performed on the demand decoding features to obtain the demand conditional probability distribution.
4. The method according to claim 3, characterized in that, The process of performing a multi-head self-attention transformation on the historical demand, the historical material attribute covariates, and the target material attribute covariates for the first target time period to obtain demand attention features includes: The historical demand, the historical material attribute covariates, and the target material attribute covariates for the first target time period are vectorized to obtain a demand embedding vector. The query vector, key vector, and value vector are determined based on the embedded vector of the requirements. Multi-head attention computation is performed on the query vector, the key vector, and the value vector to obtain the required attention features.
5. The method according to claim 2, characterized in that, The step of adjusting the model parameters of the preset demand prediction model according to the target loss value to obtain the target prediction model includes: Calculate the gradient of the target loss value with respect to the model parameters; Determine the update step size for the model parameters; The model parameters are updated based on the update step size and the gradient to obtain the target prediction model.
6. The method according to any one of claims 1 to 5, characterized in that, After adjusting the model parameters of the preset demand forecasting model based on the initial demand, demand probability and the reference demand for each target period to obtain the target forecasting model, the material demand forecasting method further includes: initializing the inventory cycle, safety stock level and order level; Based on the inventory cycle, determine the future time period and obtain the reference historical demand, reference historical material attribute covariates, and reference material attribute covariates for the target material in the reference historical time period. Using the target prediction model, based on the reference historical demand, the reference historical material attribute covariates, and the reference material attribute covariates, the target demand for the target material in the future period is predicted. Based on the safety stock level, the order level, and the preset service level constraints, determine the inventory level for future periods; The target inventory cost is determined based on the target demand, the inventory level, and the safety stock level. The inventory strategy is obtained by adjusting the inventory cycle, the safety stock level, and the order level based on the target inventory cost.
7. The method according to claim 6, characterized in that, Determining the target inventory cost based on the target demand, the inventory level, and the safety stock level includes: The first inventory cost is determined based on the preset unit order procurement cost, the target demand, the inventory level, and the safety stock level. The second inventory cost is determined based on the preset unit inventory holding cost, the target demand, and the inventory level. The third inventory cost is determined based on the preset unit delay penalty cost, the target demand, and the inventory level; The target inventory cost is determined based on the first inventory cost, the second inventory cost, and the third inventory cost.
8. A material demand forecasting device, characterized in that, The device includes: The acquisition module is used to acquire the historical demand of materials in historical time periods, historical material attribute covariates, and target material attribute covariates and reference demand in multiple consecutive target time periods. The first prediction module is used to predict the demand conditional probability distribution of the material in the first target period by using a preset demand prediction model, based on the historical demand, the historical material attribute covariates and the target material attribute covariates in the first target period, and to randomly sample the demand conditional probability distribution to obtain the initial demand of the material in the first target period and the demand probability of the initial demand. The second prediction module is used to predict the initial demand and demand probability of the current target period, starting from the second target period, for each target period, through the preset demand prediction model, based on the historical demand, the historical material attribute covariates, the target material attribute covariates of each target period from the first target period to the current period, and the initial demand of each target period from the first target period to the previous target period, until the initial demand and demand probability of each target period are obtained. The training module is used to adjust the model parameters of the preset demand prediction model based on the initial demand, demand probability and the reference demand for each target time period, so as to obtain the target prediction model. The target prediction model is used to predict the target demand of the target material in the future period based on the reference historical demand of the target material in the reference historical period, the reference historical material attribute covariates, and the reference material attribute covariates in the future period.
9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the method according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 7.