Multi-stage stochastic programming method based on deep neural network
By introducing a deep neural network with bidirectional LSTM and attention mechanism in multi-stage random planning, the problems of complex multi-stage random planning and unexpected constraint coupling are solved, efficient solution and stable results are achieved, and the solution speed is significantly improved and quality.
Patent Information
- Application Number
- CN202411423806.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-12
- Publication Date
- 2025-01-14
AI Technical Summary
The existing technology is difficult to effectively deal with complex multi-stage random planning problems, especially the solution problems caused by unanticipated constraints and complex coupling. Traditional methods have high computational complexity and high memory consumption, and it is difficult to make effective breakthroughs in deep neural networks in such problems. .
Using a multi-stage random planning method based on deep neural network, the average hidden state and 0-1 of the dynamic replenishment and distribution scheduling problems of random multi-products are calculated by introducing the Encoder module of bidirectional LSTM, the Decoder module of LSTM layer and the attention mechanism module. Decision variables, using attention scores to fuse the output of Encoder and Decoder modules, optimize the loss function to obtain the optimal prediction result.
It improves the solution efficiency and stability of multi-stage random planning problems, effectively deals with complex dynamic changes, breaks through the unexpected constraints and complex coupling problems, significantly speeds up the solution speed, and ensures the executability of the results.
Smart Images

