Real-time monitoring method for harmful gas emission concentration of large-scale farm based on Informer

By integrating the Informer and RLS models, a real-time monitoring method was constructed to solve the problems of response lag and inaccurate prediction in the detection of harmful gas emission concentrations in large-scale farms, achieving high-precision and robust gas emission prediction and adapting to complex environmental changes.

CN120703307APending Publication Date: 2025-09-26SHANDONG UNIV OF SCI & TECH

Patent Information

Application Number
CN202510852718.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-24
Publication Date
2025-09-26

AI Technical Summary

Technical Problem

Existing technologies for detecting harmful gas emission concentrations in large-scale farms have problems with response lag and inaccurate predictions. Traditional equipment has high detection accuracy but time lag and high operation and maintenance costs, making it impossible to achieve real-time monitoring and rapid response.

Method used

A fusion model based on the Informer model and the recursive least squares algorithm (RLS model) is adopted. Informer is used for global trend prediction, RLS is used for dynamic error correction, and a mechanism of prediction first and parameter lag update is combined to construct a real-time monitoring method that can adapt to the complex environment of large-scale farms.

Benefits of technology

The prediction accuracy and robustness of harmful gas emission concentrations have been significantly improved, and continuous and efficient predictions can be achieved in dynamically changing farm environments, reducing detection lag effects and providing a reliable prediction basis to optimize emission management.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120703307A_ABST
    Figure CN120703307A_ABST
Patent Text Reader

Abstract

The invention belongs to the technical field of gas emission concentration monitoring, and particularly discloses an Informer-based method for monitoring the emission concentration of harmful gas in a large-scale farm in real time. According to the method, aiming at the characteristics of high nonlinearity, variable redundancy, complex coupling and the like of the emission data of the farm, a fusion model based on an Informer model and an RLS model is constructed, and the perception and response capability to the harmful gas emission concentration change is improved. According to the fusion model, global trend prediction is achieved through an Informer model, then dynamic error correction is conducted through an RLS model, the real-time performance, self-adaptability and robustness of the fusion model are effectively enhanced in combination with a processing mechanism of prediction first and parameter lagging update, and the fusion model is obviously superior to a traditional static or single model prediction mode. The method provided by the invention effectively solves the problems of response lag and inaccurate prediction in the current harmful gas emission concentration detection technology.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of gas emission concentration monitoring, and relates to an Informer-based real-time monitoring method for harmful gas emission concentration in large-scale farms, which is particularly suitable for real-time monitoring and early warning of greenhouse gas emissions in animal breeding processes. Background Art

[0002] With increasingly stringent environmental regulations, large-scale livestock farms face higher requirements for controlling hazardous gas emission concentrations. Effective monitoring and control of hazardous gases has become a pressing need for industry development. Currently, monitoring of various hazardous gases primarily relies on traditional, specialized gas detection equipment. While these devices offer high detection accuracy, they often suffer from time lags and high maintenance costs, significantly limiting their ability to provide real-time monitoring and rapid response. Advances in computer technology and data analysis methods have enabled many large-scale livestock farms to install distributed control systems and monitoring information platforms, accumulating extensive historical data. This data includes a rich collection of environmental and operational parameters, such as animal behavior data (e.g., feeding / rumination activity intensity collected via RFID ear tags and multi-dimensional sensors), environmental parameters (pen temperature and humidity, ground pressure, ventilation negative pressure), and manure characteristics (compost temperature, pH, and conductivity). This data provides the potential and technical foundation for developing data-driven prediction models for hazardous gas concentrations. Therefore, developing a fast and accurate prediction model for hazardous gas concentrations is crucial not only for improving the quality of the livestock farming environment but also for enhancing the efficiency of environmental regulation on farms. Summary of the Invention

[0003] The purpose of this invention is to propose a real-time monitoring method for harmful gas emission concentrations in large-scale farms based on Informer, so as to solve the problems of response lag and inaccurate prediction in current gas emission concentration detection technology.

[0004] In order to achieve the above-mentioned purpose, the present invention adopts the following technical solutions: A real-time monitoring method for harmful gas emission concentrations in large-scale farms based on Informer includes the following steps: Step 1. Collect multi-source environmental monitoring time series data from large-scale farms, construct a harmful gas emission characteristic dataset, and perform preprocessing. Then, use the correlation coefficient to construct a correlation matrix to select the final input variables for the fusion model. Based on the final input variables screened, the harmful gas emission feature dataset is divided into training set and test set data; Step 2. Use the double sliding window method to remove outliers from the training set data; Step 3. Build a fusion model based on the Informer model and the RLS model, and use the training set data after outliers have been removed to pre-train the parameters of the Informer model and the RLS model in the fusion model; Step 4. Use an optimization algorithm to optimize the hyperparameters of the Informer model. Step 5. Test the fusion model using the test set data. The test consists of two stages: The first stage is the RLS model retraining stage; In the first stage, the parameters of the RLS model are retrained using the first part of the test set data. The final output of the fusion model in the first stage is equal to the predicted value of the informer model, so that the RLS model can adapt to the test set data. The second stage is the RLS model prediction and online update stage; Using the remaining data in the test set, the Informer model first performs preliminary predictions, and then inputs the preliminary prediction results into the RLS model for prediction. The predicted value output by the RLS model is the final output of the second-stage fusion model. At the same time, when the actual emission concentration value corresponding to the previous prediction moment is obtained, the actual emission concentration value is paired with the final output of the fusion model corresponding to the previous prediction moment to perform online parameter update of the RLS model; Step 6. Use the fusion model after the test to detect the actual emission concentration of harmful gases in real time.

[0005] The current detection system has a certain lag, resulting in that during the real-time operation of the model, although the input data can be obtained in real time, the corresponding true label (that is, the actual emission concentration of harmful gases) often has a time delay and cannot be obtained simultaneously with the input data at the current moment. In order to adapt to the temporal characteristics of "predicted output arrives before the actual output" that are common in large-scale farms, the present invention rationally designs and optimizes the operating mechanism of the fusion model.

