Natural gas consumption data processing method and system based on reinforcement learning

By using a reinforcement learning-based method for natural gas consumption data processing, combined with user gas consumption behavior profiles and real-time scene perception, normal and abnormal gas consumption periods are identified and processed. A reinforcement learning model adapted to both modes is constructed, solving the problems of low processing accuracy and response delay in existing technologies, and achieving efficient and accurate gas consumption data processing.

CN122365240APending Publication Date: 2026-07-10SHAANXI ZHONGHE YUANQI PLANNING & DESIGN CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610433408.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-04-03
Publication Date
2026-07-10

Smart Images

  • Figure CN122365240A_ABST
    Figure CN122365240A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for processing natural gas consumption data based on reinforcement learning, belonging to the field of natural gas management and control technology. The method includes: intelligently adjusting the acquisition frequency, dynamically adapting to user gas consumption behavior profiles and real-time scene perception; classifying gas consumption into normal and abnormal modes, and activating regular or enhanced detection modes as needed; implementing differentiated preprocessing and feature extraction for the two modes, and fusing multi-source data; constructing a reinforcement learning model adapted to both modes, splitting the training module and supplementing samples; dynamically processing data using the model, and simultaneously adjusting the model and operating parameters based on deviation analysis; the system includes a gas consumption data acquisition unit, a time period type identification module, and a data preprocessing module as core modules; this application can flexibly adapt to dynamic gas consumption scenarios, effectively improve data processing accuracy and response speed, and significantly optimize edge device energy consumption and user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of natural gas data management and control technology, specifically to a method and system for processing natural gas consumption data based on reinforcement learning. Background Technology

[0002] Natural gas, as a clean and efficient energy source, is widely used in residential life, industrial production and other fields. Its gas consumption data includes multi-dimensional information such as flow rate, pressure and consumption time, which is of great value for scenarios such as gas consumption forecasting, pipeline network scheduling and leak detection.

[0003] Existing natural gas consumption data processing methods mostly rely on fixed algorithms such as statistical regression and threshold judgment for analysis and processing. The core drawback is that it is difficult to adaptively adjust the data processing strategy for dynamic scenarios such as fluctuations in gas load and changes in environmental parameters. This leads to problems such as low processing accuracy and response delay when facing sudden gas consumption data characteristics, making it unsuitable for the actual application requirements of intelligent scheduling and control of natural gas. Summary of the Invention

[0004] On the one hand, in order to solve the problems of the existing technology, the present invention provides a method for dynamic processing of natural gas consumption data based on reinforcement learning, including: Collect raw natural gas consumption data, and intelligently adjust the collection frequency by combining user gas consumption behavior profiles and real-time scene perception through the set gas consumption data collection unit; The current time period type is identified according to the preset time division rules. The time period type includes normal gas consumption period and abnormal gas consumption period, and the first operation mode or the second operation mode is activated accordingly. The first operation mode is the gas supply guarantee and routine detection mode for normal gas consumption period, and the second operation mode is the enhanced detection and anomaly identification mode for abnormal gas consumption period. Different preprocessing methods are used for the raw gas consumption data under the two modes. Data features are extracted by combining known anomaly characteristics and dynamically adjustable adaptation rules. Data integration and alignment at the edge are used to achieve the fusion of data from multiple sources. Based on the extracted features, a reinforcement learning model adapted to the two modes is constructed. Multiple optimization objectives are set around the accuracy of gas consumption data processing, response speed, edge device energy consumption, and user experience. The model training module is split to simplify the training process. At the same time, simulation scenario settings and data generation technology are combined to supplement the training samples required. Using the trained reinforcement learning model, combined with near real-time data processing nodes, natural gas consumption data under two modes are dynamically processed. In the second operating mode, anomaly type identification and abnormal user location are completed simultaneously, and the processing results and anomaly judgment information are output. Based on the deviation analysis between the actual operating data and the model processing results, the parameters of the reinforcement learning model and the operating parameters of the two modes are dynamically adjusted, and the training sample set is supplemented and updated.

[0005] Furthermore, the preset time division rules are determined based on the type of gas usage scenario and the user's gas usage behavior profile. The normal gas usage periods for residential gas usage scenarios include 6:00-8:00 AM, 11:30 AM-1:30 PM, and 5:30 PM-8:30 PM daily, while the abnormal gas usage periods are the remaining times. For commercial gas usage scenarios, the normal gas usage periods are their business hours, while the abnormal gas usage periods are their shutdown times. The user's gas usage profile is generated through historical data clustering analysis, including the user's personalized gas usage baseline and fluctuation range; The raw gas consumption data includes gas load data, gas consumption scenario-related data, user behavior tag data, and equipment health data. Among them, the gas load data covers gas consumption per unit time and peak gas consumption duration parameters; the gas consumption scenario-related data includes gas consumption area attributes, environmental temperature and humidity conditions, and user identification information; the user behavior tag data includes classification information for long-term vacant users and high-frequency gas users; and the equipment health data includes the service life of the gas meter and the number of times the valve is opened and closed. The intelligent adjustment of the acquisition frequency adopts a step-by-step strategy, including: In the first operating mode, the gas consumption fluctuates dynamically around the user's personalized gas consumption baseline, with a higher sampling frequency during peak hours than during off-peak hours. In the second operating mode, if the real-time data deviates from the user's personalized gas consumption baseline by ±15%, a scenario verification is triggered. If the verification is still abnormal, the collection frequency is increased in steps of basic frequency, 2 times, and 4 times. After the abnormality is confirmed, the frequency is maintained at 2 times. The first operating mode has a sampling frequency adapted to normal gas supply demand. The second operating mode has a basic sampling frequency that is twice that of the first operating mode, and after a step-by-step increase, it does not exceed four times that of the first operating mode. In addition, the second operating mode simultaneously collects special detection data on user-end pressure fluctuations and flow stability.

[0006] Furthermore, the following steps are taken to preprocess the raw gas consumption data under the two modes using different methods and extract data features: Acquire the raw gas consumption data collected under the corresponding mode. Perform light preprocessing operations in the first operating mode, including outlier filtering, missing value completion, and data normalization. The second operating mode performs enhanced preprocessing operations, adding data noise filtering, instantaneous fluctuation capture, and anomaly feature comparison steps on top of the lightweight preprocessing. The temporal feature extraction method was used to capture the temporal dimension change pattern of the data under two different modes. The first mode focused on extracting periodic fluctuation features, while the second mode focused on extracting non-periodic fluctuation and abnormal correlation features. By reducing data dimensionality while retaining effective information, feature alignment of data from multiple sources is achieved through edge-side data mapping rules, forming feature datasets that are adapted to the two operating modes respectively.

[0007] Furthermore, the known anomaly features include the characteristics of three main types of anomalies: air leakage, misoperation, and equipment failure. Each type of feature includes numerical threshold, trend of change, and time dimension features. The abnormal feature comparison steps in the second operating mode include: The preprocessed real-time data is compared with the characteristic patterns of known anomalies. After matching the corresponding anomaly features, a dedicated preprocessing logic is triggered. When matching the air leakage feature, the pressure gradient feature is retained; when matching the misoperation feature, the short-term spike feature is retained; and when matching the equipment failure feature, the periodic fluctuation and temperature anomaly correlation feature is retained. The time-series feature extraction method includes trend analysis and periodic identification. In the first operating mode, the sliding window method is used to capture short-term fluctuation characteristics of the data, and the periodic graph analysis is used to identify long-term repetitive patterns of the data. In the second operating mode, a sliding window compression technique is used to enhance the capture of instantaneous anomalies, and the characteristics of unexpected flow changes are identified through difference analysis. The redundant information stripping technique uses a feature importance ranking method to remove feature variables whose impact on the processing results is lower than a set threshold. In the second operating mode, user identification-related features, pipeline local parameter features, and equipment health-related features are retained. The edge-side data mapping rule is used to map different types of data into feature vectors of a unified dimension.

