Foaming agent prediction model training method and foaming agent filling method

By constructing a foaming agent prediction model and using random forests and genetic algorithms to optimize parameters, the problem of difficulty in determining the amount of foaming agent to be added in foam drainage gas production has been solved, stabilizing and increasing gas well production, reducing human intervention, and ensuring This ensures the accuracy and timeliness of the filling amount.

CN118690631APending Publication Date: 2024-09-24PETROCHINA CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202310301330.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-03-24
Publication Date
2024-09-24

AI Technical Summary

Technical Problem

The amount of foaming agent added in the existing foam drainage gas production process is difficult to determine scientifically and is greatly affected by human experience, resulting in serious liquid accumulation in gas wells, limited production capacity, and lagging adjustment of the filling system, affecting the stable and increased production of gas wells.

Method used

By obtaining gas well production data, a foaming agent prediction model is constructed, using random forest algorithms and genetic algorithms to extract key characteristic parameters, optimize model parameters, and achieve accurate prediction and automatic adjustment of the foaming agent injection amount.

Benefits of technology

It improves the accuracy and speed of the foaming agent prediction model, reduces human intervention, ensures the stability of gas well production and the effect of increasing production, and adjusts the injection amount in a timely manner to avoid gas well water flooding and production shutdown.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118690631A
    Figure CN118690631A
Patent Text Reader

Abstract

The invention relates to a foaming agent prediction model training method and a foaming agent filling method.The training method comprises the steps that a sample data set is obtained, and the sample data set comprises multiple pieces of gas well production data; performing feature construction processing on the sample data set to obtain feature parameters of a specified dimension; key feature parameters are extracted from the feature parameters of the specified dimension according to a preset feature extraction algorithm, a key feature parameter set is obtained, and the relevancy between the key feature parameters and the foaming agent meets a preset relevancy requirement; model training is carried out according to the key feature parameter set and a random forest algorithm, a foaming agent prediction model is obtained, the foaming agent prediction model is used for outputting the foaming agent filling amount according to data to be measured, and the dimension of the data to be measured corresponds to the dimension of the key feature parameters. The method can improve the prediction accuracy of the foaming agent filling amount.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the technical field of gas production engineering, and in particular to a foaming agent prediction model training method and a foaming agent injection method. Background Art

[0002] Liquid accumulation in gas wells is a common problem faced by gas field exploitation at home and abroad, and drainage gas production is an effective means to solve this problem. Foam drainage gas production is the most economical, effective and widely used gas production technology. At present, foam drainage gas production technology has become one of the important means to increase production, tap potential and stabilize production in some water-bearing gas fields (wells).

[0003] With the development of the Internet of Things, more and more gas mines have adopted automatic filling devices for foam drainage and gas production, realizing functions such as automatic mixing of reagents and automatic filling, greatly saving manpower and material resources.

[0004] However, the formulation of the foaming agent injection system is still mainly based on the workers' experience and is obviously affected by human experience. There are phenomena such as excessive foaming agent injection or unreasonable system. In addition, the adjustment of the gas well injection system is usually issued by production technicians, and there is often a time lag. The gas well has already accumulated liquid seriously, and relevant measures have not been taken, so the gas well production capacity is seriously affected, and even the gas well is flooded and shut down. Summary of the invention

[0005] In order to overcome the problems existing in the related art, the present disclosure provides a foaming agent prediction model training method and a foaming agent filling method.

[0006] According to a first aspect of an embodiment of the present disclosure, a method for training a foaming agent prediction model is provided, comprising: acquiring a sample data set, wherein the sample data set comprises a plurality of gas well production data;

[0007] Performing feature construction processing on the sample data set to obtain feature parameters of a specified dimension;

[0008] Extracting key feature parameters from the feature parameters of the specified dimension according to a preset feature extraction algorithm to obtain a key feature parameter set, wherein the correlation between the key feature parameters and the foaming agent meets a preset correlation requirement;

[0009] Model training is performed according to the key feature parameter set and the random forest algorithm to obtain a foaming agent prediction model, wherein the foaming agent prediction model is used to output the foaming agent filling amount according to the data to be tested, wherein the dimension of the data to be tested corresponds to the dimension of the key feature parameter.

[0010] Optionally, the performing model training according to the key feature parameter set and the random forest algorithm to obtain the foaming agent prediction model includes:

[0011] Randomly resampling the key feature parameter set to obtain a plurality of sample subsets, wherein the capacity of each sample subset in the plurality of sample subsets is the same as the capacity of the key feature parameter set;

[0012] Performing model training based on the random forest algorithm and each sample subset to obtain a decision tree model corresponding to each sample subset, and determining an initial random forest model based on all decision tree models;

[0013] Acquire test data, and input the test data into each decision tree model respectively to obtain a predicted value output by each decision tree model; wherein the dimension of the test data corresponds to the dimension of the key feature parameter set;

[0014] Determining a prediction error value according to the prediction value output by each decision tree model;

[0015] If the prediction error value meets the preset error condition, the initial random forest model is determined as the foaming agent prediction model.

[0016] Optionally, the method further comprises:

[0017] If the prediction error value does not meet the preset error condition, the specified model parameters in the initial random forest model are optimized by a preset genetic algorithm to obtain an optimized model;

[0018] Based on the optimized model, return to execute the operation of obtaining test data, input the test data into each decision tree model respectively, and obtain the predicted value output by each decision tree model, until the prediction error value meets the preset error condition, and it is determined that the training of the foaming agent prediction model is completed.

[0019] Optionally, the prediction error value includes a root mean square error, and the parameter optimization process is performed on the specified model parameters in the initial random forest model by a preset genetic algorithm to obtain an optimized model, including:

[0020] Determine a fitness value according to the root mean square error;

[0021] If it is determined according to the fitness value that the genetic algorithm does not meet the termination condition, then the fitness value is updated to obtain an updated fitness value;

