A Production Prediction Model of Tight Gas Well Optimized with a Back Propagation (BP) Neural Network Based on the Sparrow Search Algorithm

: The production of tight gas wells decreases rapidly, and the traditional method is difficult to accurately predict the production of tight gas wells. At present, intelligent algorithms based on big data have been applied in oil and gas well production prediction, but there are still some technical problems. For example, the traditional error back propagation neural network (BP) still has the problem of finding the local optimal value, resulting in low prediction accuracy. In order to solve this problem, this paper establishes the output prediction method of BP neural network optimized with the sparrow search algorithm (SSA), and optimizes the hyperparameters of BP network such as activation function, training function, hidden layer, and node number based on examples, and constructs a high-precision SSA-BP neural network model. Data from 20 tight gas wells, the SSA-BP neural network model, Hongyuan model, and Arps model are predicted and compared. The results indicate that when the proportion of the predicted data is 20%, the SSA-BP model predicts an average absolute mean percentage error of 20.16%. When the proportion of forecast data is 10% of the total data, the SSA-BP algorithm has high accuracy and high stability. When the proportion of predicted data is 10%, the mean absolute average percentage error is 3.97%, which provides a new method for tight gas well productivity prediction.


Introduction
Oil and gas well production prediction is one of the important contents of oil and gas reservoir development scheme design.Predecessors have carried out a lot of research on oil and gas well production prediction, and put forward various production prediction methods.They can be roughly divided into three categories: mechanism model production prediction method, decline curve production prediction method, and intelligent algorithm production prediction method based on big data.A conventional oil reservoir is one that has a stable geological structure, high rock porosity and permeability, and can typically be explored and produced using conventional seismic exploration and drilling technology.An unconventional reservoir, on the other hand, is one that has a complex geological structure and low rock porosity and permeability.This includes shale gas, tight oil, and oil sand, among others.Oil and gas reservoirs frequently necessitate the use of unconventional techniques, such as horizontal wells and fracturing, which are more costly than conventional reservoirs but also have greater potential reserves.In the field of unconventional oil and gas well production prediction, mechanical production prediction models are mostly established based on the double medium theory put forward by Warren and Root [1] in 1963.The dual medium theory assumes that fractured reservoirs are composed of uniformly distributed matrix systems and natural fracture systems.On this basis, many scholars have established the prediction model of tight oil and gas production.The representative scholars comprise Guo et al. [2], Horne et al. [3], Lian et al. [4], Larsen et al. [5], Raghavan et al. [6], Chen et al. [7], Ozkan et al. [8], Yao et al. [9], Su et al. [10], Ren et al. [11,12], Tang [13], and Bai et al. [14].In 1945, Arps [15] established an exponential decline, hyperbolic decline, and harmonic decline model for predicting oil and gas well production based on the law of oil well decline.
However, most of these models are suitable for the development of conventional oil and gas reservoirs.In order to solve the percolation problem of unconventional oil and gas reservoirs, domestic and foreign scholars have established many production prediction models of decline curve, such as Ilk et al. [16], Valk ó P.P. [17], Duong [18], and Hong [19].The prediction of production and reserves of tight oil and gas reservoir is an important part of reservoir engineering, and also a key index to evaluate the development effect of oil and gas field.Multi-stage fractured horizontal well technology is used to develop unconventional oil and gas reservoirs.The complexity of fluids near reservoirs and production wells makes conventional production decline method, such as the Arps production decline method, not applicable in many cases.At present, most of the models used to predict production and reserves of production wells are analytical, numerical, or empirical models.In contrast, the empirical model (production decline method) is still the most widely used method in the oil and gas industry to predict future production and reserves based on dynamic production trends.It is simple, easy to operate, has good time-to-production, and allows us to easily predict production and life cycles.The actual application shows the following: (1) The longer the production time and more data used in forecasting, the smaller the relative error, but when the data of the first year are included, it is easy to underestimate the output.(2) SEPD, YM-SEPD, and Duong are more suitable for early decline, while hyperbolism is suitable for late decline.The production data predicted by the late SEPD model are often low, while the value predicted by the Duong model is high.Therefore, the combination model is recommended for the analysis of tight oil and gas production decline.(3) Select wells with a long production history and analyze the time for a single well to reach the boundary control flow.When the production time is less than this time, the comprehensive use of YM-SEPD method and Duong method can obtain conservative and reliable results; after the boundary effect appears, the hyperbolic decline method is more convenient to predict than other methods.However, the above two kinds of methods are established on the basis of certain assumptions and cannot 100% reflect the law of real formation seepage.In order to solve the defects of traditional prediction methods, scholars introduce machine learning technology into the field of oil and gas exploration and production.The random forest algorithm, support vector machine, artificial neural network, and other technologies are applied in the field of productivity prediction.Scholars have established the production prediction model of oil and gas wells based on artificial neural networks.In 2008, Ni [20] and others used artificial neural network to predict productivity and establish a three-layer BP neural network model, but the network will have the problem of slow convergence and low accuracy.In order to improve the convergence speed, in 2011, Li [21] adopted the Lmure M (Levenberg-Marquardt) algorithm to optimize the loss function on the basis of BP neural network to accelerate convergence, but the problem of low convergence accuracy still appeared without optimizing the weights and thresholds of the network.In 2015, Ma [22] used genetic algorithm to optimize the BP neural network to optimize the network weight, but the neural network will still converge slowly and fall into local optimization in the highly volatile data.However, the above two kinds of methods are established on the basis of certain assumptions and cannot fully (100%) reflect the law of real formation seepage.In order to solve the defects of traditional prediction methods, scholars introduce machine learning technology into the field of oil and gas exploration and production.
In order to solve the problems of slow convergence and susceptibility to local optima the BP neural network, this paper optimizes the activation function and loss function of the BP neural network, and then uses the sparrow search algorithm to optimize the weight and threshold of the BP network.On this basis, the SSA-BP neural network's productivity prediction model is established, which provides a good prediction tool for calculating the production of tight gas wells.