[0008] Furthermore, the construction of a reinforcement learning model adapted to the two modes based on the extracted features includes the following steps: The state space of the model is defined based on the features corresponding to the two modes. The state space of the first operating mode includes the feature parameters related to normal gas consumption, and the state space of the second operating mode includes the feature parameters related to normal gas consumption and the feature parameters related to abnormality. Using the data processing parameter adjustment amount as the action space of the model, the second running mode additionally incorporates the anomaly detection threshold and user location weight into the action space parameters. The design incorporates a multi-objective reward function that adapts to two modes. The accuracy error value and processing delay time of gas data processing are used as core input variables, while the energy consumption value of edge nodes and the false alarm rate of users are used as constraint input variables. The reward benchmark is determined by the Pareto optimal solution set. The first operating mode focuses on the balance between accuracy and energy consumption, while the second operating mode focuses on the balance between accuracy, real-time performance and false alarm rate. A deep reinforcement learning network architecture is constructed, using multilayer perceptrons to extract feature mapping relationships, combined with recurrent units to capture the temporal correlation of data processing, and a local feature focusing module is added for the second operating mode to complete the basic construction of the reinforcement learning model.

[0009] Furthermore, the process of splitting the model training module and simplifying the training process by leveraging knowledge transfer includes the following steps: Construct pipeline and user simulation scenarios, restore pipeline topology, user terminal equipment and environmental factors, simulate the anomaly occurrence process under different scenarios, and generate semi-realistic anomaly data; Based on semi-real anomaly data, the feature distribution of real anomalies is learned through the generation end of the data generation model to generate high-fidelity composite anomaly samples, which are then added to the training sample set. The preprocessed historical gas consumption data and supplemented composite abnormal samples under the two modes are divided into training set, validation set and test set respectively. The number of training iterations and convergence threshold are set. The training samples of the first operating mode are mainly normal gas consumption data and slightly abnormal data, while the training samples of the second operating mode are mainly composite abnormal data and real abnormal data generated by simulated scenarios. The reinforcement learning model is split into a pattern recognition module, a normal data processing module, and an anomaly recognition and localization module. A knowledge transfer simplification strategy is adopted. First, the complex basic model is trained. After training with the training set until convergence, the learned features and rules are transferred to two simplified models respectively, which are adapted to the first and second operating modes respectively. By recording past interaction information during model training, saving relevant samples of states, actions and corresponding rewards generated during training, setting sampling weights for anomaly identification samples in the second running mode, and randomly selecting samples to update the parameters of the corresponding modules. The model's processing accuracy, response speed, energy consumption, and false alarm rate are monitored in real time using a validation set in both modes. Training is stopped and the model parameters are saved when the Pareto optimal solution set requirement is met after multiple consecutive iterations.

[0010] Furthermore, the near real-time data processing node adopts a low-power multi-core processor and an embedded real-time operating system, and combines communication protocols to realize data transmission. It is set up in the gas data collection centralized area, important scheduling nodes and user-end branch pipeline nodes. The edge nodes, acting as local clients for federated learning, perform feature extraction and encryption on local data from multiple sources. They only upload the encrypted feature vectors to the central node for global fusion, without transmitting the original data. Simultaneously, they complete feature alignment of local data from multiple sources through edge-side data mapping rules. In the first operating mode, the aligned data undergoes routine preliminary processing before being transmitted to the reinforcement learning model. In the second operating mode, they simultaneously complete the association matching between user-end data and network node data, as well as the preliminary comparison of abnormal features. The edge nodes adopt a basic computing power and dynamic expansion configuration, and automatically call the backup computing power module when the second operating mode or when the data volume surges.

[0011] Furthermore, the dynamic adjustment of reinforcement learning model parameters and operating parameters for both modes based on the deviation analysis between actual operating data and model processing results includes the following steps: The model's dynamic processing output is compared with the actual gas consumption data calibration value. The accuracy deviation, real-time difference, and edge node energy consumption deviation are calculated for the two modes respectively. The anomaly identification error and positioning deviation are calculated additionally for the second operating mode. Based on the above deviation values, an adaptive adjustment algorithm is used to dynamically correct the reward function weights and network parameters of the model, and simultaneously optimize the regular detection threshold of the first operating mode and the enhanced detection frequency and anomaly judgment threshold of the second operating mode. By combining the changing trends of gas usage patterns under the two modes and the newly added abnormal cases, samples of new scenarios are generated through simulation scenarios and data generation models. The training sample sets of the two modes are updated regularly to perform incremental training on the model.

[0012] On the other hand, this application provides a natural gas consumption data processing system based on reinforcement learning, the system comprising: The gas consumption data acquisition unit is used to collect raw natural gas consumption data, and adjusts the acquisition frequency by combining user gas consumption behavior profiles and real-time scene perception results to provide raw data input for subsequent data processing. The time period type identification module identifies the current normal or abnormal gas consumption period based on preset time division rules, and automatically switches to the corresponding first or second operating mode to achieve matching between processing mode and time period characteristics. The data preprocessing module receives the mode signal output by the time period type identification module, and performs differentiated operations of light preprocessing or enhanced preprocessing on the raw gas consumption data in the first and second operating modes respectively to complete data purification and normalization. The feature extraction and fusion module captures the time-dimensional change patterns of the two types of preprocessed pattern data to extract targeted features, and realizes feature alignment and fusion of multi-source data through edge side data mapping rules to form a feature dataset adapted to the two operating modes. The reinforcement learning model building and training module constructs a dual-mode reinforcement learning model based on the aforementioned feature dataset. It simplifies the training process by splitting the training module and using knowledge transfer strategies, while supplementing training samples with simulated scenarios and data generation techniques to complete model training and optimization. The near real-time data processing node is equipped with a trained reinforcement learning model to dynamically process feature data in two modes. In the second operating mode, anomaly type identification and abnormal user location are completed simultaneously, and the final processing results and anomaly judgment information are output. The parameter dynamic adjustment module dynamically corrects the reinforcement learning model parameters and the operating parameters of the two modes based on multi-dimensional deviation analysis between actual operating data and model processing results. At the same time, it supplements and updates the training sample set, so that the system can continuously adapt to dynamic gas usage scenarios.

[0013] Furthermore, the reinforcement learning model construction and training module includes: a simulated scene generation unit, a data generation model, a sample partitioning unit, a model splitting unit, and a training optimization unit; The simulation scenario generation unit is used to recreate the pipeline network topology, user terminal equipment and environmental factors, construct high-fidelity pipeline network and user simulation scenarios, simulate the abnormal occurrence process under different working conditions, and generate semi-realistic abnormal data. The data generation model is used to generate high-fidelity composite anomaly samples based on semi-real anomaly data. By learning the feature distribution of real anomalies through the generation end, it can supplement the training sample set and solve the problem of scarcity of real anomaly samples. The sample partitioning unit is used to receive preprocessed historical gas consumption data and supplementary composite abnormal samples, and divide them into training set, validation set and test set according to preset ratio. At the same time, it sets the number of training iterations, convergence threshold and other key training parameters, and selects suitable samples according to the needs of the two operating modes. The model splitting unit is used to split the reinforcement learning base model into a pattern recognition module, a normal data processing module, and an anomaly recognition and localization module. It adopts a knowledge transfer simplification strategy, first trains the base model until convergence, and then passes the learned features and rules to the two simplified models, which are adapted to the first and second running modes respectively. The training optimization unit is used to record the state, actions and corresponding reward samples during the model training process. It sets sampling weights for anomaly identification samples in the second running mode and randomly selects samples to update the corresponding module parameters. At the same time, it monitors the processing accuracy, response speed, energy consumption and false alarm rate of the model in the two modes in real time through the validation set. When the Pareto optimal solution set requirement is met for multiple consecutive iterations, training is stopped and the model parameters are saved.