[0022] Determining target values ​​of specified model parameters of the initial random forest model based on the updated fitness value;

[0023] The current values ​​of the specified model parameters of the initial random forest model are adjusted to the target values ​​to obtain the optimized model.

[0024] Optionally, the method further comprises:

[0025] If the fitness value is within a specified range, determining that the genetic algorithm meets a termination condition;

[0026] If the optimized model returns to execute the operation of obtaining test data, inputting the test data into each decision tree model respectively, and the number of executions of the operation of obtaining the predicted value output by each decision tree model reaches a specified number of times, it is determined that the genetic algorithm meets the termination condition.

[0027] Optionally, the specified model parameters of the initial random forest model include: the number of decision trees, the maximum depth of the tree, the minimum number of samples for internal node partitioning, the minimum number of samples for leaf nodes, and the maximum number of features.

[0028] Optionally, extracting key feature parameters from the feature parameters of the specified dimension according to a preset feature extraction algorithm includes:

[0029] Determine, according to the extreme gradient boosting algorithm, the degree of correlation between the characteristic parameters of each dimension of the characteristic parameters of the specified dimensions and the foaming agent;

[0030] The first N characteristic parameters with the greatest correlation with the foaming agent among the characteristic parameters of the specified dimension are determined as the key characteristic parameters, wherein N is a positive integer.

[0031] Optionally, the gas well production data includes instantaneous daily production, yesterday's average production, metered static pressure, metered differential pressure, metered temperature, wellhead oil pressure, wellhead casing pressure and bottom hole liquid accumulation.

[0032] Optionally, performing feature construction processing on the sample data set to obtain feature parameters of a specified dimension includes:

[0033] Preprocessing the sample data set to obtain a preprocessed sample data set; wherein the preprocessing includes missing value filtering processing, outlier filtering processing, duplicate value filtering processing, and wavelet denoising processing;

[0034] Perform feature construction processing on the preprocessed sample data set to obtain feature parameters of specified dimensions.

[0035] According to a second aspect of an embodiment of the present disclosure, a method for adding a foaming agent is provided. The method is applied to the foaming agent prediction model of the first aspect, and the method comprises:

[0036] In the process of foam drainage and gas production, the data to be measured is obtained; wherein the dimension of the data to be measured corresponds to the dimension of the key characteristic parameter;

[0037] Inputting the data to be measured into the foaming agent prediction model, and obtaining the foaming agent filling amount output by the foaming agent prediction model;

[0038] Based on the foaming agent injection amount, the foaming agent is injected into the gas well.

[0039] The technical solution provided by the embodiments of the present disclosure may include the following beneficial effects: by acquiring a sample data set, wherein the sample data set includes a plurality of gas well production data; performing feature construction processing on the sample data set to obtain feature parameters of a specified dimension; extracting key feature parameters from the feature parameters of the specified dimension according to a preset feature extraction algorithm to obtain a key feature parameter set, wherein the correlation between the key feature parameters and the foaming agent meets the preset correlation requirement; performing model training according to the key feature parameter set and the random forest algorithm to obtain a foaming agent prediction model, the foaming agent prediction model is used to output the foaming agent injection amount according to the data to be tested, wherein the dimension of the data to be tested corresponds to the dimension of the key feature parameters. In other words, after performing feature construction processing on the sample data set, the key feature parameters whose correlation with the foaming agent meets the preset correlation requirement are extracted to train the prediction model, thereby reducing the influence of irrelevant or redundant parameters on the prediction results of the foaming agent prediction model, thereby improving the prediction accuracy of the model and reducing the complexity of the foaming agent prediction model. In addition, the foaming agent prediction model is trained by the random forest algorithm. Since the random forest algorithm uses an integrated algorithm, its accuracy is better than most single algorithms and its accuracy is high. In addition, samples are randomly extracted and features are randomly extracted. The random forest is not easy to fall into overfitting and can process very high-dimensional data. Each decision tree is independent of each other, so the training speed is very fast, which can ensure that the trained foaming agent prediction model can predict the foaming agent addition amount in a timely and accurate manner.

[0040] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] The accompanying drawings are used to provide a further understanding of the present disclosure and constitute a part of the specification. Together with the following specific embodiments, they are used to explain the present disclosure but do not constitute a limitation of the present disclosure. In the accompanying drawings:

[0042] Figure 1 is a flow chart of a method for training a foaming agent prediction model according to an exemplary embodiment;

[0043] Figure 2 is based on Figure 1 Parameter importance score distribution diagram of each characteristic parameter shown in the embodiment;

[0044] Figure 3 is based on Figure 1The corresponding relationship diagrams of the number of characteristic parameters shown in the embodiment and the mean absolute error and the root mean square error respectively;

[0045] Figure 4 is a flow chart of a method for training a foaming agent prediction model according to another exemplary embodiment;

[0046] Figure 5 is based on Figure 4 A flowchart of the construction of the RF model shown in the embodiment;

[0047] Figure 6 is based on Figure 4 The flowchart of optimizing the initial random forest model by genetic algorithm shown in the embodiment;

[0048] Figure 7 is based on Figure 4 A specific implementation flow chart of steps 210 to 270 shown in the embodiment;

[0049] Figure 8 is based on Figure 4 A schematic diagram showing the comparison results of the prediction effects of various models shown in the embodiment;

[0050] Fig. 9 is a flow chart of a method for adding a foaming agent according to an exemplary embodiment;

[0051] Fig.10 is a block diagram of a foaming agent prediction model training device according to an exemplary embodiment;

[0052] Fig.11 is a block diagram of a foaming agent filling device according to an exemplary embodiment;

[0053] Fig.12 It is a functional block diagram of an electronic device shown in an exemplary embodiment. DETAILED DESCRIPTION

[0054] The specific implementation of the present disclosure is described in detail below in conjunction with the accompanying drawings. It should be understood that the specific implementation described herein is only used to illustrate and explain the present disclosure, and is not used to limit the present disclosure.