[0006] Since the multi-step prediction mode is used for model prediction, the time of the current data value passed into the Informer model is set as the moment , when the model predicts Used in the process of time The data values ​​are all predicted values, and x is the step length of multi-step prediction. In this process, there will inevitably be cumulative errors, which will affect the final The accuracy of the predicted value at that moment.

[0007] To alleviate this problem, during the testing phase, a complete cycle in the test set is first selected as the initial input and input into the trained Informer model to obtain a continuous sequence of predicted outputs. Next, these Informer predicted values ​​are fed into the RLS model as input vectors, matched with the actual emission concentration values ​​corresponding to the test set, and used to retrain the parameters of the RLS model. The retraining phase further optimizes the parameter vector and covariance matrix based on the test data, so that the fusion model can better adapt to the system behavior under specific working conditions. At this stage, the output of the fusion model is equal to the Informer's prediction result, and RLS is used to absorb error information, adjust parameters, and realize adaptive optimization of the model before entering the inference phase.

[0008] After retraining is completed, the Informer model generates prediction results based on the currently available input data and passes them to the RLS model in real time. Since the true label at that moment has not yet been obtained, the RLS model does not perform parameter updates at this stage. Instead, it keeps the existing parameter vector and covariance matrix in a "frozen state" and relies only on the existing parameters for forward prediction reasoning to output the final prediction value at the current moment. This mechanism ensures that even if the label arrives with a lag, the prediction results can still be output continuously without interrupting the reasoning process. After the sensor detects the true emission concentration value corresponding to the previous prediction moment in a subsequent time period, the true concentration emission value is paired with the RLS model prediction output at that time and imported into the RLS model for parameter update. RLS dynamically corrects the parameter vector and covariance matrix through a recursive formula, thereby enabling the model to learn and adapt to the latest system behavior.

[0009] By organically combining the parameter retraining phase (pre-tuned based on test data) with the asynchronous update mechanism used in real-time prediction (dynamic optimization based on lagged labels), the fusion model achieves continuous and efficient prediction while also possessing continuous learning and self-correction capabilities. Compared to prediction methods based solely on the informer model, this mechanism significantly improves prediction accuracy and robustness. This is particularly true in scenarios with frequent system dynamics or significant interference factors. By continuously incorporating real-world feedback, performance can be continuously optimized, fully meeting the practical application requirements of hazardous gas emission monitoring systems for large-scale farms.

[0010] The present invention has the following advantages: As described above, the present invention describes an informer-based real-time monitoring method for hazardous gas emission concentrations from large-scale livestock farms, addressing the response lag and prediction inaccuracies inherent in current detection technologies. Unlike existing shallow combination approaches that only focus on error correction, the present method addresses the strong nonlinearity, variable redundancy, and complex coupling characteristics of livestock farm emission data by constructing a fusion model based on the informer model and the RLS model (i.e., recursive least squares algorithm). This model improves the ability to perceive and respond to changes in emission concentrations. This fusion model utilizes the informer model for global trend prediction and the RLS model for dynamic error correction. Combined with a "prediction-first, parameter-lagged update" processing mechanism, it effectively enhances the real-time, adaptability, and robustness of the fusion model, significantly outperforming traditional static or single-model prediction approaches. The present method effectively analyzes high-dimensional historical environmental data from large-scale livestock farms, eliminates redundant and irrelevant variables, and extracts key feature information from long-term data series, thereby reducing computational costs and improving the model's prediction accuracy and generalization. Through this fusion model, the influence of the hysteresis effect in the gas detection process can be effectively reduced, thereby providing a reliable prediction basis for the environmental management and harmful gas emission control of the farm, and helping to optimize the emission management measures in the breeding process. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Figure 1 This is a flowchart of a method for real-time monitoring of harmful gas emission concentrations from large-scale farms based on Informer in an embodiment of the present invention; Figure 2 The figure is a schematic diagram of some test results of the method of the present invention on a historical data set of a large-scale farm. DETAILED DESCRIPTION

[0012] The present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments: Example like Figure 1As shown, this embodiment provides an Informer-based real-time monitoring method for harmful gas emission concentrations from large-scale farms. This method first preprocesses historical data sets from large-scale farms, calculates correlation coefficients, and constructs a correlation matrix to screen the optimal input variables. A double sliding window mechanism is then used to remove outliers from the training set data. A fusion model, or real-time prediction model for harmful gas concentrations, is then constructed based on the Informer model and the recursive least squares algorithm (RLS model). The hyperparameters of the Informer model are optimized using a genetic evolutionary algorithm. Finally, after the fusion model is established, the system can collect real-time environmental dynamic data from large-scale farms online. After processing, the data is input into the fusion model for real-time analysis, ultimately predicting the emission concentrations of various harmful gases. In order to adapt to the common problem of "predicted output arriving before true output" on large-scale farms, that is, the predicted value is ahead of the true value obtained by the sensor in time, the operating mechanism of the fusion model is reasonably designed and optimized. In the testing phase, for the parameter retraining phase of the RLS model, the output value of the fusion model is equal to the predicted value output by the Informer model; after the parameter retraining of the fusion model is completed, the prediction result of the subsequent input data is output through the fusion model, and the parameters of the RLS model are updated when the farm gas monitoring system detects the true value of the emission concentration of various harmful gases.

[0013] like Figure 1 As shown in the figure, the real-time monitoring method of harmful gas emission concentration in large-scale farms based on Informer includes: Step 1: Collect multi-source environmental monitoring time series data from large-scale farms to construct a harmful gas emission characteristic dataset. This dataset undergoes preprocessing, including normalization and missing value removal. Then, a correlation matrix is ​​constructed using correlation coefficients to screen the final input variables for the fusion model. After screening the correlation matrix, the present invention identified 10 final input variables.

[0014] After screening out the 10 final input variables, the harmful gas emission feature dataset contains n data samples, each of which contains 10 original environmental variables and 3 labels, where n is a natural number.

[0015] The 10 original environmental variables are the 10 final input variables screened out, including pen temperature, pen humidity, ground pressure, ventilation negative pressure, compost temperature, manure pH value, light intensity, animal weight, animal density and feed amount.

[0016] The three labels refer to the concentrations of three types of harmful gases, including nitrogen oxides, carbon oxides and ammonia.

