A traffic prediction model training method, detection method, system and storage medium
By denoising the flow data at the beginning and end of natural gas pipelines and training neural networks, a flow prediction model was constructed, which solved the problem of difficulty in model training caused by the small number of leakage data samples, and achieved efficient and accurate natural gas leakage detection.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- PETROCHINA CO LTD
- Filing Date
- 2022-05-09
- Publication Date
- 2026-07-10
AI Technical Summary
Existing natural gas pipeline leak detection methods suffer from difficulties in model training due to the extremely limited number of leak data samples, which affects detection effectiveness. Furthermore, existing hardware methods are costly and pose a significant risk of environmental pollution.
By denoising the historical data of the inlet and outlet flow rates of a leak-free natural gas pipeline, the input and output vectors of a neural network are established, a flow prediction model is constructed, and the relevant structure and parameters are adjusted using a sliding window and a neural network training dataset to achieve flow prediction and leak detection.
It simplifies data measurement costs, improves detection accuracy, reduces environmental pollution risks, simplifies neural network structure, and improves leak detection accuracy.
Smart Images

Figure CN117009801B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for training a traffic prediction model, a method for testing it, a system for it, and a storage medium. Background Technology
[0002] Natural gas is a clean, efficient, and green energy source, and its storage and transportation primarily rely on pipelines. This method connects various regions through pipelines, forming a complex, large-scale pipeline transmission system. Natural gas pipelines are characterized by high pressure, flammability and explosiveness, wide distribution, long transmission lines, and deep underground burial. They are susceptible to corrosion, aging, natural disasters, and third-party sabotage, all of which can affect the normal operation of natural gas pipeline transmission and cause leaks. Due to the complexity of the pipeline network, pipeline leaks are highly unpredictable and uncontrollable. Natural gas is flammable and explosive, contains toxic gases, and leaks can cause explosions, poisoning incidents, environmental pollution, resource waste, and pose a serious threat to human life and property. Therefore, natural gas pipeline leak detection is essential.
[0003] Utilizing data reflecting pipeline operating status to detect natural gas pipeline leaks is a trenchless, low-cost method, particularly suitable for in-service pipelines. Existing methods often involve installing new equipment and employing techniques such as negative pressure wave, vibration wave, and acoustic wave detection. However, due to the compressibility of natural gas and the long-distance transmission of natural gas pipelines, signals from leaks, such as negative pressure waves, vibration waves, and acoustic waves, attenuate during propagation and are easily affected by the environment. While hardware-based methods and products, such as laying fiber optic cables along pipelines, are accurate and simple, their high cost makes them unsuitable for large-scale upgrades of in-service buried natural gas pipelines. Building leak detection models using pipeline operating status data often involves extracting time-domain or frequency-domain features from normal and leak data, then labeling these features as normal or leaking to train a classifier. This trained classifier is then used to identify whether a leak has occurred, thus achieving leak detection. This approach requires a large number of normal and leak data samples to train the classifier, and ensuring the accuracy and completeness of both data is crucial to avoid increasing the difficulty of classifier training. In reality, pipelines contain a large amount of normal data, while leaks occur very infrequently, resulting in a very small number of leak data samples. This leads to an extreme imbalance between normal and leak samples, significantly impacting the classification accuracy of the classifier. Simulating leaks is not only wasteful of manpower and resources, but the simulated results may also differ significantly from reality, causing environmental pollution and posing significant safety hazards. Summary of the Invention
[0004] To address the technical problem that existing natural gas pipeline leak detection methods suffer from difficulties in model training due to the extremely limited number of leak data samples, which affects the detection effectiveness, this invention provides a flow prediction model training method, detection method, system, and storage medium.
[0005] The embodiments of the present invention are achieved through the following technical solutions:
[0006] In a first aspect, embodiments of the present invention provide a method for training a traffic prediction model, comprising:
[0007] Noise reduction is performed on the historical data of the inlet flow rate and the outlet flow rate of the leak-free natural gas pipeline.
[0008] The historical data of the input flow rate at the beginning of the denoised natural gas pipeline at the current moment and the historical data of the output flow rate at the end of the denoised natural gas pipeline at the current moment are used as the input vector of the neural network, and the historical data of the output flow rate at the end of the denoised natural gas pipeline at the next moment is used as the output vector of the neural network to establish a dataset for training and testing the neural network.
[0009] The dataset used to train and test the neural network is used to obtain the traffic prediction model.
[0010] Secondly, embodiments of the present invention provide a method for training a traffic prediction model, comprising:
[0011] S1. Obtain historical data on the inlet flow rate and outlet flow rate of the leak-free natural gas pipeline;
[0012] S2. Select a sliding window of size M, and at time k, perform noise reduction on the historical data of the input flow at the beginning and the output flow at the end of the window respectively;
[0013] S3. Select the historical data of the noise-reduced first-end input flow and the historical data of the noise-reduced last-end output flow with a length of N at time k and before time k as the input vector of the neural network, and use the historical data of the noise-reduced last-end output flow of the natural gas pipeline at time k+1 as the output vector of the neural network.
[0014] S4. Let k = k + 1 according to the pipeline data sampling period, move the sliding window, return to S2, and continue until a dataset for training and testing the neural network is established to execute S5;
[0015] S5. Divide the dataset used for training and testing the neural network into a training dataset and a test dataset. Train the neural network with the training dataset and test the trained neural network with the test dataset.
[0016] S6. Determine whether the neural network after testing the test dataset can be used to predict natural gas leaks. If so, obtain the flow prediction model.
[0017] Where M, k, and N are integers greater than zero and N ≤ M.
[0018] Furthermore, S6 also includes: determining whether the neural network after testing the test dataset can be used to predict natural gas leaks; if not, adjusting the relevant structure and parameters, and returning to S5; the relevant structure and parameters include the size of the sliding window, the length of the selected historical flow data, the size of the training dataset, the number of training iterations of the neural network, the learning rate, the number of hidden layers and nodes, the activation functions of the hidden layers and the output layer, the network training function, and the training target accuracy.
[0019] Furthermore, the ratio of the training dataset to the test dataset is 3:1; the neural network is a multi-layer BP neural network.
[0020] Thirdly, embodiments of the present invention provide a traffic prediction model training system, comprising:
[0021] The data acquisition unit is used to acquire historical data of the inflow rate at the beginning and the outflow rate at the end of the leak-free natural gas pipeline.
[0022] The noise reduction unit is used to select a sliding window of size M and perform noise reduction on the historical data of the input flow at the beginning and the output flow at the end of the window at time k.
[0023] The neural network processing unit is used to select the historical data of the noise-reduced first-end input flow and the historical data of the noise-reduced last-end output flow of length N at time k and before time k as the input vector of the neural network, and to use the historical data of the noise-reduced last-end output flow of the natural gas pipeline at time k+1 as the output vector of the neural network.
[0024] The dataset creation unit is used to move the sliding window according to the pipeline data sampling period, setting k = k + 1, and return to the noise reduction unit until a dataset for training and testing the neural network is created, returning to the model training and testing unit.
[0025] The model training and testing unit is used to divide the dataset used for training and testing the neural network into a training dataset and a test dataset, using the training dataset to train the neural network and the test dataset to test the trained neural network; and
[0026] The judgment unit is used to determine whether the neural network after testing the test dataset can be used to predict natural gas leaks. If so, the flow prediction model is obtained; where M, k, and N are integers greater than zero and N≤M.
[0027] Furthermore, the judgment unit is also used to determine whether the neural network after testing the test dataset can be used to predict natural gas leaks. If not, the relevant structure and parameters are adjusted, and the model training and testing unit is returned.
[0028] Fourthly, embodiments of the present invention provide a natural gas leak detection method, comprising:
[0029] The collected input flow data at the beginning and output flow data at the end of the natural gas pipeline are input into the flow prediction model obtained by the training method to obtain the predicted value y'(k+1);
[0030] The predicted value y'(k+1) and the noise-reduced value of the terminal output flow data are compared. By comparing the results, the error in the terminal flow prediction can be obtained.
[0031] If the predicted flow rate at the end point exceeds the error threshold, a natural gas leak is determined to exist in the pipeline. Furthermore, the historical data for the initial input flow rate and the historical data for the final output flow rate are represented as follows:
[0032] [x(k-M+2),x(k-M+3),...,x(k-1),x(k),x(k+1)]
[0033] [y(k-M+2),y(k-M+3),...,y(k-1),y(k),y(k+1)]
[0034] Where x(k) is the input flow rate at the beginning of the pipe, and y(k) is the output flow rate at the end of the pipe;
[0035] The historical data of the input flow rate at the beginning and the output flow rate at the end after noise reduction are expressed as follows:
[0036]
[0037]
[0038] The input vector of a neural network is represented as:
[0039]
[0040] The output vector of a neural network is represented as:
[0041] Furthermore, the predicted value y'(k+1) and the denoised value of the terminal output flow data are then compared. By comparing the results, the error in the terminal flow prediction is obtained; including:
[0042] According to the formula The prediction error was calculated.
[0043] Fifthly, embodiments of the present invention provide a natural gas leak detection system, comprising:
[0044] The prediction model unit is used to input the collected natural gas pipeline's initial input flow data and final output flow data into the flow prediction model obtained by the training method to obtain the predicted value y'(k+1).
[0045] The comparison unit is used to compare the predicted value y'(k+1) with the denoised value of the terminal output flow data. By comparing the results, the error in the terminal flow prediction can be obtained; and
[0046] The determination unit is used to determine whether the terminal flow prediction error is greater than the error threshold. If so, it is determined that there is a natural gas leak in the natural gas pipeline.
[0047] In a sixth aspect, embodiments of the present invention provide a computer-readable storage medium storing instructions that, when executed on a computer, perform the training method or the detection method.
[0048] Compared with the prior art, the embodiments of the present invention have the following advantages and beneficial effects:
[0049] This invention discloses a flow prediction model training method, detection method, system, and storage medium. The method involves denoising historical data of the input flow at the beginning and the output flow at the end of a leak-free natural gas pipeline. The denoised historical data of the input and output flow at the beginning and end are used as the input vectors of a neural network, while the denoised historical data of the output flow at the end of the natural gas pipeline is used as the output vector. This establishes a dataset for training and testing the neural network. This dataset is then used to train and test the flow prediction model, resulting in the flow prediction model. This avoids the drawback of existing natural gas pipeline leak detection methods, where the limited number of leak data samples hinders model training and affects detection effectiveness. Attached Figure Description
[0050] To more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0051] Figure 1 This is a schematic diagram of a traffic prediction model training method according to one embodiment.
[0052] Figure 2 This is a schematic diagram of a traffic prediction model training method according to another embodiment.
[0053] Figure 3 The flowchart illustrates the specific process for detecting leaks in natural gas pipelines in this case study.
[0054] Figure 4 A schematic diagram of the neural network structure used to train the natural gas pipeline flow prediction model.
[0055] Figure 5 A schematic diagram of the structure of a traffic prediction model training system.
[0056] Figure 6 This is a schematic diagram of a natural gas leak detection system. Detailed Implementation
[0057] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the embodiments and accompanying drawings. The illustrative embodiments and descriptions of the present invention are only used to explain the present invention and are not intended to limit the present invention.
[0058] In the following description, numerous specific details are set forth in order to provide a thorough understanding of the invention. However, it will be apparent to those skilled in the art that these specific details are not necessary to practice the invention. In other embodiments, well-known structures, circuits, materials, or methods have not been specifically described in order to avoid obscuring the invention.
[0059] Throughout this specification, references to "an embodiment," "an example," or "an example" mean that a particular feature, structure, or characteristic described in connection with that embodiment or example is included in at least one embodiment of the invention. Therefore, the phrases "an embodiment," "an example," "an example," or "an example" appearing in various places throughout the specification do not necessarily refer to the same embodiment or example. Furthermore, specific features, structures, or characteristics can be combined in one or more embodiments or examples in any suitable combination and / or sub-combination. Moreover, those skilled in the art will understand that the illustrations provided herein are for illustrative purposes and are not necessarily drawn to scale. The term "and / or" as used herein includes any and all combinations of one or more of the associated listed items.
[0060] In the description of this invention, the terms "front", "rear", "left", "right", "up", "down", "vertical", "horizontal", "high", "low", "inner", and "outer" indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limiting the scope of protection of this invention.
[0061] Example
[0062] To address the technical problem of limited leak data samples hindering model training and thus affecting detection effectiveness in existing natural gas pipeline leak detection methods, this invention provides a flow prediction model training method, detection method, system, and storage medium. In a first aspect, this invention provides a flow prediction model training method, referring to… Figure 1 As shown, it includes:
[0063] T2. Noise reduction is performed on the historical data of the inlet flow rate and the outlet flow rate of the leak-free natural gas pipeline.
[0064] T3. Use the historical data of the input flow rate at the beginning of the denoised natural gas pipeline at the current moment and the historical data of the output flow rate at the end of the denoised natural gas pipeline at the current moment as the input vector of the neural network, and use the historical data of the output flow rate at the end of the denoised natural gas pipeline at the next moment as the output vector of the neural network to establish a dataset for training and testing the neural network.
[0065] T4. The dataset used to train and test the neural network is used to train and test the neural network to obtain the traffic prediction model.
[0066] Optionally, before T2, the following step is also included: T1. Obtaining historical data on the inlet flow rate and outlet flow rate of the leak-free natural gas pipeline.
[0067] Therefore, this embodiment of the invention predicts the flow rate changes at the beginning and end of a natural gas pipeline under leak-free conditions by establishing a flow prediction model, and compares the flow rate changes at the beginning and end of the natural gas pipeline in real time to determine whether there is a leak in the natural gas pipeline. This avoids the shortcomings of existing natural gas pipeline leak detection methods, which suffer from difficulties in model training due to the extremely small number of leak data samples, thus affecting the effectiveness of natural gas leak detection. It can not only effectively simplify the cost of data measurement and improve the quality of data, but also simplify the neural network model structure and improve the accuracy of leak detection.
[0068] In a second aspect, embodiments of the present invention provide a method for training a traffic prediction model, the principle of which is as follows:
[0069] In actual natural gas pipeline operation, when a leak occurs, the measured temperature and pressure at the pipeline's inlet and outlet remain largely unchanged, while the flow rate fluctuates significantly. Furthermore, the number of actual leak samples is very limited. Leakage experiments not only differ from actual leaks but also pose safety hazards, waste resources, and pollute the environment. Therefore, this method establishes a normal natural gas pipeline flow prediction model. It uses historical data of length N, including the input and output flow rates at the pipeline's inlet and outlet at time k and prior to time k, as the input vector of a neural network. The output flow rate at the pipeline's outlet at time k+1, generated after processing the input vector, is used as the output vector. This model predicts the flow rate at the pipeline's outlet in real time, obtaining the prediction error. By comparing this error with a threshold, it determines whether a leak has occurred, thus achieving leak detection. This method addresses the problem of an imbalance between normal and leak samples due to the limited number of leak samples. It not only effectively simplifies data measurement costs and improves data quality but also simplifies the neural network model structure, improving the accuracy of leak detection.
[0070] Specifically, refer to Figure 2 As shown, the training methods for the traffic prediction model include:
[0071] S1. Obtain historical data on the inlet flow rate and outlet flow rate of the leak-free natural gas pipeline;
[0072] S2. Select a sliding window of size M, and at time k, perform noise reduction on the historical data of the input flow at the beginning and the output flow at the end of the window respectively;
[0073] S3. Select the historical data of the noise-reduced first-end input flow and the historical data of the noise-reduced last-end output flow with a length of N at time k and before time k as the input vector of the neural network, and use the historical data of the noise-reduced last-end output flow of the natural gas pipeline at time k+1 as the output vector of the neural network.
[0074] S4. Let k = k + 1 according to the pipeline data sampling period, move the sliding window, return to S2, and continue until a dataset for training and testing the neural network is established to execute S5;
[0075] S5. Divide the dataset used for training and testing the neural network into a training dataset and a test dataset. Train the neural network with the training dataset and test the trained neural network with the test dataset.
[0076] S6. Determine whether the neural network after testing the test dataset can be used to predict natural gas leaks. If so, obtain the flow prediction model.
[0077] Where M, k, and N are integers greater than zero and N ≤ M.
[0078] Furthermore, S6 also includes: determining whether the neural network after testing the test dataset can be used to predict natural gas leaks; if not, adjusting the relevant structure and parameters, and returning to S5; the relevant structure and parameters include the size of the sliding window, the length of the selected historical flow data, the size of the training dataset, the number of training iterations of the neural network, the learning rate, the number of hidden layers and nodes, the activation functions of the hidden layers and the output layer, the network training function, and the training target accuracy.
[0079] Furthermore, the ratio of the training dataset to the test dataset is 3:1; the neural network is a multi-layer BP neural network.
[0080] Secondly, embodiments of the present invention provide a traffic prediction model training system, with reference to Figure 5 As shown, it includes:
[0081] The data acquisition unit is used to acquire historical data of the inflow rate at the beginning and the outflow rate at the end of the leak-free natural gas pipeline.
[0082] The noise reduction unit is used to select a sliding window of size M and perform noise reduction on the historical data of the input flow at the beginning and the output flow at the end of the window at time k.
[0083] The neural network processing unit is used to select the historical data of the noise-reduced first-end input flow and the historical data of the noise-reduced last-end output flow of length N at time k and before time k as the input vector of the neural network, and to use the historical data of the noise-reduced last-end output flow of the natural gas pipeline at time k+1 as the output vector of the neural network.
[0084] The dataset creation unit is used to move the sliding window according to the pipeline data sampling period, setting k = k + 1, and return to the noise reduction unit until a dataset for training and testing the neural network is created, returning to the model training and testing unit.
[0085] The model training and testing unit is used to divide the dataset used for training and testing the neural network into a training dataset and a test dataset, using the training dataset to train the neural network and the test dataset to test the trained neural network; and
[0086] The judgment unit is used to determine whether the neural network after testing the test dataset can be used to predict natural gas leaks. If so, the flow prediction model is obtained; where M, k, and N are integers greater than zero and N≤M.
[0087] Furthermore, the judgment unit is also used to determine whether the neural network after testing the test dataset can be used to predict natural gas leaks. If not, the relevant structure and parameters are adjusted, and the model training and testing unit is returned.
[0088] The principle is the same as the above-mentioned traffic prediction model training method, and will not be repeated here.
[0089] Thirdly, embodiments of the present invention provide a natural gas leak detection method, comprising:
[0090] The collected input flow data at the beginning and output flow data at the end of the natural gas pipeline are input into the flow prediction model obtained by the training method to obtain the predicted value y'(k+1);
[0091] The predicted value y'(k+1) and the noise-reduced value of the terminal output flow data are compared. By comparing the results, the error in the terminal flow prediction can be obtained.
[0092] Determine whether the terminal flow prediction error is greater than the error threshold. If so, determine that there is a natural gas leak in the natural gas pipeline.
[0093] Furthermore, the historical data of the initial input flow and the historical data of the final output flow are represented as follows:
[0094] [x(k-M+2),x(k-M+3),...,x(k-1),x(k),x(k+1)]
[0095] [y(k-M+2),y(k-M+3),...,y(k-1),y(k),y(k+1)]
[0096] Where x(k) is the input flow rate at the beginning of the pipe, and y(k) is the output flow rate at the end of the pipe;
[0097] The historical data of the input flow rate at the beginning and the output flow rate at the end after noise reduction are expressed as follows:
[0098]
[0099]
[0100] The input vector of a neural network is represented as:
[0101]
[0102] The output vector of a neural network is represented as:
[0103] Furthermore, the predicted value y'(k+1) and the denoised value of the terminal output flow data are then compared. By comparing the results, the error in the terminal flow prediction is obtained; including:
[0104] According to the formula The prediction error was calculated.
[0105] Specifically, the training methods for flow prediction models and the methods for detecting natural gas leaks include:
[0106] Step 1: Measure the historical data of the initial input flow and the historical data of the final output flow under normal operating conditions of the pipeline.
[0107] Step 2: Select a sliding window of size M, and at time k, perform noise reduction on the historical data of the input flow at the beginning and the output flow at the end of the window respectively;
[0108] Step 3: In the noise-reduced flow data at the beginning and end, select the historical flow data at the beginning and end with a length of N before time k as the input vector of the neural network. After processing the input vector, the neural network outputs the flow data at the end at time k+1 as the output of the neural network.
[0109] Step 4: Let k = k + 1 according to the pipeline data sampling period, move the sliding window, and repeat steps 2 to 3 to establish a dataset for training the normal natural gas pipeline flow prediction model.
[0110] Step 5: Divide the dataset into a training dataset and a test dataset in a 3:1 ratio. Use the training dataset to train a normal natural gas pipeline terminal flow prediction model, and use the test dataset to test the trained model. Observe whether the prediction effect meets the requirements. If it does not meet the requirements, adjust the relevant structure and parameters, and retrain until the requirements are met; if the requirements are met, save the trained model. The relevant structure and parameters include the size of the sliding window, the length of the selected historical flow data, the size of the training dataset, the number of training iterations of the neural network, the learning rate, the number of hidden layers and nodes, and the activation functions of the hidden and output layers, etc. The neural network is a multi-layer BP neural network.
[0111] Step 6: Measure the real-time input and output flow rates at the beginning and end of the pipeline. After preprocessing in Step 2, use the model trained in Step 5 to predict the real-time flow rate at the end of the natural gas pipeline. The predicted value y'(k+1) and the actual pipeline value y(k+1) are then compared after noise reduction. By comparing the results, the error in the terminal flow prediction can be obtained.
[0112] Step 7: Compare the prediction error with the error threshold. If the prediction error is less than the error threshold, it means that there is no leak in the pipeline; if the prediction error is greater than the error threshold, it means that there is a leak in the pipeline.
[0113] In step 2, the steps for determining the position of the sliding window and the specific data within the window that needs to be denoised are as follows:
[0114] Step 2.1: Set the size of the sliding window to M and its position to the current time k;
[0115] Step 2.2: The input and output flow data that need to be denoised are as follows:
[0116] [x(k-M+2),x(k-M+3),...,x(k-1),x(k),x(k+1)]
[0117] [y(k-M+2),y(k-M+3),...,y(k-1),y(k),y(k+1)]
[0118] Where x(k) is the input flow rate at the beginning of the pipe, and y(k) is the output flow rate at the end of the pipe;
[0119] Step 2.3: Denoise the input and output flow data determined in Step 2.2 to obtain the denoised input and output flow data.
[0120]
[0121]
[0122] Step 3 selects the network input vector as...
[0123]
[0124] The network output is Where N is the length of the selected historical data.
[0125] In step 6, when using the trained normal natural gas pipeline flow prediction model to predict the actual data, the specific procedure is to process the historical data before the k+1 time point to be predicted through step 2 to obtain the input vector of the prediction model. The input is given to the prediction model to obtain the predicted value y'(k+1). The actual value y(k+1) is then denoised. Comparison, application of formulas The prediction error is obtained, and the prediction error is compared with the error threshold to determine whether a pipeline leak has occurred.
[0126] Therefore, this embodiment of the invention only requires flow data from the beginning and end of the pipeline. Since a pipeline is a closed system, when a leak occurs, the flow data can more directly and quickly reflect changes in the system's mass conservation principle. It is less affected by long-distance pipeline transmission and environmental changes, resulting in better data quality. Because this method only uses pipeline flow data, it not only reduces measurement costs but also reduces the input parameters of the artificial neural network, making the network structure many-to-one, greatly simplifying the network structure. The network input uses the current flow rate at the beginning of the pipeline and the historical flow rate at the end, comprehensively considering the mass conservation principle of the pipeline's input and output, resulting in a higher correlation between the network input parameters and making network training easier. Using a certain length of historical data when predicting pipeline flow effectively reduces the impact of real-time data fluctuations on the prediction effect and improves prediction accuracy. This method is more economical, simple, efficient, and fast.
[0127] Implementation Cases
[0128] This implementation case uses a single-line natural gas pipeline currently in operation as an example to illustrate the method described in this invention. It involves collecting flow data from both ends of the natural gas pipeline, performing wavelet noise reduction on a selected length of flow data, and constructing the training and test datasets needed to train a natural gas pipeline end-flow prediction model. Finally, the trained model is used for natural gas pipeline leak detection. (Refer to...) Figure 3 As shown, the specific implementation includes the following steps:
[0129] Step 1: Measure the historical data of the input flow at the beginning and output flow at the end of the pipeline under normal operating conditions;
[0130] Step 2: Select a sliding window of size M, and perform wavelet denoising on the input and output flow data at the beginning and end of the window at time k.
[0131] Step 2.1: Set the size of the sliding window to M = 50, and its position to the current time k;
[0132] Step 2.2: The input and output flow data for wavelet denoising are as follows:
[0133] [x(k-48),x(k-47),...,x(k-1),x(k),x(k+1)]
[0134] [y(k-48),y(k-47),...,y(k-1),y(k),y(k+1)]
[0135] Where x(k) is the input flow rate at the beginning of the pipe, and y(k) is the output flow rate at the end of the pipe;
[0136] Step 2.3: Perform wavelet denoising on the input and output flow data determined in Step 2.2 to obtain the denoised input and output flow data.
[0137]
[0138]
[0139] Step 3: From the denoised first- and last-terminal flow data, select historical flow data of length N=5 at time k and before time k as the input vector of the neural network, i.e. The output flow data at time k+1 is used as the output of the neural network, which is... A dataset is used to train a normal natural gas pipeline end-flow prediction model.
[0140] Step 4: Let k = k + 1 according to the pipeline data sampling period, move the sliding window, and repeat steps 2 to 3 to establish a dataset for training a normal natural gas pipeline end flow prediction model.
[0141] Step 5: Divide the dataset into a training dataset and a test dataset in a 3:1 ratio. Use the training dataset to train a normal natural gas pipeline terminal flow prediction model, and use the test dataset to test the trained model. Observe whether the prediction effect meets the requirements. If it does not meet the requirements, adjust the relevant structure and parameters, and retrain until the requirements are met; if the requirements are met, save the trained model. The relevant structure and parameters include the size of the sliding window, the length of the selected historical flow data, the size of the training dataset, the number of training iterations of the neural network, the learning rate, the number of hidden layers and nodes, and the activation functions of the hidden and output layers. The neural network used is a BP neural network. Figure 4 As shown. The specific structure of the model needs to be adjusted according to the prediction accuracy required by the actual prediction model; this is just a simple example.
[0142] Step 6: Measure the real-time input and output flow rates at the beginning and end of the pipeline. After preprocessing in Step 2, obtain the input vector for the prediction model. The model trained in step 5 is used to predict the flow rate of natural gas pipelines in real time. The predicted value y'(k+1) and the actual pipeline value y(k+1) are then compared after noise reduction. Compare and use formulas The terminal flow prediction error is obtained;
[0143] Step 7: Compare the prediction error with the error threshold. If the prediction error is less than the error threshold, it means that there is no leak in the pipeline; if the prediction error is greater than the error threshold, it means that there is a leak in the pipeline.
[0144] Fourthly, embodiments of the present invention provide a natural gas leak detection system, with reference to... Figure 6 As shown, it includes:
[0145] The prediction model unit is used to input the collected natural gas pipeline's initial input flow data and final output flow data into the flow prediction model obtained by the training method to obtain the predicted value y'(k+1).
[0146] The comparison unit is used to compare the predicted value y'(k+1) with the denoised value of the terminal output flow data. By comparing the results, the error in the terminal flow prediction can be obtained; and
[0147] The determination unit is used to determine whether the terminal flow prediction error is greater than the error threshold. If so, it is determined that there is a natural gas leak in the natural gas pipeline.
[0148] Fifthly, embodiments of the present invention provide a computer-readable storage medium storing instructions that, when executed on a computer, perform the training method or the detection method.
[0149] The principles are the same as those described in the training method or the detection method above, and will not be repeated here.
[0150] The specific embodiments described above further illustrate the purpose, technical solution, and beneficial effects of the present invention. It should be understood that the above description is only a specific embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for training a traffic prediction model, characterized in that, include: Noise reduction is performed on the historical data of the inlet flow rate and the outlet flow rate of the leak-free natural gas pipeline. The historical data of the input flow rate at the beginning of the denoised natural gas pipeline at the current moment and the historical data of the output flow rate at the end of the denoised natural gas pipeline at the current moment are used as the input vector of the neural network, and the historical data of the output flow rate at the end of the denoised natural gas pipeline at the next moment is used as the output vector of the neural network to establish a dataset for training and testing the neural network. The dataset used to train and test the neural network is used to train and test the neural network to obtain the traffic prediction model; include: S1. Obtain historical data on the inlet flow rate and outlet flow rate of the leak-free natural gas pipeline; S2. Select a sliding window of size M, and perform wavelet denoising on the historical data of the input flow at the beginning and the output flow at the end of the window at time k. S3. Select the historical data of the noise-reduced first-end input flow and the historical data of the noise-reduced last-end output flow with a length of N at time k and before time k as the input vector of the neural network, and use the historical data of the noise-reduced last-end output flow of the natural gas pipeline at time k+1 as the output vector of the neural network. S4. Let k=k+1 according to the pipeline data sampling period, move the sliding window, return to S2, and continue until a dataset for training and testing the neural network is established to execute S5; S5. Divide the dataset used for training and testing the neural network into a training dataset and a test dataset. Train the neural network with the training dataset and test the trained neural network with the test dataset. S6. Determine whether the neural network after testing the test dataset can be used to predict natural gas leaks. If so, obtain the flow prediction model. Where M, k, and N are integers greater than zero and N ≤ M.
2. The traffic prediction model training method as described in claim 1, characterized in that, S6 further includes: determining whether the neural network after testing the test dataset can be used to predict natural gas leaks; if not, adjusting the relevant structure and parameters and returning to S5; the relevant structure and parameters include the size of the sliding window, the length of the selected historical flow data, the size of the training dataset, the number of training iterations of the neural network, the learning rate, the number of hidden layers and nodes, the activation functions of the hidden layers and the output layer, the network training function, and the training target accuracy.
3. A traffic prediction model training system, characterized in that, include: The data acquisition unit is used to acquire historical data of the inflow rate at the beginning and the outflow rate at the end of the leak-free natural gas pipeline. The noise reduction unit is used to select a sliding window of size M and perform noise reduction on the historical data of the input flow at the beginning and the output flow at the end of the window at time k. The neural network processing unit is used to select the historical data of the noise-reduced head input flow and the historical data of the noise-reduced tail output flow of length N at time k and before time k as the input vector of the neural network, and to use the historical data of the noise-reduced tail output flow of the natural gas pipeline at time k+1 as the output vector of the neural network. The dataset creation unit is used to move the sliding window according to the pipeline data sampling period (k=k+1), return to the noise reduction unit, and return to the model training and testing unit until a dataset for training and testing the neural network is created. The model training and testing unit is used to divide the dataset used for training and testing the neural network into a training dataset and a test dataset, to train the neural network with the training dataset and to test the trained neural network with the test dataset. as well as The judgment unit is used to determine whether the neural network after testing the test dataset can be used to predict natural gas leaks. If so, the flow prediction model is obtained; where M, k, and N are integers greater than zero and N≤M.
4. The traffic prediction model training system as described in claim 3, characterized in that, The judgment unit is also used to determine whether the neural network after testing the test dataset can be used to predict natural gas leaks. If not, the relevant structure and parameters are adjusted, and the model training and testing unit is returned.
5. A method for detecting natural gas leaks, characterized in that, include: The collected inflow data from the beginning and outflow data from the natural gas pipeline are input into the flow prediction model obtained by the training method described in any one of claims 1-2 to obtain the predicted value. ; Predicted values The value of the output flow rate data after noise reduction By comparing the results, the error in the terminal flow prediction can be obtained. Determine whether the terminal flow prediction error is greater than the error threshold. If so, determine that there is a natural gas leak in the natural gas pipeline.
6. The natural gas leak detection method as described in claim 5, characterized in that, The historical data of the input flow at the beginning and the historical data of the output flow at the end are represented as follows: ; in Input flow at the beginning of the pipeline. The output flow rate at the end of the pipeline; The historical data of the input flow rate at the beginning and the output flow rate at the end after noise reduction are represented as follows: ; The input vector of a neural network is represented as: ; The output vector of a neural network is represented as: .
7. The natural gas leak detection method as described in claim 5, characterized in that, Predicted values The value of the output flow rate data after noise reduction By comparing the results, the error in the terminal flow prediction is obtained; including: According to the formula The prediction error was calculated.
8. A natural gas leak detection system, characterized in that, include: The prediction model unit is used to input the collected inflow data from the beginning and the outflow data from the end of the natural gas pipeline into the flow prediction model obtained by the training method described in any one of claims 1-2, to obtain predicted values. ; Comparison unit, used to compare predicted values The value of the output flow rate data after noise reduction By comparing the results, the error in the terminal flow prediction can be obtained. as well as The determination unit is used to determine whether the terminal flow prediction error is greater than the error threshold. If so, it is determined that there is a natural gas leak in the natural gas pipeline.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores instructions that, when executed on a computer, perform the training method as described in any one of claims 1-2 or the detection method as described in any one of claims 5-7.