[0014] The beneficial effects of this invention are: By setting up an intelligent data collection frequency adjustment mechanism that combines user gas consumption behavior profiles with real-time scene perception, flexible data collection effects adapted to different gas consumption scenarios and time periods were achieved, providing a high-quality raw data foundation for subsequent data processing. By setting up dual operating modes based on time division rules, differentiated data processing solutions adapted to normal and abnormal gas consumption periods were obtained, achieving precise adaptation between gas supply guarantee and routine detection during normal periods and enhanced detection and anomaly identification during abnormal periods. By setting up differentiated preprocessing methods, feature extraction strategies, and multi-source data fusion mechanisms for the two modes, high-quality feature datasets that meet the needs of different modes were obtained, improving the data's adaptability to subsequent model training and data processing. By setting up a reinforcement learning model construction and training method that revolves around multiple optimization objectives and splits training modules, a model that takes into account multiple needs and has higher training efficiency was obtained, providing reliable algorithmic support for dynamic data processing. Attached Figure Description

[0015] Figure 1 A schematic flowchart of the dynamic processing method for natural gas consumption data based on reinforcement learning provided by the present invention; Figure 2 The following are schematic block diagrams illustrating the two modes of stepped frequency acquisition provided by this invention; Figure 3 A schematic flowchart illustrating the construction process of the dual-mode reinforcement learning model provided by the present invention; Figure 4 A schematic flowchart of the natural gas consumption data processing system based on reinforcement learning provided by the present invention. Detailed Implementation

[0016] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0017] Example 1 Please see Figure 1-3This invention provides a method for dynamic processing of natural gas consumption data based on reinforcement learning, including: Collect raw natural gas consumption data, and intelligently adjust the collection frequency by combining user gas consumption behavior profiles and real-time scene perception through the set gas consumption data collection unit; When collecting raw natural gas consumption data, the gas consumption data acquisition unit is used to deeply integrate the user gas consumption behavior profile generated by cluster analysis of historical data. The user gas consumption behavior profile includes the user's personalized gas consumption baseline and fluctuation range. Combined with real-time scene perception technology, the collection frequency can be intelligently and dynamically adjusted, which not only ensures the targeting of data collection, but also avoids the waste of resources caused by ineffective collection. The current time period type is identified according to the preset time division rules. The time period type includes normal gas consumption period and abnormal gas consumption period, and the first operation mode or the second operation mode is activated accordingly. The first operation mode is the gas supply guarantee and routine detection mode for normal gas consumption period, and the second operation mode is the enhanced detection and anomaly identification mode for abnormal gas consumption period. Based on the preset time division rules formulated according to the gas usage scenario type and user gas usage behavior profile, the system identifies whether the current gas usage period is normal or abnormal. The system then activates the first operating mode, which is the gas supply guarantee and regular detection mode during normal periods, or the second operating mode, which is the enhanced detection and anomaly identification mode during abnormal periods, so that the data processing strategy can be accurately matched with the gas usage characteristics of the time period. Different preprocessing methods are used for the raw gas consumption data under the two modes. Data features are extracted by combining known anomaly characteristics and dynamically adjustable adaptation rules. Data integration and alignment at the edge are used to achieve the fusion of data from multiple sources. Based on the extracted features, a reinforcement learning model adapted to the two modes is constructed. Multiple optimization objectives are set around the accuracy of gas consumption data processing, response speed, edge device energy consumption, and user experience. The model training module is split to simplify the training process. At the same time, simulation scenario settings and data generation technology are combined to supplement the training samples required. To address the needs of the two modes, a differentiated preprocessing and feature extraction scheme is adopted. That is, by combining the characteristic patterns of known anomalies, such as the numerical thresholds, changing trends and time dimension features of the three core anomalies of air leakage, misoperation and equipment failure, data features are extracted with dynamic adaptation rules. At the same time, data fusion and use are achieved through edge-side data integration and alignment technology. Based on the extracted features, a reinforcement learning model adapted to the two modes is constructed. The model is designed around the goals of gas data processing accuracy, response speed, edge device energy consumption, and user experience. The training process is simplified by splitting the training modules, and scarce samples are supplemented by simulation scenario settings and data generation technology to improve the model's capabilities. Using the trained reinforcement learning model, combined with near real-time data processing nodes, natural gas consumption data under two modes are dynamically processed. In the second operating mode, anomaly type identification and abnormal user location are completed simultaneously, and the processing results and anomaly judgment information are output. Based on the deviation analysis between the actual operating data and the model processing results, the parameters of the reinforcement learning model and the operating parameters of the two modes are dynamically adjusted, and the training sample set is supplemented and updated.

[0018] By utilizing a well-trained reinforcement learning model and combining it with near real-time data processing nodes located at key positions, gas consumption data under two modes is dynamically processed. In the second operating mode, the accurate identification of anomaly types and the location of abnormal users must be completed simultaneously, and complete processing results and anomaly judgment information must be output. Subsequently, by comparing the actual operating data with the model processing results, multi-dimensional deviation analysis is carried out to dynamically adjust the parameters of the reinforcement learning model and the operating parameters of the two modes, while continuously supplementing and updating the training sample set.

[0019] In some embodiments, the preset time division rules are formulated by combining the core features of the gas usage scenario type and the user's gas usage behavior profile to ensure that the time division is accurately matched with the actual gas usage pattern: Among them, the residential gas usage scenario focuses on high-frequency gas usage behaviors such as daily cooking and washing, and clearly defines 6:00-8:00 am, 11:30 am-1:30 pm and 5:30 pm-8:30 pm as normal gas usage periods, and the rest of the time is defined as abnormal gas usage periods due to low gas demand and small fluctuations; the commercial gas usage scenario is based on actual business activities, and its publicly announced business hours are defined as normal gas usage periods, and the time when the business is closed is defined as abnormal gas usage periods.

[0020] The user gas consumption behavior profile is generated using historical data clustering analysis algorithms such as K-means. It comprehensively includes the user's personalized gas consumption baseline, such as average daily gas consumption, peak gas consumption during typical periods, and reasonable fluctuation range. The reasonable fluctuation range is determined based on the standard deviation of historical data, providing data support for frequency adjustment and period identification.

[0021] The intelligent adjustment of the sampling frequency adopts a refined, tiered strategy, balancing data effectiveness and resource economy: In the first operating mode, it dynamically adapts to the user's personalized gas consumption baseline, increasing the sampling frequency to 1.5-2 times that of the off-peak period during peak gas consumption periods, while maintaining the base frequency during off-peak periods to reduce invalid sampling; In the second operating mode, the base sampling frequency is already set to twice that of the first operating mode. If the data is detected to deviate from the user's personalized gas consumption baseline by ±15% in real time, a scenario verification is immediately triggered. If the verification confirms the anomaly, the sampling frequency is increased in a tiered manner: base frequency, then twice the base frequency, then four times the base frequency. After the anomaly is confirmed, the frequency is stably maintained at twice the base frequency. Simultaneously, in the second operating mode, specific detection data such as the user's pressure fluctuation amplitude, pressure change rate, and flow stability deviation are collected, providing multi-dimensional evidence for anomaly analysis. Moreover, the sampling frequency after the tiered increase does not exceed four times that of the first operating mode, avoiding excessive sampling that leads to excessive energy consumption of the equipment.

[0022] In some embodiments, a differentiated preprocessing and feature extraction scheme is adopted to address the feature differences in the raw gas consumption data under the two modes, including the following steps: The first step is to acquire the raw gas consumption data collected under the corresponding mode. In the first operating mode, a light preprocessing operation is performed to balance efficiency and basic data quality: outlier screening uses the 3σ principle to remove extreme data that exceed the mean ± 3 times the standard deviation; missing value completion uses adjacent data interpolation for short-term missing values ​​and the same-period mean of users of the same type for long-term missing values; and data normalization maps gas consumption data of different levels to the [0,1] interval to ensure data format uniformity. The second step involves performing enhanced preprocessing operations in the second operating mode, further improving data purity and anomaly correlation on the basis of lightweight preprocessing: additional steps are added for data noise filtering, instantaneous fluctuation capture, and anomaly feature comparison to accurately mine anomaly-related information; The third step is to capture the time dimension change patterns of data under the two modes using professional time series feature extraction methods: under the first operating mode, the focus is on extracting periodic fluctuation features, which conform to the stable and repetitive patterns of normal gas consumption; under the second operating mode, the focus is on extracting non-periodic fluctuations, such as sudden changes in flow without a fixed period, as well as abnormal correlation features, such as inverse abnormal changes in pressure and flow, focusing on the needs of anomaly identification. The fourth step is to achieve feature alignment of data from multiple sources through edge-side data mapping rules. That is, different types of data, such as gas load, scene environment, and equipment status, are mapped into feature vectors of a unified dimension through normalization, dimensional transformation and other methods, and finally form high-quality feature datasets that are adapted to the two operating modes respectively.