[0017] In order to eliminate the influence of dimensional differences between different environmental variables, the original environmental variables were normalized.

[0018] Each original environmental variable in the harmful gas emission characteristic dataset is standardized using Min-Max, so that the value range of each original environmental variable is compressed between 0 and 1, and the dataset is divided into a training set and a test set.

[0019] The normalization formula is as follows: (1) in For sample data Normalized value, and The first 70% of the dataset is divided into the training set, the next 10% is divided into the validation set, and the last 20% is divided into the test set.

[0020] Before using the correlation coefficient to construct the correlation matrix, the data variables in the harmful gas emission characteristic data set are preliminarily screened using the manual selection method to obtain the preliminarily screened variables.

[0021] By reviewing recent influential literature, we extracted the variables involved in each paper and took their intersection. We then combined these intersection variables with the actual collected data variables to obtain a manually screened variable set.

[0022] After manual selection, a total of 20 variables were initially screened.

[0023] Then the Pearson correlation coefficient, Spearman rank correlation coefficient and maximum information coefficient were selected, and the Pearson correlation coefficient, Spearman rank correlation coefficient and maximum information coefficient of the variables and labels after preliminary screening were calculated.

[0024] The Pearson correlation coefficient is used to measure the strength and direction of the linear relationship between two variables. Its value range is [-1, 1]. A value of 1 indicates a perfect positive correlation, -1 indicates a perfect negative correlation, and 0 indicates no linear correlation. The calculation formula is as follows: (2) in represents the Pearson correlation coefficient, It is of samples value (i.e. the original environment variable), It is of samples value (i.e., predicted label), yes The mean of yes The mean of .

[0025] In this embodiment, the Pearson correlation coefficient between each variable in the 20 selected variables and the concentration of each type of harmful gas emission is calculated by using the above formula (2), and the first row of data in the correlation matrix is ​​formed.

[0026] The Spearman rank correlation coefficient is used to measure the monotonic relationship between two variables and is applicable to nonlinear but monotonic relationships. It calculates the correlation between two variables by ranking the data, and the value range is [-1, 1]. The calculation formula is as follows: (3) in represents the Spearman rank correlation coefficient, Represents the rank difference (rank difference) of the data corresponding to the two variables, Indicates the number of data points. In this embodiment, the Spearman rank correlation coefficient between each variable in the 20 variables and the concentration of each type of harmful gas emission is calculated by using the above formula (3), and the second row of data in the correlation matrix is ​​formed.

[0027] The maximum information coefficient is used to measure the nonlinear relationship between two variables. It is more flexible than Pearson and Spearman and can capture complex dependencies. Its value range is [0, 1], and larger values ​​indicate a stronger relationship.

[0028] The maximum information coefficient is calculated by the binning method, which is mainly achieved by discretizing the data at different resolutions and calculating the corresponding correlation. The purpose is to find the best binning method to capture the information between variables.

[0029] This embodiment calculates the maximum information coefficient between each of the 20 variables and the concentration of each type of harmful gas emission (the formula is relatively conventional and is not given in this embodiment) to form the third row of data in the correlation matrix.

[0030] Finally, a correlation matrix is ​​constructed based on the calculated Pearson correlation coefficient, Spearman rank correlation coefficient, and maximum information coefficient. The data in the correlation matrix is ​​normalized by row, and the value of each column of data in the correlation matrix is ​​calculated after adding each label variable with the same weight. The data are arranged in order from large to small, and the top 10 variables are selected to form the final input variables.

[0031] Based on the 10 final input variables selected, the harmful gas emission characteristic dataset was divided into a training set and a test set. The first 70% of the dataset was divided into the training set, the next 10% was divided into the validation set, and the last 20% was divided into the test set.

[0032] Step 2. Use the double sliding window method to remove outliers from the training set data.

[0033] Outliers are data points that are obviously inconsistent with other samples. They may be caused by measurement errors, data entry errors, or real extreme observations. When outliers exist, they affect the fitting results of the regression model and the accuracy of hypothesis testing. Common methods for removing outliers include K-means clustering, Law and density clustering.

[0034] The basic idea of ​​K-means clustering is to calculate the distance between each data point and its nearest cluster center. If the distance exceeds a certain threshold, the point is considered an outlier and is removed.

[0035] The rule calculates the mean and standard deviation of the data to determine the 3∑ range (the range of the mean plus or minus three standard deviations). Data points outside this range are considered outliers and are removed.

[0036] Density clustering is a density-based clustering algorithm that can effectively identify clusters in data sets with different densities and can automatically handle noise, defining outliers as data points that do not belong to any cluster.

[0037] After comparing the three clustering methods, the present invention preferably adopts K-means clustering as the basic outlier removal method, and uses the double sliding mechanism proposed in the present invention to remove outliers from the training set.

[0038] Environmental monitoring data from large-scale farms (such as temperature, humidity, and fecal pH) exhibit significant temporal and periodic characteristics. Temporal characteristics are manifested as the temporal dependence between data points, while periodicity is reflected in the regular fluctuations of environmental parameters following fixed operations such as day and night and feeding. Traditional anomaly detection methods are easily affected by global disturbances and are unable to distinguish between normal periodic fluctuations and true anomalies. The dual sliding window mechanism of the present invention overcomes this problem through localized analysis, using sliding windows to divide long sequences into multiple short time periods, and independently detecting anomalies within each window, thereby reducing interference caused by changes in global data distribution. At the same time, dual-window cross-validation is used to improve the robustness of detection and avoid misjudgments that may be caused by a single window.

[0039] The method defines two sliding windows, A and B. Window A begins at the data's starting point with a step size of 10% of the total length; window B's starting point is offset by half the step size, or 5%. Window A and window B have the same step size. These two windows interleave to cover the entire time series, ensuring that each data point is detected by at least one window and that key areas are scanned twice.

[0040] For example, for 10 days of historical data (14,400 minutes), each window covers 1,440 minutes. The detection interval of window A is [0, 1,440), [1,440, 2,880), ..., [12,960, 1,4400], while that of window B is [720, 2,160), [2,160, 3,600), ..., [12,240, 13,680]. This can not only capture local anomalies, but also reduce false positives through the dual-window voting mechanism (confirmation is only made when both types of windows are marked as anomalies). It is especially suitable for short-term anomalies in periodic data (such as temperature spikes caused by equipment failure).