[0055] It should be noted that all actions of acquiring signals, information or data in the present disclosure are carried out in compliance with the relevant data protection laws and policies of the country where the device is located and with the authorization given by the owner of the corresponding device.

[0056] First, the terms involved in this application are explained:

[0057] Random forest (RF) refers to a classifier that uses multiple trees to train and predict samples.

[0058] eXtreme Gradient Boosting (XGBoost) is a high-performance feature selection algorithm.

[0059] Genetic Algorithm (GA) is a search algorithm used to solve optimization problems.

[0060] Foam drainage gas production technology is currently the most economical, effective and widely used gas production technology. Therefore, how to scientifically and timely determine the foam drainage system and how to use the changes in gas well production data to reasonably adjust the amount of foaming agent (hereinafter also referred to as foam drainage agent) are key technologies in the foam drainage gas production process and are also urgent problems to be solved in order to achieve intelligent production of gas wells. By using the historical production data of gas wells to build a big data prediction model for the amount of foaming agent, intelligent injection of foam drainage gas production in gas wells can be realized, achieving the positive effects of stabilizing and increasing the production of gas wells.

[0061] With the rapid development of information technology, all major gas fields have carried out corresponding intelligent technology research on drainage and gas production processes. In some related technologies, based on the traditional oil-casing pressure difference to estimate liquid accumulation, a liquid accumulation depth analysis method based on five indicators such as flow type and liquid holding rate has been established, which can automatically prompt the liquid accumulation amount of liquid-accumulated wells and wellbores, and then form an intelligent injection mode. In other related technologies, the cluster gas well intelligent foam drainage and gas production process is applied to analyze the changing trends of production parameters such as oil-casing pressure, temperature, and gas volume, and realize intelligent foam drainage. In addition, with the help of 3G wireless communication, the intelligent addition and injection of foam drainage agents has been successfully realized. In some other related technologies, the theoretical calculation method and the production practice method are combined to quickly determine whether the gas well is liquid-accumulated, forming some gas field matching foam drainage process technologies. In some other related technologies, by analyzing the source of gas well liquid and the gas-liquid two-phase flow pattern, a method for judging the gas well liquid accumulation is established with reference to the critical flow rate, the calculated bottom hole flow pressure and bottom hole pressure difference, the wellbore flow state and production dynamics, and the amount of foaming agent added is determined to be 0.5% to 1% of the liquid accumulation. The Yanchang gas field uses solar panels and wind power generation to supply electricity, and the filling operation is automatically completed by the computer system in a timely and quantitative manner. In some other related technologies, by fixing the pump displacement and the foaming agent preparation ratio, the filling time of each well can be adjusted remotely to achieve intelligent foaming agent filling.

[0062] However, although the above method realizes the intelligent injection of foaming agent, it does not scientifically determine the dosage according to the actual gas well production situation, or only determines the dosage of foaming agent by considering several production parameters such as bottom hole liquid accumulation, casing pressure, temperature, etc., and fails to comprehensively use gas well production parameters to predict dosage. There is a phenomenon of obvious reliance on workers' experience or unreasonable injection system, which leads to inaccurate and untimely injection of foaming agent into gas wells.

[0063] The foaming agent prediction model training method and foaming agent injection method provided in this application are intended to solve the above technical problems of the prior art.

[0064] Figure 1 is a flow chart of a method for training a foaming agent prediction model according to an exemplary embodiment. Figure 1 As shown, the method may include the following steps:

[0065] 110. Obtain a sample data set, wherein the sample data set includes production data of multiple gas wells.

[0066] Exemplarily, the foaming agent prediction model training method can be applied to an electronic device, which may be a server, a mobile terminal, etc., which is not limited here.

[0067] In some embodiments, the gas well production data includes one or more of instantaneous daily production, yesterday's average production, metered static pressure, metered differential pressure, metered temperature, wellhead oil pressure, wellhead casing pressure, and bottom hole liquid accumulation. It is understandable that the above production specifically refers to the production of the gas mine corresponding to the gas well, such as the natural gas production of a natural gas well.

[0068] For example, an information collection device may be provided at the gas well end, and the information collection device may be used to collect the gas well production data, and upload the collected gas well production data to the electronic device in real time, and the electronic device may store the gas well production data in a corresponding database. When training the foaming agent prediction model, the above-mentioned multiple gas well production data may be extracted from the database, and the above-mentioned multiple gas well production data may be used as sample data to obtain a sample data set.

[0069] 120. Perform feature construction processing on the sample data set to obtain feature parameters of specified dimensions.

[0070] For example, the staff can use the electronic device to construct the 8-dimensional original features of the instantaneous daily production, yesterday's average production, metering static pressure, metering differential pressure, metering temperature, wellhead oil pressure, wellhead casing pressure and bottom hole liquid accumulation in the sample data set according to production experience and actual needs, so as to obtain the feature parameters of the specified dimension. Optionally, the specified dimension can be 36 dimensions.

[0071] As a more specific example, after constructing the oil-casing pressure difference feature, sliding window feature, change rate feature, differential feature, and binning and hierarchical feature, the above 8-dimensional original features can be constructed into 36-dimensional feature parameters. The specific 36-dimensional feature parameters can be shown in Table 1:

[0072] Table 1

[0073]

[0074]

[0075] 130. Extract key feature parameters from the feature parameters of the above-mentioned specified dimensions according to a preset feature extraction algorithm to obtain a key feature parameter set, wherein the correlation between the above-mentioned key feature parameters and the foaming agent meets the preset correlation requirement.

[0076] In some implementations, specific implementations of step 130 may include:

[0077] According to the extreme gradient boosting algorithm, the correlation between the characteristic parameters of each dimension of the characteristic parameters of the specified dimensions and the foaming agent is determined.