[0023] In some embodiments, the characteristic patterns of the known anomalies have been verified and summarized through numerous practical cases, accurately covering the core characteristic manifestations of three main types of anomalies: air leakage, misoperation, and equipment failure. Each type of characteristic manifestation includes clear numerical thresholds, trends of change, and time dimension characteristics. Among them, the air leakage characteristic is characterized by a slow decrease in pressure at a rate of 0.01-0.05 MPa / h, lasting for more than 30 minutes, with the value being lower than 80% of the normal operating pressure threshold; the misoperation characteristic is characterized by a sudden increase in flow rate of more than 3 times within 10 seconds, forming a short-term spike, lasting for no more than 5 minutes; the equipment failure characteristic is characterized by periodic fluctuations in flow rate, with a fluctuation period of 5-15 minutes, accompanied by an abnormal increase in temperature.

[0024] The abnormal feature comparison step in the second operating mode adopts a precise matching logic: first, the pre-processed real-time data is compared with the known abnormal feature patterns in sequence according to the order of air leakage, misoperation, and equipment failure. After matching the corresponding abnormal feature, the pre-processing logic is triggered immediately. That is, when matching the air leakage feature, the continuous data sequence of pressure gradual change is retained; when matching the misoperation feature, the peak value, duration and other key parameters of short-term spikes are retained; when matching the equipment failure feature, the period, amplitude and temperature correlation data of periodic fluctuations are retained, and irrelevant interference information is filtered out.

[0025] The time-series feature extraction method comprehensively covers trend analysis and periodic identification, and is designed differently for the two modes. In the first operating mode, a 15-30 minute sliding window method is used to capture short-term fluctuation features of data, and a periodic graph analysis algorithm is used to identify long-term repetitive patterns in daily and weekly data. In the second operating mode, a sliding window compression technique is used to enhance the capture of instantaneous anomalies, and unexpected traffic change features are identified through adjacent data difference analysis. The redundant information stripping technique uses the feature importance ranking method of the random forest algorithm to remove feature variables with an impact of less than 0.05 on the processing results, ensuring the efficiency of the feature dataset.

[0026] In some embodiments, constructing a reinforcement learning model adapted to the two modes based on the extracted features includes the following steps: The first step is to define the state space of the model based on the characteristics corresponding to the two modes: the state space of the first operating mode includes the characteristic parameters related to normal gas consumption, specifically covering the gas consumption per unit time, the stable value of gas pressure, the average daily peak gas consumption duration, and the environmental temperature and humidity adaptation coefficient; the state space of the second operating mode, based on the first operating mode, additionally includes the abnormal correlation characteristic parameters, including the pressure change amplitude, the duration of abnormal flow, the equipment temperature deviation value, and the local pressure fluctuation coefficient of the pipeline network, to ensure that the state description fully covers abnormal scenarios.

[0027] The second step is to use the data processing parameter adjustment amount as the action space of the model, specifically including the adjustment amount of the filter coefficient, the adjustment amount of the feature extraction window size, and the adjustment amount of the data fusion weight. In the second running mode, the anomaly detection threshold and user positioning weight are additionally included in the action space parameters to improve the accuracy of anomaly handling.

[0028] The third step is to design a multi-objective reward function that adapts to both modes: the gas data processing accuracy error value and processing delay time are used as core input variables, while the edge node energy consumption value is also included, which is the power consumption per unit time, and the user false alarm rate is used as a constraint input variable; the reward benchmark is determined by the Pareto optimal solution set, the normalized value of each input variable is calculated, and the reward value is obtained by weighted summation according to the weights. In the first operating mode, the accuracy weight is 0.4 and the energy consumption weight is 0.3, focusing on the balance between the two; in the second operating mode, the accuracy weight is 0.3, the real-time weight is 0.3, and the false alarm rate weight is 0.2, focusing on the balance of all three.

[0029] The fourth step is to construct a deep reinforcement learning network architecture, which includes an input layer, a feature extraction layer, and a decision output layer. The input layer takes as input standardized feature vectors output by the feature extraction and fusion module. The vector dimension is determined by the number of state-space parameters in the two modes. The first operating mode includes normal gas consumption-related feature parameters with a dimension of 12-18; the second operating mode adds abnormal correlation feature parameters, expanding the dimension to 20-28. After normalization, the input data is synchronously fed into the multilayer perceptron unit of the feature extraction layer to ensure a consistent data format suitable for network computation.

[0030] The feature extraction layer, as the core feature processing unit of the network, adopts a combination structure of "multilayer perceptron (MLP) and long short-term memory (LSTM) recurrent units," which can simultaneously achieve static feature mapping and dynamic temporal correlation capture, as follows: The multilayer perceptron has 3-5 fully connected layers, with 64-128 neurons in each layer. The activation function is ReLU. The nonlinear mapping relationship between features is learned through weight iteration, and the input high-dimensional feature vector is converted into a low-dimensional dense feature representation. The LSTM recurrent unit receives the dense features output by the multilayer perceptron, sets 1-2 hidden layers, and captures the long-term and short-term dependencies of gas consumption data in the time dimension through the synergistic effect of forget gate, input gate, and output gate, and outputs a feature vector containing time-series correlation information. Local Feature Focusing Module (only compatible with the second operating mode): Employs a multi-head attention mechanism, adding a feature weight allocation stage after the LSTM unit. By calculating the similarity between each feature and anomaly-related features, it assigns 1.2-2.0 times the attention weight to anomaly-related features, strengthening the signal strength of key anomaly features while weakening interference from irrelevant features, and outputting a strengthened feature vector that focuses on anomaly information.

[0031] The decision output layer receives the feature vectors output by the feature extraction layer. It adopts a fully connected layer structure, and the output dimension corresponds one-to-one with the number of parameters in the model's action space, as detailed below: The first operating mode outputs 3-5 dimensions, corresponding to the adjustment of data processing parameters. The activation function is Sigmoid, and the output value is mapped to the [0,1] interval, serving as the quantitative basis for parameter adjustment. The second operating mode expands the output dimensions to 5-7 dimensions. Based on the output parameters of the first operating mode, it adds anomaly judgment threshold adjustment and user location weight allocation values. The activation function adopts a hybrid strategy to ensure that the output conforms to the actual parameter value range. The action instructions finally output by the output layer directly serve as the model's decision results for the current gas consumption data processing scenario, guiding subsequent data processing procedures and parameter configurations.

[0032] In some embodiments, the splitting of the model training module and the simplification of the training process by leveraging knowledge transfer includes the following steps: The first step is to construct a high-fidelity pipeline network and user simulation scenarios: using simulation software to recreate the pipeline network topology, user-end equipment models and operating status, and environmental factors, such as temperature, humidity, and air pressure, to simulate the abnormal occurrence process under different scenarios, such as pipeline aging, user misoperation, and long-term equipment operation, and generate semi-realistic abnormal data. The semi-realistic abnormal data contains a complete data chain of abnormal occurrence time, development trend, and final result.

[0033] The second step is to supplement high-quality training samples: Based on semi-real anomaly data, a Generative Adversarial Network (GAN) is used as a data generation model. The generator learns the feature distribution of real anomalies and generates high-fidelity composite anomaly samples, such as combined anomaly data of air leakage and minor equipment failure. These samples are then added to the training sample set to solve the problem of scarcity of real anomaly samples.