Principle of Sparrow Search Algorithm
The sparrow search algorithm (SSA) was proposed by Xue [23] in 2020.The SSA mainly imitates the foraging behavior and anti-predation behavior of sparrows.The whole process is a mechanism in which the participant follows the discoverer and superimposes vigilant at the same time.Discoverers often have a better adaptation value, can find a better foraging location, and explore a wide range.In order to improve their fitness, the participants always look for food around the discoverers, while the participators may constantly monitor the discoverers and compete for food sources in order to increase their predation rate.At the same time, the sparrow population will randomly appear a certain proportion of vigilant; when the danger is found, the alarm will be issued by the discoverer to decide whether to anti-feeding.With each iteration, the discoverer location is updated, as follows: where t represents the current number of iterations, iter max 1 and 2, 3, . .., d. inter max is a constant that represents the maximum number of iterations.X ij represents the location information of the Ist sparrow in dimension j. α ∈ (0 ]) and S T (S T ∈ [0.5, 1]) denote early warning value and safety value, respectively.Q is a random number with a normal distribution.L denotes a 1 × d matrix, where each element in the matrix is 1.When R 2 < S T , this means that there are no predators around the foraging environment, and the discoverer can perform a wide range of search operations.If R 2 ≥ S T , it means that some sparrows in the population have found predators and have alerted other sparrows in the population, and all sparrows need to fly quickly to other safe places to look for food.
The location of the participant for each iteration is updated as follows: Among them, X p is the best position occupied by the discoverer at present, and X worst represents the worst position in the whole world.A represents a 1 × d matrix, where each element is randomly assigned to 1 or −1, and A + = A T AA T −1 .When i > n/2, this shows that the i participant with lower fitness value has no food and is very hungry, so it needs to fly to other places to find food in order to get more energy.
The positions of the vigilantes are as follows: where is the current global optimal location.As a step size control parameter, β is a random number with a normal distribution with a mean of 0 and a variance of 1. K ∈ [−1, 1] is a random number, and f i is the fitness value of the current sparrow.f g and f w are the current global best and worst adaptation values, respectively.The constant of ε to avoid zero denominator.For simplicity, when f i > f g indicates that the sparrow is on the edge of the population, it is extremely vulnerable to predators.X best says the sparrows in this position are the best and are safe in the population.When f i = f g , this indicates that sparrows in the middle of the population are aware of the danger and need to be close to their sparrows to minimize their risk of predation.K indicates that the direction in which the sparrow moves is also a step size control parameter.