[0041] Before removing data from the training set, the raw data is preprocessed and then segmented using windows A and B. K-means clustering is most effective for removing outliers from historical farm data. Within each window, K-means clustering is applied, and points that represent less than 5% of the sample size or are farthest from the cluster center (occupying 1%-5% of the data in that cluster, with the specific value determined by cluster density: comparing the cluster densities of all clusters within the window, the cluster with the highest density is assigned 1%, the cluster with the lowest density is assigned 5%, and the intermediate values ​​are assigned based on the number of clusters) are classified as outliers. Only points marked by both windows A and B are removed, and continuous outlier segments are deleted entirely. Isolated points are interpolated using neighboring values. For example, if anomalies in carbon oxide emissions are detected during a certain period, they are verified by comparing them with historical data from the same period. Only after confirming non-periodic fluctuations are identified can they be removed. The entire process balances temporal coherence and cyclical regularity, significantly improving the accuracy of farm environmental monitoring.

[0042] Step 3. Build a fusion model based on the Informer model and the RLS model, and use the training set data after outliers are removed to pre-train the parameters of the Informer model and RLS model in the fusion model.

[0043] The Informer model framework mainly consists of two parts: encoder and decoder. Based on the Transformer framework, it improves the problems of high memory usage and low efficiency of long sequence output by using sparse self-attention layers.

[0044] In order to enable the model to process data with sequence information more effectively, the model embeds both the features and positions of the data in the input, and the final input is obtained by adding the two. The position embedding is calculated by the following formula: (4) (5) in Indicates the position of the data in the sequence, Indicates the position in the sequence, Represents the dimension, represents an even number of dimensions, represents odd-order dimensions, represents the position embedding value of the even-numbered dimension, Represents the positional embedding value of odd-numbered dimensions.

[0045] Holistic Query matrix pair The key-value matrix is ​​queried using the dot product operation. Respectively represent The first The attention output corresponding to each row is as follows: (6) In actual predictions, not all All of these bring learning capabilities to the model, and a large part of The prediction of the model does not work. Informer uses the probability theory to judge that part That part makes sense. It makes no sense for the model.

[0046] Judge by the following formula Value: (7) in, Represents the query vector With the key matrix The interaction results, Represents the bond matrix length, represents the dimensions of the query and key vectors, Indicates the key vectors.

[0047] The output of the sparse attention layer is expressed as follows, where By the value greater than the set threshold composition.

[0048] (8) Recursive least squares is a matrix recursive algorithm based on the least squares algorithm, which can be used for online parameter estimation of models. It mainly includes three parts: initialization, prediction and calculation error, and parameter update.

[0049] I. Initialization parameters: Initialize the parameters used by the recursive least squares algorithm and give the parameter vector is a zero vector, the covariance matrix is the identity matrix, the forgetting factor It is a value greater than 0 and less than 1; the smaller the value, the more sensitive it is to historical data.

[0050] The algorithm receives the prediction vector from the Informer model , predict output through the prediction module, the formula is as follows: (9) in Represents the predicted output value, is the parameter vector.

[0051] II. Calculate the prediction error: The algorithm receives the true value predicted by the external system and calculates the prediction error using the following formula: (10) in is the prediction error, is the true value; III. Parameter Update: After the prediction error and prediction vector calculated in steps I and II are combined, the gain vector of the algorithm is updated , parameter vector and covariance matrix , the calculation formulas are as follows: (11) (12) (13) in, 、 They represent the parameter vector and covariance matrix of the algorithm at the nth iteration respectively.

[0052] Aiming at the strong nonlinearity, long-term dependence and frequent changes in environmental conditions of the emission process of various harmful gases (such as methane and ammonia) in large-scale farms, this paper proposes to construct a fusion model that effectively combines the Informer regression prediction model (Informer model for short) with the recursive least squares algorithm (RLS model).

[0053] The emission characteristics of large-scale farms are usually affected by multiple factors, such as temperature and humidity, ventilation frequency, stocking density, and feces characteristics. These factors are highly time-varying and have complex interactions, posing great challenges to traditional static modeling methods.

[0054] As an efficient long-series time prediction model, the Informer model can use the sparse self-attention mechanism to mine global dependencies in large-scale time series, thereby achieving preliminary predictions of future trends in harmful gas concentration changes.

[0055] However, after the Informer model is trained, its parameters are fixed, making it difficult to quickly adjust its own prediction strategy in situations such as sudden changes in farm working conditions and frequent environmental disturbances. This may lead to problems such as slow response or fluctuating prediction errors.

[0056] In order to improve the dynamic adaptability and prediction stability of the model, the present invention proposes to use the output of the informer model as the input of the RLS model to build a serial dual model fusion structure. In this structure, the informer model first generates a preliminary prediction value based on historical sensor data. , and then form the input vector and input it into the RLS model for dynamic regression prediction. The RLS model updates the parameter vector through online iteration and outputs the final fusion prediction result in real time. , thereby performing error correction and dynamic optimization on the preliminary results of Informer.

[0057] To ensure that the fusion model has good response speed and stability during actual deployment, the training set data is first used to complete the training of the Informer model. After the Informer model training is completed, the same training set data is used to pre-train the RLS model in the fusion model. Specifically, the training set data is input into the trained Informer model to generate the corresponding one-dimensional predicted output value, and the predicted value is used as the input vector of the RLS model. It is paired with the true label (i.e., the true emission concentration value) at the corresponding moment in the training set to perform the parameter update operation within the RLS. It should be noted that the RLS model only receives the output vector from the Informer throughout the training process and does not directly process the original environmental variables or multi-dimensional feature data. Although the training set is used, it is essentially training the RLS model in the constructed fusion model to perform initial error modeling and parameter vector estimation based on the deviation between the Informer prediction result and the true value.

