Method and system for on-line monitoring of chemical oxygen demand of biogas slurry
By using a multi-parameter fusion partial least squares regression model and a Bayesian adaptive regularization method, dissolved oxygen, turbidity, redox potential, and conductivity of biogas slurry are monitored in real time. This solves the problems of low detection efficiency, insufficient accuracy, and high cost in existing technologies, and achieves efficient and accurate online monitoring of biogas slurry chemical oxygen demand.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- WUHAN ACADEMY OF AGRI SCI
- Filing Date
- 2025-08-13
- Publication Date
- 2026-06-09
AI Technical Summary
In existing technologies, the detection efficiency of biogas slurry chemical oxygen demand is low, the accuracy is insufficient, the online monitoring system has poor dynamic adaptability and high cost, making it difficult to meet the real-time monitoring needs of large-scale farms.
By real-time monitoring of dissolved oxygen, turbidity, redox potential, and conductivity, a multi-parameter fusion partial least squares regression prediction model is constructed. Combined with the Bayesian adaptive regularization method, rapid and low-cost detection of chemical oxygen demand is achieved.
It improves prediction accuracy and stability, reduces detection costs, and enables efficient online monitoring of biogas slurry chemical oxygen demand. It adapts to the seasonal fluctuations and time-varying nature of biogas slurry composition and meets the accuracy requirements of industrial monitoring.
Smart Images