Sparrow Search Algorithm to Optimize BP Neural Network
According to the calculation logic of a traditional BP neural network, it is evident that the subject has a strong self-learning ability and non-linear mapping ability, which are very consistent with oil field production prediction.However, when the objective function is very complex, because the loss function in BP algorithm is optimized by gradient descent, it may fall into the trap of local optimization.Moreover, the uncertainty of the network also increases because of the random initialization of weights and thresholds, that is, the weights and thresholds of the network depend on the quality of sample data, which reduces the accuracy of BP neural network in oil field production prediction.
The global search ability of the sparrow search algorithm can better search the weights and thresholds of the BP neural network, so that the neural network can reach a stable state more quickly and obtain the optimal prediction result.The sparrow search algorithm is used to optimize the BP neural network and also to fully utilize their respective strengths, achieving mutual complementarity and improving the accuracy of the model.
The process of optimizing the BP network via the sparrow search algorithm mainly consists of two parts: sparrow search algorithm optimization and neural network prediction.In order to optimize the sparrow search algorithm, we first determine the sparrow population.Because the weight and threshold are m × n-dimensional matrix, respectively, the vector exists in the BP neural network structure (net).In order to optimize each element, we first take out the elements, and then put them into the vector according to the order to complete the composition of the sparrow population.The length of each sparrow in the population is the sum of all connection weights and threshold lengths of the neural network.There are n neurons in the hidden layer, h neurons in the output layer, w is the weight between the input layer and the hidden layer, lw is the weight between the output layer and the hidden layer, b is the threshold of the hidden layer, and o is the threshold of the output layer.When the input layer is i, the length of the sparrow is I × n + n + n × h + h.The optimization process represented with a flow chart added via the sparrow search algorithm to optimize the BP neural network is shown in Figure 1.
The individual fitness value of the sparrow was calculated.The initial weight and threshold are used for network training, and the overall mean square error (MSE) of the training set and the test set is taken as the fitness function.The smaller the fitness function value is, the more accurate the training is.The sparrow position is gradually updated and iterated to find the global optimal solution, that is, the optimal sparrow individual.The optimal individual position of the output is used as the weight and threshold of the neural network for training and prediction.

Model Evaluation Criteria
The root mean square error (RMSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) are selected as the evaluation index of the model.The first performance index is the root mean square error (RMSE), which is used to measure the deviation between the predicted value and the actual value.The smaller the root mean square error, the higher the prediction accuracy.The second performance index is the mean absolute error (MAE), which is the average of the absolute error between the predicted value and the actual value, which can directly reflect the actual situation of the predicted error.The closer the value is to 0, the more accurate the prediction.The third performance indicator is the mean absolute percentage error (MAPE), which refers to the ratio of the absolute value of all predicted errors to the actual value.The closer the value is to 0, the more accurate the prediction.

Neural Network Hyperparameter Optimization
Taking a well (Well-1) in the Ordos Basin as an example, this paper introduces the super-parameter optimization process of activation function, training function, and

Case Prediction 4.1. Model Evaluation Criteria
The root mean square error (RMSE), mean absolute error (MAE), and mean absolute percentage error (MAPE) are selected as the evaluation index of the model.The first performance index is the root mean square error (RMSE), which is used to measure the deviation between the predicted value and the actual value.The smaller the root mean square error, the higher the prediction accuracy.The second performance index is the mean absolute error (MAE), which is the average of the absolute error between the predicted value and the actual value, which can directly reflect the actual situation of the predicted error.The closer the value is to 0, the more accurate the prediction.The third performance indicator is the mean absolute percentage error (MAPE), which refers to the ratio of the absolute value of all predicted errors to the actual value.The closer the value is to 0, the more accurate the prediction.

