A sewage denitrification dosing method and system based on machine learning and a storage medium
The wastewater denitrification dosing method constructed through machine learning solves the problems of lag effect and multi-factor coupling in carbon source dosing control, realizes precise control of carbon source dosing and nitrogen conversion relationship, and improves the automation and stability of wastewater treatment.
Patent Information
- Application Number
- CN202511395087.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-09-28
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2045-09-28
AI Technical Summary
Existing wastewater treatment technologies suffer from problems such as unquantified lag effects, uncontrolled multi-factor coupling, and difficulty in correcting human influences, resulting in low carbon source utilization efficiency, low nitrogen removal accuracy, and difficulty in adapting to complex operating conditions and achieving automated control.
Machine learning methods were employed to analyze the lagged effects of carbon source addition on nitrogen removal through data acquisition and preprocessing. A prediction model was constructed using shallow CART trees and XGBoost models, and combined with a time series prediction model to quantify the nonlinear relationship between carbon source addition and nitrogen conversion, thereby achieving precise control.
Precise quantification of lag effects optimizes carbon source dosage and timing, improves carbon source utilization efficiency and nitrogen removal accuracy, enhances the model's adaptability to complex operating conditions, and enables unmanned operation of wastewater treatment.
Smart Images

Figure CN120877905B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the technical field of wastewater treatment, specifically relating to a wastewater denitrification dosing method, system, and storage medium based on machine learning. Background Technology
[0002] Currently, in the field of wastewater treatment, nitrogen removal is a key step in preventing eutrophication of water bodies, mainly encompassing two technical routes: biological and physicochemical methods. Biological nitrogen removal, centered on the nitrification-denitrification process, uses microorganisms to convert ammonia nitrogen into gaseous nitrogen through oxidation-reduction reactions under aerobic / anoxic conditions, and is widely used in conventional wastewater treatment. Among these, denitrification is one of the crucial steps in biological nitrogen removal, and influencing factors include the carbon source in the wastewater, temperature, and the nitrification liquor recirculation ratio, with the carbon source being a significant factor.
[0003] Traditional carbon source dosing control technologies for denitrification processes mainly rely on manual dosing or dosing systems based on intermediate variables. Manual dosing technology depends on the operator's experience in judging the amount of carbon source to be added, and its core drawbacks are: ① High subjectivity: Dosing amount is dominated by human experience, lacking quantitative basis, and easily leads to overdosing or underdosing due to differences in operating habits and sense of responsibility, resulting in carbon source waste or inadequate nitrogen removal; ② Neglecting lag effects: It does not consider the time lag in the denitrification process after carbon source addition (such as the time difference in microbial utilization of carbon source), and cannot adjust the dosing strategy in a timely manner according to dynamic changes in nitrogen concentration; ③ High labor intensity: It requires continuous monitoring of water quality changes and frequent adjustments, making it difficult to meet the high-efficiency operation requirements of modern wastewater treatment plants. Automatic dosing systems based on intermediate variables, such as those used in some water plants, employ intermediate process variables like turbidity and transmittance as detection indicators for automatic dosing. However, these systems have the following fundamental limitations: ① Disjointed control logic: Using intermediate variables (such as SCD and FCD) rather than the final effluent nitrogen concentration as the control target leads to frequent manual adjustments of setpoints when influent water quality and flow fluctuate, resulting in poor stability; ② Weak anti-interference capability: The systems do not incorporate the coupled effects of multiple factors such as sludge concentration and temperature, making them insufficiently adaptable to complex operating conditions. Furthermore, the detection instruments are non-standardized, making maintenance complex, and most water plants have stopped using them due to practicality issues; ③ Insufficient dynamic adaptability: The systems do not have an iterative update mechanism designed for parameter drift in the wastewater treatment process (such as changes in sludge characteristics), which can easily lead to prediction deviations with long-term use.
[0004] Machine learning-based drug dosing prediction models are currently a hot research topic in academia. This technology mainly includes the following steps:
[0005] (1) Collect sensor data and monitor changes in key parameters in real time;
[0006] (2) Perform feature engineering to generate candidate variables;
[0007] (3) Establishing a model for prediction: The most common modeling method is simple linear regression, or the previous experience-based drug addition logic and theoretical function are modified.
[0008] For example, Chinese patent CN120335398A discloses an AI-based intelligent urban water purification and wastewater treatment process optimization system and method. It utilizes a multiple linear regression model to establish a water quality change prediction model, which predicts water quality changes based on real-time collected key data. A dynamic reagent AI model adjusts the dosage, and a water treatment chemical / biological reaction kinetic AI model predicts pollutant degradation. A local lightweight AI model optimizer, combined with a multi-objective genetic algorithm, considers energy consumption, reagent cost, treatment efficiency, and carbon emissions to obtain the optimal control model. This approach uses a genetic algorithm to continuously cross-reference and grow features, selecting the final variable based on the objective function. The advantage of this approach is that it yields a large number of candidate features. However, overly complex features can lose interpretability, making the model more prone to overfitting. Existing research uses neural network encoders and principal component analysis (PCA) to aggregate features and achieve dimensionality reduction, but these aggregated features still possess high complexity, increasing the risk of model overfitting. On the other hand, this approach introduces a correction coefficient γ(pH) to modify the Arrhenius equation, obtaining γ(pH) based on historical data through a multiple linear regression model. However, the correction dimension of this scheme is rather one-sided: when the Arrhenius equation describes the reaction rate, in addition to pH, it is also affected by factors such as reactant concentration and pressure. The pre-exponential factor A may also change with temperature, catalyst activity, etc. It is difficult to fully reflect the reaction law under complex conditions by using only a single correction coefficient.
[0009] For example, Chinese patent CN119191556A discloses an intelligent control method for the adjustable zone of an AOA process in wastewater treatment, including the following steps: S100, obtaining three indicators that meet the effluent requirements, namely the target ammonia nitrogen concentration Nout, the target nitrate concentration NO, and the target total phosphorus concentration TP; S200, obtaining the real-time ammonia nitrogen concentration Nout,t, the real-time nitrate concentration NOt, and the real-time total phosphorus concentration TPt at the effluent end; S300, determining the magnitudes of Nout and Nout,t; if Nout,t > Nout, then controlling the adjustable zone to be in the open state; if Nout ≥ Nout,t, then controlling the adjustable zone to be in the closed state; determining the magnitudes of NO and NOt; if NOt > NO, then controlling the dosing device to add carbon source to the adjustable zone; if NO ≥ NOt, then controlling the dosing device to stop adding carbon source to the adjustable zone; determining the magnitudes of TP and TPt; if TPt > TP, then controlling the dosing device to add phosphorus removal agent to the adjustable zone; if TP ≥ TPt, then controlling the dosing device to stop adding phosphorus removal agent to the adjustable zone. The advantages of this approach are its simplicity and intuitiveness, requiring no complex algorithms, low hardware computing power, and rapid response in scenarios with stable water quality fluctuations. However, this approach relies heavily on human experience, is highly subjective, and its accuracy is greatly affected by the operator's skill. It is difficult to adapt to scenarios with sudden changes in water quality parameters or complex dynamic changes, and it cannot achieve automated continuous control.
[0010] For example, Chinese patent CN119954236B discloses a fuzzy logic-based intelligent dosing control system for wastewater treatment, comprising: a data acquisition module for collecting wastewater quality data and optimizing the data acquisition process, including chemical oxygen demand (COD), ammonia nitrogen content, total phosphorus content, and wastewater flow rate; a data analysis module for receiving real-time data and performing small-batch gradient descent analysis to obtain analysis results; an optimization module for optimizing the parameters and rules of the fuzzy logic controller through differential evolution based on the analysis results to obtain optimized parameters and rules; and a fuzzy logic control module for performing fuzzy logic calculations of the dosing dosage through simulated annealing based on the received water quality parameters and optimized rules, and converting the calculations into dosing control signals. The advantages of this solution are that it replaces experience-based judgment with data-driven approaches, reducing human intervention; the model training process can process data in batches; and it can stably output prediction results even in scenarios with significant linear relationships between variables. However, this scheme assumes a linear relationship between variables based on multiple linear regression, making it difficult to capture the nonlinear interactions between water quality parameters (such as the nonlinear dynamics of pollutant degradation). Furthermore, it does not consider the sequential correlation in the time dimension, resulting in limited accuracy in predicting water quality changes with lag effects or periodicity. The real-time performance of small-batch training may also fail to match rapidly fluctuating water quality scenarios.
[0011] In summary, the core problems of existing technologies are as follows:
[0012] 1. Lagged effects not quantified: Existing studies on the correlation between time series rely heavily on manually set hyperparameters, failing to effectively capture the delayed impact of carbon source addition on nitrogen removal. This fuzzy approach leads to a mismatch between the timing of regulation and the actual reaction patterns, reducing carbon source utilization efficiency and nitrogen removal accuracy.
[0013] 2. Uncontrolled Coupling of Multiple Factors: The synergistic effects of variables such as influent water quality and sludge activity are not systematically modeled, and the relationships between variables often exhibit complex nonlinear characteristics. Existing technologies rely on single-variable analysis or linear models, which are difficult to adapt to dynamic changes in operating conditions, leading to control failure in complex scenarios.
[0014] 3. Difficulty in correcting human influence: Historical data contains a large number of human operation errors, which weakens the real correlation between chemical dosing behavior and effluent water quality, requiring the model to have higher robustness. Summary of the Invention
[0015] The purpose of this invention is to provide a wastewater denitrification dosing method, system, and storage medium based on machine learning, in order to solve the above-mentioned problems.
[0016] This invention is mainly achieved through the following technical solutions:
[0017] A wastewater denitrification dosing method based on machine learning includes the following steps:
[0018] Step S1: Data Acquisition and Preprocessing; Collect historical operating data of the wastewater treatment plant to obtain variable data that affect the carbon source dosing behavior in the biological treatment tank;
[0019] Step S2: Analyze the lagged effect of carbon source input on nitrogen removal index, and analyze the time change curve of Pearson correlation coefficient on nitrate nitrogen conversion in the future t+X period after drug administration, so as to determine the time range of drug effect duration as P2-P1; where P1 is the time point when the initial Pearson correlation coefficient rises after drug administration, and P2 is the time point when the Pearson correlation coefficient returns to the corresponding P1 at the end of drug administration.
[0020] Step S3: Set the target variable as the dosage TY_JY in period t+1. t+1 ;
[0021] Step S4: Based on step S1, filter variables and determine predictor variables;
[0022] Step S5: Based on the target variable in step S3 and the predicted variable in step S4, use a shallow CART tree as the base learner and integrate the shallow tree with an XGBoost model to build a prediction model;
[0023] Step S6: Using the trained prediction model and based on the nitrogen removal rate in the future t+X period, obtain the pesticide application rate TY_JY in the (t+1)th period.t+1 =XGBoost(predictor variables) t Predictor variables t-2 , ..., predictor variables t-(P2-P1+1) Denitrification index t+X ).
[0024] To better implement the present invention, step S1 further includes the following steps:
[0025] Step S11: Collect historical operating data of the wastewater treatment plant through preset sensors, and delete variables after the effluent process of the biological treatment tank to obtain variable data that affect the carbon source dosing behavior of the biological treatment tank.
[0026] Step S12: Align the data from each sensor in the time series.
[0027] To better realize the present invention, in step S2, the nitrogen removal index is any one of the total nitrogen index, nitrate nitrogen index, and nitrite nitrogen index.
[0028] To better realize the present invention, further, in step S2, the nitrogen removal rate index is the nitrate nitrogen index; step S2 includes the following steps:
[0029] Step S21: Determine the sampling frequency F, and calculate the nitrate nitrogen conversion amount (F) within time F = the total amount of nitrogen flowing into the biological treatment tank within time F - LEAD(N (kg), I flowing into the biological treatment tank within time F);
[0030] Where: LEAD(N(kg),I) outflowing into the biochemical pool within time F represents the amount of nitrate nitrogen converted in the future period I;
[0031] Step S22: Analyze the correlation between drug administration and nitrate nitrogen conversion in the future t+X period, calculate the Pearson correlation coefficient between drug administration and nitrate nitrogen conversion in the future t+X period, plot the time variation curve of the Pearson correlation coefficient, and determine the duration of drug effect as P2-P1.
[0032] To better realize the present invention, step S4 further includes the following steps:
[0033] Step S41: Based on the sampling frequency F, derive the characteristics of the initial value, end value, and change value corresponding to the variable;
[0034] Step S42: Filter variables based on variance to obtain continuous variables with variance greater than the threshold thr;
[0035] Step S43: Based on step S2, determine that the carbon source input will affect the nitrate nitrogen conversion in the future P1 period, continuing from P2 to P1+1.
[0036] Step S44: From period t to t-(P2-P1+1), calculate the Pearson correlation coefficient between the variable and the target variable for each period. If the Pearson correlation coefficient for any period reaches the set threshold, the variable is included in the predictor variable.
[0037] To better realize the present invention, further, in step S5, a time series prediction model of influent flow rate and influent nitrogen concentration is constructed; step S6 includes the following steps:
[0038] Step S61: Using the predicted values of influent flow rate and influent nitrogen concentration at different X values, combined with the nitrate nitrogen concentration in the effluent of the target biological treatment tank, calculate the nitrate nitrogen conversion amount in the next t+1 period.
[0039] Step S62: Using the nitrate nitrogen conversion rate in the future period t+X and the predictor variables in step S4, predict the dosage TY_JY in period t+1. t+1 =XGBoost(predictor variables) t Predictor variables t-2 , ..., predictor variables t-(P2-P1+1) Nitrate nitrogen conversion t+1 ).
[0040] To better implement the present invention, further, in step S6, when the number of steps X∈[P1,P2], P2-P1+1 trained prediction models are obtained, and the output results (M1, M...) of the first P2-P1+1 prediction models are... 12 M (PP-P1+1) Integrate and output:
[0041] When the nitrate nitrogen concentration in the biological effluent tank at time t exceeds the upper limit threshold... h Then TY_JY t+1 =max(M1, M 12 M (PP-P1+1) );
[0042] When the nitrate nitrogen concentration in the biochemical effluent tank at time t is less than the lower limit threshold... l Then TY_JY t+1 =min(M1, M 12 M (PP-P1+1) );
[0043] otherwise, ;
[0044] Where: PP is the time point at which the Pearson correlation coefficient reaches its peak between P1 and P2;
[0045] w i As weight;
[0046] M i (t) is the th i The output value of the prediction model.
[0047] This invention is mainly achieved through the following technical solutions:
[0048] A wastewater denitrification dosing system based on machine learning, implemented based on the aforementioned machine learning-based wastewater denitrification dosing method, includes a data acquisition and preprocessing module, a hysteresis effect analysis module, a predictor variable determination module, a prediction module, and a dosing analysis module.
[0049] The prediction module is used to construct a prediction model based on the XGBoost model and shallow trees.
[0050] The drug administration analysis module is used to predict the dosage using a predictive model.
[0051] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned machine learning-based wastewater denitrification dosing method.
[0052] This invention is mainly achieved through the following technical solutions:
[0053] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the aforementioned machine learning-based wastewater denitrification dosing method.
[0054] The beneficial effects of this invention are as follows:
[0055] (1) This invention uses correlation analysis to analyze the correlation between carbon source addition and nitrogen conversion in the future X period, clarify the duration of the drug effect, accurately quantify the lag effect, avoid the problem of mismatch in regulation timing, and solve the error problem caused by neglecting the reaction lag in traditional methods. Based on the model to capture the lag effect and multi-factor coupling analysis, this invention optimizes the amount and timing of carbon source addition, avoids the system load fluctuation caused by excessive carbon source or the nitrogen removal caused by insufficient carbon source, and gradually improves the stability of the original wastewater ecosystem.
[0056] (2) This invention uses a time series prediction model to predict the influent water quality in the future period t+X, and combines it with a nonlinear machine learning model to model the coupling relationship of multiple factors, quantify the impact of key variables such as influent water quality and sludge parameters on the nitrogen conversion in the future period X, and improve the model's adaptability to complex operating conditions. This invention integrates prediction models for different prediction periods, which can flexibly set various dosing strategies; it can continuously iterate and correct historical dosing errors through the model, gradually optimize the water quality control effect, enhance robustness, and ultimately promote the unmanned operation of the sewage treatment process.
[0057] (3) Based on the actual nitrogen effluent concentration requirements of the biological treatment tank, this invention calculates the required nitrate nitrogen conversion amount in the future through a time series prediction model of influent flow rate and influent nitrogen concentration. This invention establishes prediction models for nitrate nitrogen conversion amount and carbon source addition amount for different prediction periods, and further integrates the results of multiple prediction models to set the dosing function, so as to achieve a balance between dosing regulation and nitrogen conversion demand.
[0058] (4) This invention achieves precise control over the relationship between carbon source addition and nitrate nitrogen conversion; this invention guides and corrects the subjectivity of manual dosing through a data-driven model, realizing precise control and unmanned operation of denitrification dosing in wastewater treatment plants. This invention is based on the metabolic laws of denitrifying bacteria, where the carbon source acts as an electron donor to provide energy for nitrate nitrogen reduction. The dynamic correlation between its input and denitrification efficiency is influenced by multiple factors such as influent water quality, sludge concentration, and hydraulic retention time. This invention collects historical operating data from wastewater treatment plant sensors (including carbon source addition, influent nitrogen concentration, flow rate, temperature, sludge parameters, etc.), uses machine learning algorithms to learn the nonlinear mapping relationship between carbon source input and nitrogen conversion, and constructs a quantifiable mathematical model to guide dosing, thereby reducing the cost of manual dosing and correcting subjective human bias. Attached Figure Description
[0059] Figure 1 This is a flowchart of the wastewater denitrification dosing method based on machine learning according to the present invention;
[0060] Figure 2 The time-varying curves of the Pearson correlation coefficient under different influent-to-effluent times I;
[0061] Figure 3 This is a schematic diagram of the prediction model of the present invention. Detailed Implementation
[0062] Example 1
[0063] A machine learning-based wastewater denitrification dosing method, such as Figure 1 As shown, it includes the following steps:
[0064] Step S1: Data acquisition and preprocessing;
[0065] Historical operational data of wastewater treatment plant M is collected using pre-set sensors to obtain variable data affecting the carbon source dosing behavior in the biological treatment tank. Examples include: carbon source dosage (TY_JY), influent flow rate, sludge concentration, and temperature. Variables following the effluent flow from the biological treatment tank should be removed, as these do not affect the carbon source dosing behavior in the biological treatment tank.
[0066] Since the feedback data from each sensor has a different time frequency, a sampling frequency F (e.g., 30 min) is needed to align the data from each sensor in the time series.
[0067] Secondly, this invention focuses on nitrogen removal, therefore a metric for measuring the amount of nitrogen removed is needed—a nitrogen removal rate metric. This metric can be any reasonable chemical expression for nitrogen content, such as total nitrogen, nitrate nitrogen, nitrite nitrogen, etc.
[0068] If the total nitrogen index is used, the denitrification in the biological treatment tank can be described as: Total nitrogen conversion = Total nitrogen in the influent over a period of time - Total nitrogen in the effluent over a period of time;
[0069] If nitrate nitrogen is used as the indicator, denitrification in the biological treatment tank can be described as: nitrate nitrogen conversion = total influent nitrogen over a period of time - nitrate nitrogen content in the effluent over a period of time; the same applies if nitrite nitrogen is used.
[0070] In real-world scenarios, most of the organic nitrogen and ammonia nitrogen entering the biological treatment tank have already been oxidized and decomposed into nitrate nitrogen in the previous aeration tank. Therefore, this invention will subsequently use nitrate nitrogen to describe the amount of nitrogen removed. This invention is not limited to methods for analyzing nitrate nitrogen levels.
[0071] Step S2: Analyze the lag effect of carbon source input on the nitrogen removal index—nitrate nitrogen conversion, determine the time range of the effect duration, and thus determine the time range of historical information to be input into the model.
[0072] Calculate the amount of nitrate nitrogen converted within time F:
[0073] Formula ①: Total nitrogen flowing into the biological treatment tank within time period F (kg):
[0074] m1= ;
[0075] Formula ②: Total nitrogen flowing out of the biochemical tank within time F (kg):
[0076] m2= ;
[0077] Wherein: TN(t) is the total nitrogen concentration in the influent at time t (mg / L);
[0078] L(t) is the influent flow rate (m³ / h) at time t;
[0079] NO_2(t) is the nitrate nitrogen concentration (mg / L) in the effluent of the biological treatment tank at time t;
[0080] NO_2_L(t) is the influent flow rate (m³ / h) of the biological treatment tank at time t;
[0081] k is a constant representing the nitrogen content in the molecular formula. For example, for nitrate nitrogen, k = 14 / (14 + 16 * 3), which corresponds to the molecular formula of NO3.
[0082] Using formulas ① and ②, we can obtain the amount of nitrogen consumed or retained in the entire biological tank during time period F:
[0083] Formula ③: Nitrate nitrogen conversion (F) = Total nitrogen flowing into the biological treatment tank within time F - LEAD (N (kg), I flowing into the biological treatment tank within time F);
[0084] Since it may take a certain amount of time (I) for the water to flow from the influent to the effluent, in order to accurately describe the amount of nitrate nitrogen converted in the current influent, the LEAD future operator is introduced. LEAD(N(kg) flowing out of the biochemical tank within time F), I) represents the amount of nitrate nitrogen converted in the future period I.
[0085] Correlation analysis of pesticide application on nitrate nitrogen conversion in the future period t+X: Calculate the Pearson correlation coefficient between pesticide application and nitrate nitrogen conversion in the future period t+X, such as... Figure 2 As shown, the time variation curve of Pearson correlation coefficient under the time I from influent to effluent is plotted. The focus is on the time point P1 when the Pearson correlation coefficient begins to rise after the dosing and the time point P2 when it regresses to the Pearson correlation coefficient corresponding to P1. That is, the time when the dosing starts to affect the future nitrate nitrogen conversion is P1, and it will last for the time P2-P1.
[0086] Taking the data from wastewater treatment plant M with F=30 minutes as an example, such as Figure 2 As shown, all three curves indicate that the correlation coefficient significantly increases around period 15 (P1) after dosing, peaks at period 43 (PP), and returns to the level of P1 around period 62 (P2), with the effect lasting approximately 48 periods (about 24 hours). When I=0, the absolute values of the slopes of the correlation coefficients from P1 to PP and from PP to P2 are larger, indicating a more sensitive description of the correlation between carbon source input and future nitrate nitrogen conversion. Therefore, based on the data from wastewater treatment plant M, the following two conclusions can be drawn using this method:
[0087] ① The time from water inlet to water outlet in the biological treatment tank is less than 30 minutes; for ease of understanding, 30 minutes is used here, but a more general expression is: (I+1)*F, where 1 itself represents the starting point of the next period;
[0088] ②The drug begins to take effect approximately after the first P1 period (approximately P1*F / 60 hours), and the effect lasts for approximately (P2-P1)*F / 60 hours.
[0089] Step S3: Set the target variable;
[0090] Since the final dosage is determined by the expected value of nitrate nitrogen conversion in the future period t+X, predicting nitrate nitrogen conversion using dosage would require reverse engineering a machine learning model, which is highly complex and yields non-unique solutions. Therefore, the target variable is set as the dosage in period t+1. This simplifies the modeling process and allows for an intuitive understanding of the required dosage in t+1 based on observable data from period t and the expected nitrate nitrogen conversion.
[0091] Step S4: Determine the predictor variables;
[0092] ① Derivation of predictor variables: Based on the sampling frequency F, features such as the initial value, ending value, and change value of the variable can be derived;
[0093] ② Predictor variable selection: Since there are many initial predictor variables, it is necessary to select the predictor variables in order to improve the efficiency of model operation.
[0094] First, variance filtering and variable type selection were adopted, prioritizing continuous variables with variance greater than the threshold thr (a threshold set by the supervisor).
[0095] Then, according to step 2, it can be concluded that carbon source input will affect nitrate nitrogen conversion in the future P1 period, continuing through P2-P1+1 periods. That is, the dosing in the past P2-P1+1 periods may affect the future nitrate nitrogen conversion, and the dosing behavior may be caused by the combined influence of other variables. In order to consider the factors affecting dosing as comprehensively as possible, Pearson correlation coefficients are calculated between each variable and the target variable for periods t to t-(P2-P1+1). As long as the Pearson correlation coefficient in any period reaches the set threshold (e.g., the absolute value is greater than 0.1), it can be included in the predictor variable.
[0096] ③ Preparation of key predictor variables: When the model is applied in practice in the future, it is necessary to input the amount of nitrate nitrogen conversion in the Xth period in the future. Therefore, it is necessary to supplement the amount of nitrate nitrogen conversion in the t+Xth period in the future; where X∈[P1,P2].
[0097] Step S5: Construct a prediction model;
[0098] Based on the target variable from step 3 and the predictor variable from step 4, a shallow CART tree is used as the base learner, and these shallow trees are integrated using an XGBoost model to construct a predictive model. The advantages of this approach are: ① It controls the model's complexity, reducing the risk of overfitting; ② It requires less computational power, has higher model training efficiency, and can learn the non-linear relationships between variables. Figure 3 As shown, the prediction model uses the nitrate nitrogen conversion in the future period t+X and other predictor variables to predict the carbon source input in period t+1:
[0099] Formula ④ TY_JYt+1 =XGBoost(predictor variables) t Predictor variables t-2 Predictor 1, Nitrate Nitrogen Variable t+X ).
[0100] The training steps for the prediction model are as follows:
[0101] (1) Data preparation: The data are arranged in the order of time series and formed into training set, validation set and test set in a ratio of 14:3:3. This method can effectively prevent future data leakage and reflect the predictive ability of the model more objectively.
[0102] (2) Filling out outliers and missing values; This invention uses a tail reduction method to remove outliers and fills in missing values linearly according to the time series order;
[0103] (3) Set the hyperparameter optimization range of the model (e.g., the maximum depth does not exceed 7), and perform hyperparameter optimization;
[0104] (4) Based on the optimization results of hyperparameters, the optimal prediction model is obtained.
[0105] like Figure 3 As shown, regarding the nitrate nitrogen variable t+X Considering that the influent flow rate and influent nitrogen concentration are unknown in the model prediction stage, this invention models the influent flow rate and influent nitrogen concentration, constructing a time series prediction model for influent flow rate and influent nitrogen concentration to predict future water quality. This invention is based on the SARIMA concept and uses the XGBoost model for modeling, as detailed below:
[0106] (1) The unit root test is used to check whether the influent flow rate and influent nitrogen concentration are stationary time series. If they are not stationary time series, they are converted into stationary time series data by using differencing or periodic differencing. The advantage of doing this is that modeling for stationary time series can reduce the learning layer of mean-varying or variance-varying features, thus reducing the learning difficulty of the model and improving the prediction accuracy of the model.
[0107] (2) The variables of stationary time series in periods t-1, t-2...tn are used to predict the value of period t. Here, the model does not directly use the ARMA model for modeling and prediction, but uses the XGBoost model for modeling and prediction. The advantage of doing this is that it can consider the correlation between the time series lagged terms and the predicted values as comprehensively as possible, and can learn nonlinear relationships.
[0108] (3) Recursive prediction, based on the model's recursive formula:
[0109] Formula ⑤ (1-B) s )D (1-L) d yt=XGBoost(diff t-1 diff t-2 , ..., diff t-n );
[0110] It can predict the value at any point in the future;
[0111] Where B is the periodic lag operator,
[0112] s is the period number.
[0113] L is the lag operator.
[0114] D is the period difference order.
[0115] d is the difference order;
[0116] diff t-n For the variable in period tn.
[0117] Step S6: Predict the dosage for period t+1;
[0118] Based on the model training in step S5, when X∈[P1,P2], we can obtain P2-P1+1 trained prediction models. Using the influent flow rate and influent nitrogen concentration time series prediction models at different X values, combined with the nitrate nitrogen concentration in the effluent of the target biological treatment tank, we can calculate the target nitrate nitrogen conversion amount in the future t+X period. Then, according to formula ④, we can predict the dosage in the t+1 period.
[0119] Example 2:
[0120] This embodiment optimizes step S6 based on embodiment 1. Specifically, in step S6, we only need to focus on the first PP-P1+1 prediction models. This is because during this period, the correlation coefficient between drug application and nitrate nitrogen conversion has covered all values from P1 to P2. That is, the candidate results for drug application from P1 to PP already include the candidate results from PP to P2. Moreover, for time series prediction models, predictions of long time series often lead to larger prediction errors. Shortening the number of prediction steps can also improve the model's prediction accuracy. The output results (M1, M...) of these PP-P1+1 models (assuming 29 models) are... 12 M 29 The integration output is performed using the following method:
[0121] When the nitrate nitrogen concentration (NO) in the biological effluent tank at time t exceeds the upper limit threshold... h(For example, 75% of historical levels) This threshold can also be adjusted according to the actual situation. At this time, the nitrate nitrogen concentration is considered too high, and a conservative dosing strategy needs to be adopted, that is, the maximum predicted carbon addition amount from 29 models is selected for dosing; when the nitrate nitrogen concentration in the biological effluent tank at time t is lower than the lower limit threshold. l (For example, at 25% of historical levels), the nitrate nitrogen concentration is considered low, and a pesticide-saving strategy can be adopted, i.e., the minimum predicted carbon addition amount among the 29 models is selected for dosing; in other cases, a balanced dosing strategy is adopted, using a weighted method based on prediction time. The dosing strategy can be expressed as:
[0122] When the nitrate nitrogen concentration in the biological effluent tank at time t exceeds the upper limit threshold... h Then TY_JY t+1 =max(M1, M 12 M 29 );
[0123] When the nitrate nitrogen concentration in the biochemical effluent tank at time t is less than the lower limit threshold... l Then TY_JY t+1 =min(M1, M 12 M 29 );
[0124] otherwise, ;
[0125] Where: M i (t) is the th i The output value of the prediction model;
[0126] w i The weight is calculated using the following formula: ;
[0127] To further illustrate the effectiveness of the method of the present invention, the prediction models in Example 1, Example 2, and the comparative example are evaluated using the following two metrics:
[0128] ①MAPE: Mean Absolute Error, obtained from the results of the validation set during model training;
[0129] ② Compliance rate: The nitrate nitrogen concentration in the effluent of the aerobic tank of the biological treatment tank (needs to be below 5 mg / L) is obtained from the statistical data of different scenarios (weather temperature * rainfall) after model iteration.
[0130] In Example 1, the data source for the time-delay-single model is the model iterated in July 2024. During actual operation, we randomly sampled 30 data points under different temperature and rainfall scenarios.
[0131] In Example 2, the data source for the time-delay-ensemble model is the model generated after the new iteration in 2025. In actual operation, we randomly sampled 30 data points under different temperature-rainfall scenarios.
[0132] The data source for the comparative model without considering time lag - a single model: the model iterated in February 2024. In actual operation, we randomly sampled 30 data points under different temperature and rainfall scenarios.
[0133] As shown in Table 1, compared with traditional methods, Example 1 showed a higher MAPE on the validation set during the model training and fitting phase; and a higher compliance rate in practical application, improving by approximately 10.1%. This is because past wastewater treatment plant dosing was remedial, focusing only on the current nitrate nitrogen concentration in the aerobic tank. This aligns with the modeling approach of traditional methods, but it leads to a decrease in the model's predictive ability. The model of this invention, which considers time lags, can solve this problem. Compared with Example 1, Example 2 showed a lower MAPE on the validation set during the model training and fitting phase (7.2% lower); and a higher compliance rate in practical application (2.4% higher). Both the model's fitting effect and compliance rate were improved, demonstrating the advantages of the model in this invention.
[0134] Table 1 Model Test Information
[0135]
[0136] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention in any way. Any simple modifications or equivalent changes made to the above embodiments based on the technical essence of the present invention shall fall within the protection scope of the present invention.
Claims
1. A wastewater denitrification dosing method based on machine learning, characterized in that, Includes the following steps: Step S1: Data Acquisition and Preprocessing; Collect historical operating data of the wastewater treatment plant to obtain variable data that affect the carbon source dosing behavior in the biological treatment tank; Step S2: Analyze the lagged effect of carbon source input on nitrogen removal index, and analyze the time change curve of Pearson correlation coefficient on nitrate nitrogen conversion in the future t+X period after drug administration, so as to determine the time range of drug effect duration as P2-P1; where P1 is the time point when the initial Pearson correlation coefficient rises after drug administration, and P2 is the time point when the Pearson correlation coefficient returns to the corresponding P1 at the end of drug administration. Step S3: Set the target variable as the dosage TY_JY in period t+1. t+1 ; Step S4: Based on step S1, filter variables and determine predictor variables; Step S5: Based on the target variable in step S3 and the predicted variable in step S4, use a shallow CART tree as the base learner and integrate the shallow tree with an XGBoost model to build a prediction model; Step S6: Using the trained prediction model and based on the nitrogen removal rate in the future t+X period, obtain the pesticide application rate TY_JY in the (t+1)th period. t+1 =XGBoost(predictor variables) t Predictor variables t-2 , ..., predictor variables t-(P2-P1+1) Denitrification index t+X ).
2. The wastewater denitrification dosing method based on machine learning according to claim 1, characterized in that, Step S1 includes the following steps: Step S11: Collect historical operating data of the wastewater treatment plant through preset sensors, and delete variables after the effluent process of the biological treatment tank to obtain variable data that affect the carbon source dosing behavior of the biological treatment tank. Step S12: Align the data from each sensor in the time series.
3. The wastewater denitrification dosing method based on machine learning according to claim 1, characterized in that, In step S2, the denitrification index is any one of the following: total nitrogen index, nitrate nitrogen index, and nitrite nitrogen index.
4. The wastewater denitrification dosing method based on machine learning according to claim 3, characterized in that, In step S2, the denitrification index is the nitrate nitrogen index; step S2 includes the following steps: Step S21: Determine the sampling frequency F, and calculate the nitrate nitrogen conversion amount (F) within time F = the total amount of nitrogen flowing into the biological treatment tank within time F - LEAD(N (kg), I flowing into the biological treatment tank within time F); Where: LEAD(N(kg),I) outflowing into the biochemical pool within time F represents the amount of nitrate nitrogen converted in the future period I; Step S22: Analyze the correlation between drug administration and nitrate nitrogen conversion in the future t+X period, calculate the Pearson correlation coefficient between drug administration and nitrate nitrogen conversion in the future t+X period, plot the time variation curve of the Pearson correlation coefficient, and determine the duration of drug effect as P2-P1.
5. The wastewater denitrification dosing method based on machine learning according to claim 3, characterized in that, Step S4 includes the following steps: Step S41: Based on the sampling frequency F, derive the characteristics of the initial value, end value, and change value corresponding to the variable; Step S42: Filter variables based on variance to obtain continuous variables with variance greater than the threshold thr; Step S43: Based on step S2, determine that the carbon source input will affect the nitrate nitrogen conversion in the future P1 period, continuing from P2 to P1+1. Step S44: From period t to t-(P2-P1+1), calculate the Pearson correlation coefficient between the variable and the target variable for each period. If the Pearson correlation coefficient for any period reaches the set threshold, the variable is included in the predictor variable.
6. The wastewater denitrification dosing method based on machine learning according to claim 1, characterized in that, In step S5, a time series prediction model for influent flow rate and influent nitrogen concentration is constructed; step S6 includes the following steps: Step S61: Using the predicted values of influent flow rate and influent nitrogen concentration at different X values, combined with the nitrate nitrogen concentration in the effluent of the target biological treatment tank, calculate the nitrate nitrogen conversion amount in the next t+1 period. Step S62: Using the nitrate nitrogen conversion rate in the future period t+X and the predictor variables in step S4, predict the dosage TY_JY in period t+1. t+1 =XGBoost(predictor variables) t Predictor variables t-2 , ..., predictor variables t-(P2-P1+1) Nitrate nitrogen conversion t+1 ).
7. The wastewater denitrification dosing method based on machine learning according to claim 6, characterized in that, In step S6, when the number of steps X∈[P1,P2], P2-P1+1 trained prediction models are obtained, and the output results (M1, M...) of the first P2-P1+1 prediction models are... 12 M (PP-P1+1) Integrate and output: When the nitrate nitrogen concentration in the biological effluent tank at time t exceeds the upper limit threshold... h Then TY_JY t+1 =max(M1, M 12 M (PP-P1+1) ); When the nitrate nitrogen concentration in the biochemical effluent tank at time t is less than the lower limit threshold... l Then TY_JY t+1 =min(M1, M 12 M (PP-P1+1) ); otherwise, ; Where: PP is the time point at which the Pearson correlation coefficient reaches its peak between P1 and P2; w i As weight; M i (t) is the th i The output value of the prediction model.
8. A wastewater denitrification dosing system based on machine learning, implemented based on the wastewater denitrification dosing method based on machine learning as described in any one of claims 1-7, characterized in that, It includes a data acquisition and preprocessing module, a lag effect analysis module, a predictor variable determination module, a prediction module, and a drug administration analysis module; The prediction module is used to construct a prediction model based on the XGBoost model and shallow trees. The drug administration analysis module is used to predict the dosage using a predictive model.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by the processor, the program implements a wastewater denitrification dosing method based on any one of claims 1-7.
Citation Information
Patent Citations
Intelligent control method for adjustable area of sewage treatment AOA process
CN119191556A
An intelligent dosing and regulation system for sewage treatment based on fuzzy logic
CN119954236B
AI-based intelligent urban water purification sewage treatment process optimization system and method
CN120335398A
Nitrous nitrogen concentration monitoring method and system based on sensor coupling soft measurement model
CN120254202A
Control method for adding carbon source for sewage treatment
CN120271128A