[0078] The first N characteristic parameters with the greatest correlation with the foaming agent among the characteristic parameters of the specified dimensions are characteristic parameters that meet the preset relevance requirements and are determined as the key characteristic parameters, wherein N is a positive integer.

[0079] Among them, the correlation between the characteristic parameter and the foaming agent can represent the sensitivity of the characteristic parameter to the foaming agent. The higher the correlation, the higher the sensitivity. It can also be understood that the higher the correlation between the characteristic parameter and the foaming agent, the greater the impact of the foaming agent on the characteristic parameter.

[0080] Exemplarily, the electronic device can determine the correlation between the characteristic parameters of each dimension of the characteristic parameters of the above 36 dimensions and the above foaming agent according to the XGBoost algorithm, and sort them in order from high to low according to the correlation, wherein the characteristic parameter with a higher correlation indicates that the importance of the characteristic parameter (hereinafter also referred to as the importance score) is higher. As an example, in order to simplify the foaming agent prediction model, shorten the training time, avoid overfitting to improve the prediction accuracy, the electronic device uses the XGBoost algorithm to extract characteristic parameters with a high correlation with the foaming agent. After adjusting the parameters by the grid search method, the number of decision trees of the XGBoost model is set to 500, the maximum depth of the tree is 12, the minimum leaf sample weight is 2, the minimum loss function descent value is 0.02, the sample random sampling ratio is 0.8, the random extraction feature ratio is 0.8, the leaf node complexity coefficient of the regular term is γ=0, the penalty coefficient λ=10, and the learning rate is 0.05. The importance scores of all characteristic parameters can be obtained in descending order as follows: Figure 2 As shown. Figure 2 In , the ordinate represents the parameter number of the parameter feature, and the abscissa represents the importance score of the parameter feature.

[0081] In some embodiments, since too many or too few feature parameters will affect the prediction effect of the trained bubble agent prediction model, the prediction accuracy evaluation of the bubble agent prediction model trained under different numbers of feature parameters can be tested, and the final number of feature parameters can be determined based on the prediction accuracy evaluation. For example, Figure 3 As shown, Figure 3 To evaluate the prediction accuracy of the bubble agent prediction model obtained by selecting different numbers of characteristic parameters after sorting. Figure 3 The horizontal axis is the number of characteristic parameters, and the vertical axis is the mean absolute error and root mean square error. Figure 3 It can be seen that, among the feature parameters of 36 dimensions sorted by correlation, when the first 8 feature parameters are taken as model training data (i.e., the above-mentioned key feature parameters), the mean absolute error (MAE) and root mean square error (RMSE) of the trained model are minimized, so the first 8 feature parameters are used as the key feature parameters of the bubble agent prediction model, where the bubble agent prediction model can be an RF model. Exemplarily, the key feature parameter set composed of the first 8 feature parameters selected from the sorted feature parameters can be shown in Table 2:

[0082] Table 2

[0083]

[0084] According to Table 2, the selected key characteristic parameters include metering temperature, 1-day sliding window characteristics of casing pressure, 1-day sliding window characteristics of bottom hole liquid accumulation, 1-day sliding window characteristics of oil pressure, yesterday's average production, 1-day sliding window characteristics of oil-casing pressure difference, 12-hour sliding window characteristics of casing pressure, and 1-day sliding window characteristics of instantaneous daily production.

[0085] 140. Perform model training based on the above key feature parameter set and random forest algorithm to obtain a foaming agent prediction model, wherein the foaming agent prediction model is used to output the foaming agent filling amount according to the data to be tested, wherein the dimension of the data to be tested corresponds to the dimension of the above key feature parameters.

[0086] Continuing with the above example, the key feature parameter set in Table 2 can be trained through the random forest algorithm to obtain a foaming agent prediction model.

[0087] It can be seen that in this embodiment, by obtaining a sample data set, wherein the sample data set includes a plurality of gas well production data; performing feature construction processing on the sample data set to obtain feature parameters of a specified dimension; extracting key feature parameters from the feature parameters of the specified dimension according to a preset feature extraction algorithm to obtain a key feature parameter set, wherein the correlation between the key feature parameters and the foaming agent meets the preset correlation requirement; performing model training according to the key feature parameter set and the random forest algorithm to obtain a foaming agent prediction model, the foaming agent prediction model is used to output the foaming agent injection amount according to the data to be tested, wherein the dimension of the data to be tested corresponds to the dimension of the key feature parameters. In other words, after performing feature construction processing on the sample data set, the key feature parameters whose correlation with the foaming agent meets the preset correlation requirement are extracted to train the prediction model, thereby reducing the influence of irrelevant or redundant parameters on the prediction results of the foaming agent prediction model, thereby improving the prediction accuracy of the model and reducing the complexity of the foaming agent prediction model. In addition, the foaming agent prediction model is trained by the random forest algorithm. Since the random forest algorithm uses an integrated algorithm, its accuracy is better than most single algorithms and its accuracy is high. In addition, samples are randomly extracted and features are randomly extracted. The random forest is not easy to fall into overfitting and can process very high-dimensional data. Each decision tree is independent of each other, so the training speed is very fast, which can ensure that the trained foaming agent prediction model can predict the foaming agent addition amount in a timely and accurate manner.

[0088] Figure 4 is a flow chart of a method for training a foaming agent prediction model according to an exemplary embodiment. Figure 4 As shown, the method may include the following steps:

[0089] 210. Obtain a sample data set, wherein the sample data set includes production data of multiple gas wells.

[0090] The specific implementation of step 210 may refer to step 110, so it will not be described here in detail.

[0091] 220. Perform feature construction processing on the sample data set to obtain feature parameters of specified dimensions.

[0092] In some implementations, specific implementations of step 220 may include:

[0093] 221. Preprocess the sample data set to obtain a preprocessed sample data set; wherein the preprocessing includes missing value filtering, outlier filtering, duplicate value filtering, and wavelet denoising.