[0058] To ensure training stability, the RLS model initially sets the covariance matrix to the identity matrix and the parameter vector to all zeros, then gradually estimates the parameters using a recursive formula. This pre-training process not only improves the RLS model's convergence speed and response sensitivity in subsequent practical operations, but also ensures that the RLS model quickly reaches a stable prediction state when put into practical application, and demonstrates good sensitivity and adaptability to short-term fluctuations in farm emission concentrations.

[0059] The fusion model proposed in this invention fully combines the global modeling capability of the Informer model and the online adaptive capability of the RLS model, and has significant advantages in coping with complex gas emission prediction tasks in large-scale farms. The fusion model proposed in this invention can not only accurately grasp long-term trends, but also make real-time corrections when the external environment changes, thereby effectively improving the prediction accuracy and system robustness, thereby providing reliable support for intelligent monitoring and early warning control of harmful gas emissions from farms.

[0060] Step 4. Use an optimization algorithm to optimize the hyperparameters of the Informer model.

[0061] During the training phase, the Informer model itself continuously updates its network parameters through optimization algorithms such as gradient descent to obtain optimal model performance. However, this process is limited to the adjustment of the model's internal weight parameters and does not cover the global optimal configuration of the model's external structural or hyperparameters (such as learning rate, time step, embedding dimension, number of attention heads, etc.).

[0062] Traditional training processes carry a risk of local optimality traps and are sensitive to initial hyperparameter settings, potentially limiting model performance when faced with complex, high-dimensional prediction tasks. To address this, a genetic evolutionary algorithm was introduced to jointly optimize several key hyperparameters of the Informer model, enhancing the overall stability of the model and predictive accuracy.

[0063] As a global optimization method based on natural selection and genetic mechanisms, the genetic evolutionary algorithm can search for the optimal solution in a wide parameter space and has a strong ability to escape local optimality. It achieves hyperparameter optimization by setting the following parameters: Optimization range: Set corresponding upper and lower limits for each parameter to be optimized to ensure that the search space covers all potential optimal solutions.

[0064] Optimizing generations: Set to 10 to indicate that the evolution process will proceed for 10 generations, with the population fitness improving generation by generation.

[0065] Population size: Set to 150 to ensure sufficient diversity and evolutionary potential in each generation.

[0066] Fitness function: The prediction accuracy or error index of the Informer model on the validation set is used as the fitness evaluation standard to guide the selection and reproduction of superior and inferior individuals.

[0067] During the genetic evolutionary algorithm's operation, a roulette wheel selection strategy is used to select individuals with higher fitness from the current population. Crossover and mutation operations are then used to generate the next generation of candidate solutions. Individuals with higher fitness are more likely to be retained and propagated, thereby guiding the population towards a global optimum. After multiple generations of iteration, the parameter combination with the optimal fitness within a given search interval is ultimately obtained, providing better initial hyperparameter settings for the Informer model.

[0068] The genetic evolutionary algorithm not only overcomes the Informer model's inability to automatically optimize hyperparameters during training, but also improves the model's generalization and predictive performance across diverse operating conditions and data scenarios. While the two approaches differ in their objectives, they complement and synergize during model building and optimization, jointly enhancing both prediction performance and system robustness.

[0069] The genetic evolutionary algorithm is used to optimize the multi-parameters of the prediction model. The genetic evolutionary algorithm searches for the individual with the largest fitness function within the given optimization interval, optimization generation, population number and fitness function.

[0070] The optimization generation number of the present invention is set to 10, and the population number is set to 150. The optimization process of important parameters is shown in Table 1.

[0071] Table 1 Main parameter optimization interval table

[0072] After an iterative optimization process, the optimal model parameters are found, and the learning rate is finally set to 63.9*10 -5 The final value of the batch length is 42, the final value of the model dimension D_model is 168, and the final value of the number of heads N_headvs is 6.

[0073] Step 5. Test the fusion model using the test set data. The test consists of two stages: The first stage is the RLS model retraining stage; In the first stage, the parameters of the RLS model are retrained using the first part of the data in the test set. The final output of the fusion model in the first stage is equal to the predicted value of the Informer model, so that the RLS model can adapt to the test set data.

[0074] The second stage is the RLS model prediction and online update stage; Using the remaining data in the test set, the Informer model first performs preliminary predictions, and then inputs the preliminary prediction results into the RLS model for prediction. The predicted value output by the RLS model is the final output of the second-stage fusion model. At the same time, after obtaining the true emission concentration value corresponding to the previous prediction moment, the true emission concentration value is paired with the final output of the fusion model corresponding to the previous prediction moment for online parameter update of the RLS model.

[0075] The current detection system has a certain lag, resulting in that during the real-time operation of the model, although the input data can be obtained in real time, the corresponding real label (that is, the actual emission concentration of the harmful gas) often has a time delay and cannot be obtained simultaneously with the input data at the current moment in a one-to-one correspondence. In order to adapt to the common phenomenon of "predicted output arriving before the actual output" in large-scale farms, that is, the obtained predicted value is ahead of the actual value obtained by the sensor in time (for example, assuming that the current time is 15:00, the predicted value at 16:00 can be predicted, but only the time series characteristics of the actual emission concentration value obtained by the sensor at 14:00 can be obtained), the present invention reasonably designs and optimizes the operation mechanism of the fusion model.

[0076] Since the present invention uses a multi-step prediction mode for model prediction, let the time of the current moment data value input into the Informer be the moment , when the model predicts Used in the process of time The data values ​​are all predicted values, and x is the step length of multi-step prediction. In this process, there will inevitably be cumulative errors, which will affect the final The accuracy of the predicted value at that moment.

[0077] In the first stage of the testing process, the first complete cycle of the test set data (for example, the data of the entire day after the first data of the test set) is predicted in the informer model, and the predicted value is used as retraining data to input the recursive least squares model for parameter retraining. During the parameter retraining process, the output value of the fusion model is equal to the predicted value output by the informer model, that is, At the beginning of the testing phase, the RLS model parameters undergo a retraining phase (assuming the test data set consists of 10 cycles with a total of 1000 data points, the retraining phase is based on the first 100 data points). When predicting the first 100 data points, the final output of the fusion model equals the prediction of the informer model. This allows the RLS model to adapt to the test data. These 100 data points are used to retrain the RLS model parameters. After retraining, the remaining 900 data points are used to make preliminary predictions using the informer. These preliminary predictions are then fed into the RLS model for prediction. The predicted values ​​output by the RLS model become the final predictions of the fusion model. The core purpose of the retraining phase is to further optimize the parameter vector and covariance matrix based on the test data, enabling the fusion model to better adapt to system behavior under specific operating conditions. During this phase, the output of the fusion model equals the informer predictions. The RLS model absorbs error information and adjusts parameters, achieving adaptive optimization before entering the inference phase.