[0034] The third step is sample partitioning and parameter setting: The preprocessed historical gas consumption data and supplementary composite abnormal samples under the two modes are divided into training set, validation set and test set in a ratio of 7:1:2. The training samples of the first operating mode are mainly normal gas consumption data, accounting for 70%, and slightly abnormal data, accounting for 30%. The training samples of the second operating mode are mainly composite abnormal data, accounting for 50%, and real abnormal data generated by simulated scenarios, accounting for 50%. At the same time, the number of training iterations is set to 500-1000 rounds, and the convergence threshold is that the fluctuation of the reward function value does not exceed 0.01 for 10 consecutive rounds.

[0035] The fourth step, model decomposition and knowledge transfer: A decomposition strategy combining general module reuse and specialized module adaptation, along with a knowledge transfer mechanism involving parameter transfer and feature sharing, is adopted to achieve efficient adaptation of the dual-mode model. This ensures the functional specificity of both modes while avoiding the waste of computational power caused by repeated training. The implementation process is as follows: First, a full-featured basic model was built, consisting of a complex foundation encompassing pattern recognition, normal data processing, and anomaly identification and localization. This complex model's network structure comprehensively covers the core capabilities required for both modes. The basic model includes a complete feature extraction layer, pattern judgment layer, normal data processing branch, and anomaly identification and localization branch. The feature extraction layer learns general gas consumption data feature mapping relationships and time-series correlations to adapt to the basic feature processing requirements of both modes. The pattern judgment layer outputs the probabilities of normal and abnormal modes based on the time period identifiers and data fluctuation features in the input feature vector. The normal data processing branch focuses on parameter optimization logic that balances accuracy and energy consumption, while the anomaly identification and localization branch includes dedicated logic for anomaly feature matching, type classification, and user location weight calculation. After construction, the basic model was trained using the full training set, iterating until convergence. The convergence criterion was that the reward function value fluctuation did not exceed 0.01 for 10 consecutive rounds, ensuring the basic model fully grasped the core processing rules and feature patterns of both modes.

[0036] Next, the specific boundaries and functional allocation of the module split were clarified. Based on the structure of the basic model and the differentiated requirements of the dual modes, it was split into three independent modules. The core function of the pattern recognition module is to determine the current operating mode based on input features and output a mode switching command. Its input is the feature vector output by the feature extraction and fusion module and the current time period information; the output is the mode identifier. This module is a dual-mode universal module. The core function of the normal data processing module is to optimize the normal gas consumption data processing parameters and output the processing parameter adjustment amount adapted to the first mode. Its input is the 0 identifier output by the pattern recognition module and the normal feature dataset; the output is the filter coefficient, window size, and fusion weight adjustment amount, adapted to the first operating mode. The core function of the anomaly identification and localization module is to realize anomaly feature enhancement, type determination, and user location weight calculation, outputting anomaly-related parameters and location results. Its input is the 1 identifier output by the pattern recognition module and the anomaly feature dataset; the output is the anomaly determination threshold, location weight, and anomaly type label, adapted to the second operating mode. The splitting follows the principle of reusing general capability modules and adapting special capability modules separately. The pattern recognition module reuses the pattern judgment layer and related parameters of the basic model, while the normal data processing module and the anomaly recognition and localization module reuse the branch structure and core parameters corresponding to the basic model, ensuring that each module is functionally complete after splitting. At the same time, the interface between modules adopts a standardized design, and the output of the pattern recognition module serves as the switch signal for subsequent special modules. Special modules are only activated under the corresponding pattern identifier.

[0037] Subsequently, the definitions and knowledge transfer implementation methods of the two simplified models were clarified. The two simplified models, after being split, are adapted to two different operating modes, with their core parameters and rules inherited from the base model through knowledge transfer. The first simplified model is a normal data processing simplified model, consisting of a pattern recognition module, a normal data processing module, and a basic feature extraction layer. The knowledge transfer content includes the MLP weights of the feature extraction layer, the forget gate and input gate weights of the LSTM unit, the parameter adjustment logic and reward function weights of the normal data processing branch, and the normal gas consumption periodicity characteristics learned by the base model, adapting to the first operating mode. The second simplified model is an anomaly identification and localization simplified model, consisting of a pattern recognition module, an anomaly identification and localization module, a basic feature extraction layer, and a local feature focusing module. The knowledge transfer content includes all parameters of the feature extraction layer, the anomaly feature matching rules, type classifier parameters, and user location weight calculation logic of the anomaly identification and localization branch, the attention weight allocation rules of the local feature focusing module, and the distribution patterns of the three types of anomaly features learned by the base model, adapting to the second operating mode. Knowledge transfer is achieved through three specific methods: First, parameter transfer, which directly copies the network parameters of the corresponding modules in the base model to the same layer in the simplified model as initialization parameters, avoiding training from scratch; second, feature sharing, which allows the simplified model to directly possess the general feature mapping relationship learned by the base model through parameter reuse in the feature extraction layer; and third, rule inheritance, which synchronizes the rules such as pattern judgment thresholds and abnormal feature matching standards formed during the training of the base model to the simplified model through configuration files, ensuring consistency in processing logic.

[0038] After knowledge transfer, the two simplified models are fine-tuned to ensure they fully adapt to the requirements of the corresponding modes. For the simplified model of normal data processing, fine-tuning is performed using the dedicated training set for the first mode, iterating 50-100 times. The focus is on optimizing the balance parameters between accuracy and energy consumption, ensuring that dynamic adjustment of the acquisition frequency and routine detection thresholds meet the operational requirements during normal periods. For the simplified model of anomaly identification and localization, fine-tuning is performed using the dedicated training set for the second mode, iterating 80-150 times. The focus is on optimizing the anomaly judgment threshold, the weight allocation of the local feature focusing module, and the user location weight calculation logic to improve anomaly identification accuracy and localization precision. During fine-tuning, the parameters of the pattern recognition module remain unchanged; only the local parameters of the dedicated processing module are updated to ensure the stability of pattern judgment.

[0039] Finally, the linkage logic for dual-mode switching is clarified. In actual deployment, the three separate modules work together through standardized interfaces to achieve seamless mode switching. First, the feature dataset output by the feature extraction and fusion module is fed into the pattern recognition module. The pattern recognition module outputs a pattern identifier based on the time period features and data fluctuation amplitude in the features, combined with the judgment rules inherited from the basic model. If it is the first mode identifier, the normal data processing simplified model is started, the anomaly identification and localization module is closed, and the parameter adjustment amount is output according to the normal data processing logic. If it is the second mode identifier, the anomaly identification and localization simplified model is started, and the local feature focusing module is called simultaneously to complete anomaly identification and user localization, and output complete anomaly information.

[0040] The fifth step is to optimize the training process: record past interaction information during model training through an experience replay mechanism, and save relevant samples of states, actions and corresponding rewards generated during training; set a sampling weight of 1.5-2 times for anomaly identification samples in the second running mode, randomly select samples to update the parameters of the anomaly identification and localization module, and improve the anomaly handling capability.

[0041] Step 6, performance monitoring and model saving: The model's processing accuracy, response speed, energy consumption and false alarm rate are monitored in real time in both modes through the validation set. When the Pareto optimal solution set requirement is met for 10 consecutive iterations, training is stopped and the model parameters are saved.

[0042] In some embodiments, the near real-time data processing node adopts a high-performance, low-power design: It is equipped with an ARM Cortex-A series multi-core processor and an embedded real-time operating system, such as FreeRTOS or VxWorks, to ensure the real-time performance and stability of data processing; it supports multiple communication protocols such as MQTT and TCP / IP to achieve efficient data transmission with the acquisition unit and central node; and its deployment location is precisely planned to cover areas with concentrated gas data acquisition and important scheduling nodes, such as pipeline distribution stations and user-end branch pipeline nodes, ensuring that data is processed nearby and responded to quickly.