Neural Network Hyperparameter Optimization
Taking a well (Well-1) in the Ordos Basin as an example, this paper introduces the super-parameter optimization process of activation function, training function, and hidden layers in a BP neural network, and then constructs the SSA-BP network model.Among them, the data of more than 600 days since the production of Well-1 are taken as a sample, and the predicted data accounts for 10%.The four nodes in the input layer of the neural network are cumulative production time, daily production time of the gas well, oil pressure, and casing pressure. (

1) Optimization of activation function
The predicted values of the BP neural network under different activation functions are shown in Table 1.It can be seen that the hyperbolic tangent S-type transfer function (tansig) is the best for the input layer activation function, so the activation function is tansig.(2) Optimization of training function When the activation function is tansig, the prediction accuracy of the BP network under different training functions is shown in Table 2; it can be seen that the prediction effect is the best when the training function is trainlm (Lmurm algorithm), so the training function is optimized for trainlm.(3) Optimization of the number of hidden layers and nodes The single hidden layer BP neural network model and the double hidden layer neural network model are established, respectively.The number of hidden layer neuron nodes is adjusted using the following empirical formula.
In the formula, m is the number of nodes in the input layer, n is the number of nodes in the output layer, and a is generally taken as an integer between 1 and 10.
The number of hidden layer neurons in the single hidden layer network model is 7.In the double hidden layer neural network model, the best number of nodes in the first hidden layer is 9, and the best number of nodes in the second hidden layer is 5.The prediction results of the model are shown in Table 3, and the results show that the prediction effect of double hidden layers is better.(4) SSA-optimized BP neural network model On this basis, SSA is used to optimize a single-layer BP neural network and doublelayer BP neural network, respectively.The population size of the sparrow algorithm is set to 30, the maximum evolution algebra of population is 50, the proportion of discoverers is set to 70%, and the proportion of vigilant is set to 20%.The best sparrow individual is optimized with the sparrow search algorithm, which is used as the weight and threshold of the BP neural network.Results as shown in Table 4; after the SSA optimization of weights and thresholds, the prediction effect of single hidden layer BP network model is better than that of double hidden layer model, and the double hidden layer model will appear to be over-fitting after optimization.Tight gas reservoirs account for more than half of unconventional natural gas resources in China and have a good development prospect.
The efficient development of tight gas reservoirs has long-term strategic significance for ensuring energy supply and promoting social and economic development of our country.Due to the special geological characteristics and complex percolation mechanism, tight gas reservoirs are different from conventional gas reservoirs with poor reservoir physical properties, low natural productivity, rapid production decline, and poor production stability, and they usually require horizontal wells and hydraulic fracturing to achieve industrial gas flow.Therefore, it is of great theoretical and practical significance to study the basic seepage theory of different well types of tight gas reservoirs and reveal the influence of various gas well formation parameters on the development of tight gas reservoirs.This is important in order to accurately grasp the production performance of gas wells and guide the reasonable development of tight gas reservoirs.Using the single-layer BP model optimized with the sparrow search algorithm and the model without the sparrow search algorithm, the prediction effect of gas well productivity is shown in Figure 2. From Figure 2b, we can see that the network model optimized without the sparrow search algorithm has a poor fitting result in the training stage, and the predicted value of the model in the learning stage is generally lower than the real production value.This is because the selection of weights and thresholds of the model without SSA optimization is random; even if other super parameters of this model have been optimized, it is still difficult to use directly.The model optimized with the sparrow algorithm is obviously better in both the fitting effect of the training section and the test results of the test section (as shown in Figure 2b).

Comparative Analysis of Prediction Results
In order to further verify the practicability and stability of the SSA-BP neural network built in this paper, the SSA-BP neural network, HongYuan model [20], and Arps model [16] are used to predict productivity based on the actual production data of 20 tight gas wells in the Ordos Basin.The average prediction days are 49.75 days when the forecast accounts for 10%, and the average absolute mean percentage error predicted with the SSA-BP model is 3.97%.The average absolute mean percentage error predicted with the HongYuan model is 33.04%.The average absolute mean percentage error predicted with the Arps model is 22.94%.When the forecast ratio is 20%, the average prediction days are