[0078] In order to simulate the tag hysteresis in the actual operation field, the present invention reflects the hysteresis of tag data acquisition in the test process of the programming program. When the program reads the tag, it will read 10 data points slower than the input variable of the model.

[0079] After completing parameter retraining, the fusion model first uses the trained Informer model output value as the input of the RLS model in the second stage, and calculates the predicted output value of the fusion model based on the currently available input data. Since the actual emission concentration value corresponding to the current predicted value has not yet been obtained at this time, the RLS model does not perform parameter updates for the time being, and only performs prediction and inference operations based on the existing parameter vector and input vector, and outputs the predicted value at the current moment. When the system needs to predict the current emission concentration, because real data has not yet been measured (for example, due to delays in sensor instrument measurements and label lags during the simulation run during the testing phase), the fusion model has no way of knowing whether its prediction is accurate. Therefore, it does not immediately adjust its internal calculation rules (parameters). Instead, it directly uses the previously learned rules and provides a prediction. In layman's terms, suppose it is currently 3:00 PM and only the ammonia emission concentration before 2:00 PM is known (measured by sensors). Now, the ammonia emission concentration at 4:00 PM needs to be predicted. In this prediction, the RLS model will use the parameters updated before 2:00 PM to predict the ammonia emission concentration at 4:00 PM. Although there are predicted ammonia emissions between 2:00 PM and 3:00 PM, there are no corresponding real-world measurements, making it impossible to calibrate the RLS model parameters. This is the key to the innovative online update feature. This approach is equivalent to using "frozen" parameters in the current state for real-time inference, ensuring that the system can continue to provide predictions even in the absence of labels.

[0080] After a period of delay, the sensor measures the actual emission concentration of harmful gases corresponding to the predicted value at the previous moment. When the actual emission concentration value is paired with the predicted value vector at the previous prediction time, it is used to correct the prediction rules of the RLS model. For example, it is now 15:05, and the sensor detects the actual emission concentration value at 14:05. This actual emission concentration value is then paired with the predicted value at 14:05 predicted by the RLS model. The parameters of the RLS model are updated in real time in the online parameter update module (updating the gain vector, parameter vector, and covariance matrix of the RLS model). The parameters are imported into the RLS algorithm for parameter estimation, and the parameter vector and covariance matrix are dynamically updated through the recursive formula. In this way, the model can achieve effective decoupling between real-time prediction and asynchronous learning, enabling the model to maintain continuous prediction capabilities while still having the ability to adaptively learn and optimize.

[0081] Thanks to this mechanism, the fusion model demonstrates greater accuracy and robustness than predictions based solely on the informer model. This is particularly true in scenarios with frequent system dynamics or significant external interference. By continuously introducing new real-world feedback, the fusion model achieves continuous optimization, significantly improving prediction performance. This strategy of predicting first and then updating parameters later not only adapts to the responsiveness of farm hazardous gas emission detection systems but also better meets the needs of actual deployment.

[0082] Step 6. Use the fusion model after the test to detect the actual emission concentration of harmful gases in real time.

[0083] Obtain an online dataset, preprocess it, and use it as input for the fusion model to obtain prediction results and perform online analysis. The online deployment of the model is exactly the same as the testing process.

[0084] After the fusion model is deployed, data from a few hours after the deployment is first used to retrain the RLS model. During the RLS model retraining phase, the output of the fusion model is the predicted value output by the informer. The RLS model is only trained and does not predict.

[0085] After the RLS model retraining phase is completed, the output of the fusion model is the output value of the RLS model, where the predicted value output by the informer model is used as the input value of the RLS model, and the RLS model enters the online update phase.

[0086] Whenever the sensor obtains the actual emission concentration value of the harmful gas, it is paired with the final output of the fusion model at the corresponding moment of the actual emission concentration value to update the RLS model parameters online, that is, to calibrate the RLS model online.

[0087] The present invention uses a constructed fusion model to perform real-time monitoring of the emission concentrations of various types of hazardous gases. The fusion model continuously acquires new online datasets derived from the real-time environmental dynamics of the farm. The acquisition of online datasets ensures that the model's predictions remain consistent with the current environmental dynamics. The acquired online datasets undergo necessary data preprocessing steps, including normalization, variable selection, and missing value removal, to ensure data quality suitable for model input. The preprocessed online datasets are passed as input to the fusion model, which uses this data for real-time predictive analysis, providing predicted values ​​for key indicators such as the emission concentrations of hazardous gases. The trained fusion model is then applied to real-time prediction tasks and begins predicting subsequent data. As new data is continuously fed into the model, its predictive capabilities are continuously verified and optimized. The model updates its parameters with each new data input. Through this online learning approach, the model can adapt to changes in real-time data and gradually improve its prediction accuracy. As real-time data continues to be input, the model dynamically adjusts and optimizes its parameters, enhancing its robustness, adapting to environmental changes, and maintaining prediction stability and accuracy.

[0088] The method proposed in this paper automatically screens key variables using real-time environmental data and constructs a robust and highly accurate prediction model for harmful gas emissions based on the Informer and RLS models. This fusion model not only has excellent practicality and potential for widespread adoption, but can also effectively improve the efficiency of detecting various harmful gas emission concentrations in large-scale farms. Its application provides strong technical support and theoretical foundation for controlling harmful gases in farms.

[0089] To verify the effectiveness of the method presented in this paper, the following specific experiment was conducted: The experimental data was collected from the historical operation records of a large-scale livestock farm in China. The data was collected over 18 days, containing 51,840 data points, with a sampling period of 30 seconds. The data included 60 characteristic variables, covering key parameters such as pen temperature and humidity, ground pressure, ventilation negative pressure, compost temperature, and manure pH. There was a strong correlation between these variables. It is the emission concentration of various harmful gases.