[0094] Missing values ​​refer to clustering, grouping, deletion or truncation of data due to lack of information in rough data. It means that the value of one or some attributes in the existing data set is incomplete.

[0095] Herein, an outlier may refer to a measurement value in a group of measurement values ​​whose deviation from the mean value exceeds two times the standard deviation.

[0096] 222. Perform feature construction processing on the preprocessed sample data set to obtain feature parameters of specified dimensions.

[0097] In this embodiment, the sample data set is preprocessed to obtain a preprocessed sample data set; wherein the preprocessing includes missing value filtering, outlier filtering, duplicate value filtering, and wavelet denoising, thereby ensuring the quality of the samples used to train the model, and further ensuring the prediction accuracy of the trained prediction model.

[0098] 230. Randomly resample the key feature parameter set to obtain multiple sample subsets, wherein the capacity of each sample subset in the multiple sample subsets is the same as the capacity of the key feature parameter set.

[0099] 240. Perform model training based on the random forest algorithm and each of the sample subsets to obtain a decision tree model corresponding to each of the sample subsets, and determine an initial random forest model based on all the decision tree models.

[0100] 250. Obtain test data, and input the test data into each decision tree model respectively to obtain a predicted value output by each decision tree model; wherein the dimension of the test data corresponds to the dimension of the key feature parameter set.

[0101] Exemplarily, steps 230 to 250 can be regarded as the construction process of the RF model (i.e., the initial random forest model). The specific flow of the construction process can be as follows: Figure 5 As shown:

[0102] First, the above key feature parameter set can be used as the original training data set, and then bootstrap random resampling is used to establish sample subsets to obtain n subsets with the same capacity as the original training set (such as Figure 5 The sample subsets X1 to sample subsets Xn in the.

[0103] Then, for each of the n sample subsets, a decision tree model corresponding to the sample subset is established. For details, please refer to Figure 5 , each tree randomly selects a specified number of features for node splitting, and each time the best feature is selected for splitting based on information gain, and no pruning is required. n decision tree models are trained (such as Figure 5 Regression model M1 to regression model Mn).

[0104] Afterwards, the electronic device can call the pre-saved test data from the memory and input the test data into each of the above decision tree models to obtain the predicted value output by each decision tree model (such as Figure 5 The predicted value Y1 to predicted value Yn).

[0105] Finally, the electronic device may take the average value of the predicted values ​​Y1 to Yn as the prediction result of the RF model.

[0106] 260. Determine the prediction error value based on the prediction value output by each of the above decision tree models.

[0107] Exemplarily, the electronic device may compare the prediction value output by each decision tree model with a preset reference prediction value to obtain a comparison result, and determine a prediction error value according to the comparison result. Optionally, the prediction error value may include a mean absolute error and a root mean square error.

[0108] 270. If the above prediction error value meets the preset error condition, the above initial random forest model is determined as the above foaming agent prediction model.

[0109] Continuing with the above example, if the prediction error value is within the specified error range, it can be determined that the above prediction error value meets the preset error condition, indicating that the foaming agent prediction model training is completed, and the initial random forest model can be determined as the above foaming agent prediction model.

[0110] In some embodiments, the above method further comprises:

[0111] If the above prediction error value does not meet the preset error condition, the specified model parameters in the above initial random forest model are optimized by a preset genetic algorithm to obtain an optimized model;

[0112] Based on the optimized model, return to execute the above-mentioned operation of obtaining test data, input the above-mentioned test data into each decision tree model respectively, and obtain the predicted value output by each decision tree model, until the above-mentioned prediction error value meets the preset error condition, and it is determined that the training of the above-mentioned foaming agent prediction model is completed.

[0113] In some embodiments, the prediction error value includes a root mean square error, and the parameter optimization process of the specified model parameters in the initial random forest model using a preset genetic algorithm to obtain an optimized model may include:

[0114] The fitness value is determined based on the above root mean square error.

[0115] If it is determined according to the fitness value that the genetic algorithm does not meet the termination condition, the fitness value is updated to obtain an updated fitness value.

[0116] Based on the updated fitness values, target values ​​of the specified model parameters of the initial random forest model are determined.

[0117] The current values ​​of the specified model parameters of the above initial random forest model are adjusted to the above target values ​​to obtain the above optimized model.

[0118] For example, Figure 6 As shown, genetic algorithm (GA) is a random global search and optimization method developed by imitating the natural selection and genetic variation mechanism of nature. Its main principle can be described as, the decision variables of the problem are written as "chromosomes" through binary coding, a group of "chromosomes" are initialized with random numbers in advance and called populations, and then each "chromosome" is decoded and evaluated with a fitness function, and the encoding with high fitness is selected and copied, and then crossover and mutation are performed with a certain probability, and finally a new population (offspring population) is generated, and the above process is repeated until the termination condition is met. In this embodiment, the RF model (i.e., the above-mentioned initial random forest model) is used as the optimization target, and its root mean square error can be used as the fitness value, and 5 decision parameters (i.e., the above-mentioned specified model parameters) need to be optimized, which are the number of decision trees, the maximum depth of the tree, the minimum number of samples for internal node division, the minimum number of samples for leaf nodes, and the maximum number of features.

[0119] Please refer again Figure 6 , the process of optimizing the initial random forest model through genetic algorithm can specifically include:

[0120] Random parameters are selected within the boundaries of the pre-set decision parameters, and the random parameters are encoded to generate an initial population, wherein the initial population includes a "chromosome" obtained by encoding the selected random parameters, and then the "chromosome" included in the initial population is decoded to obtain the corresponding model parameters, and the specified model parameters of the initial random forest model are replaced with the model parameters corresponding to the "chromosome" (i.e. Figure 6 The parameters in the target function are input into the objective function), and the updated RF model is obtained. Then, the root mean square error is obtained based on the prediction results of the updated RF model, and the root mean square error is determined as the fitness value.

[0121] Then, determine whether the fitness value meets the termination condition (such as the maximum number of iterations). If it does, decode the "chromosomes" in the current population to obtain the optimal parameters of the specified model parameters. If it does not meet the requirements, select a relatively cross difference to obtain a new population (i.e., obtain a new "chromosome"), and then decode the new "chromosome" and input it into the objective function to calculate the fitness value, and then return to execute the step of determining whether the fitness value meets the termination condition until the fitness value meets the termination condition. Each time the step of selecting a relatively cross difference to obtain a new population can be regarded as an iteration. When the fitness value meets the termination condition, it indicates that the specified model parameters are optimal, and it can also indicate that the training of the foaming agent prediction model is completed.

[0122] As a method, the specified model parameters of the initial random forest model include one or more combinations of the number of decision trees, the maximum depth of the tree, the minimum number of samples for internal node partitioning, the minimum number of samples for leaf nodes, and the maximum number of features.

[0123] In some embodiments, the above method further comprises:

[0124] If the fitness value is within a specified range, it is determined that the genetic algorithm meets the termination condition.

[0125] If the above-mentioned optimized model returns to execute the above-mentioned acquisition of test data, inputs the above-mentioned test data into each decision tree model respectively, and the number of executions of the operation of obtaining the predicted value output by each decision tree model reaches the specified number of times, it is determined that the above-mentioned genetic algorithm meets the termination condition.

[0126] Using the above example, when the number of iterations reaches the specified number, it is determined that the above genetic algorithm meets the termination condition.

[0127] Exemplarily, the optimization results of the RF model using the genetic algorithm show that the minimum RMSE is 0.03165, and the corresponding RF optimal parameter population is shown in Table 3.

[0128] Table 3

[0129] Parameter name meaning Optimal value n_estimators Number of decision trees 194 max_depth Maximum depth of the tree 65 min_samples_split Minimum number of samples for internal node partitioning 2 min_samples_leaf Minimum number of samples for leaf nodes 1 max_features Maximum number of features 3

[0130] It can be seen from Table 3 that the specified model parameters of the RF model can be accurately optimized by the genetic algorithm.

[0131] As a more specific example, the specific implementation process of step 210 to step 270 is as follows: Figure 7 As shown:

[0132] First, you can get a sample dataset and use it as Figure 7 The original training data set in . The original data set includes eight gas well production data: instantaneous daily production, yesterday's average production, metering static pressure, metering differential pressure, metering temperature, wellhead oil pressure, wellhead casing pressure, and bottom hole liquid accumulation.

[0133] Then, the data is preprocessed to obtain preprocessed data. The preprocessing may include one or more combinations of missing value, outlier, duplicate value filtering and wavelet denoising. Feature construction is then performed based on the preprocessed data to obtain 36-dimensional feature parameters. Thereafter, based on XGBoost feature selection, 8-dimensional key feature parameters are selected from the 36-dimensional feature parameters.

[0134] Then, the RF prediction model is trained based on the 8-dimensional key characteristic parameters, and the model is optimized by the GA algorithm during the training process. Finally, the optimized RF prediction model, namely the foaming agent prediction model, is obtained.

[0135] Finally, the test sample is input into the optimized RF prediction model to obtain the prediction result output by the optimized RF prediction model.

[0136] Exemplarily, the following examples are given to further illustrate the model training method of this embodiment.

[0137] Taking the production data of a gas well in the test gas mine as an example, a comparative analysis and verification of the proposed prediction method was carried out. 20% of the original data of the gas well, a total of more than 20,000 data points, were used as the validation set. In order to verify the superior prediction performance of the improved random forest optimization algorithm, four models, XGBoost, RF, XGBoost-RF, and XGBoost-RF-GA, were used for comparative analysis. Among them, the XGBoost model and the RF model used all the feature numbers, the XGBoost-RF and XGBoost-RF-GA models used the screened 8-dimensional feature parameter set, and the XGBoost-RF-GA model used the genetic algorithm to optimize the parameters. The mean absolute error (MAE) and root mean square error (RMSE) were selected for effect comparison and analysis. The comparison results are shown in the figure below. Figure 8 As shown. Among them, Figure 8The horizontal axis in the figure represents different prediction models, and the vertical axis represents the corresponding MAE and RMSE of different prediction models. Figure 8 It can be seen that the RF model has better prediction effect than the XGBoost model because the RF algorithm has advantages in processing high-dimensional data; the MAE and RMSE of the XGBoost-RF model are lower than those of the simple XGBoost model and the RF model, indicating that the XGBoost-RF model that uses XGBoost to extract key feature parameters reduces the complexity of the model, has higher accuracy and better effect; and the XGBoost-RF-GA model obtained by further optimizing the XGBoost-RF model parameters using genetic algorithm has significantly reduced MAE and RMSE, both reaching the minimum values ​​of 0.0028 and 0.0315, respectively, achieving accurate prediction of the amount of foaming agent added.

[0138] In summary, through comparative analysis and verification of the proposed prediction method, the results show that the foaming agent prediction model trained by the model training method of this embodiment has better prediction accuracy and robustness for the foaming agent injection amount, and plays a positive role in guiding the field production of gas wells.

[0139] Fig. 9 is a flow chart of a foaming agent filling method according to an exemplary embodiment. The foaming agent filling method is applied to the foaming agent prediction model in the above embodiment. Fig. 9 As shown, the method may include the following steps:

[0140] 310. In the process of foam drainage and gas production, obtain the data to be measured; wherein the dimension of the data to be measured corresponds to the dimension of the key characteristic parameter.

[0141] For example, please refer to Table 2 again, the data to be measured may include the metering temperature, the sliding window characteristics of the casing pressure for one day, the sliding window characteristics of the bottom hole liquid accumulation for one day, the sliding window characteristics of the oil pressure for one day, the average production yesterday, the sliding window characteristics of the oil casing pressure difference for one day, the sliding window characteristics of the casing pressure for 12 hours, and the sliding window characteristics of the instantaneous daily production for one day in Table 2. The electronic device can directly or indirectly obtain the above-mentioned data to be measured through various monitoring devices set at the gas well end.

[0142] 320. Input the data to be tested into the foaming agent prediction model, and obtain the foaming agent filling amount output by the foaming agent prediction model.

[0143] Exemplarily, the electronic device may input the data to be measured into the foaming agent prediction model, and obtain the foaming agent filling amount output by the foaming agent prediction model.

[0144] 330. Based on the above foaming agent injection amount, inject foaming agent into the gas well.

[0145] For example, the electronic device can output the amount of foaming agent added, so as to instruct the staff to add the foaming agent to the gas well through the amount of foaming agent added. The way of outputting the amount of foaming agent added can be through screen display or voice broadcast, etc. Optionally, the electronic device can also generate a corresponding filling instruction according to the amount of foaming agent added, and control the foaming agent filling device through the filling instruction to add the foaming agent to the gas well.

[0146] Among them, the foaming agent prediction model used in the foaming agent injection method of this embodiment relies on seven gas well production data, namely, instantaneous daily production, yesterday's average production, metered static pressure, metered differential pressure, metered temperature, wellhead oil pressure and wellhead casing pressure, combined with the real-time calculated value of bottom hole liquid accumulation to realize foaming agent dosage prediction. After feature construction, the dimension reaches 36 dimensions, and characteristic parameters with high sensitivity to foaming agents are extracted, reducing the influence of irrelevant or redundant parameters on the foaming agent prediction results, thereby improving the prediction accuracy of the model.

[0147] Since eXtreme Gradient Boosting (XGBoost) is an excellent feature selection algorithm and has been effectively applied in various fields, the foaming agent injection method of this embodiment uses the XGBoost algorithm to screen features and uses a high-importance feature parameter set to input the RF model.

[0148] In addition, the genetic algorithm (GA) is a search algorithm used to solve optimization problems and is widely used, so the foaming agent injection method of this embodiment uses it to optimize the random forest model to improve the accuracy and training speed.

[0149] To sum up, the foaming agent filling method of this embodiment proposes a random forest foam drainage and gas production dosage prediction method based on genetic algorithm optimization. First, the XGBoost algorithm is used to extract key feature parameters to reduce the complexity of the RF model and improve the accuracy; then the RF algorithm is used to establish a foam drainage and gas production dosage prediction model to achieve scientific and accurate prediction of the foaming agent dosage; then the genetic algorithm is used to optimize the RF model to reduce the prediction error; finally, the optimized RF model (i.e., the foaming agent prediction model) is used to predict the foaming agent filling amount, which can ensure the accuracy and timeliness of the prediction.

[0150] Fig.10 is a block diagram of a foaming agent prediction model training device according to an exemplary embodiment. Fig.10 As shown, the foaming agent prediction model training device 400 may include:

[0151] The sample data set acquisition module 410 is used to acquire a sample data set, wherein the sample data set includes a plurality of gas well production data.

[0152] The feature construction module 420 is used to perform feature construction processing on the sample data set to obtain feature parameters of a specified dimension.

[0153] The extraction module 430 is used to extract key feature parameters from the feature parameters of the above-mentioned specified dimensions according to a preset feature extraction algorithm to obtain a key feature parameter set, wherein the correlation between the above-mentioned key feature parameters and the foaming agent meets the preset correlation requirement.

[0154] The training module 440 is used to perform model training according to the above key feature parameter set and the random forest algorithm to obtain a foaming agent prediction model, wherein the foaming agent prediction model is used to output the foaming agent filling amount according to the data to be tested, wherein the dimension of the data to be tested corresponds to the dimension of the key feature parameter.

[0155] Fig.11 is a block diagram of a foaming agent filling device according to an exemplary embodiment. Fig.11 As shown, the foaming agent filling device 500 may include:

[0156] The test data acquisition module 510 is used to acquire the test data during the foam drainage and gas production process; wherein the dimension of the test data corresponds to the dimension of the key characteristic parameter.

[0157] The prediction module 520 is used to input the above-mentioned data to be tested into the above-mentioned foaming agent prediction model, and obtain the foaming agent filling amount output by the above-mentioned foaming agent prediction model.

[0158] The injection module 530 is used to inject the foaming agent into the gas well based on the foaming agent injection amount.

[0159] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0160] Fig.12 FIG. 7 is a block diagram of an electronic device 700 according to an exemplary embodiment. Fig.12 As shown, the electronic device 700 may include: a processor 701 , a memory 702 . The electronic device 700 may also include one or more of an input / output (I / O) interface 704 , and a communication component 705 .