Figure CN119313193A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of multi-stage stochastic programming. Background Art
[0002] Multi-stage stochastic programming problems are widely found in fields such as finance, energy management, production planning, and supply chain optimization. The characteristic of this type of problem is that decisions are made in multiple time stages, and the decisions in each stage are affected by random events, which makes the problem very complex and difficult to solve. Traditional methods include branch-and-bound method, dynamic programming, and Monte Carlo simulation method. Branch-and-bound method and its improved method have high computational complexity and large memory consumption in the face of multi-stage stochastic programming problems of practical scale, and the solution process depends on the quality of the initial solution and the relaxation problem, resulting in low solution efficiency. The basic idea of dynamic programming method is to decompose the multi-stage problem into a series of single-stage sub-problems and solve them recursively, but with the increase of state and decision variables, the computational complexity increases exponentially, making it difficult to solve. Monte Carlo simulation method evaluates the decision effect by simulating multiple sample paths of random variables, which has the characteristics of strong flexibility, but this method requires a lot of computing resources to obtain accurate results, and the results depend on the number and quality of samples. In general, these methods often find it difficult to effectively deal with the high-dimensional state space and complex randomness problems of practical-scale multi-stage stochastic programming problems, especially the solution difficulties caused by the complex coupling of unexpected constraints.
[0003] As a powerful machine learning tool, deep neural network has the characteristics of high reliability, high efficiency and high flexibility. It has shown great potential and broad application prospects in the optimization and solution of complex models (including integer programming, mixed integer programming, nonlinear integer programming, etc.). Deep learning methods achieve significant improvements over classical mathematical programming methods by learning heuristic branching strategies, solving initial relaxation problems, and effective pruning rules. In addition, deep learning performs well in dealing with complex combinatorial optimization problems (such as traveling salesman problems and knapsack problems), and can quickly find approximate optimal solutions through generative adversarial networks or graph neural networks. However, for complex multi-stage stochastic programming problems, especially the complex coupling problems of unexpected constraints, it is difficult for both traditional methods and current deep neural networks to make effective breakthroughs. Summary of the invention
[0004] The present invention aims to solve the problem that it is difficult to solve the multi-stage stochastic programming problem of complex models using deep neural networks, and now provides a multi-stage stochastic programming method based on deep neural networks.
[0005] A multi-stage stochastic programming method based on deep neural network, comprising:
[0006] Inputting the parameters of the random multi-product dynamic replenishment and distribution scheduling problem to be optimized into the deep neural network to obtain the optimal prediction result of the parameters of the random multi-product dynamic replenishment and distribution scheduling problem, wherein the optimal prediction result is a 0-1 decision quantity of the parameters of the random multi-product dynamic replenishment and distribution scheduling problem;
[0007] The parameters of the random multi-product dynamic replenishment and distribution scheduling problem include: supply capacity upper limit, unit storage cost and product demand;
[0008] The deep neural network includes: an Encoder module including a bidirectional LSTM, a Decoder module including an LSTM layer, and an attention mechanism module;
[0009] The Encoder module is used to calculate the average hidden state of the parameters of the random multi-product dynamic replenishment and distribution scheduling problem under each scenario;
[0010] The Decoder module is used to calculate the hidden state of the 0-1 decision variable in each scenario;
[0011] The attention mechanism module is used to integrate the average hidden state of the Encoder module and the hidden state of the Decoder module to obtain an attention score, and is also used to calculate the hidden state of the Encoder module using the attention score, and fuse the hidden state of the Encoder module and the hidden state of the Decoder module to obtain the optimal prediction result.
[0012] Furthermore, the loss function expression of the above deep neural network is:
[0013]
[0014] Among them, L() represents the binary cross entropy loss function, Y * represents the optimal value matrix of Y, Y * The elements in represent the optimal decision quantity of product type i in the scenario of t cycle s, represents the predicted value matrix of Y, for The elements in represent the predicted values of product type i under scenario s in cycle t. N and T represent the total number of SMCLDSP product types and cycles respectively.
[0015] Furthermore, the above Encoder module is used to calculate the average hidden state of the parameters of the random multi-product dynamic replenishment and distribution scheduling problem under each scenario, including:
[0016] Calculate the hidden states of the forward layer and the backward layer in the Encoder module under scenario s respectively:
[0017]
[0018] in, and are the hidden states of the forward layer and the backward layer in the Encoder module in the scenario of t cycles and s, respectively, W is the length of the attention window, and Respectively represent the operations of the forward layer and the backward layer in the Encoder module, x :,t,s represents the parameter vector of the product in the t-cycle s scenario;
[0019] Will and Merge to obtain the hidden state of the Encoder module in the t cycle s scenario
[0020] The average hidden state of the Encoder module in the t-cycle s scenario is calculated according to the following formula
[0021]
[0022] Among them, Φ t,s The path index.
[0023] Furthermore, the above decoder module is used to calculate the hidden state of the 0-1 decision variable in each scenario, including:
[0024]
[0025] in, is the hidden state in the scenario of t cycle s, y :,t,s is the 0-1 decision variable vector of the product in the scenario of t cycle s, L D () represents the LSTM layer operation of the Decoder module.
[0026] Furthermore, the above-mentioned integration of the average hidden state of the Encoder module and the hidden state of the Decoder module to obtain the attention score includes:
[0027] The average hidden state of the Encoder module and the hidden state of the Decoder module are integrated through the Attention module:
[0028]
[0029] And there is
[0030] in, W αis the trainable weight matrix of the attention layer, Γ j,s is the attention score in the j-cycle s scenario, is the hidden state in the scenario of t period s, is the average hidden state of the Encoder module in the j-cycle s scenario, is the average hidden state of the Encoder module in the scenario of t′ cycle s, and W is the length of the attention window.
[0031] Furthermore, the above-mentioned calculation of the hidden state of the Encoder module using the attention score includes:
[0032] The attention score Γ in the j-cycle s scenario j,s The weighted average hidden state C of the Encoder module is calculated as the weight t,s :
[0033]
[0034] in, is the hidden state of the Encoder module in the j cycle s scenario.
[0035] Furthermore, the training process of the above deep neural network is as follows:
[0036] Constructing a sample set according to the distribution of parameters of a random multi-product dynamic replenishment and delivery scheduling problem, wherein the sample set includes a training set and a validation set;
[0037] The strategy of extraction with replacement is adopted. Samples of one scenario are extracted from the training set each time as a set of deterministic multi-stage models. The optimal solution of the deterministic multi-stage model is obtained using the optimal solver Gurobi.
[0038] The samples in the training set are used as input, the optimal solution is used as output, the parameters of the deep neural network are trained, and the parameters are adjusted through the samples in the validation set to obtain the trained deep neural network.
[0039] Furthermore, the sample set also includes a test set, and the training set, validation set and test set account for 70%, 10% and 20% of the sample set respectively;
[0040] The training process of the deep neural network also includes:
[0041] Input the samples in the test set into the trained deep neural network to obtain the predicted value of the 0-1 decision variable corresponding to each sample and calculate the measured value of each predicted value;
[0042] The larger the value of the metric, the The closer it is to 1 or 0, the higher the prediction reliability of the deep neural network;
[0043] The smaller the value of the metric, the The closer it is to 0.5, the lower the prediction reliability of the deep neural network.
[0044] Furthermore, the measurement values of the above prediction values are:
[0045]
[0046] O i,t,s is the measured value of product type i in scenario s during period t.
[0047] After calculating the measurement value of the predicted value, all the measurement values are arranged in descending order, and the predicted value corresponding to the front measurement value is selected as the selected result according to a preset ratio, and the selected result is rounded to 0 or 1, so as to obtain the prediction result of the deep neural network.
[0048] The present invention provides an Encoder-Decoder deep neural network optimization framework for efficiently solving multi-stage stochastic programming problems. By introducing an attention mechanism, the unexpected constraints are effectively handled, the executable results are guaranteed, the solution efficiency and stability are improved, and the practical scale multi-stage stochastic programming problem is solved. At the same time, it can also effectively capture the complex dynamic changes in the multi-stage stochastic programming problem, break through the complex coupling problem of unexpected constraints, and compared with the existing solution scheme, the present invention significantly speeds up the solution speed while ensuring the solution quality. BRIEF DESCRIPTION OF THE DRAWINGS
[0049] Figure 1 The Encoder-Decoder deep neural network training flow chart for introducing the attention mechanism;
[0050] Figure 2 A schematic diagram of the multi-stage stochastic planning process with unexpected constraints and complex coupling;
[0051] Figure 3 This is the structure diagram of the Encoder-Decoder deep neural network that introduces the attention mechanism. DETAILED DESCRIPTION
[0052] The following will be combined with the accompanying drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work belong to the scope of protection of the present invention. It should be noted that the embodiments of the present invention and the features in the embodiments can be combined with each other without conflict.
[0053] Reference Figures 1 to 3 Specifically describing this embodiment, a multi-stage stochastic programming method based on a deep neural network described in this embodiment includes:
[0054] S1: Define the multi-stage stochastic programming problem
[0055] It is a mixed integer programming problem. Taking the stochastic multi-item capacitated lot-sizing and delivery scheduling problem (SMCLDSP) as an example, Indicates a product category. represents a certain cycle, s∈{1,…,S} represents a certain scenario, and N, T and S represent the total number of SMCLDSP product types, the total number of cycles and the total number of scenarios, respectively.
[0056] X is the SMCLDSP model parameter, including product price, preparation cost, storage cost and delivery cost, etc. i,t,s ∈X represents the model parameters of category i products under the scenario of t cycle s. In this implementation, the SMCLDSP model parameters adopt the supply capacity upper limit c of category i products under the scenario of t cycle s. i,t,s , unit storage cost h i,t,s , product demand i,t,s etc. as input data for deep neural networks.
[0057] Y is a 0-1 decision variable, y i,t,s ∈Y represents the decision variable of product type i in scenario s in period t.
[0058] Z is a non-0-1 decision variable.
[0059] Then the SMCLDSP model can be simplified as f(X,Y,Z).
[0060] minf(X,Y,Z) is the objective function, and the inequality g(X,Y,Z)≥0 is the SMCLDSP model constraint.
[0061] S2: Variable prediction
[0062] In order to reduce the complexity of the problem definition, the 0-1 decision variable Y in the model such as whether to place an order or deliver in each cycle is predicted, and the prediction result is added to the problem in the form of deterministic constraints.
[0063] According to the model parameter structure, a binary cross entropy loss function is designed. The specific formula is as follows:
[0064]
[0065] Where L() represents the binary cross entropy loss function; Y * represents the optimal value matrix of Y, Y * The elements in represent the optimal decision for product type i in scenario s of period t; represents the predicted value matrix of Y, for The elements in represent the predicted values of category i products under scenario s in period t.
[0066] S3: Encoder-Decoder deep neural network optimization algorithm with attention mechanism
[0067] The core difficulty of multi-stage stochastic programming problem is the complex constraint coupling caused by unexpectedness. Figure 2 The core idea of the Encoder-Decoder deep neural network optimization algorithm that introduces the attention mechanism is to generate the same encoder hidden state information for all subsequent time periods that share the same parent node, solving the problem of unexpected constraint coupling.
[0068] 1) Build an Encoder module containing a bidirectional LSTM.
[0069] The forward layer and backward layer of the Encoder module containing the bidirectional LSTM are represented as and And in the t cycle s scenario, the hidden state is generated respectively and Given the attention window length W, the hidden states of the forward layer and the backward layer in the s scenario can be expressed as follows:
[0070]
[0071] Among them, x :,t,s Represents the parameter vector for all types of products in the t-cycle s scenario.
[0072] Merge the hidden states of the forward layer and the backward layer to obtain the hidden state of the Encoder module in the t cycle s scenario
[0073]
[0074] Definition Φ t,s is the index of the same scenario realization path as that in cycle t, then the average hidden state in scenario s It is expressed as:
[0075]
[0076] 2) Build a Decoder module containing an LSTM layer.
[0077] The LSTM layer of the Decoder module is represented as L D (), then the hidden state of the Decoder module It can be expressed as the following formula:
[0078]
[0079] Among them, y :,t,s A vector of 0-1 decision variables representing all types of products in the t-cycle s scenario.
[0080] 3) Design the attention mechanism module.
[0081] First, the attention weights are calculated, then the normalized weights are calculated using the Softmax function, and finally the context vector is calculated. The specific steps are as follows:
[0082] The attention score Γ is obtained by integrating the average hidden state of the Encoder module and the hidden state of the Decoder module through the Attention module. j,s
[0083]
[0084] W α is the trainable weight matrix of the attention layer.
[0085] With attention score Γ j,s As the weight, calculate the weighted average Encoder hidden state C t,s :
[0086]
[0087] Finally, C t,s It is fused with the decoder hidden state information, and then the prediction result y for the scenario of t period s is output through the linear layer t,s Its structure is attached Figure 3 .
[0088] It should be emphasized that the inputs in the training phase are all single-scenario deterministic problems of the stochastic programming model, and the average hidden state of the Encoder is not needed. The average hidden state of the Encoder is only used in the testing phase. In addition, since the prediction results are all based on the same average hidden state of the Encoder (i.e., Formula 4), the prediction results are the same for all scenarios with the same scenario realization path to the t period, which ensures the executableness of the results, that is, the results must satisfy the unexpected constraints.
[0089] S4: Model training and validation
[0090] 1) Generate a dataset
[0091] For the multi-stage stochastic programming problem defined in S1, namely SMCLDSP, a sample set Ω is randomly generated according to the parameter setting distribution, and each sample is a multi-stage stochastic programming problem. The sample set is divided into three parts: training set, validation set and test set (accounting for 70%, 10% and 20% respectively), which are used for model training, parameter selection and effect verification respectively.
[0092] 2) Model training
[0093] In order to avoid the complex problems caused by directly solving the multi-stage random programming problem examples themselves, the training process adopts a replacement extraction strategy. Each training extracts a scenario of each example in the training set, that is, a set of deterministic multi-stage mathematical programming models is formed, and the optimal solver Gurobi is used to quickly find the optimal solution of the deterministic multi-stage model. The extracted deterministic model parameters are input for each training, and the optimal solution is used as the label.
[0094] Set the parameters of the Encoder-Decoder deep neural network optimization algorithm that introduces the attention mechanism, including the number of RNN layers in the Encoder and Decoder, the number of neurons in each layer, and the drop rate, and input the parameters of the training set into the algorithm for model training. Adjust the parameters of the training model through the validation set data, select a satisfactory parameter combination, and form the final training model.
[0095] 3) Test output
[0096] Input the test set data into the final training model and predict the predicted value of the 0-1 decision variable at each stage.
[0097]
[0098] In order to select a more confident prediction result, the weight value O is calculated by formula (9): i,t,s :
[0099]
[0100] O i,t,s The larger the value, the The closer it is to 1 or 0, the higher the prediction reliability; otherwise, The closer it is to 0.5, the lower the prediction reliability.
[0101] 4) Iterative Optimization
[0102] In the calculation to obtain all O i,t,s After that, they are sorted in descending order, and then some prediction results with high reliability are selected according to a certain proportion, and the selected Converted to 0 or 1. Compared with selecting all prediction results, the selection method of this embodiment can effectively reduce the probability of prediction error and avoid the model being unsolvable due to prediction error.
[0103] Specifically:
[0104] Set the selection ratio of 0-1 variable prediction results, and select The constraints are added to the original multi-stage stochastic programming model. The commercial solver Gurobi is used to search for the optimal solution efficiently. If the model is not feasible, the selection ratio of 0-1 variable prediction results is reduced and the above process is repeated until the optimal solution is obtained.
[0105]
[0106] Among them, α represents the index of the decision variable selected during the iteration process.
[0107] Although the present invention is described herein with reference to specific embodiments, it should be understood that these embodiments are merely examples of the principles and applications of the present invention. It should therefore be understood that many modifications may be made to the exemplary embodiments and that other arrangements may be devised without departing from the spirit and scope of the present invention as defined by the appended claims. It should be understood that the various dependent claims and features described herein may be combined in a manner different from that described in the original claims. It should also be understood that the features described in conjunction with a single embodiment may be used in other described embodiments.
Claims
1. A multi-stage stochastic programming method based on deep neural network, characterized in that: include: Inputting the parameters of the random multi-product dynamic replenishment and distribution scheduling problem to be optimized into the deep neural network to obtain the optimal prediction result of the parameters of the random multi-product dynamic replenishment and distribution scheduling problem, wherein the optimal prediction result is a 0-1 decision quantity of the parameters of the random multi-product dynamic replenishment and distribution scheduling problem; The parameters of the random multi-product dynamic replenishment and distribution scheduling problem include: supply capacity upper limit, unit storage cost and product demand; The deep neural network includes: an Encoder module including a bidirectional LSTM, a Decoder module including an LSTM layer, and an attention mechanism module; The Encoder module is used to calculate the average hidden state of the parameters of the random multi-product dynamic replenishment and distribution scheduling problem under each scenario; The Decoder module is used to calculate the hidden state of the 0-1 decision variable in each scenario; The attention mechanism module is used to integrate the average hidden state of the Encoder module and the hidden state of the Decoder module to obtain an attention score, and is also used to calculate the hidden state of the Encoder module using the attention score, and fuse the hidden state of the Encoder module and the hidden state of the Decoder module to obtain the optimal prediction result.
2. A multi-stage stochastic programming method based on a deep neural network according to claim 1, characterized in that: The loss function expression of the deep neural network is: Among them, L() represents the binary cross entropy loss function, Y * represents the optimal value matrix of Y, Y * The elements in represent the optimal decision quantity of product type i in the scenario of t cycle s, represents the predicted value matrix of Y, for The elements in represent the predicted values of product type i under scenario s in cycle t. N and T represent the total number of SMCLDSP product types and cycles respectively.
3. A multi-stage stochastic programming method based on a deep neural network according to claim 1 or 2, characterized in that: The Encoder module is used to calculate the average hidden state of the parameters of the random multi-product dynamic replenishment and distribution scheduling problem under each scenario, including: Calculate the hidden states of the forward layer and the backward layer in the Encoder module under scenario s respectively: in, and are the hidden states of the forward layer and the backward layer in the Encoder module in the scenario of t cycles and s, respectively, W is the length of the attention window, and Respectively represent the operations of the forward layer and the backward layer in the Encoder module, x :,t,s represents the parameter vector of the product in the t-cycle s scenario; Will and Merge to obtain the hidden state of the Encoder module in the t cycle s scenario The average hidden state of the Encoder module in the t-cycle s scenario is calculated according to the following formula Among them, Φ t,s The path index.
4. A multi-stage stochastic programming method based on a deep neural network according to claim 1 or 2, characterized in that: The Decoder module is used to calculate the hidden state of the 0-1 decision variable in each scenario, including: in, is the hidden state in the scenario of t cycle s, y :,t,s is the 0-1 decision variable vector of the product in the scenario of t cycle s, L D () represents the LSTM layer operation of the Decoder module.
5. A multi-stage stochastic programming method based on a deep neural network according to claim 1 or 2, characterized in that: The step of integrating the average hidden state of the Encoder module and the hidden state of the Decoder module to obtain an attention score includes: The average hidden state of the Encoder module and the hidden state of the Decoder module are integrated through the Attention module: And there is in, W α is the trainable weight matrix of the attention layer, Γ j,s is the attention score in the j-cycle s scenario, is the hidden state in the scenario of t period s, is the average hidden state of the Encoder module in the j-cycle s scenario, is the average hidden state of the Encoder module in the scenario of t′ cycle s, and W is the length of the attention window.
6. A multi-stage stochastic programming method based on a deep neural network according to claim 5, characterized in that: The method of calculating the hidden state of the Encoder module using the attention score includes: The attention score Γ in the j-cycle s scenario j,s The weighted average hidden state C of the Encoder module is calculated as the weight t,s : in, is the hidden state of the Encoder module in the j cycle s scenario.
7. The multi-stage stochastic programming method based on deep neural network according to claim 1, characterized in that: The training process of the deep neural network is as follows: Constructing a sample set according to the distribution of parameters of a random multi-product dynamic replenishment and delivery scheduling problem, wherein the sample set includes a training set and a validation set; The strategy of extraction with replacement is adopted. Samples of one scenario are extracted from the training set each time as a set of deterministic multi-stage models. The optimal solution of the deterministic multi-stage model is obtained using the optimal solver Gurobi. The samples in the training set are used as input, the optimal solution is used as output, the parameters of the deep neural network are trained, and the parameters are adjusted through the samples in the validation set to obtain the trained deep neural network.
8. The multi-stage stochastic programming method based on deep neural network according to claim 7, characterized in that: The sample set also includes a test set, and the training set, validation set and test set account for 70%, 10% and 20% of the sample set respectively; The training process of the deep neural network also includes: Input the samples in the test set into the trained deep neural network to obtain the predicted value of the 0-1 decision variable corresponding to each sample and calculate the measured value of each predicted value; The larger the value of the metric, the The closer it is to 1 or 0, the higher the prediction reliability of the deep neural network; The smaller the value of the metric, the The closer it is to 0.5, the lower the prediction reliability of the deep neural network.
9. The multi-stage stochastic programming method based on deep neural network according to claim 8, characterized in that: The measurement values of the predicted values are: O i,t,s is the measured value of product type i in scenario s during period t.
10. The multi-stage stochastic programming method based on deep neural network according to claim 9, characterized in that: After calculating the measurement value of the predicted value, all the measurement values are arranged in descending order, and the predicted value corresponding to the front measurement value is selected as the selected result according to a preset ratio, and the selected result is rounded to 0 or 1, so as to obtain the prediction result of the deep neural network.