[0090] After preprocessing, the last 30% of the data is divided into a test set, and the first 70% of the data is used as a training set after outliers are removed for model training. The training set is used to train the three comparison models of Autoformer, Informer, and Transformer, as well as the fusion model of the present invention, and the performance of each model is evaluated on the test set to verify the effectiveness of the method of the present invention. The evaluation indicators of the comparison model and the fusion model of the present invention are root mean square error (RMSE), mean absolute error (MAE), and determination coefficient (R). 2 The statistical results of the generalization performance of different models on the test set are shown in Table 2.

[0091] Table 2 Comparison of test set performance of different models

[0092] As shown in Table 2, the proposed method (the fusion model) demonstrates superior performance compared to traditional single models (Autoformer, Informer, and Transformer models) across multiple evaluation metrics, including root mean square error, mean absolute error, and coefficient of determination. Furthermore, variable screening and outlier removal effectively reduce the computational cost of the fusion model while significantly improving its generalization accuracy, further validating the reliability of the proposed method.

[0093] The prediction result of a label variable (NH3) of the fusion model is as follows Figure 2 As shown in the figure, the solid line represents the error curve between the predicted value and the true value when using only the informer model; the dotted line represents the error curve between the predicted value and the true value when using the fusion model that fuses the informer model with the RLS model. It is clear that the solid line is farther from the X-axis than the dotted line. This indicates that the fusion model significantly improves prediction accuracy and stability compared to prediction using only the informer model.

[0094] Of course, the above description is only a preferred embodiment of the present invention, and the present invention is not limited to the above-mentioned embodiments. It should be noted that all equivalent substitutions and obvious deformation forms made by any technician familiar with this field under the guidance of this specification fall within the substantive scope of this specification and should be protected by the present invention.

Claims

1. A real-time monitoring method for harmful gas emission concentration in large-scale farms based on Informer, characterized in that: The steps include: Step 1. Collect multi-source environmental monitoring time series data from large-scale farms, construct a harmful gas emission characteristic dataset, and perform preprocessing. Then, use the correlation coefficient to construct a correlation matrix to select the final input variables for the fusion model. Based on the final input variables screened, the harmful gas emission feature dataset is divided into training set and test set data; Step 2. Use the double sliding window method to remove outliers from the training set data; Step 3. Build a fusion model based on the Informer model and the RLS model, and use the training set data after outliers are removed to pre-train the parameters of the Informer model and RLS model in the fusion model; Step 4. Use an optimization algorithm to optimize the hyperparameters of the Informer model. Step 5. Test the fusion model using the test set data. The test consists of two stages: The first stage is the RLS model retraining stage; In the first stage, the parameters of the RLS model are retrained using the first part of the test set data. The final output of the fusion model in the first stage is equal to the predicted value of the informer model, so that the RLS model can adapt to the test set data. The second stage is the RLS model prediction and online update stage; Using the remaining data in the test set, the Informer model first performs preliminary predictions, and then inputs the preliminary prediction results into the RLS model for prediction. The predicted value output by the RLS model is the final output of the second-stage fusion model. At the same time, when the actual emission concentration value corresponding to the previous prediction moment is obtained, the actual emission concentration value is paired with the final output of the fusion model corresponding to the previous prediction moment to perform online parameter update of the RLS model; Step 6. Use the fusion model after the test to detect the actual emission concentration of harmful gases in real time.

2. The real-time monitoring method for harmful gas emission concentrations from large-scale farms based on Informer according to claim 1 is characterized in that: In step 1, the process of selecting the final input variables of the fusion model is as follows: Before using the correlation coefficient to construct the correlation matrix, the data variables in the harmful gas emission characteristic data set are preliminarily screened using the manual selection method to obtain the preliminarily screened variables; Then, the Pearson correlation coefficient, Spearman rank correlation coefficient and maximum information coefficient were selected, and the Pearson correlation coefficient, Spearman rank correlation coefficient and maximum information coefficient of the variables and labels after preliminary screening were calculated; Finally, the correlation matrix was constructed based on the Pearson correlation coefficient, Spearman rank correlation coefficient and maximum information coefficient; The calculated Pearson correlation coefficient, Spearman rank correlation coefficient and maximum information coefficient are used as the first row, second row and third row data of the correlation matrix respectively; Normalize the data in the correlation matrix by row, calculate the value of each column of data in the correlation matrix after adding each label variable with the same weight, arrange them in order from large to small, and select the first 10 variables to constitute the final input variables.

3. The real-time monitoring method for harmful gas emission concentrations from large-scale farms based on Informer according to claim 1 is characterized in that: In step 1, after the final input variables are screened, the harmful gas emission feature dataset contains n data samples, each of which contains 10 original environmental variables and 3 labels; The 10 original environmental variables are the 10 final input variables screened, including pen temperature, pen humidity, ground pressure, ventilation negative pressure, compost temperature, manure pH, light intensity, animal weight, animal density and feed amount; The three labels refer to the concentrations of three types of harmful gases, including nitrogen oxides, carbon oxides and ammonia; Each original environmental variable in the harmful gas emission characteristic dataset is standardized using Min-Max, so that the value range of each original environmental variable is compressed between 0 and 1, and the dataset is divided into a training set and a test set; The first 70% of the data set is divided into the training set, the next 10% is divided into the validation set, and the last 20% is divided into the test set.

4. The real-time monitoring method for harmful gas emission concentrations from large-scale farms based on Informer according to claim 1 is characterized in that: In step 2, the process of using the double sliding window method to remove outliers is as follows: Define two sliding windows, A and B, where window A starts from the starting point of the training set data and has a step length of 10% of the total length; the starting point of window B is offset by half of the step length, that is, 5%, and the step length of window B is the same as that of window A. K-means clustering is used within each window to independently detect anomalies to reduce interference caused by changes in global data distribution. At the same time, dual-window cross-validation is used to improve the robustness of detection and avoid misjudgments caused by a single window. The A and B windows cover the entire time series in an interleaved manner to ensure that each data point is detected by at least one window. At the same time, the data marked as abnormal points by the A and B sliding windows are eliminated to generate a healthy data set.