[0161] The processor 701 is used to control the overall operation of the electronic device 700 to complete all or part of the steps in the above-mentioned foaming agent prediction model training method. The memory 702 is used to store various types of data to support the operation of the electronic device 700, and these data may include, for example, instructions for any application or method used to operate on the electronic device 700, and application-related data, such as contact data, sent and received messages, pictures, audio, video, etc. The memory 702 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The I / O interface 704 provides an interface between the processor 701 and other interface modules, and the above-mentioned other interface modules can be a keyboard, a mouse, buttons, etc. These buttons can be virtual buttons or physical buttons. The communication component 705 is used for wired or wireless communication between the electronic device 700 and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, 4G, NB-IOT, eMTC, or other 5G, etc., or a combination of one or more of them, is not limited here. Therefore, the corresponding communication component 705 may include: Wi-Fi module, Bluetooth module, NFC module, etc.

[0162] In an exemplary embodiment, the electronic device 700 may be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned foaming agent prediction model training method.

[0163] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned foaming agent prediction model training method or foaming agent filling method are implemented. For example, the computer-readable storage medium may be the above-mentioned memory 702 including program instructions, and the above-mentioned program instructions may be executed by the processor 701 of the electronic device 700 to complete the above-mentioned foaming agent prediction model training method or foaming agent filling method.