[0043] The edge nodes integrate federated learning and edge computing technologies: as local clients of federated learning, they first extract features from various sources of data, such as gas load, equipment status, and scene environment, using the PCA algorithm, and then encrypt them using homomorphic encryption technology. Only the encrypted feature vectors are uploaded to the central node for global fusion, without transmitting the original data, effectively protecting user data privacy and security. Simultaneously, through edge-side data mapping rules, such as dimensional transformation based on a unified data dictionary, feature alignment of local multi-source data is completed. In the first operating mode, the aligned data undergoes routine preliminary processing, such as format standardization, before being transmitted to the reinforcement learning model to meet the high-efficiency requirements of routine detection. In the second operating mode, the association and matching of user-end data and pipeline node data are completed simultaneously, that is, based on user identifiers and pipeline location codes, as well as preliminary comparison of abnormal features, laying the foundation for accurate model processing.

[0044] The edge nodes adopt an elastic computing power configuration scheme: the basic computing power is set to meet the data processing needs of the first operating mode on a daily basis. When switching to the second operating mode or when the data volume surges, the backup computing power module is automatically called to ensure stable data processing performance and avoid response delays caused by insufficient computing power.

[0045] In some embodiments, the dynamic adjustment of reinforcement learning model parameters and operating parameters for both modes based on the deviation analysis between actual operating data and model processing results includes the following steps: The first step is to calculate the multi-dimensional deviation: The dynamic processing output of the model is compared with the actual gas consumption data calibration value, and the key deviation indicators are calculated for the two modes respectively: the accuracy deviation is calculated using the mean square error, the real-time difference is the difference between the model processing time and the standard processing time, and the edge node energy consumption deviation is the ratio of the actual energy consumption to the designed energy consumption; in the second operating mode, the anomaly identification error and positioning deviation are calculated separately, that is, the distance error between the actual location of the abnormal user and the model positioning location, in meters.

[0046] The second step is dynamic parameter correction: Based on the above deviation values, the particle swarm optimization algorithm is used as an adaptive adjustment algorithm to dynamically correct the reward function weights of the model. For example, when the accuracy deviation is too large, the accuracy weight is increased, as well as the network parameters, such as the forget gate weight of the LSTM unit and the connection weight of the multilayer perceptron. At the same time, the normal detection threshold of the first running mode and the enhanced detection frequency and anomaly judgment threshold of the second running mode are optimized to ensure that the parameters are adapted to the actual running state.

[0047] The third step is sample updating and incremental training: Combining the gas usage pattern change trends and new abnormal cases under the two modes, samples of new scenarios are generated through simulated scenarios and data generation models. The training sample sets of the two modes are updated once a month. The model is incrementally trained, with each training iteration consisting of 100-200 rounds. Based on the original model parameters, fine-tuning is performed to ensure that the model continuously adapts to new scenarios and new abnormalities and maintains stable processing performance.

[0048] Example 2 On the other hand, see Figure 4 This application provides a natural gas consumption data processing system based on reinforcement learning. The system is modularly designed, with each module working together to form a complete data processing chain, specifically including: The gas consumption data acquisition unit consists of a high-precision gas flow sensor, pressure sensor, temperature sensor, data storage module, and communication module. Its core function is to collect raw natural gas consumption data, which includes gas load data, gas consumption scenario-related data, user behavior tag data, and equipment health data. It also incorporates a frequency adjustment algorithm that intelligently adjusts the acquisition frequency by combining user gas consumption behavior profiles generated through historical data clustering analysis with real-time scenario perception results. During normal gas consumption periods, the frequency dynamically fluctuates around a personalized baseline, while during abnormal gas consumption periods, it is adjusted according to a step-by-step strategy, providing high-quality, targeted raw data input for subsequent data processing.

[0049] Time Period Type Recognition Module: Equipped with a time period recognition algorithm, based on preset time division rules, that is, combined with gas usage scenario type and user gas usage behavior profile, the module takes current time information, gas usage scenario identifier and real-time gas usage data as input, and accurately identifies the current normal or abnormal gas usage period by comparing the time period division threshold with real-time gas usage characteristics. After recognition, the module automatically triggers a mode switching command to switch the system operation status to the corresponding first or second operation mode, and synchronizes the mode signal to the data preprocessing module and near real-time data processing node to ensure that the end-to-end processing strategy matches the time period characteristics.

[0050] Data preprocessing module: It has two switchable algorithm logics: lightweight preprocessing and enhanced preprocessing. By receiving the pattern signal output by the time period type recognition module, it automatically matches the corresponding preprocessing scheme. For the first operating mode, it performs lightweight preprocessing operation, uses the 3σ principle to filter outliers, fills short-term missing data with adjacent data interpolation, and fills long-term missing data with the average value of users of the same type during the same period. It normalizes the data to the [0,1] interval to complete data normalization. For the second operating mode, it performs enhanced preprocessing operation on the basis of lightweight preprocessing. This includes using wavelet transform to filter data noise, capturing instantaneous fluctuations through sliding window compression technology, and comparing the preprocessed data with known anomaly characteristics to mine anomaly-related information and output preprocessed data with higher cleanliness.

[0051] Feature Extraction and Fusion Module: This module integrates professional time-series feature extraction algorithms with edge-side data fusion mechanisms to extract features from preprocessed data for two different operating modes. In the first operating mode, a sliding window method is used to capture short-term fluctuation features, and periodic graph analysis is used to identify long-term repetitive patterns, with a focus on extracting periodic fluctuation features. In the second operating mode, difference analysis is used to identify unexpected flow change features, with a focus on extracting non-periodic fluctuations and abnormal correlation features. Simultaneously, through edge-side data mapping rules, multi-source data such as gas load, scene environment, and equipment status are mapped into feature vectors of a unified dimension, achieving feature alignment and fusion of multi-source data. Ultimately, high-quality feature datasets adapted to the two operating modes are formed, providing input for model training and dynamic data processing.

[0052] The reinforcement learning model construction and training module, as the system's algorithm unit, is responsible for constructing and training a reinforcement learning model adapted to both modes. Based on the two types of feature datasets output by the feature extraction and fusion module, it defines the state space and action space for the two modes respectively, and designs a multi-objective reward function. It adopts a deep reinforcement learning network architecture using multilayer perceptrons and recurrent units (LSTM), and adds a local feature focusing module for the second operating mode. It simplifies the training process by splitting the training module and using knowledge transfer strategies, and supplements training samples by combining simulated scene generation and data generation techniques. Finally, it outputs a reinforcement learning model that adapts to the differentiated processing requirements of the two modes.

[0053] Near real-time data processing node: Deployed in areas with concentrated gas data collection, important scheduling nodes (such as pipeline distribution stations), and user-end branch pipeline nodes. The hardware adopts a low-power multi-core processor (ARM Cortex-A series) paired with an embedded real-time operating system (FreeRTOS / VxWorks), supporting multiple communication protocols such as MQTT and TCP / IP to achieve efficient data transmission with various modules. As the core execution unit for data processing, it is equipped with a trained reinforcement learning model, receives the feature dataset output by the feature extraction and fusion module, and dynamically processes the data in two modes. In the first operating mode, it focuses on gas supply guarantee and routine detection, and outputs the normal gas consumption data processing results. In the second operating mode, it simultaneously runs the abnormal type identification algorithm and the abnormal user location algorithm, and outputs the complete processing results and abnormal judgment information.

[0054] The parameter dynamic adjustment module incorporates a built-in deviation analysis algorithm and an adaptive adjustment algorithm. By comparing the output results of near real-time data processing nodes with the actual gas consumption data calibration values, it conducts multi-dimensional deviation analysis, including accuracy deviation, real-time performance differences, and edge node energy consumption deviations in the two modes. In the second operating mode, it additionally calculates anomaly identification errors and positioning deviations. Based on the above deviation values, it uses a particle swarm optimization algorithm to dynamically correct the reward function weights and network parameters of the reinforcement learning model, and simultaneously optimizes the conventional detection threshold of the first operating mode and the reinforcement detection frequency and anomaly judgment threshold of the second operating mode. At the same time, it combines the gas consumption pattern change trends and new anomaly cases in the two modes, generates new scenario samples through simulated scenarios and data generation models, regularly updates the training sample set, and incrementally trains the model to ensure that the system continuously adapts to dynamic gas consumption scenarios.