5. The real-time monitoring method for harmful gas emission concentrations from large-scale farms based on Informer according to claim 1 is characterized in that: The Informer model framework consists of two parts: an encoder and a decoder. It is based on the Transformer framework and uses sparse self-attention layers to improve the problems of high memory usage and low efficiency of long sequence output.

6. The real-time monitoring method for harmful gas emission concentrations from large-scale farms based on Informer according to claim 1 is characterized in that: The online parameter estimation process of the RLS model, i.e., the recursive least squares algorithm, is as follows: I. Initialization parameters: Initialize the parameters used by the recursive least squares algorithm, give the parameter vector as the zero vector, the covariance matrix as the identity matrix, and the forgetting factor A value greater than 0 and less than 1; The algorithm receives the prediction vector from the Informer model , predict output through the prediction module, the formula is as follows: ; in Represents the predicted output value, is the parameter vector; II. Calculate the prediction error: The algorithm receives the true value predicted by the external system and calculates the prediction error using the following formula: ; in is the prediction error, is the true value, i.e. the actual emission concentration measured by the sensor; III. Parameter Update: After the prediction error calculated in step II, the gain vector of the iterative algorithm is updated , parameter vector and covariance matrix , the calculation formulas are as follows: ; ; ; in, 、 They represent the parameter vector and covariance matrix of the algorithm at the nth iteration respectively.

7. The real-time monitoring method for harmful gas emission concentrations from large-scale farms based on Informer according to claim 1 is characterized in that: In step 3, in the fusion model based on the Informer model and the RLS model, the output of the Informer model is used as the input of the RLS model; the Informer model first generates a preliminary prediction value based on the historical sensor data, and then inputs it into the RLS model for dynamic regression prediction; the RLS model updates the parameter vector through online iteration and outputs the final fusion prediction result in real time, thereby performing error correction and dynamic optimization on the preliminary result of the Informer.

8. The real-time monitoring method for harmful gas emission concentrations from large-scale farms based on Informer according to claim 1 is characterized in that: In step 4, a genetic evolutionary algorithm is used as an optimization algorithm to jointly optimize the hyperparameters of the Informer model. The genetic evolutionary algorithm achieves hyperparameter optimization by setting the following parameters: Optimization range: Set corresponding upper and lower limits for each parameter to be optimized to ensure that the search space covers all potential optimal solutions; Optimization generations: set to 10, indicating that the evolution process lasts for 10 generations, and the fitness of the population is improved generation by generation; Population size: set to 150 to ensure sufficient diversity and evolutionary potential in each generation; Fitness function: The prediction accuracy or error index of the informer model on the validation set is used as the fitness evaluation standard to guide the selection and reproduction of superior and inferior individuals; During the operation of the genetic algorithm, a roulette wheel selection strategy is used to select individuals with higher fitness from the current population, and the next generation of candidate solutions is generated through crossover and mutation operations; After multiple generations of iterations, the parameter combination with the optimal fitness within the given optimization interval is finally obtained, thereby providing a better initialization hyperparameter setting for the Informer model.

9. The real-time monitoring method for harmful gas emission concentrations from large-scale farms based on Informer according to claim 1 is characterized in that: In step 5, the process of testing the fusion model using the test set data is as follows: During the RLS model retraining phase of the test, a complete cycle in the test set is first selected as the initial input and input into the trained Informer model to obtain a continuous prediction output sequence. The Informer prediction value is then fed into the RLS model as an input vector and matched with the actual emission concentration value corresponding to the test set to retrain the parameters of the RLS model. During the RLS model retraining phase, the parameter vector and covariance matrix are further optimized based on the test data to make the fusion model better adapt to the operating characteristics under specific working conditions. The output of the fusion model is equal to the Informer prediction result. The RLS model is used to absorb error information and adjust parameters to achieve adaptive optimization of the RLS model before entering the inference phase. To simulate the label lag in the actual operation site, the lag in label data acquisition is reflected in the test. When reading the label, it is read a preset time later than the final input variable of the model to indicate that the true label at the prediction moment has not yet been obtained. After completing the RLS model retraining, the Informer model generates a prediction result based on the currently available input data and transmits it to the RLS model in real time. Since the true label at the prediction moment has not yet been obtained, the RLS model does not perform parameter updates during prediction, but only relies on the existing parameters of the RLS model for forward prediction reasoning and outputs the final prediction value at the current moment. After obtaining the true emission concentration value of the harmful gas corresponding to the previous prediction moment, the true emission concentration value is paired with the Informer prediction output at the previous prediction moment and imported into the RLS model for parameter update. RLS dynamically corrects the parameter vector and covariance matrix through a recursive formula to enable the RLS model to learn and adapt to the latest operating conditions.

10. The real-time monitoring method for harmful gas emission concentrations from large-scale farms based on Informer according to claim 1 is characterized in that: The step 6 is specifically as follows: After the fusion model is deployed, data from a few hours after the deployment is first used to retrain the RLS model. During the RLS model retraining phase, the output of the fusion model is the predicted value output by the informer. The RLS model is only trained and does not make predictions. After the RLS model retraining phase is completed, the output of the fusion model is the output value of the RLS model, where the predicted value output by the informer model is used as the input value of the RLS model, and the RLS model enters the online update phase; Whenever the sensor obtains the actual emission concentration value of the harmful gas, it is paired with the final output of the fusion model at the corresponding moment of the actual emission concentration value to update the parameters of the RLS model online, that is, to calibrate the RLS model online.

Citation Information

Patent Citations

  • PM2.5 concentration prediction method based on ST-Informer prediction model

    CN116153429A

  • Indoor air quality prediction setting method and device based on informer and medium

    CN117852582A

Cited By

  • Four-in-one diffusion type gas detection method and detection terminal

    CN120948723A

  • NOx concentration prediction integrated model online updating method based on RLS

    CN121479712A

  • Self-adaptive control method and system for animal husbandry pollutant treatment

    CN121763731A

  • Generator stator cooling water PH value control optimization method

    CN122331652A