[0164] The preferred embodiments of the present disclosure are described in detail above in conjunction with the accompanying drawings; however, the present disclosure is not limited to the specific details in the above embodiments. Within the technical concept of the present disclosure, a variety of simple modifications can be made to the technical solution of the present disclosure, and these simple modifications all fall within the protection scope of the present disclosure.

[0165] It should also be noted that the various specific technical features described in the above specific embodiments can be combined in any suitable manner without contradiction. In order to avoid unnecessary repetition, the present disclosure will not further describe various possible combinations.

[0166] In addition, various embodiments of the present disclosure may be arbitrarily combined, and as long as they do not violate the concept of the present disclosure, they should also be regarded as the contents disclosed by the present disclosure.

Claims

1. A method for training a foaming agent prediction model, It is characterized in that include: Acquire a sample data set, wherein the sample data set includes production data of a plurality of gas wells; Performing feature construction processing on the sample data set to obtain feature parameters of a specified dimension; Extracting key feature parameters from the feature parameters of the specified dimension according to a preset feature extraction algorithm to obtain a key feature parameter set, wherein the correlation between the key feature parameters and the foaming agent meets a preset correlation requirement; Model training is performed according to the key feature parameter set and the random forest algorithm to obtain a foaming agent prediction model, wherein the foaming agent prediction model is used to output the foaming agent filling amount according to the data to be tested, wherein the dimension of the data to be tested corresponds to the dimension of the key feature parameter.

2. The method according to claim 1, It is characterized in that The method of performing model training according to the key feature parameter set and the random forest algorithm to obtain a foaming agent prediction model includes: Randomly resampling the key feature parameter set to obtain a plurality of sample subsets, wherein the capacity of each sample subset in the plurality of sample subsets is the same as the capacity of the key feature parameter set; Performing model training based on the random forest algorithm and each sample subset to obtain a decision tree model corresponding to each sample subset, and determining an initial random forest model based on all decision tree models; Acquire test data, and input the test data into each decision tree model respectively to obtain a predicted value output by each decision tree model; wherein the dimension of the test data corresponds to the dimension of the key feature parameter set; Determining a prediction error value according to the prediction value output by each decision tree model; If the prediction error value meets the preset error condition, the initial random forest model is determined as the foaming agent prediction model.

3. The method according to claim 2, It is characterized in that The method further comprises: If the prediction error value does not meet the preset error condition, the specified model parameters in the initial random forest model are optimized by a preset genetic algorithm to obtain an optimized model; Based on the optimized model, return to execute the operation of obtaining test data, input the test data into each decision tree model respectively, and obtain the predicted value output by each decision tree model, until the prediction error value meets the preset error condition, and it is determined that the training of the foaming agent prediction model is completed.

4. The method according to claim 3, It is characterized in that The prediction error value includes a root mean square error, and the parameter optimization process is performed on the specified model parameters in the initial random forest model by a preset genetic algorithm to obtain an optimized model, including: Determine a fitness value according to the root mean square error; If it is determined according to the fitness value that the genetic algorithm does not meet the termination condition, then the fitness value is updated to obtain an updated fitness value; Determining target values ​​of specified model parameters of the initial random forest model based on the updated fitness value; The current values ​​of the specified model parameters of the initial random forest model are adjusted to the target values ​​to obtain the optimized model.

5. The method according to claim 4, It is characterized in that The method further comprises: If the fitness value is within a specified range, determining that the genetic algorithm meets a termination condition; If the optimized model returns to execute the operation of obtaining test data, inputs the test data into each decision tree model respectively, and the number of executions of the operation of obtaining the predicted value output by each decision tree model reaches a specified number of times, it is determined that the genetic algorithm meets the termination condition.

6. The method according to claim 3, It is characterized in that The specified model parameters of the initial random forest model include: the number of decision trees, the maximum depth of the tree, the minimum number of samples for internal node partitioning, the minimum number of samples for leaf nodes, and the maximum number of features.

7. The method according to claim 1, It is characterized in that The step of extracting key feature parameters from the feature parameters of the specified dimension according to a preset feature extraction algorithm includes: Determine, according to the extreme gradient boosting algorithm, the degree of correlation between the characteristic parameters of each dimension of the characteristic parameters of the specified dimensions and the foaming agent; The first N characteristic parameters with the greatest correlation with the foaming agent among the characteristic parameters of the specified dimension are determined as the key characteristic parameters, wherein N is a positive integer.

8. The method according to any one of claims 1 to 7, It is characterized in that The gas well production data includes instantaneous daily production, yesterday's average production, metering static pressure, metering differential pressure, metering temperature, wellhead oil pressure, wellhead casing pressure and bottom hole liquid accumulation.

9. The method according to any one of claims 1 to 7, It is characterized in that The performing feature construction processing on the sample data set to obtain feature parameters of a specified dimension includes: Preprocessing the sample data set to obtain a preprocessed sample data set; wherein the preprocessing includes missing value filtering processing, outlier filtering processing, duplicate value filtering processing, and wavelet denoising processing; Perform feature construction processing on the preprocessed sample data set to obtain feature parameters of specified dimensions.

10. A method for adding a foaming agent, It is characterized in that Applied to the foaming agent prediction model according to any one of claims 1 to 9, the method comprises: In the process of foam drainage and gas production, the data to be measured is obtained; wherein the dimension of the data to be measured corresponds to the dimension of the key characteristic parameter; Inputting the data to be measured into the foaming agent prediction model, and obtaining the foaming agent filling amount output by the foaming agent prediction model; Based on the foaming agent injection amount, the foaming agent is injected into the gas well.

Citation Information

Cited By

  • Gas well foam drainage system optimization method, device and equipment based on machine learning and medium

    CN120337797A