Metering station instantaneous flow prediction method
By constructing a neural network model based on CNN+LSTM, the gas volume for the next day is predicted using historical instantaneous flow data. This solves the problem of the significant impact of human factors, achieves more accurate gas volume prediction, and improves the stability and safety of gas supply.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- 佛山市顺德区港华燃气有限公司
- Filing Date
- 2025-12-19
- Publication Date
- 2026-05-19
AI Technical Summary
Existing technologies for predicting urban gas volume are greatly affected by human factors, resulting in significant deviations and making it difficult to meet the daily gas volume deviation requirements.
A hybrid neural network model based on CNN+LSTM is adopted, which is trained using historical instantaneous flow data to predict the instantaneous flow sequence for the next day and calculate the daily average gas volume, adapting to the influence of seasonal and holiday factors.
It improves the accuracy and small-sample adaptability of gas volume prediction, enables real-time updates, and enhances the stability and security of gas supply management.
Smart Images

Figure CN122066071A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of metering station flow prediction technology, and specifically to a method for predicting instantaneous flow at a metering station. Background Technology
[0002] For smaller towns in urban areas, daily, monthly, and annual gas consumption plans are typically submitted to the upstream supplier for appropriate gas supply allocation. Additionally, there are performance evaluation requirements for discrepancies between planned and actual gas consumption; for example, a deviation of approximately 3%-5% is generally allowed for daily gas consumption.
[0003] Most current gas volume forecasts rely on the previous day's gas volume plus human judgment of market production to predict today's planned gas volume. A common, simple method is to add the previous day's volume to the human-induced increase or decrease in today's volume. This method is heavily influenced by human judgment and, relying solely on the previous day's volume, easily exceeds the required deviation range. Summary of the Invention
[0004] The purpose of this invention is to provide a method for predicting the instantaneous flow rate of a metering station, which has significant advantages and practical value in predicting urban gas volume.
[0005] To achieve the above objectives, the present invention provides the following technical solution: A method for predicting instantaneous flow at a metering station includes the following steps: S1: Obtain historical instantaneous flow data, which includes hourly instantaneous gas flow data for multiple days; S2: Preprocess the historical instantaneous traffic data and divide it into a training set and a validation set; S3: Construct a hybrid neural network model based on CNN+LSTM, which includes a CNN module and an LSTM module; S4: Using the instantaneous traffic data from two consecutive days as input, train the CNN+LSTM model to predict the instantaneous traffic sequence for the next day; S5: Utilize the trained model to output the hourly instantaneous flow rate prediction for the next day, and calculate the daily average gas volume based on the prediction value; S6: Use the average daily gas volume for gas dispatching and planning management.
[0006] Specifically, in S1, multiple instantaneous traffic data from each day within 60 days are used as a sample pool, wherein one instantaneous traffic data is collected every hour within each day.
[0007] Specifically, the CNN module is used to extract local and global features of instantaneous traffic data, and the LSTM module is used to capture long-term dependencies in the time series.
[0008] Specifically, the CNN and LSTM algorithm combination model has an input dimension of 48 and an output dimension of 24, corresponding to 48 hours of instantaneous traffic input and 24 hours of instantaneous traffic output, respectively.
[0009] Specifically, the CNN module includes the following steps: Input a data matrix X of size T multiplied by F, where T represents the time step and F represents the number of features; Through neural network training, a k-by-F convolution kernel K is obtained through optimization, where k is the time span of the convolution kernel; Perform a convolution operation in the time dimension to output a feature map Y. The formula for calculating the i-th element of feature map Y is: Where b is the bias term; Call the activation function ; Feature maps output by convolutional layers Applying the ReLU activation function, we obtain the feature map Z after nonlinear transformation, where, , Let i be the output value of the i-th element; Pooling is performed on feature map Z with a pooling window size of p, outputting feature map P. The formula for calculating the m-th element of feature map P is: Specifically, the LSTM module includes an input gate. Forgotten Gate Output gate and memory units Candidate memory units ,in: Input gate This determines how much of the newly input information will be added to the memory unit; Forgotten Gate Control the memory unit of the previous moment How much of the information in the data will be retained to the current time? Output gate Determines the memory unit Which information will be output as the hidden state at the current moment? Candidate memory units It is a new information generated based on the current input and the hidden state of the previous time step, used to update the memory unit. ; memory unit Through the Gate of Oblivion and input gate The synergistic effect of these elements integrates the memory information from the previous moment with the new information at present; Input gate With memory unit Jointly determine the hidden state This serves as the output for the current moment and will also be one of the inputs for the next moment.
[0010] Specifically, during model training, the learning rate is set to 0.01, and the number of training rounds is no less than 600.
[0011] Specifically, the method further includes a step of evaluating the prediction results, and the evaluation indicators include mean squared error, mean absolute error, and coefficient of determination R. 2 .
[0012] Specifically, the prediction model is updated daily to adapt to the impact of seasonality, holidays, and other factors on gas volume.
[0013] Compared with the prior art, the beneficial effects of the present invention are as follows: The CNN+LSTM-based instantaneous flow prediction model for small-sample metering stations demonstrates significant superiority and practical value in predicting urban gas volume. This model not only effectively addresses the problems of traditional prediction methods but also excels in accuracy, small-sample adaptability, and real-time update capabilities. Furthermore, the method of using data from the previous two days to derive data for the third day further enhances the prediction performance. In future urban gas supply management, this model is expected to play a crucial role, providing strong technical support for ensuring the stability, efficiency, and safety of gas supply. Attached Figure Description
[0014] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0015] Figure 1 The data is a monthly sample, with the blue part representing the training set and the orange part representing the validation set. Figure 2 This is the logic schematic of the LSTM module; Figure 3 For comparison between the training set and real data; Figure 4 This is for comparing the validation set with the real data. Detailed Implementation
[0016] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0017] A method for predicting instantaneous flow at a metering station includes the following steps: S1: Obtain historical instantaneous flow data, which includes hourly instantaneous gas flow data for multiple days; S2: Preprocess the historical instantaneous traffic data and divide it into a training set and a validation set; S3: Construct a hybrid neural network model based on CNN+LSTM, which includes a CNN module and an LSTM module; S4: Using the instantaneous traffic data from two consecutive days as input, train the CNN+LSTM model to predict the instantaneous traffic sequence for the next day; S5: Utilize the trained model to output the hourly instantaneous flow rate prediction for the next day, and calculate the daily average gas volume based on the prediction value; S6: Use the average daily gas volume for gas dispatching and planning management.
[0018] Specifically, in S1, multiple instantaneous traffic data from each day within 60 days are used as a sample pool, wherein one instantaneous traffic data is collected every hour within each day.
[0019] Specifically, the CNN module is used to extract local and global features of instantaneous traffic data, and the LSTM module is used to capture long-term dependencies in the time series.
[0020] Specifically, the CNN and LSTM algorithm combination model has an input dimension of 48 and an output dimension of 24, corresponding to 48 hours of instantaneous traffic input and 24 hours of instantaneous traffic output, respectively.
[0021] Specifically, the CNN module includes the following steps: Input a data matrix X of size T multiplied by F, where T represents the time step and F represents the number of features; Through neural network training, a k-by-F convolution kernel K is obtained through optimization, where k is the time span of the convolution kernel; Perform a convolution operation in the time dimension to output a feature map Y. The formula for calculating the i-th element of feature map Y is: Where b is the bias term; Call the activation function ; Feature maps output by convolutional layers Applying the ReLU activation function, we obtain the feature map Z after nonlinear transformation, where, , Let i be the output value of the i-th element; Pooling is performed on feature map Z with a pooling window size of p, outputting feature map P. The formula for calculating the m-th element of feature map P is: Specifically, the LSTM module includes an input gate. Forgotten Gate Output gate and memory units Candidate memory units ,in: Input gate This determines how much of the newly input information will be added to the memory unit; Forgotten Gate Control the memory unit of the previous moment How much of the information in the data will be retained to the current time? Output gate Determines the memory unit Which information will be output as the hidden state at the current moment? Candidate memory units It is a new information generated based on the current input and the hidden state of the previous time step, used to update the memory unit. ; memory unit Through the Gate of Oblivion and input gate The synergistic effect of these elements integrates the memory information from the previous moment with the new information at present; Input gate With memory unit Jointly determine the hidden state This serves as the output for the current moment and will also be one of the inputs for the next moment.
[0022] Specifically, during model training, the learning rate is set to 0.01, and the number of training rounds is no less than 600.
[0023] Specifically, the method further includes a step of evaluating the prediction results, and the evaluation indicators include mean squared error, mean absolute error, and coefficient of determination R. 2 .
[0024] Specifically, the prediction model is updated daily to adapt to the impact of seasonality, holidays, and other factors on gas volume.
[0025] The principle and process of this invention are as follows: Data preparation The daily instantaneous flow data (sampled every hour) from a metering station in a certain region in November 2024 were selected as the sample pool to obtain the time-series curve of instantaneous flow in November, as shown in the figure. Figure 1 As shown in the figure, 80% of the data is used as the model dataset (blue curve), and 20% is used as the model validation set (orange curve).
[0026] from Figure 1 As can be seen, this fluctuation curve is a typical urban gas supply curve, with the data exhibiting relatively obvious periodic fluctuations. The flow rate fluctuates within a certain range, and although the amplitude of each fluctuation is not exactly the same, the frequency of fluctuation is relatively stable.
[0027] Such periodic fluctuations may reflect some kind of periodic operation or the influence of external factors. For example, in industrial production, the flow rate changes may be caused by the periodic operation of production equipment; in environmental changes, the flow rate changes may be caused by periodic factors such as diurnal temperature variations or tidal changes. These changes are either expected or continuous.
[0028] Model selection A gas volume prediction model based on CNN+LSTM for small sample metering stations was adopted.
[0029] The CNN (Convolutional Neural Network) module is a deep learning model for processing grid-structured data, automatically extracting features through convolutional layers, pooling layers, and fully connected layers. In gas flow prediction, the hourly instantaneous gas flow rate is treated as time-series data. The CNN module includes the following data operations: Input a data matrix X of size T multiplied by F, where T represents the time step and F represents the number of features; Through neural network training, a k-by-F convolution kernel K is obtained through optimization, where k is the time span of the convolution kernel; Perform a convolution operation in the time dimension to output a feature map Y. The formula for calculating the i-th element of feature map Y is: Where b is the bias term; Call the activation function ; Feature maps output by convolutional layers Applying the ReLU activation function, we obtain the feature map Z after nonlinear transformation, where, , Let i be the output value of the i-th element; Pooling is performed on feature map Z with a pooling window size of p, outputting feature map P. The formula for calculating the m-th element of feature map P is: The LSTM model is a special type of recurrent neural network (RNN) designed to address the vanishing and exploding gradient problems faced by traditional RNNs when processing long-sequence data. Its core mechanism lies in its unique gating structure, which effectively captures and remembers long-term dependencies in time series data.
[0030] The LSTM module includes input gates. Forgotten Gate Output gate and memory units Candidate memory units Its operating logic diagram is as follows Figure 2 As shown, where: Input gate This determines how much of the newly input information will be added to the memory unit; Forgotten Gate Control the memory unit of the previous moment How much of the information in the data will be retained to the current time? Output gate Determines the memory unit Which information will be output as the hidden state at the current moment? Candidate memory units It is a new information generated based on the current input and the hidden state of the previous time step, used to update the memory unit. ; memory unit Through the Gate of Oblivion and input gate The synergistic effect of these elements integrates the memory information from the previous moment with the new information at present; Input gate With memory unit Jointly determine the hidden state This serves as the output for the current moment and will also be one of the inputs for the next moment.
[0031] In the CNN+LSTM model, the LSTM module receives highly abstract feature vectors from the CNN output. These feature vectors contain both local and global features of the instantaneous traffic data extracted by the CNN. The LSTM module uses its own gating mechanism to process these feature vectors step-by-step. In this process, LSTM can capture the long-term dependencies between features at different times in the time series, uncovering potential patterns and trends in data changes over time.
[0032] Model training process Based on a CNN+LSTM algorithm combination model, the input data is processed using tensors to meet the model's input requirements. In this model, the data feature input dimension is set to 48 (i.e., the instantaneous flow rate per hour for the previous two days' 48 hours), and the model's output dimension is 24 (i.e., the predicted instantaneous flow rate per hour for tomorrow's 24 hours). The model selects the instantaneous flow rates of the previous two days as input values to predict the instantaneous flow rate of the following day. This ensures the model conforms to the requirement of periodic changes, resulting in more accurate instantaneous flow rate predictions. The learning rate is set to 0.01 (the learning rate determines the step size for updating the fitted parameters each time). The number of training epochs is set to 600. Figure 3 The training values for the model data are compared with those for the training set. Figure 4 The predicted values of the trained model are compared with those of the validation set.
[0033] Model Analysis and Evaluation For the training results on the training set and the prediction results on the validation set, calculate the mean squared error, mean absolute error, and mean squared error respectively. The indicators were evaluated. The results are as follows: Regarding the evaluation of mean squared error and mean absolute error: Very low values on the training set indicate that the model fits the training data very well. While its performance on the test set is not as perfect as on the training set, it can still make relatively accurate predictions. Evaluation: The training set value is 0.9666, very close to 1. This indicates that the model can explain approximately 96.66% of the data variation in the training set, demonstrating a very high degree of fit to the training data. The test set value is 0.7684, indicating that the model can explain approximately 76.84% of the data variation in the test set. While not as good as its performance on the training set, it is still within an acceptable range, suggesting that the model has some generalization ability.
[0034] In summary: the model performs excellently on the training set, exhibiting a high degree of fit. While its performance on the test set is slightly weaker than on the training set across various metrics, its overall performance remains good, indicating that the model possesses a certain degree of generalization ability and can make relatively accurate predictions on unseen data. However, there is a certain performance gap between the test and training sets, potentially indicating a slight overfit. Further optimization could be achieved by increasing the amount of data and employing regularization to reduce the likelihood of overfitting.
[0035] The CNN+LSTM-based instantaneous flow prediction model for small-sample metering stations demonstrates significant superiority and practical value in predicting urban gas volume. This model not only effectively addresses the problems of traditional prediction methods but also excels in accuracy, small-sample adaptability, and real-time update capabilities. Furthermore, the method of using data from the previous two days to derive data for the third day further enhances the prediction performance. In future urban gas supply management, this model is expected to play a crucial role, providing strong technical support for ensuring the stability, efficiency, and safety of gas supply.
[0036] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the present invention. Any person skilled in the art can make some modifications or alterations to the above-disclosed technical content to create equivalent embodiments without departing from the scope of the present invention. Any simple modifications, equivalent changes and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the scope of the present invention.
Claims
1. A method for predicting instantaneous flow at a metering station, characterized in that, Includes the following steps: S1: Obtain historical instantaneous flow data, which includes hourly instantaneous gas flow data for multiple days; S2: Preprocess the historical instantaneous traffic data and divide it into a training set and a validation set; S3: Construct a hybrid neural network model based on CNN+LSTM, which includes a CNN module and an LSTM module; S4: Using the instantaneous traffic data from two consecutive days as input, train the CNN+LSTM model to predict the instantaneous traffic sequence for the next day; S5: Utilize the trained model to output the hourly instantaneous flow rate prediction for the next day, and calculate the daily average gas volume based on the prediction value; S6: Use the average daily gas volume for gas dispatching and planning management.
2. The method according to claim 1, characterized in that, In S1, multiple instantaneous traffic data from each day over 60 days are used as a sample pool, with one instantaneous traffic data point collected every hour within each day.
3. The method according to claim 1, characterized in that, The CNN module is used to extract local and global features from instantaneous traffic data, and the LSTM module is used to capture long-term dependencies in time series.
4. The method according to claim 1, characterized in that, The CNN and LSTM algorithm combination model has an input dimension of 48 and an output dimension of 24, corresponding to 48 hours of instantaneous traffic input and 24 hours of instantaneous traffic output, respectively.
5. The method according to claim 3, characterized in that, The CNN module includes the following steps: Input a data matrix X of size T multiplied by F, where T represents the time step and F represents the number of features; Through neural network training, a k-by-F convolution kernel K is obtained through optimization, where k is the time span of the convolution kernel; Perform a convolution operation in the time dimension to output a feature map Y. The formula for calculating the i-th element of feature map Y is: Where b is the bias term; Call the activation function ; Feature maps output by convolutional layers Applying the ReLU activation function, we obtain the feature map Z after nonlinear transformation, where, , Let i be the output value of the i-th element; Pooling is performed on feature map Z with a pooling window size of p, outputting feature map P. The formula for calculating the m-th element of feature map P is: 。 6. The method according to claim 1, characterized in that, The LSTM module includes an input gate. Forgotten Gate Output gate and memory units Candidate memory units ,in: Input gate This determines how much of the newly input information will be added to the memory unit; Forgotten Gate Control the memory unit of the previous moment How much of the information in the data will be retained to the current time? Output gate Determines the memory unit Which information will be output as the hidden state at the current moment? Candidate memory units It is a new information generated based on the current input and the hidden state of the previous time step, used to update the memory unit. ; memory unit Through the Gate of Oblivion and input gate The synergistic effect of these elements integrates the memory information from the previous moment with the new information at present; Input gate With memory unit Jointly determine the hidden state This serves as the output for the current moment and will also be one of the inputs for the next moment.
7. The method according to claim 1, characterized in that, During model training, the learning rate was set to 0.01, and the number of training rounds was no less than 600.
8. The method according to claim 1, characterized in that, The method further includes a step of evaluating the prediction results, with evaluation indicators including mean squared error, mean absolute error, and coefficient of determination R. 2 .
9. The method according to claim 1, characterized in that, The prediction model is updated daily to adapt to the impact of seasonality, holidays, and other factors on gas volume.