[0055] In some embodiments, the reinforcement learning model construction and training module includes: Simulation Scenario Generation Unit: Based on real pipeline network data and user gas consumption scenario information, it uses professional simulation tools (ANSYS, MATLAB) to recreate the pipeline network operating environment, user-end equipment operating status and environmental influencing factors; by setting different operating parameters, it simulates the abnormal occurrence process under different scenarios, and generates semi-realistic abnormal data containing abnormal occurrence time, data change curves and final results, providing basic data support for sample supplementation.

[0056] Data generation model: Adopting a GAN architecture, it consists of a generator and a discriminator. The generator uses semi-realistic anomaly data output by the simulated scene generation unit as training samples to learn the feature distribution of real anomalies and generate high-fidelity composite anomaly samples. The discriminator receives generated samples and real anomaly samples, verifies the authenticity of the samples, removes generated samples that do not conform to the features of real anomalies, and supplements the training sample set with high-fidelity composite anomaly samples that pass the verification, thus solving the problems of scarce real anomaly samples and the inability of a single anomaly sample to cover complex scenarios.

[0057] Sample partitioning unit: Receives preprocessed historical gas consumption data from the data preprocessing module under two modes, as well as composite abnormal samples supplemented by the data generation model, and divides them into training set, validation set, and test set in a 7:1:2 ratio; samples are selected to meet the differentiated needs of the two operating modes, with the training samples for the first operating mode mainly consisting of normal gas consumption data and slightly abnormal data, and the training samples for the second operating mode mainly consisting of composite abnormal data and real abnormal data generated from simulated scenarios; at the same time, core training parameters are set, including the number of training iterations, convergence threshold, and learning rate, to provide standardized input for model training.

[0058] Model Splitting Unit: Employing a model splitting and knowledge transfer strategy, a complex base model is first constructed, encompassing full functionality of pattern recognition, normal data processing, and anomaly detection and localization. The training set is then input into the base model for training until the model's processing accuracy, response speed, energy consumption, and other metrics meet preset requirements and converge. Subsequently, the feature extraction rules, parameter initialization values, network layer weights, and other knowledge learned by the base model are transferred to two simplified models through parameter transfer and feature sharing. One simplified model retains the core functionality of normal data processing and adapts to the first operating mode; the other simplified model enhances the anomaly detection and localization function and adapts to the second operating mode. This process quickly completes the adaptation of the dual-mode models, reducing the complexity and computational consumption of training two models separately.

[0059] Training and optimization unit: It incorporates an experience replay mechanism and dynamic sampling strategy to record state data, action commands, and corresponding reward value samples during model training, constructing a sample replay pool. For anomaly identification samples in the second operating mode, a sampling weight of 1.5-2 times is set, prioritizing the extraction of such samples during parameter updates to optimize the performance of the anomaly identification and localization module. Simultaneously, the validation set is input into two simplified models, and the core performance indicators of the model in both modes are monitored in real time, including processing accuracy, response speed, edge node energy consumption, and user false alarm rate. When all performance indicators of the model meet the Pareto optimal solution set requirements for 10 consecutive iterations, training is stopped, model parameters are saved, and a final model file adapted to both operating modes is generated for use by near real-time data processing nodes.

[0060] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the protection scope of the present invention.

Claims

1. A natural gas consumption data processing method based on reinforcement learning, characterized in that, The method includes the following steps: Collect raw natural gas consumption data, and intelligently adjust the collection frequency by combining user gas consumption behavior profiles and real-time scene perception through the set gas consumption data collection unit; The current time period type is identified according to the preset time division rules. The time period type includes normal gas consumption period and abnormal gas consumption period, and the first operation mode or the second operation mode is activated accordingly. The first operation mode is the gas supply guarantee and routine detection mode for normal gas consumption period, and the second operation mode is the enhanced detection and anomaly identification mode for abnormal gas consumption period. Different preprocessing methods are used for the raw gas consumption data under the two modes. Data features are extracted by combining known anomaly characteristics and dynamically adjustable adaptation rules. Data integration and alignment at the edge are used to achieve the fusion of data from multiple sources. Based on the extracted features, a reinforcement learning model adapted to the two modes is constructed. Multiple optimization objectives are set around the accuracy of gas consumption data processing, response speed, edge device energy consumption, and user experience. The model training module is split to simplify the training process. At the same time, simulation scenario settings and data generation technology are combined to supplement the training samples required. Using the trained reinforcement learning model, combined with near real-time data processing nodes, natural gas consumption data under two modes are dynamically processed. In the second operating mode, anomaly type identification and abnormal user location are completed simultaneously, and the processing results and anomaly judgment information are output. Based on the deviation analysis between the actual operating data and the model processing results, the parameters of the reinforcement learning model and the operating parameters of the two modes are dynamically adjusted, and the training sample set is supplemented and updated.

2. The method for dynamic processing of natural gas consumption data based on reinforcement learning according to claim 1, characterized in that, The preset time division rules are determined based on the type of gas usage scenario and the user's gas usage behavior profile. Normal gas usage periods for residential gas usage scenarios include 6:00-8:00 AM, 11:30 AM-1:30 PM, and 5:30 PM-8:30 PM daily, while abnormal gas usage periods are the remaining times. Normal gas usage periods for commercial gas usage scenarios are their business hours, while abnormal gas usage periods are their shutdown times. The user's gas usage profile is generated through historical data clustering analysis, including the user's personalized gas usage baseline and fluctuation range; The intelligent adjustment of the acquisition frequency adopts a step-by-step strategy, including: In the first operating mode, the gas consumption fluctuates dynamically around the user's personalized gas consumption baseline, with a higher sampling frequency during peak hours than during off-peak hours. In the second operating mode, if the real-time data deviates from the user's personalized gas consumption baseline by ±15%, a scenario verification is triggered. If the verification is still abnormal, the collection frequency is increased in steps of basic frequency, 2 times, and 4 times. After the abnormality is confirmed, the frequency is maintained at 2 times. The first operating mode has a sampling frequency adapted to normal gas supply demand. The second operating mode has a basic sampling frequency that is twice that of the first operating mode, and after a step-by-step increase, it does not exceed four times that of the first operating mode. In addition, the second operating mode simultaneously collects special detection data on user-end pressure fluctuations and flow stability.

3. The method for dynamic processing of natural gas consumption data based on reinforcement learning according to claim 1, characterized in that, Different preprocessing methods were used to extract data features from the raw gas consumption data under the two modes, including the following steps: Acquire the raw gas consumption data collected under the corresponding mode. Perform light preprocessing operations in the first operating mode, including outlier filtering, missing value completion, and data normalization. The second operating mode performs enhanced preprocessing operations, adding data noise filtering, instantaneous fluctuation capture, and anomaly feature comparison steps on top of the lightweight preprocessing. The temporal feature extraction method was used to capture the temporal dimension change pattern of the data under two different modes. The first mode focused on extracting periodic fluctuation features, while the second mode focused on extracting non-periodic fluctuation and abnormal correlation features. By using edge-side data mapping rules, feature alignment of data from multiple sources is achieved, forming feature datasets that are adapted to the two operating modes respectively.

4. The method for dynamic processing of natural gas consumption data based on reinforcement learning according to claim 3, characterized in that, The known anomaly features include the characteristics of three main types of anomalies: air leakage, misoperation, and equipment failure. Each type of feature includes numerical threshold, trend, and time dimension features. The abnormal feature comparison steps in the second operating mode include: The preprocessed real-time data is compared with the characteristic patterns of known anomalies, and the corresponding anomaly features are matched to trigger dedicated preprocessing logic. The time-series feature extraction method includes trend analysis and periodic identification. In the first operating mode, the sliding window method is used to capture short-term fluctuation characteristics of the data, and the periodic graph analysis is used to identify long-term repetitive patterns of the data. In the second operating mode, a sliding window compression technique is used to enhance the capture of instantaneous anomalies, and the characteristics of unexpected traffic changes are identified through difference analysis; the redundant information stripping technique uses a feature importance ranking method to remove feature variables whose influence on the processing results is lower than a set threshold.

