Gas prediction method based on combination of whale optimization algorithm and bidirectional long-short term memory network
By combining whale optimization algorithm and bidirectional long and short-term memory network, the parameters of the gas prediction model are automatically optimized, and the problems of low artificial parameter adjustment efficiency and insufficient prediction accuracy in the existing technology are solved, and more efficient and accurate gas prediction is achieved.
Patent Information
- Application Number
- CN202411739081.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-29
- Publication Date
- 2025-03-04
AI Technical Summary
The existing gas prediction model relies on manual operation during parameter adjustment, making it difficult to ensure that the optimal parameter configuration is found while the data volume increases, resulting in insufficient prediction accuracy.
The gas prediction method based on the combination of whale optimization algorithm and bidirectional long and short-term memory network is adopted, and the key parameter combinations in the BiLSTM model are automatically explored and determined through the whale optimization algorithm to improve the prediction speed and accuracy.
This method can automatically optimize model parameters, significantly reduce the time and effort required for traditional manual parameter adjustment, and improve prediction accuracy and efficiency.
Smart Images

Figure CN119558480A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of coal gas prediction in steel enterprises, and more specifically, relates to a coal gas prediction method based on the combination of a whale optimization algorithm and a bidirectional long short-term memory network. Background Art
[0002] Against the backdrop of increasingly serious resource shortages, energy crises and environmental degradation, the industry is actively seeking strategies to improve energy efficiency in order to achieve the goals of energy conservation, carbon emission reduction and cost control. In the steel industry, blast furnace gas (BFG), coke oven gas (COG) and converter gas (LDG) are core secondary energy resources. Their effective recovery, efficient utilization and supply and demand balance management have become the key driving force for enterprises to achieve green transformation and improve economic benefits. The optimal management of these gas resources is not only related to the fulfillment of corporate environmental protection responsibilities, but also an important path to enhance market competitiveness and achieve sustainable development. Through technological innovation and management upgrades, enterprises can maximize the value of these by-product gases and reduce dependence on traditional energy, thereby protecting the environment while also bringing tangible economic benefits to themselves.
[0003] There is a close connection between the effective recovery of coal gas and the gas control strategy, and the accuracy of coal gas control is directly restricted by the accuracy of coal gas prediction. Specifically, improving the accuracy of coal gas prediction can make coal gas control more accurate, thereby promoting the effective recovery and utilization of coal gas. Therefore, optimizing the coal gas prediction model and improving the prediction accuracy are of vital importance to achieve efficient recovery and control of coal gas resources. At present, the existing coal gas prediction models generally rely on manual operation and repeated experiments in the parameter adjustment process. However, with the continuous growth of data volume, it is difficult to ensure that the optimal parameter configuration combination can be accurately found by adjusting parameters based on past experience alone. The limitations of this traditional method are becoming increasingly prominent, and there is an urgent need to introduce more intelligent and efficient optimization strategies to cope with complex and changeable prediction needs. Therefore, a method is needed to improve the efficiency and accuracy of coal gas prediction.
[0004] After searching, patent CN118396173A provides a carbon flux prediction method based on a whale algorithm to optimize a neural network, including obtaining observation data and future climate factor data, constructing downscaled prediction data based on the observation data and future climate factor data, and constructing a data set based on the downscaled prediction data; dividing the data set into a training set and a test set, and performing data normalization; constructing a hybrid network framework based on a convolutional neural network and a bidirectional long short-term memory network; obtaining the optimal parameters of the model based on the whale optimization algorithm; inputting the optimal parameters of the model into the hybrid network framework, and generating a carbon flux prediction model after model training; obtaining prediction results based on the carbon flux prediction model; and denormalizing the prediction results.
[0005] Patent CN110888059A discloses an algorithm for estimating the state of charge of a power battery based on an improved random forest combined with a volumetric Kalman filter. This method combines the random forest regression and volumetric Kalman filter algorithms to jointly estimate the state of charge of the power battery, and optimizes the parameters of the random forest by weighted optimization of the taboo whale search algorithm to achieve the optimization of the algorithm pruning threshold, the number of pre-test samples, and the number of decision trees. The optimization algorithm can quickly find the optimal solution and improve the efficiency of the algorithm; through a bidirectional long short-term memory artificial neural network, the remaining life of the power battery is predicted to achieve the purpose of correcting the maximum available capacity of the battery and improving the accuracy of the state of charge estimation of the power battery under full-time working conditions; through a joint estimation algorithm, the random forest and volumetric Kalman filter algorithms are combined to give full play to the advantages of the two algorithms and avoid the disadvantages of both algorithms, so that the accuracy of the power battery state of charge estimation is higher.
[0006] Patent CN116972098A discloses an intelligent vibration reduction method for a hydropower plant building based on a magnetorheological damper, comprising the following steps: (1) a vibration sensor collects the vibration response of the plant structure during the operation of the generator set; (2) a vibration response prediction model for the hydropower plant building is constructed, and the vibration response value of the vibration reduction part of the hydropower plant building is predicted in real time using the trained vibration response prediction model for the hydropower plant building; (3) the magnetorheological damping device outputs a damping force in real time to reduce the vibration response of the plant building; (4) when the vibration response prediction result of the hydropower plant building vibration response prediction model reaches a preset threshold, the fuzzy logic controller receives the vibration response prediction data and controls the magnetorheological damping device; (5) the magnetorheological damping device uses the current transmitted by the fuzzy logic controller to output a magnetorheological damping force to act on the corresponding part of the hydropower plant building structure.
[0007] The above patent functions are too narrowly targeted and only work in their respective specific fields. The application scenarios are also quite limited and difficult to expand to other categories. These characteristics do not match the actual needs of gas forecasting well and cannot effectively meet the multi-dimensional, complex and changeable application requirements of gas forecasting. Summary of the invention
[0008] 1. Problem to be solved
[0009] In view of the problem that the existing prediction models are not suitable for gas prediction, the present invention provides a gas prediction method based on the combination of whale optimization algorithm and bidirectional long short-term memory network. The method is suitable for gas prediction. Through the efficient optimization process of the whale optimization algorithm, the model can automatically explore and determine the key parameter combination in BiLSTM, thereby improving the speed and accuracy of prediction.
[0010] 2. Technical solution
[0011] In order to solve the above problems, the technical solution adopted by the present invention is as follows:
[0012] A gas prediction method based on a combination of a whale optimization algorithm and a bidirectional long short-term memory network comprises the following steps:
[0013] S1. Read real-time gas data from the online database, pre-process the data, and construct the data set required for the experiment;
[0014] S2, dividing the data set obtained in step S1 into a training set and a test set, and then modeling them, wherein the training set is used to determine the model parameters, and the test set is used to judge the model effect;
[0015] S3, build BiLSTM gas prediction model;
[0016] S4, optimizing the parameters of the model obtained in step S4;
[0017] S5. Load the model with the optimal parameter combination for training and prediction, and save the predicted value in the database.
[0018] Furthermore, the specific operation of the preprocessing in step S1 is: connecting to a database, reading the required real-time data from the database, setting upper and lower limits for data processing, and converting the data into a two-dimensional array, and finally saving the processed data to obtain a data set, which specifically includes the steps of:
[0019] S1.1. Set upper and lower limits: First, set the highest threshold value Z of gas data max and the minimum threshold Z of gas data min , compare the gas data read with the two thresholds. If the gas data read is greater than the set highest threshold Z max , adjust the value of gas data directly to Z max On the contrary, if the gas data read is less than the set minimum threshold Z min , adjust the value of gas data to Z min If the gas data happens to be at the highest threshold Z min and the minimum threshold Z min If it is between , then it means that the current gas level is within the normal range and no adjustment is needed.
[0020] S1.2. Data conversion: The data after upper and lower limit processing is reshaped through the reshape function to convert the one-dimensional array into a two-dimensional array, where each element of the original array is converted into a row in the new array to form a separate row vector.
[0021] Furthermore, step S2 divides the data set obtained in step S1 into a training set and a test set, and then models them, wherein the training set is used to determine the model parameters and the test set is used to judge the model effect; it specifically includes the steps of:
[0022] S2.1. Divide the data set: First, set the sample input amount as a variable, divide the data in turn, obtain the training set and test set data, normalize the data, and use the MinMaxScaler function to scale the data;
[0023] S2.2, Normalization processing: First, find the minimum value X in the data set min and the maximum value X max , and then use the normalization formula to calculate each data point. The normalization formula is as follows:
[0024]
[0025] Where X represents the true value at a certain moment in the time series, X min is the minimum value of the sequence, X max is the maximum value of the sequence, and X1 represents the normalized result.
[0026] S3. Constructing BiLSTM gas prediction model: The process of building LSTM model includes two parts: updating a single LSTM cell and combining all LSTM cells.
[0027] The internal information update process of a single LSTM neuron cell includes: a. updating of the forget gate; b. updating of the input gate; c. updating of the cell state and d. updating of the output gate.
[0028] a. The update formula of the forget gate is as follows:
[0029] f t =σ(W t [h t-1 , X t ]+b f )
[0030] Among them, f t represents the state of the forget gate at time t, h t-1 represents the output at time t-1, X t represents the input at time t, σ represents the sigmoid activation function, W t is the forget gate weight matrix, b f is the forget gate bias. The forget gate determines which information from the previous moment should be retained, and the output result is between 0 and 1. When its value is close to 0, it means that most of the old information will be forgotten, and when it is close to 1, it means that the old information is basically retained.
[0031] b. The update formula of the input gate is as follows:
[0032] i t =σ(W i [h t-1 ,X t ]+b i )
[0033] C t =tanh(W c [h t-1 ,X t ]+b c )
[0034] where i t represents the input gate state at time t, σ represents the sigmoid activation function, W i is the input gate weight, h t-1 represents the output at time t-1, X t represents the input at time t, b i is the input gate bias term, C t represents the cell state of the candidate memory unit, W c is the neuron state weight, b c is the neuron state bias term.
[0035] c. The update formula of cell state is as follows:
[0036]
[0037] where f t represents the state of the forget gate at time t, C t represents the cell state at time t, i t represents the input gate state at time t, C t-1 represents the cell state at time t-1, C t Represents the cell state of the candidate memory unit.
[0038] d. The update formula of the output gate is as follows:
[0039] o t =σ(W o [h t-1 , X t ]+b o )
[0040] h t =o t *tanh(C t )
[0041] Among them, t represents the output gate state at time t, σ represents the sigmoid activation function, WO is the output gate weight, h t-1 represents the output at time t-1, X t represents the input at time t, b O is the input gate bias term, h t represents the output at time t, C t represents the cell state at time t.
[0042] Finally, the combined workflow of all LSTM cells is: The combined workflow of the long short-term memory network (LSTM) follows a rigorous and well-organized mechanism. The core lies in the orderly coordinated operation of multiple LSTM cell units. Relying on the four key components of the forget gate, input gate, cell state update mechanism and output gate, each cell unit is connected in series in a predetermined order to achieve efficient information processing and integration. In the initial stage, to build an LSTM network, multiple LSTM cell units need to be connected in sequence. This connection order starts with the forget gate, followed by the input gate, followed by the change of cell state, and finally ends with the output gate. Each part is closely connected and works together. When time series data is input into the network, the corresponding LSTM cell unit immediately starts to operate independently for each time step in the sequence.
[0043] The process of building a BiLSTM model is divided into three parts: forward LSTM, backward LSTM and combined LSTM.
[0044] The forward LSTM workflow is as follows: at time t, a single forward LSTM cell receives the hidden layer output of the previous moment and the input of the current moment, and calculates the hidden layer output of the current moment through the forget gate, input gate, output gate and cell state update. The calculation formula is as follows:
[0045]
[0046] in represents the hidden layer output of the forward LSTM at time t. LSTM represents the calculation process of the short-term memory unit at this time step. X t is the input at time t, is the hidden layer output at time t-1.
[0047] The backward LSTM workflow is as follows: at time t, a single backward LSTM neuron receives the hidden layer output of the previous moment and the input of the current moment, and calculates the hidden layer output of the current moment through the forget gate, input gate, output gate and cell state update. The calculation formula is as follows:
[0048]
[0049] in represents the hidden layer output of the backward LSTM at time t. LSTM represents the calculation process of the short-term memory unit at this time step. X t is the input at time t, is the hidden layer output at time t-1.
[0050] The combined LSTM workflow is: output the forward LSTM hidden layer And the backward LSTM hidden layer output The output h1 of the BiLSTM hidden layer is obtained by splicing. The calculation formula is as follows:
[0051]
[0052] S4: Optimize the model parameters. The optimization process is as follows: use the whale optimization algorithm to tune the parameters, select the mean absolute percentage error (MAPE) as the fitness function, and update the whale position according to the whale optimization algorithm principle and the fitness function value;
[0053] The whale optimization algorithm parameter tuning step includes:
[0054] a. Initialize the parameters of the whale optimization algorithm: set the number of whale populations to N and the maximum number of iterations to T max ,The optimization parameters are (a, b, c, d, e), and the dimension of the search space is the number of optimization parameters D, where a represents the number of neurons in each layer of the bidirectional long short-term memory network (BiLSTM), b represents the number of layers of BiLSTM neurons, c represents the loss rate of BiLSTM neurons, d represents the size of BiLSTM batch processing, and e represents the input amount of BiLSTM samples.
[0055] b. Whale optimization algorithm parameter tuning: Calculate the values of A and C, and then intelligently select which search phase to enter based on the value of p and A, where p is the probability value, and A and C are coefficient vectors:
[0056] When p<0.5 and A<1, the prey encirclement phase is performed by performing a fine search closely around the potential optimal solution;
[0057] The formula is as follows:
[0058] D=|CX * (t)-X(t)|
[0059] X(t+1)=X * (t)-AD
[0060] A=2ar-a
[0061]
[0062] C=2r
[0063] Where p is a probability value randomly generated by the algorithm, D is the distance between the current whale individual and the optimal position, t is the current iteration number, T max is the maximum number of iterations, X(t) is the position of the current whale individual in the tth generation, X(t+1) is the position of the current whale individual in the (t+1) generation, and X * (t) is the current optimal position vector, A and C are coefficient vectors, A is used to adjust the step size and direction of the whale moving to the optimal position, C is mainly used to balance the exploration and development capabilities of the algorithm, a is a value that decreases linearly from 2 to 0, and r is a random real number in [0,1].
[0064] When p≥0.5, the bubble net attack hunting phase is selected. The algorithm simulates the behavior of whales to capture prey by forming bubble nets, hoping to quickly locate a better solution in the solution space;
[0065] The formula is as follows:
[0066] X(t+1)=De bl cos(2πl)+X * (t)
[0067] D=|X * (t)-X(t)|
[0068] Where X(t+1) is the position of the current whale individual in the (t+1) generation, b is a constant used to define the shape of the spiral, and X * (t) is the current optimal position vector, l is a random number in the interval (-1,1), and D is the distance between the current whale individual and the optimal position.
[0069] When p<0.5 and A>1, the algorithm chooses to perform a random search for prey, increasing the possibility of discovering new solutions by expanding the search range, thereby avoiding falling into the local optimum.
[0070] The formula is as follows:
[0071] D=|CX rand -X(t)|
[0072] X(t+1)=X rand -AD
[0073] Where X rand is the random position vector for selecting individuals from the current population, X(t) is the position of the current whale individual in the tth generation, X(t+1) is the position of the current whale individual in the (t+1)th generation, A and C are coefficient vectors, and D is the distance between the current whale individual and the optimal position.
[0074] c. Iteration The specific operation is: during the execution of the algorithm, repeat step b. When the cumulative number of iterations reaches the preset maximum number of iterations threshold T max When , the entire iteration process will automatically terminate. At this time, the algorithm has completed the entire parameter tuning process and obtained the optimal model parameter combination under given conditions.
[0075] Furthermore, in each iteration of the algorithm, the MAPE value of each whale individual is calculated using the following formula and the calculated MAPE value is used as the fitness score of each whale individual. Then in each iteration, the MAPE values of all whale individuals are compared and the global optimal solution is updated. The whale individual with the smallest MAPE value is considered to be the best solution currently found. The MAPE calculation formula is as follows:
[0076]
[0077] Where n represents the number of samples, y1 represents the actual value, and y2 represents the predicted value. y1 is the gas data divided in step S2.1, and y2 is the predicted value obtained by substituting y1 into the BiLSTM model constructed by the above optimized parameter combination. The variable value of the sample input in S2.1 is the parameter e in this step.
[0078] S5. Load the model with the optimal parameter combination for training and prediction, and save the predicted value in the database.
[0079] S5.1. Use the best parameter combination selected by the whale optimization algorithm to build a BiLSTM model. According to the best parameter combination obtained after optimization in S4, a BiLSTM model with the corresponding number of neurons, number of neuron layers, neuron loss rate, batch size and sample input amount is built.
[0080] S5.2. Apply the trained BiLSTM model to the prediction data set and obtain the final prediction results.
[0081] The present invention firstly optimizes the parameters of the bidirectional long short-term memory network (BiLSTM) model using the whale optimization algorithm (WOA), and automatically locks the optimal configuration of the model parameters by simulating the intelligent search behavior of whales in the predation process. Then the BiLSTM model optimized by WOA is applied to the actual prediction of gas data; the key parameters of the model are optimized through intelligent algorithms, which effectively avoids the blindness and inefficiency of traditional parameter adjustment methods, and greatly improves the training speed and prediction accuracy of the model.
[0082] 3. Beneficial effects
[0083] Compared with the prior art, the present invention has the following beneficial effects:
[0084] The present invention combines the intelligent search mechanism of the whale optimization algorithm with the powerful time series data processing capability of the bidirectional long short-term memory network (BiLSTM). Through the efficient optimization process of the whale optimization algorithm, the model can automatically explore and determine the key parameter combinations in BiLSTM. This process greatly reduces the time and effort required for traditional manual parameter adjustment. At the same time, the BiLSTM model, with its unique two-way processing mechanism, can capture the time series dependencies in the data more comprehensively and deeply, thereby further improving the accuracy of the prediction. BRIEF DESCRIPTION OF THE DRAWINGS
[0085] The technical solution of the present invention will be further described in detail below in conjunction with the accompanying drawings and embodiments, but it should be understood that these drawings are designed only for explanation purposes and are not intended to limit the scope of the present invention. In addition, unless otherwise specified, these drawings are intended only to conceptually illustrate the structural configurations described herein and are not necessarily drawn to scale.
[0086] Figure 1 A flow chart of a gas prediction method based on a combination of a whale optimization algorithm and a bidirectional long short-term memory network provided by the present invention;
[0087] Figure 2 Modeling diagram for the BiLSTM model;
[0088] Figure 3 Schematic diagram of the BiLSTM neural network model parameter optimization process. DETAILED DESCRIPTION
[0089] The following detailed description of exemplary embodiments of the present invention refers to the accompanying drawings, which form a part of the description, and in which exemplary embodiments of the present invention that can be implemented are shown as examples. Although these exemplary embodiments are described in sufficient detail to enable those skilled in the art to implement the present invention, it should be understood that other embodiments can be implemented and various changes can be made to the present invention without departing from the spirit and scope of the present invention. The following more detailed description of the embodiments of the present invention is not intended to limit the scope of the claimed invention, but is only for the purpose of illustrating and not limiting the description of the characteristics and features of the present invention, so as to propose the best mode for performing the present invention and to enable those skilled in the art to implement the present invention. Therefore, the scope of the present invention is limited only by the appended claims.
[0090] It should be understood that the following text is only used to describe one or several specific embodiments of the present invention, and does not strictly limit the scope of protection of the specific claims of the present invention. As used herein, the terms "parallel" and "perpendicular" are not limited to their strict geometric definitions, but include tolerances for reasonable and inconsistent machining or human errors.
[0091] Example
[0092] A gas prediction method based on a combination of a whale optimization algorithm and a bidirectional long short-term memory network comprises the following steps:
[0093] S1. Read real-time gas data from the online database, pre-process the data, and construct the data set required for the experiment;
[0094] The specific operations of the preprocessing are: connecting to the database, reading the required real-time data from the database, setting upper and lower limits for data processing, and converting the data into a two-dimensional array, and finally saving the processed data to obtain a data set.
[0095] S1.1. Set upper and lower limits: First, set two key thresholds: one is the highest threshold Z of gas data. max , and the other is the minimum threshold Z of gas data min Next, the gas data read is compared with the two thresholds. If the gas data read is greater than the set highest threshold Z max , adjust the value of gas data directly to Z max On the contrary, if the gas data read is less than the set minimum threshold Z min , adjust the value of gas data to Z min If the gas data happens to be at the highest threshold Z min and the minimum threshold Z min If the gas level is between , then it means that the current gas level is within the normal range and no adjustment is required. This step is used to filter out excessively high or low values. Preferably, when the gas data read is greater than the initial set maximum threshold Z max , the highest threshold is twice the mean value of the gas data, then the value is considered too large and is removed; when the gas data read is less than the initial set minimum threshold Z min , the minimum threshold is 50% of the mean value of gas data, then the value is considered too small and is eliminated.
[0096] S1.2, data conversion: reshape the data after the upper and lower limits are processed through the reshape function, which accepts two main parameters: the data to be converted a, the newshape that defines the dimensions of the new array, and the optional parameter order that specifies the order of the array elements. In this scenario, the data after the upper and lower limits are processed in step S1.1 is a, and newshape is set to -1. The purpose is to convert the one-dimensional array after the upper and lower limits into a two-dimensional array, in which each element of the original array is converted into a row in the new array to form a separate row vector.
[0097] S2, dividing the data set obtained in step S1 into a training set and a test set, and then modeling them, wherein the training set is used to determine the model parameters, and the test set is used to judge the model effect;
[0098] S2.1. Divide the data set: First, set the sample input amount as a variable, divide the data in turn, obtain the training set and test set data, normalize the data, and use the MinMaxScaler function to scale the data.
[0099] The specific operation of dividing the data set is: first, the original feature quantity and output number of the input variables and output variables required by the model are clarified; then, according to the preset delay step, the data set is divided, wherein 70% of the data is designated as the training set, and the remaining 30% is used as the test set. Among them, temperature, blast volume, furnace pressure difference, raw material quality, etc. are selected as input variables, and gas flow rate is selected as output variable.
[0100] S2.2, Normalization processing: First, find the minimum value X in the data set min and the maximum value X max , and then use the normalization formula to calculate each data point. This formula linearly transforms the data to a standardized range to obtain the normalized data results. The normalization formula is as follows:
[0101]
[0102] Where X represents the true value at a certain moment in the time series, X min is the minimum value of the sequence, X max is the maximum value of the sequence, and X1 represents the normalized result.
[0103] S3. Construct BiLSTM gas prediction model: The BiLSTM model combines two parallel LSTM layers, forward and backward. The forward LSTM layer processes each data of the input sequence in order to capture the forward information; while the backward LSTM layer processes in reverse order to capture the backward information. Each LSTM layer contains several LSTM cells, and each LSTM cell includes three gate structures: input gate, output gate and forget gate. These three gate structures are responsible for controlling the inflow and outflow of information and the selective retention of past information. Its construction process is as follows: Figure 2 As shown in the figure, the specific operations are as follows: the number of neurons in each layer, the number of neuron layers, the neuron loss rate, the batch processing size, and the sample input amount are set as variables, and the whale optimization algorithm is used to iteratively optimize each parameter to obtain the best parameter combination, and finally the final BiLSTM model is constructed.
[0104] The process of building an LSTM model consists of two parts: the update of a single LSTM cell and the combination of all LSTM cells.
[0105] The internal information update process of a single LSTM neuron cell includes: a. updating of the forget gate; b. updating of the input gate; c. updating of the cell state and d. updating of the output gate.
[0106] a. The update process of the forget gate is:
[0107] Calculate the forget gate state, the calculation formula is as follows:
[0108] f t =σ(W t [h t-1 , X t ]+b f )
[0109] Among them, f t represents the state of the forget gate at time t, h t-1 represents the output at time t-1, X t represents the input at time t, σ represents the sigmoid activation function, W t is the forget gate weight matrix, b f is the forget gate bias. The forget gate determines which information from the previous moment should be retained, and the output is between 0 and 1. When its value is close to 0, it means that most of the old information will be forgotten, and when it is close to 1, it means that the old information is basically retained.
[0110] b. The update process of the input gate is:
[0111] The input gate is responsible for deciding which new information should be integrated into the cell state. The input gate consists of two core components: the sigmoid layer and the tanh layer. The sigmoid layer is responsible for determining which values will be updated in the cell state, while the tanh layer is responsible for generating a candidate value vector containing potential new information. The new information is integrated into the cell state by combining the output of the sigmoid layer with the candidate value vector generated by the tanh layer. The calculation formula is as follows:
[0112] i t =σ(W i [h t-1 ,X t ]+b i )
[0113] C t =tanh(W c [h t-1 ,X t ]+b c )
[0114] where i t represents the input gate state at time t, σ represents the sigmoid activation function, W i is the input gate weight, h t-1 represents the output at time t-1, X t represents the input at time t, b i is the input gate bias term, C t represents the cell state of the candidate memory unit, W c is the neuron state weight, b c is the neuron state bias term.
[0115] c. The process of updating the cell state is: updating the old cell state, and the calculation formula is as follows:
[0116]
[0117] where f t represents the state of the forget gate at time t, C t represents the cell state at time t, i t represents the input gate state at time t, C t-1 represents the cell state at time t-1, C t Represents the cell state of the candidate memory unit.
[0118] d. The update process of the output gate is as follows: The output gate determines which information in the current cell state should be passed to the hidden state at the next moment. The input gate first reads the hidden state of the previous moment and the input of the current moment, and processes this information through the sigmoid function. Then the updated cell state is processed nonlinearly by the tanh function and the result is multiplied by the value of the output gate to obtain the hidden state at the current moment. Finally, this hidden state will be passed to the next LSTM cell or output layer as the key information of the LSTM network. The calculation formula is as follows:
[0119] o t =σ(W o [h t-1 , X t ]+b o )
[0120] h t =o t *tanh(C t )
[0121] Among them, t represents the output gate state at time t, σ represents the sigmoid activation function, W O is the output gate weight, h t-1 represents the output at time t-1, X trepresents the input at time t, b O is the input gate bias term, h t represents the output at time t, C t represents the cell state at time t.
[0122] Finally, the combined workflow of all LSTM cells is: The combined workflow of the long short-term memory network (LSTM) follows a rigorous and well-organized mechanism. The core lies in the orderly coordinated operation of multiple LSTM cell units. Relying on the four key components of the forget gate, input gate, cell state update mechanism and output gate, each cell unit is connected in series in a predetermined order to achieve efficient information processing and integration. In the initial stage, to build an LSTM network, multiple LSTM cell units need to be connected in sequence. This connection order starts with the forget gate, followed by the input gate, followed by the change of cell state, and finally ends with the output gate. Each part is closely connected and works together. When time series data is input into the network, the corresponding LSTM cell unit immediately starts to operate independently for each time step in the sequence.
[0123] Specifically, at the first time step, the first activated LSTM cell unit receives the input data corresponding to that moment, and introduces the pre-set initial cell state and initial hidden state, and then starts the key operation process. The forget gate weighs the need to retain the initial cell state information based on the current input and initial hidden state, through linear transformation and activation function operation, and generates a screening coefficient in a specific interval (mostly 0-1) to control the selection of information. Synchronously, the input gate uses the weight matrix, bias vector and activation function to generate candidate information with update potential and measure the degree of adaptation for accepting new information. Based on the coordinated judgment of the two, the cell state update link eliminates the old information according to the screening coefficient, integrates the new information filtered by the input gate, and completes the optimization and innovation. Then the output gate extracts the key and characteristic parts of the updated cell state according to the established rules and mechanisms, condenses the new hidden state and passes it to the next step as the key input of the subsequent unit. As the time series advances to the second time step and subsequent time steps, the subsequent LSTM cell units use the hidden state output by the previous unit as a connecting element, and re-combine with the input data corresponding to the current time step, strictly replicating the detailed process of the above forget gate, input gate, cell state update, and output gate, continuously iterating and optimizing the long-term information stored in the cell state, and updating and outputting the hidden state one by one. By repeating this rigorous process at each time step of the time series, each LSTM cell unit gradually accumulates and transmits key information, allowing the entire network structure to transcend time limitations, deeply explore the hidden intrinsic connections between time series data at different times, and finally build an LSTM network architecture with powerful long-term dependency capture capabilities.
[0124] The process of building a BiLSTM model is divided into three parts: forward LSTM, backward LSTM and combined LSTM.
[0125] The forward LSTM workflow is as follows: at time t, a single forward LSTM cell receives the hidden layer output of the previous moment and the input of the current moment, and calculates the hidden layer output of the current moment through the forget gate, input gate, output gate and cell state update. The calculation formula is as follows:
[0126]
[0127] in represents the hidden layer output of the forward LSTM at time t. LSTM represents the calculation process of the short-term memory unit at this time step. X t is the input at time t, is the hidden layer output at time t-1.
[0128] The backward LSTM workflow is as follows: at time t, a single backward LSTM neuron receives the hidden layer output of the previous moment and the input of the current moment, and calculates the hidden layer output of the current moment through the forget gate, input gate, output gate and cell state update. The calculation formula is as follows:
[0129]
[0130] in represents the hidden layer output of the backward LSTM at time t. LSTM represents the calculation process of the short-term memory unit at this time step. X t is the input at time t, is the hidden layer output at time t-1.
[0131] The combined LSTM workflow is: output the forward LSTM hidden layer And the backward LSTM hidden layer output The output h1 of the BiLSTM hidden layer is obtained by concatenation. The calculation formula is as follows:
[0132]
[0133] S4: Optimize the model parameters. The optimization process is as follows: use the whale optimization algorithm to tune the parameters, select the mean absolute percentage error (MAPE) as the fitness function, and update the whale position according to the whale optimization algorithm principle and the fitness function value;
[0134] The steps for tuning the parameters of the whale optimization algorithm include:
[0135] a. Initialize the parameters of the whale optimization algorithm; b. Tune the parameters of the whale optimization algorithm; c. Iterate.
[0136] a. Initialize the parameters of the whale optimization algorithm. The specific steps are: set the number of whale populations to N and the maximum number of iterations to T. max ,The optimization parameters are (a, b, c, d, e), and the dimension of the search space is the number of optimization parameters D. Among them, a represents the number of neurons in each layer of the bidirectional long short-term memory network (BiLSTM), b represents the number of layers of BiLSTM neurons, c represents the loss rate of BiLSTM neurons, d represents the size of BiLSTM batch processing, and e represents the input amount of BiLSTM samples.
[0137] The specific steps to determine the optimization range of the selected parameters are: for these optimization objects, reasonable upper and lower limits are set respectively to ensure that the algorithm can cover a broad and practical parameter space when exploring the optimal configuration.
[0138] b. The specific steps for tuning the parameters of the whale optimization algorithm are as follows: first calculate the values of A and C, and then the algorithm intelligently chooses which search phase to enter based on the values of p and A: The whale optimization algorithm is based on the hunting behavior of humpback whale groups in nature. The position of each humpback whale is symbolically mapped to a potential feasible solution, which mainly includes three stages: surrounding prey, bubble net attack, and searching for prey.
[0139] When p<0.5 and A<1, the prey encirclement phase is performed by performing a fine search closely around the potential optimal solution;
[0140] Specifically, when the conditions p<0.5 and A<1 are met, the prey encirclement behavior is performed. In this stage, the whale group first calculates the fitness value of each humpback whale, gradually reduces the search range, and then moves closer to the optimal prey position currently searched, so as to more accurately locate the optimal solution. The formula is as follows:
[0141] D=|CX * (t)-X(t)|
[0142] X(t+1)=X * (t)-AD
[0143] A=2ar-a
[0144]
[0145] C=2r
[0146] Where p is a probability value randomly generated by the algorithm, D is the distance between the current whale individual and the optimal position, t is the current iteration number, T max is the maximum number of iterations, X(t) is the position of the current whale individual in the tth generation, X(t+1) is the position of the current whale individual in the (t+1) generation, and X *(t) is the current optimal position vector, A and C are coefficient vectors, which play an important role in the algorithm. A is used to adjust the step size and direction of the whale moving to the optimal position, and its value is affected by the parameter a. C is mainly used to balance the exploration and development capabilities of the algorithm. a is a value that decreases linearly from 2 to 0, and r is a random real number in [0,1].
[0147] When p≥0.5, the bubble net attack hunting phase is selected. The algorithm simulates the behavior of whales to capture prey by forming bubble nets, hoping to quickly locate a better solution in the solution space;
[0148] Specifically, when the condition p≥0.5 is met, the bubble net attack hunting behavior is performed. In this stage, an accurate mathematical model is first established based on the natural behavior of whales releasing bubbles. The model regards each whale in the population as a point in the search space and simulates them marking their positions or exchanging information by releasing bubbles. This model is used to calculate the distance between each individual whale and the current optimal solution. These distances are then normalized to ensure that the search process follows the established constraints. Finally, a local search strategy is adopted to limit the search focus to the spiral path, which can more accurately locate and find the optimal solution. The formula is as follows:
[0149] X(t+1)=De bl cos(2πl)+X * (t)
[0150] D=|X * (t)-X(t)|
[0151] Where X(t+1) is the position of the current whale individual in the (t+1) generation, b is a constant used to define the shape of the spiral, and X * (t) is the current optimal position vector, l is a random number in the interval (-1,1), and D is the distance between the current whale individual and the optimal position.
[0152] When p<0.5 and A>1, the algorithm chooses to perform a random search for prey phase, increasing the possibility of discovering new solutions by expanding the search range, thereby avoiding falling into a local optimum.
[0153] Specifically, when the conditions p<0.5 and A>1 are met, random prey search behavior is performed. At the beginning, a whale's current location is randomly selected as the starting point of the search, and then other whale positions are dynamically updated based on this starting point, guiding the whale to temporarily deviate from the known prey location. This gives the whale a chance to find a more suitable or better prey location, thereby optimizing its hunting behavior. The formula is as follows:
[0154] D=|CX rand -X(t)|
[0155] X(t+1)=X rand -AD
[0156] Where X rand is the random position vector for selecting individuals from the current population, X(t) is the position of the current whale individual in the tth generation, X(t+1) is the position of the current whale individual in the (t+1)th generation, A is the coefficient vector, and D is the distance between the current whale individual and the optimal position.
[0157] c. Iteration The specific operation is: during the execution of the algorithm, repeat step b. When the cumulative number of iterations reaches the preset maximum number of iterations threshold T max When , the entire iteration process will automatically terminate. At this time, the algorithm has completed the entire parameter tuning process and obtained the optimal model parameter combination under given conditions.
[0158] At each search stage, the algorithm evaluates the fitness of each whale. In this method, the mean absolute percentage error (MAPE) is selected as the measure of the fitness function. Then, according to the principle of the whale optimization algorithm, the position of the whale in the search space is updated according to the fitness evaluation results. After updating the whale position, the algorithm will further determine whether the updated whale fitness value is better than the best fitness value recorded before. If so, the best fitness record of the whale is immediately updated, and its current position is marked as the optimal position of the whale group.
[0159] In each iteration of the algorithm, the MAPE value of each whale individual is calculated using the following formula and the calculated MAPE value is used as the fitness score of each whale individual. Then in each iteration, the MAPE values of all whale individuals are compared and the global optimal solution is updated. The whale individual with the smallest MAPE value is considered to be the best solution currently found. The MAPE calculation formula is as follows:
[0160]
[0161] Where n represents the number of samples, y1 represents the actual value, and y2 represents the predicted value. y1 is the gas data divided in step S2.1, and y2 is the predicted value obtained by substituting y1 into the BiLSTM model constructed by the above optimized parameter combination. The variable value of the sample input in S2.1 is the parameter e in this step.
[0162] S5. Load the model with the optimal parameter combination for training and prediction, and save the predicted value in the database.
[0163] S5.1. Then, the BiLSTM model is constructed using the best parameter combination selected by the whale optimization algorithm. According to the best parameter combination obtained after optimization in S4, a BiLSTM model with the corresponding number of neurons, number of neuron layers, neuron loss rate, batch processing size and sample input amount is constructed.
[0164] S5.2. Finally, the trained BiLSTM model is applied to the prediction data set and the final prediction results are obtained.
[0165] The dataset to be predicted processed by S5.1 is fed into the BiLSTM model trained by S5.2, and the complex calculation and bidirectional information flow mechanism within the model are used to deeply explore the time series characteristics and potential patterns in the gas data. Finally, the prediction result of the gas flow rate of the steel plant 30 minutes later is obtained from the model.
[0166] The above description is only a preferred embodiment of the present application and an explanation of the technical principles used. Those skilled in the art should understand that the scope involved in the present application is not limited to the technical solution formed by a specific combination of the above-mentioned technical features, but should also cover other technical solutions formed by any combination of the above-mentioned technical features or their equivalent features without departing from the inventive concept, such as a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this application.
[0167] Except for the technical features described in the specification, the remaining technical features are known technologies to those skilled in the art. In order to highlight the innovative features of the present invention, the remaining technical features will not be described here in detail.
Claims
1. A gas prediction method based on the combination of whale optimization algorithm and bidirectional long short-term memory network, characterized in that: Includes steps: S1. Read real-time gas data from the online database, pre-process the data, and construct the data set required for the experiment; S2, dividing the data set obtained in step S1 into a training set and a test set, wherein the training set is used to determine the model parameters, and the test set is used to judge the model effect; S3, build BiLSTM gas prediction model; S4, optimizing the parameters of the model obtained in step S4; S5. Load the model with the optimal parameter combination for training and prediction to obtain the predicted value.
2. The gas prediction method according to claim 1, characterized in that: Step S1 includes the steps of: S1.
1. Set upper and lower limits: Set the highest threshold value Z of gas data max and the minimum threshold Z of gas data min , compare the gas data read with the highest threshold Z max and the minimum threshold Z min Compare and filter out gas values that are too high or too low; S1.
2. Data conversion: The data after upper and lower limit processing is reshaped through the reshape function to convert the one-dimensional array into a two-dimensional array, where each element of the original array is converted into a row in the new array to form a separate row vector.
3. The gas prediction method according to claim 2, characterized in that: Step S2 comprises the steps of: S2.
1. Divide the data set: Set the sample input amount as a variable, divide the data in turn, and obtain the training set and test set data; S2.2, Normalization: First find the minimum value X in the data set min and the maximum value X max , and then use the normalization formula to calculate each data point. The normalization formula is as follows: Where X represents the true value at a certain moment in the time series, X min is the minimum value of the sequence, X max is the maximum value of the sequence, and X1 represents the normalized result.
4. The gas prediction method according to claim 3, characterized in that: Step S3 of constructing the BiLSTM gas prediction model includes: updating of a single LSTM cell and combining of all LSTM cells. The LSTM network connects multiple LSTM cell units through the sequence of forget gate, input gate, cell state and output gate. Each unit processes a time step in the time series. Then, the above-mentioned single LSTM cell update process is used to gradually accumulate and transmit information, thereby forming a network structure that can capture long-term dependencies in time series data.
5. The gas prediction method according to claim 4, characterized in that: The internal information updating process of a single LSTM neuron cell includes updating of a forget gate, updating of an input gate, updating of a cell state and updating of an output gate, which specifically includes the following steps: a. Update of the forget gate, the formula is as follows: f t =σ(W t [h t-1 ,X t [+b f ) Among them, f t represents the state of the forget gate at time t, h t-1 represents the output at time t-1, X t represents the input at time t, σ represents the sigmoid activation function, W t is the forget gate weight matrix, b f is the forget gate bias term; b. Update of input gate, the formula is as follows: i t =σ(W i [h t-1 ,X t ]+b i ) C t =tanh(W c [h t-1 ,X t ]+b c ) Among them, i t represents the input gate state at time t, σ represents the sigmoid activation function, W i is the input gate weight, h t-1 represents the output at time t-1, X t represents the input at time t, b i is the input gate bias term, C t represents the cell state of the candidate memory unit, W c is the neuron state weight, b c is the neuron state bias term; c. Update of cell status, the formula is as follows: where f t represents the state of the forget gate at time t, C t represents the cell state at time t, i t represents the input gate state at time t, C t-1 represents the cell state at time t-1, C t Represents the cell state of the candidate memory unit; d. Update of the output gate, the formula is as follows: the t =σ(W O [h t-1 ,X t ]+b o ) h t =o t *tanh(C t ) Among them, t represents the output gate state at time t, σ represents the sigmoid activation function, W O is the output gate weight, h t-1 represents the output at time t-1, X t represents the input at time t, b O is the input gate bias term, h t represents the output at time t, C t represents the cell state at time t.
6. The gas prediction method according to claim 5, characterized in that: The process of establishing the BiLSTM model is divided into forward LSTM, backward LSTM and combined LSTM, which specifically includes the following steps: The forward LSTM workflow is as follows: at time t, a single forward LSTM cell receives the hidden layer output at the previous moment and the input at the current moment, and calculates the hidden layer output at the current moment through the forget gate, input gate, output gate, and cell state update; The backward LSTM workflow is as follows: at time t, a single neuron of the backward LSTM receives the hidden layer output at the previous moment and the input at the current moment, and calculates the hidden layer output at the current moment through the forget gate, input gate, output gate, and cell state update; The combined LSTM workflow is: output the forward LSTM hidden layer And the backward LSTM hidden layer output The concatenation is performed to obtain the output h1 of the BiLSTM hidden layer.
7. The gas prediction method according to claim 6, characterized in that: The whale optimization algorithm parameter tuning step in step S4 includes: a. Initialize the parameters of the whale optimization algorithm: set the number of whale populations to N and the maximum number of iterations to T max ,The optimization parameters are (a, b, c, d, e), and the dimension of the search space is the number of optimization parameters D, where a represents the number of neurons in each layer of the bidirectional long short-term memory network (BiLSTM), b represents the number of layers of BiLSTM neurons, c represents the loss rate of BiLSTM neurons, d represents the size of BiLSTM batch processing, and e represents the input amount of BiLSTM samples. b. Whale optimization algorithm parameter tuning; c. Iteration: Repeat step b. When the number of iterations reaches the preset maximum number of iterations threshold T, max When , the iteration process automatically terminates and the optimal model parameter combination under given conditions is obtained.
8. The gas prediction method according to claim 7, characterized in that: The whale optimization algorithm parameter tuning steps include: According to the value of p and A, the algorithm intelligently selects to enter the search phase, where p is the probability value and A and C are coefficient vectors: When p<0.5 and A<1, the prey encirclement phase is selected to perform a fine search closely around the potential optimal solution, and the formula is as follows: D=|CX * (t)-X(t)| X(t+1)=X * (t)-AD A=2ar-a C=2r Where D is the distance between the current whale individual and the optimal position, t is the current iteration number, T max is the maximum number of iterations, X(t) is the position of the current whale individual in the tth generation, X(t+1) is the position of the current whale individual in the (t+1) generation, and X * (t) is the current optimal position vector, A and C are coefficient vectors, a is a value that decreases linearly from 2 to 0, and r is a random real number in [0,1]; When p≥0.5, the bubble net attack hunting phase is selected, and the formula is as follows: X(t+1)=From bl cos(2πl)+X * (t) D=|X * (t)-X(t)| Where X(t+1) is the position of the current whale individual in the (t+1) generation, b is a constant used to define the shape of the spiral, and X * (t) is the current optimal position vector, l is a random number in the interval (-1,1), and D is the distance between the current whale individual and the optimal position; When p<0.5 and A>1, the algorithm chooses to perform a random search for prey phase, and the formula is as follows: D=|CX rand -X(t)| X(t+1)=X rand -AD Among them, X rand is the random position vector for selecting individuals from the current population, X(t) is the position of the current whale individual in the tth generation, X(t+1) is the position of the current whale individual in the (t+1)th generation, A and C are coefficient vectors, and D is the distance between the current whale individual and the optimal position.
9. The gas prediction method according to claim 8, characterized in that: In each iteration of the algorithm, the calculated MAPE value is used as the fitness score of each whale individual. In each iteration, the MAPE values of all whale individuals are compared, and the global optimal solution is updated. The whale individual with the smallest MAPE value is considered to be the best solution currently found. The MAPE calculation formula is as follows: Where n represents the number of samples, y1 represents the actual value, and y2 represents the predicted value.
10. The gas prediction method according to claim 9, characterized in that: Step S5 specifically includes the following steps: S5.
1. Use the best parameter combination selected by the whale optimization algorithm to build a BiLSTM model. According to the best parameter combination obtained after optimization in S4, a BiLSTM model with the corresponding number of neurons, number of neuron layers, neuron loss rate, batch size and sample input amount is built. S5.
2. Apply the trained BiLSTM model to the prediction data set and obtain the final prediction results.
Citation Information
Patent Citations
Algorithm for estimating state of charge of power battery based on improved random forest joint volumetric Kalman
CN110888059A
Coal-fired boiler NOX soft measurement method based on whale algorithm for optimizing long and short term memory network
CN113627071A
Method for predicting flow of steam header pipe of waste heat boiler
CN117973196A
Carbon flux prediction method based on whale algorithm optimization neural network
CN118396173A
Wind power prediction method and system for optimizing deep transformer network
US20220197233A1
Cited By
Method for predicting remaining mileage of pure electric vehicle based on real vehicle data
CN120207123A
Production and transportation integrated intelligent scheduling method in integrated manufacturing system
CN120851752A
Synthesis gas component content prediction method based on multi-algorithm fusion modeling
CN122245487A
A syngas component content prediction method based on multi-algorithm fusion modeling
CN122245487B