Figure CN121008012B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of environmental monitoring technology, and in particular to a method and system for online monitoring of chemical oxygen demand (COD) in biogas slurry. Background Technology
[0002] Against the backdrop of intensive and large-scale development in animal husbandry, biogas slurry, as a byproduct of anaerobic fermentation of livestock and poultry waste, has become an important carrier of nutrient cycling in farmland due to its rich content of nitrogen, phosphorus, potassium, and soluble organic matter. Total Organic Carbon (TOC), as a core indicator of the organic components of biogas slurry, not only characterizes the abundance of active organic matter such as humic acid and amino acids, but also directly participates in the construction of the soil carbon pool, regulates microbial metabolic activity and the efficiency of nutrient absorption by crop roots, and is a key parameter determining the fertilizer efficiency and soil improvement potential of biogas slurry. However, Chemical Oxygen Demand (COD), by quantifying the oxygen demand of the organic matter oxidation process, can indirectly reflect the dynamic transformation behavior of total organic carbon and its potential environmental effects. Therefore, accurate monitoring of biogas slurry COD concentration is not only an important means of assessing the availability of organic carbon resources, but also a necessary prerequisite for avoiding ecological risks such as carbon and nitrogen metabolic imbalance and greenhouse gas release, and has dual significance for achieving safe return of biogas slurry to the field and agricultural ecological regulation.
[0003] At present, COD detection technology and supporting management model still have the following prominent problems: (1) Traditional chemical analysis methods are inefficient: standard methods such as potassium dichromate method require complex pretreatment and high temperature digestion, and a single detection takes more than 2 hours, which is difficult to meet the real-time monitoring needs of large-scale farms; (2) The single parameter prediction accuracy of sensors is insufficient: existing electrochemical or optical sensors are mostly based on a single parameter (such as conductivity) to indirectly estimate COD. Due to the complexity of biogas slurry composition and multicollinearity interference, the prediction error is as high as 30% or more; (3) The dynamic adaptability of online monitoring system is poor: existing models do not consider the seasonal fluctuations of biogas slurry composition (such as the effect of temperature on dissolved oxygen) and the time variability of microbial metabolites, which leads to the long-term decay of monitoring accuracy; (4) High cost of high-precision multi-parameter fusion equipment: equipment such as spectrometers need to be calibrated and maintained regularly, and the operation and maintenance costs exceed the affordability of small and medium-sized farms, which restricts the popularization of technology. Summary of the Invention
[0004] To address the problems existing in the prior art, this invention provides an online monitoring method and system for chemical oxygen demand (COD) in biogas slurry. By real-time monitoring of dissolved oxygen, turbidity, oxidation-reduction potential (ORP), and conductivity, a multi-parameter fusion partial least squares regression (PLS) prediction model is constructed to achieve rapid and low-cost detection of COD.
[0005] This invention provides a method for online monitoring of chemical oxygen demand (COD) in biogas slurry, comprising:
[0006] Obtain current characteristic data of biogas slurry, including multiple parameters such as dissolved oxygen, turbidity, redox potential, and conductivity;
[0007] The current characteristic data of the biogas slurry are input into the least squares regression model to obtain the current chemical oxygen demand prediction value of the biogas slurry output by the least squares regression model.
[0008] The least squares regression model is obtained by training the model using the characteristic data samples of the biogas slurry as feature variables and the measured chemical oxygen demand corresponding to the biogas slurry as the target variable.
[0009] According to the present invention, an online monitoring method for chemical oxygen demand (COD) of biogas slurry includes the following training steps for the least squares regression model:
[0010] Initialize the residual matrix of the feature variables based on the feature variables, and initialize the residual matrix of the target variables based on the target variables;
[0011] Calculate the weight vector based on the covariance of the current residual matrix of the feature variable and the current residual matrix of the target variable;
[0012] Calculate the latent variable score based on the weight vector and the current residual matrix of the feature variable;
[0013] Based on the latent variable scores and the current residual matrix of the target variable, the dynamic variance contribution rate is calculated, which is used to characterize the explanatory power of the current latent variable for chemical oxygen demand.
[0014] The regression strength of each feature variable is adjusted based on the Bayesian adaptive regularization method. The regularization regression coefficient is calculated based on the regression strength, the latent variable score and the current residual matrix of the target variable.
[0015] The current residual matrix of the target variable is updated based on the regularized regression coefficient and the latent variable score, and the current residual matrix of the feature variable is updated based on the latent variable score, until a preset termination condition is met.
[0016] The regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model.
[0017] According to the present invention, an online monitoring method for chemical oxygen demand (COD) of biogas slurry further includes, before initializing the residual matrix of the characteristic variables according to the characteristic variables and initializing the residual matrix of the target variables according to the target variables:
[0018] Z-score standardization is performed on the feature variables and the target variable.
[0019] According to the online monitoring method for chemical oxygen demand (COD) of biogas slurry provided by the present invention, the regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model, including:
[0020] Based on the regularized regression coefficients, weight vectors, and dynamic variance contribution rate obtained in the last iteration, a regression coefficient matrix is synthesized.
[0021] Based on the regression coefficient matrix, generate a standardized data regression equation;
[0022] The standardized data regression equation is transformed into the original data regression equation by using the mean and standard deviation of the feature variables and the mean and standard deviation of the target variable after Z-score standardization.
[0023] According to the online monitoring method for chemical oxygen demand (COD) of biogas slurry provided by the present invention, the formula of the standardized data regression equation is as follows:
[0024] Y = b1X norm1 +b2X norm2 +b3X norm3 +b4X norm4
[0025] Where Y is the standardized target variable, and X... norm1 To X norm4 These are the standardized feature variables, and b1 to b4 are the regression coefficients of the standardized data.
[0026] The formula for the regression equation of the original data is:
[0027] COD=β0+β1*EC+β2*DO+β3*NTU+β4*OPR
[0028] Wherein, COD, EC, DO, NTU and OPR are the original sensor data of the biogas slurry's chemical oxygen demand, conductivity, dissolved oxygen, turbidity and redox potential, respectively, β0 is the intercept term, and β1 to β4 are the regression coefficients of the original data.
[0029] According to the present invention, an online monitoring method for chemical oxygen demand (COD) of biogas slurry adjusts the regression strength of each characteristic variable using the following formula based on a Bayesian adaptive regularization method:
[0030]
[0031] Where, λ j ω is the regression strength corresponding to the j-th feature variable. (k) It is the weight corresponding to the j-th feature variable in the weight vector obtained in the k-th iteration, t (k) ε is the latent variable score obtained in the k-th iteration, and ε is the preset convergence threshold.
[0032] According to the online monitoring method for chemical oxygen demand (COD) of biogas slurry provided by the present invention, the regularized regression coefficient is calculated using the following formula based on the regression strength, the latent variable score, and the current residual matrix of the target variable:
[0033]
[0034] Among them, c (k) The regularized regression coefficients obtained in the k-th iteration are t. (k) Y is the latent variable score obtained in the k-th iteration, where T is the transpose operation. (k-1) λ is the residual matrix of the target variable obtained in the (k-1)th iteration. j It is the regression strength corresponding to the j-th feature variable.
[0035] According to the present invention, an online monitoring method for chemical oxygen demand (COD) of biogas slurry is provided, which updates the current residual matrix of the target variable based on the regularized regression coefficient and the latent variable score using the following formula:
[0036] Y (k) =Y (k-1) -α k ·t (k) c (k)
[0037]
[0038] Among them, Y (k) Y is the residual matrix of the target variable obtained in the k-th iteration. (k-1) Y is the residual matrix of the target variable obtained in the (k-1)th iteration. (i-1)It is the residual matrix of the target variable obtained in the (i-1)th iteration, α k It is the dynamic variance contribution rate obtained in the k-th iteration, t (k) c is the latent variable score obtained in the k-th iteration. (k) The regularized regression coefficients obtained in the k-th iteration are t. (i) is the latent variable score obtained in the i-th iteration, and T is the transpose operation;
[0039] The current residual matrix of the feature variable is updated based on the latent variable score using the following formula:
[0040]
[0041] Among them, X (k) X is the residual matrix of the characteristic variables obtained in the k-th iteration. (k-1) It is the residual matrix of the characteristic variables obtained in the (k-1)th iteration.
[0042] According to the present invention, an online monitoring method for chemical oxygen demand of biogas slurry is provided, wherein the preset termination conditions include the cumulative value of the dynamic variance contribution rate being greater than a first preset threshold, the norm of the residual matrix of the target variable being less than a preset proportion of the standard deviation of the target variable, or the number of latent variables reaching a preset upper limit.
[0043] This invention also provides an online monitoring system for chemical oxygen demand (COD) of biogas slurry, comprising:
[0044] The acquisition module is used to acquire the current characteristic data of the biogas slurry, which includes multiple parameters such as dissolved oxygen, turbidity, redox potential, and conductivity.
[0045] The prediction module is used to input the current characteristic data of the biogas slurry into the least squares regression model to obtain the current chemical oxygen demand prediction value of the biogas slurry output by the least squares regression model.
[0046] The least squares regression model is obtained by training the model using the characteristic data samples of the biogas slurry as feature variables and the measured chemical oxygen demand corresponding to the biogas slurry as the target variable.
[0047] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the online monitoring method for chemical oxygen demand of biogas slurry as described above.
[0048] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the online monitoring method for chemical oxygen demand of biogas slurry as described above.
[0049] The present invention also provides a computer program product, including a computer program that, when executed by a processor, implements the online monitoring method for chemical oxygen demand of biogas slurry as described above.
[0050] The present invention provides an online monitoring method and system for biogas slurry chemical oxygen demand (COD). By integrating multiple parameters, it comprehensively considers various characteristics among four variables: dissolved oxygen, turbidity, redox potential, and conductivity. This overcomes the limitations of traditional single-parameter prediction models and improves prediction accuracy and stability. Furthermore, by constructing a multi-parameter coupled COD prediction model using partial least squares regression, it reduces the dimensionality of high-dimensional sensor data to a latent variable space, effectively solving the multicollinearity problem while retaining key information. This ensures the accuracy and reliability of the model, enabling efficient online monitoring of biogas slurry chemical oxygen demand. Attached Figure Description
[0051] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0052] Figure 1 This is one of the flowcharts of the online monitoring method for chemical oxygen demand in biogas slurry provided by the present invention;
[0053] Figure 2 This is the second schematic diagram of the online monitoring method for chemical oxygen demand of biogas slurry provided by the present invention;
[0054] Figure 3 This is a schematic diagram of the error distribution of the online monitoring method for chemical oxygen demand of biogas slurry provided by the present invention;
[0055] Figure 4 This is a schematic diagram of the structure of the online monitoring system for chemical oxygen demand of biogas slurry provided by the present invention. Detailed Implementation
[0056] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0057] The following is combined Figure 1 The present invention describes an online monitoring method for chemical oxygen demand (COD) of biogas slurry, comprising:
[0058] Step 101: Obtain the current characteristic data of the biogas slurry, including multiple parameters such as dissolved oxygen, turbidity, redox potential, and conductivity.
[0059] Step 102: Input the current characteristic data of the biogas slurry into the least squares regression model to obtain the current chemical oxygen demand prediction value of the biogas slurry output by the least squares regression model;
[0060] Step 103: The least squares regression model is obtained by training the model using the characteristic data samples of the biogas slurry as feature variables and the measured chemical oxygen demand corresponding to the biogas slurry as target variables.
[0061] The COD detection system in biogas slurry includes a sensor module, a signal processing module, a model calculation module, and a display terminal.
[0062] Sensor modules, including an industrial-grade dissolved oxygen sensor, an infrared turbidity sensor, a platinum electrode redox potential sensor, a quadrupole conductivity probe, and a chemical oxygen demand sensor, are used to measure the current characteristic data, characteristic data samples, and chemical oxygen demand of the biogas slurry.
[0063] Signal processing modules, such as STM32 microcontrollers, are used to integrate ADC modules to filter, amplify, and convert the original signals to digital in real time.
[0064] The core module for model computation runs a partial least squares fitting algorithm through an embedded system. It uses a partial least squares regression model trained on historical data as input, multi-parameter sensor data as input, and outputs COD prediction values.
[0065] Experiments show that the coefficient of determination R for predicting COD in this embodiment is [missing information]. 2 >0.95, normalized root mean square error (NRMSE) <5%, meeting the accuracy requirements for industrial monitoring.
[0066] This embodiment overcomes the limitations of traditional single-parameter prediction models by integrating multiple parameters, comprehensively considering various features among dissolved oxygen, turbidity, redox potential, and conductivity. It improves prediction accuracy and stability. By constructing a multi-parameter coupled COD prediction model through partial least squares regression algorithm, the high-dimensional sensor data is reduced to the latent variable space, effectively solving the multicollinearity problem while retaining key information, ensuring the accuracy and reliability of the model, and realizing efficient online monitoring of biogas slurry chemical oxygen demand.
[0067] Based on the above embodiments, the training steps of the least squares regression model in this embodiment include:
[0068] Initialize the residual matrix of the feature variables based on the feature variables, and initialize the residual matrix of the target variables based on the target variables;
[0069] Calculate the weight vector based on the covariance of the current residual matrix of the feature variable and the current residual matrix of the target variable;
[0070] Calculate the latent variable score based on the weight vector and the current residual matrix of the feature variable;
[0071] Based on the latent variable scores and the current residual matrix of the target variable, the dynamic variance contribution rate is calculated, which is used to characterize the explanatory power of the current latent variable for chemical oxygen demand.
[0072] The regression strength of each feature variable is adjusted based on the Bayesian adaptive regularization method. The regularization regression coefficient is calculated based on the regression strength, the latent variable score and the current residual matrix of the target variable.
[0073] The current residual matrix of the target variable is updated based on the regularized regression coefficient and the latent variable score, and the current residual matrix of the feature variable is updated based on the latent variable score, until a preset termination condition is met.
[0074] The regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model.
[0075] The core of constructing a partial least squares regression (PLS) algorithm lies in:
[0076] Covariance maximization projection extracts the latent variables between the feature variables (X:DO, NTU, OPR, EC) and the target variable (Y:COD), so that the latent variables can maximize the explanatory power of the covariance between the two while preserving the original data features.
[0077] Dimensionality reduction and redundancy removal eliminate multicollinearity interference and improve model generalization by projecting high-dimensional sensor data into a low-dimensional latent variable space.
[0078] Iterative parameter optimization, driven by residual matrix updates, iteratively calculates weight vectors, score vectors, and regression coefficients until the preset number of iterations or residual convergence threshold is met, ensuring that the model dynamically adapts to data changes.
[0079] The COD prediction method is based on the partial least squares regression (PLS) algorithm. It constructs a multi-parameter fusion prediction model through latent variable extraction and residual iterative optimization, specifically including the following steps:
[0080] Sample collection and parameter determination: biogas slurry samples were collected, and characteristic parameters such as conductivity, dissolved oxygen, turbidity and redox potential were measured simultaneously using multi-parameter sensors. The COD reference value of the corresponding sample was determined using standard methods.
[0081] Data preprocessing involves using the Z-score standardization method to normalize the raw sensor data, eliminating the dimensional differences between DO, NTU, OPR, and EC. The standardized parameters are then integrated into a multidimensional feature vector to construct a sample dataset. The standardized data is stored, and a mapping relationship between the feature matrix X and the target variable Y is established.
[0082] Initialize the model PLS(Y,X,n_components,bias), where Y is the target variable (COD), X is the feature variable (dissolved oxygen, turbidity, redox potential, conductivity), n_components is the initial number of latent variables, bias is whether to include a bias term, and the initial residual matrix is the standardized feature matrix.
[0083] In the latent variable extraction stage, the covariance weight vector is first calculated based on the standardized feature variable X and the target variable Y. Then, the regularization strength λ of each parameter is dynamically adjusted using the Bayesian adaptive regularization method. j To suppress the interference of multiple common linearity, the weight vector is then multiplied by the current residual matrix to generate the latent variable score vector t, and the dynamic variance contribution weight α is calculated. k This is to quantify the explanatory power of the latent variable for COD. The feature residual matrix and target residual are updated synchronously after each iteration, and the iteration continues until the termination condition is met.
[0084] Model synthesis integrates the regression coefficients corresponding to each latent variable to generate the final predictive model. The formula applicable to standardized data is Y = b1X. norm1 +b2X norm2 +b3X norm3 +b4X norm4 The applicable formula for the original data is COD=β0+β1*EC+β2*DO+β3*NTU+β4*OPR;
[0085] Real-time prediction and output: Input newly collected standardized sensor data into the trained PLS model, select the prediction mode as standard prediction or iterative prediction according to the centralization flag, calculate the latent variable score and weighted regression coefficient, restore the predicted value through inverse standardization, output COD concentration and dynamically display it on the terminal interface.
[0086] Initialize the residual matrix, set the initial number of iterations k=1, and input the preset number of latent variables n_components and the convergence threshold ε. Start the iterative calculation. The iterative process includes:
[0087] (a) Calculate the weight vector: based on the current residual matrix X (k-1) With Y (k-1) The covariance is normalized to generate the weight vector ω. (k) ;
[0088] (b) Calculate the latent variable score vector t (k) and its dynamic variance contribution rate α (k) Quantify the explanatory power of current latent variables on COD changes;
[0089] (c) Bayesian adaptive regularization: Based on the L2 norm of the historical latent variable score vector and the orthogonality of the weight vector, the regularization parameter λ of the regression coefficient is dynamically adjusted. j ;
[0090] (d) Synchronously update feature residuals X (k) and target residual Y (k) .
[0091] After synthesizing the regression coefficient matrix, the model was validated using a test dataset, and the results were obtained by normalizing the root mean square error (NRMSE) and the coefficient of determination (R²). 2 Evaluate the model's predictive accuracy;
[0092] Input EC, DO, NTU, and OPR data of a new biogas slurry sample, and output COD prediction values based on a trained partial least squares regression model.
[0093] In this embodiment, Bayesian adaptive regularization is achieved by dynamically adjusting the parameter λ. j Suppressing collinearity interference of sensor parameters, λ j The method is inversely correlated with the fluctuation intensity of the historical score vector of latent variables; the residual matrix update adopts a dual update mechanism to simultaneously eliminate explained variance in the feature space and the target space; during model training, the number of latent variables n_components can be dynamically optimized through cross-validation to improve generalization ability. The method is integrated into an online monitoring system, which collects biogas slurry characteristic variable data in real time through sensors, performs COD prediction calculations simultaneously, and generates dynamic monitoring reports and visualization charts.
[0094] Based on the above embodiments, this embodiment further includes the following step before initializing the residual matrix of the feature variables according to the feature variables and initializing the residual matrix of the target variables according to the target variables:
[0095] Z-score standardization is performed on the feature variables and the target variable.
[0096] Samples of biogas slurry were collected and their target variable COD and characteristic variables EC, DO, NTU, and OPR were measured. After storing the target variable and characteristic variable data, they were preprocessed using the Z-score standardization method.
[0097] Based on the above embodiments, this embodiment integrates the regularized regression coefficients obtained from the last iteration to obtain the final least squares regression model, including:
[0098] Based on the regularized regression coefficients, weight vectors, and dynamic variance contribution rate obtained in the last iteration, a regression coefficient matrix is synthesized.
[0099] Based on the regression coefficient matrix, generate a standardized data regression equation;
[0100] The standardized data regression equation is transformed into the original data regression equation by using the mean and standard deviation of the feature variables and the mean and standard deviation of the target variable after Z-score standardization.
[0101] Based on the above embodiments, the formula for the standardized data regression equation in this embodiment is:
[0102] Y = b1X norm1 +b2X norm2 +b3X norm3 +b4X norm4
[0103] Where Y is the standardized target variable, and X... norm1 To X norm4 These are the standardized feature variables, and b1 to b4 are the regression coefficients of the standardized data.
[0104] The formula for the regression equation of the original data is:
[0105] COD=β0+β1*EC+β2*DO+β3*NTU+β4*OPR
[0106] Wherein, COD, EC, DO, NTU and OPR are the original sensor data of the biogas slurry's chemical oxygen demand, conductivity, dissolved oxygen, turbidity and redox potential, respectively, β0 is the intercept term, and β1 to β4 are the regression coefficients of the original data.
[0107] Based on the above embodiments, this embodiment adjusts the regression strength of each feature variable using the Bayesian adaptive regularization method according to the following formula:
[0108]
[0109] Where, λ j ω is the regression strength corresponding to the j-th feature variable. (k) It is the weight corresponding to the j-th feature variable in the weight vector obtained in the k-th iteration, t (k) ε is the latent variable score obtained in the k-th iteration, and ε is the preset convergence threshold.
[0110] Based on the above embodiments, this embodiment calculates the regularized regression coefficients using the following formula, based on the regression strength, the latent variable scores, and the current residual matrix of the target variable:
[0111]
[0112] Among them, c (k) The regularized regression coefficients obtained in the k-th iteration are t. (k) Y is the latent variable score obtained in the k-th iteration, where T is the transpose operation. (k-1) λ is the residual matrix of the target variable obtained in the (k-1)th iteration. j It is the regression strength corresponding to the j-th feature variable.
[0113] Based on the above embodiments, this embodiment updates the current residual matrix of the target variable according to the regularized regression coefficient and the latent variable score using the following formula:
[0114] Y (k) =Y (k-1) -α k ·t (k) c (k)
[0115]
[0116] Among them, Y (k) Y is the residual matrix of the target variable obtained in the k-th iteration. (k-1) Y is the residual matrix of the target variable obtained in the (k-1)th iteration. (i-1) It is the residual matrix of the target variable obtained in the (i-1)th iteration, α k It is the dynamic variance contribution rate obtained in the k-th iteration, t (k) c is the latent variable score obtained in the k-th iteration. (k) The regularized regression coefficients obtained in the k-th iteration are t. (i) is the latent variable score obtained in the i-th iteration, and T is the transpose operation;
[0117] The current residual matrix of the feature variable is updated based on the latent variable score using the following formula:
[0118]
[0119] Among them, X (k) X is the residual matrix of the characteristic variables obtained in the k-th iteration. (k-1) It is the residual matrix of the characteristic variables obtained in the (k-1)th iteration.
[0120] Based on the above embodiments, the preset termination conditions in this embodiment include the cumulative value of the dynamic variance contribution rate being greater than a first preset threshold, the norm of the residual matrix of the target variable being less than a preset proportion of the standard deviation of the target variable, or the number of latent variables reaching a preset upper limit.
[0121] Termination condition determination: Iteration stops when any of the following conditions are met:
[0122] (a) Cumulative Explanation Rate Σα k >95%;
[0123] (b) The norm of the target residual matrix decreases to below 1% of the initial value;
[0124] (c) The maximum number of latent variables n_components is reached = 5.
[0125] Figure 2 A preferred embodiment of the online monitoring method for COD content in biogas slurry according to the present invention includes the following steps:
[0126] F1: Collect N sets of biogas slurry samples. Collect N sets of biogas slurry samples regularly from monitoring points such as the outlet of the biogas slurry treatment pond to ensure that the samples are representative and can cover the state of biogas slurry under different time and different composition changes.
[0127] F2: Determine the target variable and characteristic variables. Determine the target variable COD concentration and four characteristic variables for each biogas slurry sample in step F1. The four characteristic variables include dissolved oxygen DO, turbidity NTU, oxidation-reduction potential OPR, and conductivity EC.
[0128] F3: Data storage and preliminary inspection. The measured COD concentration and characteristic variable data are stored in tabular form, such as an Excel file, and a preliminary inspection is performed to remove outliers and erroneous data.
[0129] F4: Perform Z-score normalization on the target variable COD concentration Y and the characteristic variables dissolved oxygen X1, turbidity X2, redox potential X3, and conductivity X4 respectively. The normalization formula is as follows: Where μ represents homogeneity and σ represents standard deviation;
[0130] F5: Set the standardized matrix obtained in step F4 as X. norm ∈R N×4 Y norm ∈R N×4 The partial least squares algorithm was used to train the model;
[0131] F6: Based on X (0) =X norm Y (0) =Y normThe residual matrix is initialized to provide initial data for subsequent latent variable extraction and model training;
[0132] F7: Set the maximum number of latent variables n_components = 5, and the convergence threshold ε = 10. -6 .
[0133] F8: Based on F7, latent variables are extracted iteratively. Taking the k-th iteration as an example: According to the formula... Calculate the weight vector ω (k) And extract the latent variable score t (k) =X (k-1) ω (k) ;
[0134] F9: According to the formula Calculate the dynamic variance contribution weight to characterize the explanatory power of the current latent variable for COD;
[0135] F10: Bayesian Adaptive Regularization: Automatically adjusts regression strength based on historical data fluctuations. And calculate the regularized regression coefficients.
[0136] F11: Update the dual residual matrix: eigenresiduals Target residual Y (k) =Y (k-1) -α k ·t (k) c (k) ;
[0137] F12: Determine if the conditions for early termination are met: ① Cumulative explanatory power ∑α k >95%; ② Residual norm ||Y (k) || F <0.01σ Y ③ If the upper limit of n_components is reached, stop if one of the above conditions is met; otherwise, continue the loop.
[0138] F13: After the loop ends, follow the formula. The composite regression coefficient matrix B, where W K =[ω (1) ,ω (2) ,...,ω (K) [C] is a 4×K dimensional weight matrix. K =[c (1) ,c (2) ,...,c (K) [] is a 1×K dimensional regression coefficient vector, and diag(α) is the diagonal element representing the contribution rate α of the dynamic variance. k A K×K dimensional diagonal matrix;
[0139] F14: Generate the standardized data regression equation Y = b1X norm1 +b2X norm2 +b3X norm3 +b4X norm4 Where Y is the standardized COD concentration, and X... norm1 ~X norm4 These are the standardized feature variables, and b1 to b4 are the regression coefficients. In this example, the regression equation for the standardized data is:
[0140] Y = 0.2876 * X norm1 +0.0209*X norm2 +0.8081*X norm3 +0.0791*X norm4 ;
[0141] F15: Generate the original data regression equation. Using the mean and standard deviation from the F4 standardization process, transform the regression equation into the original form: COD=β0+β1*EC+β2*DO+β3*NTU+β4*OPR, where β0 is the intercept term, calculated from the mean and regression coefficients according to the formula. Inverse standardization yields the regression coefficients of the original data, β1 to β4, obtained from the B vector and standard deviation using the formula... Inverse standardization yields the following regression equation for the original data in this example:
[0142] COD=-724.93+0.3112*EC+37.9191*DO+0.8986*NTU+1.7168*OPR.
[0143] F16: Check the robustness of the model using an error distribution plot, using R. 2 R and NRMSE are used to evaluate the explanatory power of the model: if the error distribution follows a normal distribution, it indicates that the model has good robustness; 2 If the NRMSE is between 0.8 and 1.0 and < 5%, the model has been successfully trained, has strong predictive ability, and can be used for practical predictions. Otherwise, it indicates that the model's predictive ability is weak, and it is necessary to return to step F3 to exclude outliers and retrain the model. In this example, R... 2 =0.9536, verifying the strong fitting ability of multi-parameter fusion and PLS algorithm for the complex components of biogas slurry; NRMSE=2.54%, far below the ±5% relative error threshold allowed by COD detectors in industrial standards. Figure 3 As shown, the error distribution exhibits a normal distribution, indicating that the overall prediction bias of the model is controllable and meets the requirements for online monitoring.
[0144] F17: Input the real-time collected biogas slurry characteristic parameters into the optimized PLSR model, output COD prediction value, and trigger system early warning in combination with preset pollution threshold to realize dynamic monitoring of COD content in biogas slurry.
[0145] This embodiment employs a dynamic robustness enhancement mechanism and residual-driven iteration, enabling the model to dynamically update and automatically adjust parameters based on real-time data. It also introduces an adaptive regularization mechanism to effectively suppress mutual interference between sensor parameters, adapt to seasonal fluctuations and time-varying characteristics of biogas slurry components, and ensure long-term monitoring accuracy.
[0146] This method eliminates the need for complex chemical analysis, reducing detection costs and offering strong real-time performance. It controls the iteration process based on dynamic variance contribution rate, automatically terminating redundant calculations while ensuring model interpretability. Detection time is reduced to the second level. Experiments show that the regression coefficient matrix B is a 4×1 floating-point vector with a total storage space of only 16 bytes, perfectly adapting to the memory limitations of embedded systems. It can achieve second-level prediction with only 5 types of sensor data, significantly improving detection efficiency.
[0147] The following describes the online monitoring system for chemical oxygen demand (COD) of biogas slurry provided by the present invention. The online monitoring system for COD of biogas slurry described below can be referred to in correspondence with the online monitoring method for COD of biogas slurry described above.
[0148] like Figure 4 As shown, the system includes an acquisition module 401 and a prediction module 402, wherein:
[0149] The acquisition module 401 is used to acquire the current characteristic data of the biogas slurry, which includes multiple features such as dissolved oxygen, turbidity, redox potential and conductivity.
[0150] The prediction module 402 is used to input the current characteristic data of the biogas slurry into the least squares regression model to obtain the current chemical oxygen demand prediction value of the biogas slurry output by the least squares regression model.
[0151] The least squares regression model is obtained by training the model using the characteristic data samples of the biogas slurry as feature variables and the measured chemical oxygen demand corresponding to the biogas slurry as the target variable.
[0152] This embodiment overcomes the limitations of traditional single-parameter prediction models by integrating multiple parameters, comprehensively considering various features among dissolved oxygen, turbidity, redox potential, and conductivity. It improves prediction accuracy and stability. By constructing a multi-parameter coupled COD prediction model through partial least squares regression algorithm, the high-dimensional sensor data is reduced to the latent variable space, effectively solving the multicollinearity problem while retaining key information, ensuring the accuracy and reliability of the model, and realizing efficient online monitoring of biogas slurry chemical oxygen demand.
[0153] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, the present invention is not intended to limit it.
[0154] Those skilled in the art should understand that they can still apply the techniques described in the foregoing embodiments.
[0155] The technical solution is modified, or some of its technical features are replaced with equivalent ones; and these modifications...
[0156] Modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the technical aspects of the embodiments of this invention.
[0157] The spirit and scope of the case.
Claims
1. A method for online monitoring of chemical oxygen demand (COD) in biogas slurry, characterized in that, include: Obtain current characteristic data of biogas slurry, including multiple parameters such as dissolved oxygen, turbidity, redox potential, and conductivity; The current characteristic data of the biogas slurry are input into the least squares regression model to obtain the current chemical oxygen demand prediction value of the biogas slurry output by the least squares regression model. The least squares regression model is trained by using the characteristic data samples of the biogas slurry as feature variables and the measured chemical oxygen demand corresponding to the biogas slurry as target variables. The training steps for the least squares regression model include: Initialize the residual matrix of the feature variables based on the feature variables, and initialize the residual matrix of the target variables based on the target variables; Calculate the weight vector based on the covariance of the current residual matrix of the feature variable and the current residual matrix of the target variable; Calculate the latent variable score based on the weight vector and the current residual matrix of the feature variable; Based on the latent variable scores and the current residual matrix of the target variable, the dynamic variance contribution rate is calculated, which is used to characterize the explanatory power of the current latent variable for chemical oxygen demand. The regression strength of each feature variable is adjusted based on the Bayesian adaptive regularization method. The regularization regression coefficient is calculated based on the regression strength, the latent variable score and the current residual matrix of the target variable. The current residual matrix of the target variable is updated based on the regularized regression coefficient and the latent variable score, and the current residual matrix of the feature variable is updated based on the latent variable score, until a preset termination condition is met. The regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model.
2. The method for online monitoring of biogas slurry chemical oxygen demand according to claim 1, characterized in that, Before initializing the residual matrix of the feature variables based on the feature variables, and before initializing the residual matrix of the target variables based on the target variables, the method further includes: Z-score standardization is performed on the feature variables and the target variable.
3. The method for online monitoring of chemical oxygen demand in biogas slurry according to claim 2, characterized in that, The regularized regression coefficients obtained from the last iteration are integrated to obtain the final least squares regression model, including: Based on the regularized regression coefficients, weight vectors, and dynamic variance contribution rate obtained in the last iteration, a regression coefficient matrix is synthesized. Based on the regression coefficient matrix, generate a standardized data regression equation; The standardized data regression equation is transformed into the original data regression equation by using the mean and standard deviation of the feature variables and the mean and standard deviation of the target variable after Z-score standardization.
4. The method for online monitoring of chemical oxygen demand in biogas slurry according to claim 3, characterized in that, The formula for the standardized data regression equation is: ; Where Y is the standardized target variable. to These are the standardized feature variables, and b1 to b4 are the regression coefficients of the standardized data. The formula for the regression equation of the original data is: ; Among them, COD, EC, DO, NTU, and OPR are the raw sensor data of the biogas slurry's chemical oxygen demand, conductivity, dissolved oxygen, turbidity, and redox potential, respectively. It is the intercept term. to These are the regression coefficients of the original data.
5. The method for online monitoring of chemical oxygen demand in biogas slurry according to claim 1, characterized in that, The regression strength of each feature variable is adjusted using the Bayesian adaptive regularization method based on the following formula: ; Where, λ j It is the regression strength corresponding to the j-th feature variable. It is the weight corresponding to the j-th feature variable in the weight vector obtained in the k-th iteration, t (k) is the latent variable score obtained in the k-th iteration, and ɛ is the preset convergence threshold.
6. The method for online monitoring of chemical oxygen demand in biogas slurry according to claim 1, characterized in that, The regularized regression coefficients are calculated using the following formula based on the regression strength, the latent variable scores, and the current residual matrix of the target variable: ; Among them, c (k) The regularized regression coefficients obtained in the k-th iteration are t. (k) Y is the latent variable score obtained in the k-th iteration, where T is the transpose operation. (k-1) λ is the residual matrix of the target variable obtained in the (k-1)th iteration. j It is the regression strength corresponding to the j-th feature variable.
7. The method for online monitoring of chemical oxygen demand in biogas slurry according to claim 1, characterized in that, The current residual matrix of the target variable is updated using the following formula based on the regularized regression coefficients and the latent variable scores: ; ; Among them, Y (k) Y is the residual matrix of the target variable obtained in the k-th iteration. (k-1) Y is the residual matrix of the target variable obtained in the (k-1)th iteration. (i-1) It is the residual matrix of the target variable obtained in the (i-1)th iteration, α k It is the dynamic variance contribution rate obtained in the k-th iteration, t (k) c is the latent variable score obtained in the k-th iteration. (k) The regularized regression coefficients obtained in the k-th iteration are t. (i) is the latent variable score obtained in the i-th iteration, and T is the transpose operation; The current residual matrix of the feature variable is updated based on the latent variable score using the following formula: ; Among them, X (k) X is the residual matrix of the characteristic variables obtained in the k-th iteration. (k-1) It is the residual matrix of the characteristic variables obtained in the (k-1)th iteration.
8. The method for online monitoring of chemical oxygen demand in biogas slurry according to claim 1, characterized in that, The preset termination conditions include the cumulative value of the dynamic variance contribution rate being greater than a first preset threshold, the norm of the residual matrix of the target variable being less than a preset proportion of the standard deviation of the target variable, or the number of latent variables reaching a preset upper limit.
9. An online monitoring system for chemical oxygen demand (COD) of biogas slurry, characterized in that, The method for online monitoring of biogas slurry chemical oxygen demand according to any one of claims 1-8 includes: The acquisition module is used to acquire the current characteristic data of the biogas slurry, which includes multiple parameters such as dissolved oxygen, turbidity, redox potential, and conductivity. The prediction module is used to input the current characteristic data of the biogas slurry into the least squares regression model to obtain the current chemical oxygen demand prediction value of the biogas slurry output by the least squares regression model. The least squares regression model is obtained by training the model using the characteristic data samples of the biogas slurry as feature variables and the measured chemical oxygen demand corresponding to the biogas slurry as the target variable.