5. The method for dynamic processing of natural gas consumption data based on reinforcement learning according to claim 1, characterized in that, The construction of a reinforcement learning model adapted to both modes based on the extracted features includes the following steps: The state space of the model is defined based on the features corresponding to the two modes. The state space of the first operating mode includes the feature parameters related to normal gas consumption, and the state space of the second operating mode includes the feature parameters related to normal gas consumption and the feature parameters related to abnormality. Using the data processing parameter adjustment amount as the action space of the model, the second running mode additionally incorporates the anomaly detection threshold and user location weight into the action space parameters. The design incorporates a multi-objective reward function that adapts to two modes. The accuracy error value and processing delay time of gas data processing are used as core input variables, while the energy consumption value of edge nodes and the false alarm rate of users are used as constraint input variables. The reward benchmark is determined by the Pareto optimal solution set. In the first operating mode, the focus is on the balance between accuracy and energy consumption, while in the second operating mode, the focus is on the balance between accuracy, real-time performance and false alarm rate. A deep reinforcement learning network architecture is constructed, using a multilayer perceptron to extract feature mapping relationships, combined with recurrent units to capture the temporal correlation of data processing, and a local feature focusing module is added for the second operating mode to complete the basic construction of the reinforcement learning model.

6. The method for dynamic processing of natural gas consumption data based on reinforcement learning according to claim 5, characterized in that, The process of splitting the model training module and simplifying the training process by leveraging knowledge transfer includes the following steps: Construct pipeline and user simulation scenarios, restore pipeline topology, user terminal equipment and environmental factors, simulate the anomaly occurrence process under different scenarios, and generate semi-realistic anomaly data; Based on semi-real anomaly data, the feature distribution of real anomalies is learned through the generation end of the data generation model to generate high-fidelity composite anomaly samples, which are then added to the training sample set. The preprocessed historical gas consumption data and supplemented composite abnormal samples under the two modes are divided into training set, validation set and test set, respectively, and the number of training iterations and convergence threshold are set. The reinforcement learning model is split into a pattern recognition module, a normal data processing module, and an anomaly recognition and localization module. A knowledge transfer simplification strategy is adopted. First, the complex basic model is trained. After training with the training set until convergence, the learned features and rules are transferred to two simplified models respectively, which are adapted to the first and second operating modes respectively. By recording past interaction information during model training, saving relevant samples of states, actions and corresponding rewards generated during training, setting sampling weights for anomaly identification samples in the second running mode, and randomly selecting samples to update the parameters of the corresponding modules. The model's processing accuracy, response speed, energy consumption, and false alarm rate are monitored in real time using a validation set in both modes. Training is stopped and the model parameters are saved when the Pareto optimal solution set requirement is met after multiple consecutive iterations.

7. The method for dynamic processing of natural gas consumption data based on reinforcement learning according to claim 1, characterized in that, The near real-time data processing node adopts a low-power multi-core processor and an embedded real-time operating system, and combines a communication protocol to realize data transmission. It is set up in the gas data collection centralized area, important scheduling nodes and user-end branch pipeline nodes. The edge nodes, acting as local clients for federated learning, perform feature extraction and encryption on local data from multiple sources. They only upload the encrypted feature vectors to the central node for global fusion, without transmitting the original data. Simultaneously, they complete feature alignment of local data from multiple sources through edge-side data mapping rules. In the first operating mode, the aligned data undergoes routine preliminary processing before being transmitted to the reinforcement learning model. In the second operating mode, they simultaneously complete the association matching between user-end data and network node data, as well as the preliminary comparison of abnormal features. The edge nodes adopt a basic computing power and dynamic expansion configuration, and automatically call the backup computing power module when the second operating mode or when the data volume surges.

8. The method for dynamic processing of natural gas consumption data based on reinforcement learning according to claim 1, characterized in that, The dynamic adjustment of reinforcement learning model parameters and operating parameters for both modes based on deviation analysis between actual operating data and model processing results includes the following steps: The model's dynamic processing output is compared with the actual gas consumption data calibration value. The accuracy deviation, real-time difference, and edge node energy consumption deviation are calculated for the two modes respectively. The anomaly identification error and positioning deviation are calculated additionally for the second operating mode. Based on the above deviation values, an adaptive adjustment algorithm is used to dynamically correct the reward function weights and network parameters of the model, and simultaneously optimize the regular detection threshold of the first operating mode and the enhanced detection frequency and anomaly judgment threshold of the second operating mode. By combining the changing trends of gas usage patterns under the two modes and the newly added abnormal cases, samples of new scenarios are generated through simulation scenarios and data generation models. The training sample sets of the two modes are updated regularly to perform incremental training on the model.

9. A natural gas consumption data processing system based on reinforcement learning, characterized in that, This system is applied to the reinforcement learning-based natural gas consumption data processing method according to any one of claims 1-8, wherein the system comprises: The gas consumption data acquisition unit is used to collect raw natural gas consumption data, and adjusts the acquisition frequency by combining user gas consumption behavior profiles and real-time scene perception results to provide raw data input for subsequent data processing. The time period type identification module identifies the current normal or abnormal gas consumption period based on preset time division rules, and automatically switches to the corresponding first or second operating mode to achieve matching between processing mode and time period characteristics. The data preprocessing module receives the mode signal output by the time period type identification module, and performs differentiated operations of light preprocessing or enhanced preprocessing on the raw gas consumption data in the first and second operating modes respectively to complete data purification and normalization. The feature extraction and fusion module captures the time-dimensional change patterns of the two types of preprocessed pattern data to extract targeted features, and realizes feature alignment and fusion of multi-source data through edge side data mapping rules to form a feature dataset adapted to the two operating modes. The reinforcement learning model building and training module constructs a dual-mode reinforcement learning model based on the aforementioned feature dataset. It simplifies the training process by splitting the training module and using knowledge transfer strategies, while supplementing training samples with simulated scenarios and data generation techniques to complete model training and optimization. The near real-time data processing node is equipped with a trained reinforcement learning model to dynamically process feature data in two modes. In the second operating mode, anomaly type identification and abnormal user location are completed simultaneously, and the final processing results and anomaly judgment information are output. The parameter dynamic adjustment module dynamically corrects the reinforcement learning model parameters and the operating parameters of the two modes based on multi-dimensional deviation analysis between actual operating data and model processing results. At the same time, it supplements and updates the training sample set, so that the system can continuously adapt to dynamic gas usage scenarios.

10. The natural gas consumption data processing system based on reinforcement learning according to claim 9, characterized in that, The reinforcement learning model construction and training module includes: a simulated scene generation unit, a data generation model, a sample partitioning unit, a model splitting unit, and a training optimization unit; The simulation scenario generation unit is used to recreate the pipeline network topology, user terminal equipment and environmental factors, construct high-fidelity pipeline network and user simulation scenarios, simulate the abnormal occurrence process under different working conditions, and generate semi-realistic abnormal data. The data generation model is used to generate high-fidelity composite anomaly samples based on semi-real anomaly data. By learning the feature distribution of real anomalies through the generation end, it can supplement the training sample set and solve the problem of scarcity of real anomaly samples. The sample partitioning unit is used to receive preprocessed historical gas consumption data and supplementary composite abnormal samples, and divide them into training set, validation set and test set according to preset ratio. At the same time, it sets the number of training iterations, convergence threshold and other key training parameters, and selects suitable samples according to the needs of the two operating modes. The model splitting unit is used to split the reinforcement learning base model into a pattern recognition module, a normal data processing module, and an anomaly recognition and localization module. It adopts a knowledge transfer simplification strategy, first trains the base model until convergence, and then passes the learned features and rules to the two simplified models, which are adapted to the first and second running modes respectively. The training optimization unit is used to record the state, actions and corresponding reward samples during the model training process. It sets sampling weights for anomaly identification samples in the second running mode and randomly selects samples to update the corresponding module parameters. At the same time, it monitors the processing accuracy, response speed, energy consumption and false alarm rate of the model in the two modes in real time through the validation set. When the Pareto optimal solution set requirement is met for multiple consecutive iterations, training is stopped and the model parameters are saved.