Comparative Analysis of Prediction Results
In order to further verify the practicability and stability of the SSA-BP neural network built in this paper, the SSA-BP neural network, HongYuan model [20], and Arps model [16] are used to predict productivity based on the actual production data of 20 tight gas wells in the Ordos Basin.The average prediction days are 49.75 days when the forecast accounts for 10%, and the average absolute mean percentage error predicted with the SSA-BP model is 3.97%.The average absolute mean percentage error predicted with the HongYuan model is 33.04%.The average absolute mean percentage error predicted with the Arps model is 22.94%.When the forecast ratio is 20%, the average prediction days are 99.5 days, and the average absolute mean percentage error predicted with the SSA-BP model is 20.16%, indicating that the long-term prediction effect is poor.The average prediction days are 49.75 days when the forecast accounts for 10%, and the average absolute mean percentage error predicted with SSA-BP model is 3.97%.The average absolute mean percentage error predicted with the HongYuan model is 33.04%.The unsteady seepage flow model of the horizontal well in tight gas reservoir is established, and the Pedrosa substitution and regular perturbation theory combined with the Laplace transform, orthogonal transform, and Green's function theory are applied to solve the model.Additionally, the pressure solution and constant pressure production solution of horizontal well are obtained.The flow stages of uniform medium pressure dynamic and production decline curve can be divided into the pure wellbore accumulation effect stage, transitional flow stage after wellbore accumulation, early vertical radial flow stage, middle linear flow stage, and late system quasi-radial flow stage.The flow stages of the dual medium pressure dynamics and production decline curves can be divided into the pure wellbore accumulation effect stage, transitional flow stage after wellbore accumulation, early vertical radial flow stage, early linear flow stage in fracture system, middle radial flow stage in fracture system, cross-flow stage in matrix system to fracture system, and late quasi-radial flow stage in system.The unsteady seepage flow model of fractured horizontal wells in tight gas reservoirs was established, and the linear sum solution expression was derived by applying Pedrosa substitution, regular perturbation theory, Laplace transform, and Green's function theory.Then, the pressure solution and constant pressure production solution of fractured horizontal wells were obtained with a discrete analysis of fractured fractures.Hence, the flow stages of uniform medium pressure dynamics and production decline curves can be divided into the pure wellbore accumulation effect stage, transition flow stage after wellbore accumulation perpendicular to the fracturing fracture in the early linear flow stage, near the fracturing fracture in the middle stage of the system linear flow stage perpendicular to the horizontal wellbore, and the late system quasi-radial flow stage.The flow stages of the dual medium pressure dynamics and production decline curves can be divided into the pure wellbore reservoir effect stage, transitional flow stage after concurrent reservoir, fracture linear flow stage, fracture radial flow stage, natural fracture linear flow stage, natural fracture radial flow stage, matrix system to fracture system cross-flow stage, and late total system pseudo-radial flow stage.

Conclusions
(1) This paper optimizes the BP neural network based on the sparrow search algorithm.
Aiming at the optimization of the trasig activation function, trainlm training function, and single-layer BP neural network for tight gas wells in the Ordos Basin, the parameters of the sparrow search algorithm are also mentioned, which realizes the automatic optimization of a neural network's weight and threshold, and avoids the tedious parameter adjustment process of a conventional neural network.(2) The production of 20 tight gas wells in the Ordos Basin is predicted by using the SSA-BP neural network, HongYuan model, and Arps model.The results show that the average absolute mean percentage error of the SSA-BP neural network is only 3.97%, the error of the HongYuan model is 33.04%, and the error of the Arps model is 22.94%.It shows that the model established in this paper has high prediction accuracy and can effectively predict the production of tight gas wells.(3) The prediction results of the SSA-BP neural network under different proportions of prediction data are compared and analyzed.The average error is 3.97% when the proportion of prediction data is 10%, and the average error is 20.16% when the proportion of prediction data is 20%.The prediction accuracy of the model decreases with the increase in the proportion of prediction data.

Figure 1 .
Figure 1.Optimization of BP neural network flow chart via sparrow search algorithm.The individual fitness value of the sparrow was calculated.The initial weight and threshold are used for network training, and the overall mean square error (MSE) of the training set and the test set is taken as the fitness function.The smaller the fitness function value is, the more accurate the training is.The sparrow position is gradually updated and iterated to find the global optimal solution, that is, the optimal sparrow individual.The optimal individual position of the output is used as the weight and threshold of the neural network for training and prediction.

Figure 1 .
Figure 1.Optimization of BP neural network flow chart via sparrow search algorithm.

Figure 2 .
Figure 2. Results of model prediction before and after SSA optimization.

Figure 2 .
Figure 2. Results of model prediction before and after SSA optimization.

Table 1 .
Forecast error table under different activation functions.

Table 2 .
Forecast error table under different training functions.

Table 3 .
Forecast error table under different hidden layers.

Table 4 .
Forecast error table under different hidden layers after SSA optimization.