Water disinfection optimization method driven by machine learning
By constructing a machine learning-driven water disinfection optimization model, the problems of time-consuming and labor-intensive traditional methods and the inability to dynamically control the generation of disinfection byproducts were solved. This model optimizes the disinfection process to reduce the amount of THM4 generated while ensuring the safety of drinking water microorganisms, thereby improving control accuracy and economy.
Patent Information
- Application Number
- CN202512000147.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-29
- Publication Date
- 2026-01-30
AI Technical Summary
Existing technologies are insufficient to effectively control the generation of disinfection byproducts, especially trihalomethanes (THM4), while ensuring the microbial safety of drinking water. Furthermore, traditional detection methods are time-consuming and labor-intensive, and cannot achieve dynamic early warning and optimization.
We constructed a machine learning-driven water disinfection optimization model. By establishing a standard dataset of water quality-DBPs, we developed a prediction model for chlorine consumption and THM4 generation. Combining global search and local refinement strategies, we optimized the chlorine dosage to achieve dual objectives: ensuring that residual chlorine meets the standards and THM4 generation is minimized.
It achieves dynamic optimization of the disinfection process while ensuring disinfection effectiveness, reducing THM4 generation, improving control precision and economy, and enhancing adaptability and safety to water quality fluctuations.
Smart Images

Figure CN121439015A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of drinking water treatment optimization, and in particular to a machine learning driven water disinfection optimization method. BACKGROUND
[0002] Drinking water disinfection effectively controls the spread of water-borne diseases and has become a key link in drinking water treatment and distribution processes. Maintaining disinfectant residual in the drinking water distribution process can effectively inhibit microbial reproduction and provide protection for tap water quality safety. However, the widely used chlorine-containing disinfectant, while inactivating pathogenic microorganisms in water, inevitably reacts with organic matter and halogen ions in drinking water to generate disinfection by-products (DBPs) with a three-terrible effect. Epidemiological studies have shown that long-term exposure to DBPs is associated with adverse pregnancy (miscarriage, fetal heart malformation, etc.), organ damage (liver, kidney, etc.), and even cancer induction (bladder cancer, rectal cancer). Water supply enterprises should minimize the generation of DBPs while ensuring the safety of drinking water microorganisms. Therefore, it is of great significance to optimize the disinfection process to reduce the generation of DBPs while ensuring disinfection efficiency.
[0003] Currently, the monitoring of DBPs mainly relies on regular sampling and gas chromatography detection analysis. This method is time-consuming and labor-intensive, and cannot provide early warning for DBP over-standard due to dynamic changes in water quality. Chinese patent document CN120833862A discloses a drinking water disinfection by-product generation prediction method based on a reaction kinetics model. This method predicts the generation of DBPs in drinking water based on a reaction kinetics model, but it cannot control the generation of DBPs in drinking water. In addition, Chinese patent document CN120911115A discloses a tap water plant disinfection process optimization method and system. The method performs polynomial fitting on the collected post-chlorination unit consumption data, and through a series of mathematical changes, predicts the residual chlorine of finished water, and dynamically adjusts the chlorination accordingly. This method cannot predict and control the generation of DBPs. Machine learning establishes a non-linear relationship between water quality parameters, disinfection process parameters, and DBP generation through a large amount of data. SUMMARY
[0004] The purpose of the present application is to provide a machine learning driven water disinfection optimization method that can precisely determine the chlorine dosage that meets the residual chlorine water quality standards of the distribution system and reduces the generation of THM4, thereby achieving the dual goal of optimizing microbial risk control and DBP generation inhibition.
[0005] To achieve the above purpose, the present application adopts the following technical solutions: A machine learning driven water disinfection optimization method, comprising the following steps: Step S1: Establish a standard dataset of water quality-DBPs: Collect water samples and conduct a simulated disinfection experiment at the end of the pipe network to establish a standard dataset that includes water quality, chlorination amount and key DBPs indicators. Step S2: Chlorine consumption prediction: Develop a chlorine consumption prediction model based on machine learning. Based on the standard dataset established in step S1, train the model to establish a nonlinear relationship between water quality, disinfectant dosage and chlorine consumption in order to predict chlorine consumption. Step S3: THM4 generation prediction: Develop a machine learning-based THM4 generation prediction model to establish a complex relationship between water quality, disinfectant dosage, chlorine consumption and THM4 generation, in order to predict THM4 generation. Step S4: Optimize the chlorination dosage algorithm: Construct a loss function that integrates the dual objectives of "target residual chlorine" and "THM4 generation amount", and set the residual chlorine range and the chlorination dosage retrieval range. Use a strategy that combines global search and local refinement to find the optimal chlorination dosage. Step S5: Algorithm integration: Integrate the above chlorine consumption and THM4 generation prediction model with the optimized chlorination algorithm. Through iterative calculation, output the chlorination amount that can simultaneously meet the target residual chlorine requirements and minimize THM4 generation. Preferably, in step S1, the effluent from the disinfection front-end process of the drinking water plant is used as the water sample.
[0006] Preferably, in step S2, the algorithm for developing a chlorine consumption prediction model based on machine learning includes the RandomForest algorithm, the CatBoost algorithm, the LightGBM algorithm, and the XGBoost algorithm.
[0007] Preferably, in step S2, water quality parameters and chlorination amount are used as inputs to the chlorine consumption prediction model.
[0008] Preferably, in step S3, the machine learning algorithm includes Random Forest algorithm, CatBoost algorithm, LightGBM algorithm, XGBoost algorithm, and model stacking algorithm based on the above tree algorithms.
[0009] Preferably, in step S3, water quality parameters, chlorine consumption, and chlorination amount are used as inputs to the THM4 generation prediction model.
[0010] Preferably, in steps S2 and S3, the coefficient of determination R is used. 2 The root mean square error (RMSE) is used to evaluate model performance, and the coefficient of determination (R²) is used to evaluate model performance. 2 The method for calculating the root mean square error (RMSE) is as follows: ; in, These are actual observed values; These are the model's predicted values. This is the average of the actual observed values. The number of samples; ; in, These are actual observed values; These are the model's predicted values. This represents the number of samples.
[0011] Preferably, in step S4, the loss function is a multi-objective optimization function that integrates the target residual chlorine and THM4 generation, and the formula of the objective optimization function is as follows: ; in, It is the output value of the multi-objective optimization function, for any chlorination amount ( Each of these will yield a numerical value. The purpose of this optimization algorithm is to find a way to make Minimum dosage; This is a predicted value for THM4 formation under the current chlorination level; This is a residual chlorine penalty item. When the residual chlorine does not meet the standard, a penalty value is applied. When the residual chlorine is within the target range, no penalty is applied. As a weighting factor, to ensure disinfection safety and ensure that residual chlorine meets the standards, Set to 300.
[0012] Preferably, in step S4, the residual chlorine range is set to 0-4 mg / L, and the chlorination dosage retrieval range is set to 0-10 mg / L; the optimized chlorination dosage algorithm adopts a strategy combining global search and local refinement, calculates candidate values within the chlorination dosage retrieval range, compares and selects the calculation results based on the loss function of the dual objectives, and uses the finally selected candidate value as the output chlorination dosage.
[0013] Preferably, in step S5, the chlorine consumption prediction model, the THM4 generation prediction model, and the optimized chlorination algorithm are integrated. Water quality parameters are used as model inputs. Through iterative calculation, the chlorination amount that meets the target residual chlorine requirements and minimizes trihalomethane generation is output, and the predicted residual chlorine and THM4 generation under the chlorination amount are obtained simultaneously.
[0014] Compared with the prior art, the present invention has the following beneficial effects: This invention achieves integrated intelligent decision-making for disinfection byproducts, from simple prediction to dynamic optimization control, by constructing a "water quality-chlorine consumption-THM4" prediction model and integrating it with a multi-objective optimization algorithm.
[0015] This invention achieves the core objective of maximally suppressing the generation of toxic disinfection byproducts while strictly ensuring disinfection effectiveness (meeting the residual chlorine standard) by establishing a loss function with the target residual chlorine and THM4 generation as dual optimization objectives and performing global optimization.
[0016] This invention utilizes a predictive model to replace some traditional laboratory testing methods, thereby reducing the frequency of manual THM4 monitoring and excessive disinfectant consumption while ensuring control accuracy, thus improving operational economy.
[0017] This invention employs a data-driven machine learning model to characterize complex nonlinear relationships, achieving strong adaptability to fluctuations in raw water quality and proactively assessing the risks under different chlorination strategies, thereby improving the robustness and safety of control.
[0018] In summary, this invention achieves dynamic prediction and precise control of disinfection byproducts by integrating machine learning and optimization algorithms, thereby ensuring the safety of drinking water microorganisms while intelligently optimizing disinfection effects. Attached Figure Description
[0019] Figure 1 A flowchart illustrating a machine learning-driven water disinfection optimization method provided for an embodiment of the present invention; Figure 2 A comparison chart of chlorine consumption predicted by the CatBoost model and the actual value in a machine learning-driven water disinfection optimization method provided for an embodiment of the present invention; Figure 3 A comparison chart of the predicted THM4 generation amount and the actual value using the XGBoost model in a machine learning-driven water disinfection optimization method provided in an embodiment of the present invention; Figure 4 A comparison chart of THM4 generation predicted by the model and measured values under the chlorination mode in a machine learning-driven water disinfection optimization method provided in an embodiment of the present invention; Figure 5 The residual chlorine in the chlorination mode is measured using an optimized chlorination algorithm provided in an embodiment of the present invention. Detailed Implementation
[0020] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0021] like Figures 1 to 4 As shown in this embodiment, a machine learning-driven water disinfection optimization method is provided, which includes the following steps: Step S1: Establish a standard dataset of water quality-disinfection byproducts (DBPs): Collect water samples and conduct a simulated end-of-pipe disinfection experiment to establish a standard dataset that includes key indicators of water quality, chlorination amount, and DBPs.
[0022] Furthermore, in this embodiment, the effluent from the disinfection front-end process of the drinking water plant is collected as a water sample.
[0023] Step S2: Chlorine consumption prediction: Develop a chlorine consumption prediction model based on machine learning. Based on the standard dataset established in step S1, train the model to establish a nonlinear relationship between water quality, disinfectant dosage and chlorine consumption in order to predict chlorine consumption.
[0024] Furthermore, in this embodiment, the chlorine consumption prediction model algorithm developed based on machine learning includes the RandomForest algorithm, CatBoost algorithm, LightGBM algorithm, and XGBoost algorithm. Water quality parameters and chlorination dosage are used as inputs to the chlorine consumption prediction model.
[0025] Step S3: Trihalomethane (THM4) generation prediction: Develop a machine learning-based THM4 generation prediction model to establish a complex relationship between water quality, disinfectant dosage, chlorine consumption and THM4 generation, in order to predict THM4 generation. Furthermore, in this embodiment, the THM4 generation prediction model algorithm developed based on machine learning includes the RandomForest algorithm, CatBoost algorithm, LightGBM algorithm, XGBoost algorithm, and a model stacking algorithm based on the above tree algorithms. Water quality parameters, chlorine consumption, and chlorination dosage are used as inputs to the THM4 generation prediction model.
[0026] Furthermore, in steps S2 and S3, the coefficient of determination R is used. 2 The root mean square error (RMSE) is used to evaluate model performance, and the coefficient of determination (R²) is used to evaluate model performance. 2 The method for calculating the root mean square error (RMSE) is as follows: ; in, These are actual observed values; These are the model's predicted values. This is the average of the actual observed values. The number of samples; ; in, These are actual observed values; These are the model's predicted values. This represents the number of samples.
[0027] Step S4: Optimize the chlorination dosage algorithm: Construct a loss function that integrates the dual objectives of "target residual chlorine" and "THM4 generation amount", and set the residual chlorine range and the chlorination dosage retrieval range. Use a strategy that combines global search and local refinement to find the optimal chlorination dosage.
[0028] In this embodiment, the target range for residual chlorine is set to 0-4 mg / L (which can be flexibly adjusted according to actual needs), and the range for chlorination dosage is set to 0-10 mg / L (which can be flexibly adjusted according to actual needs). The algorithm for optimizing chlorination dosage adopts a strategy that combines global search and local refinement, and its output value is the chlorination dosage with the minimum value of the multi-objective loss function.
[0029] Furthermore, the loss function employs a multi-objective optimization function that integrates the target residual chlorine and THM4 generation. The target range for residual chlorine is set to 0-4 mg / L, and the range for the chlorination dosage is set to 0-10 mg / L. The algorithm for optimizing the chlorination dosage uses a strategy combining global search and local refinement, and its output value is the chlorination dosage that minimizes the multi-objective loss function value.
[0030] Step S5: Algorithm integration: Integrate the above chlorine consumption and THM4 generation prediction model with the optimized chlorination algorithm. Through iterative calculation, output the chlorination amount that can simultaneously meet the target residual chlorine requirements and minimize THM4 generation. The chlorine consumption prediction model, THM4 generation prediction model, and optimized chlorination algorithm are integrated. Water quality parameters are used as model inputs. Through iterative calculation, the chlorination amount that meets the target residual chlorine requirements and minimizes THM4 generation is output. The predicted residual chlorine and THM4 generation at the chlorination amount are obtained simultaneously.
[0031] The following details the specific models and parameters: Step S1: Collect effluent from the front-end process of disinfection from multiple drinking water plants, test water quality parameters, and then use the simulated end-of-pipe disinfection method to simulate disinfection of the water samples, test residual chlorine content and THM4 generation, and then compile water quality parameters, chlorine dosage, chlorine consumption and THM4 generation to form a water quality-DBPs standard dataset, and this dataset must contain at least 300 water samples; In this embodiment, the method for simulating disinfection at the end of the pipe network can refer to the methods published in Environmental Science & Technology and Water Research.
[0032] Step S2: Divide the above dataset into training and testing sets in a 7:3 ratio. Use the RandomForest, CatBoost, LightGBM, and XGBoost algorithms, with water quality parameters and chlorine dosage as inputs and chlorine consumption as the model prediction target (i.e., output). After training the model, use the coefficient of determination R... 2 The root mean square error (RMSE) is used to evaluate model performance, and the calculation method is as follows: ; in, These are actual observed values; These are the model's predicted values. This is the average of the actual observed values. The number of samples; ; in, These are actual observed values; These are the model's predicted values. This represents the number of samples.
[0033] The CatBoost algorithm has a high R-value. 2 The CatBoost algorithm was chosen as the final chlorine consumption prediction model due to its low RMSE value and high chlorine consumption. The predicted chlorine consumption values are similar to the measured values. Figure 2 As shown.
[0034] Step S3: Divide the dataset from Step S1 into training and testing sets in a 7:3 ratio. Use RandomForest, CatBoost, LightGBM, and XGBoost algorithms, with water quality parameters, chlorine dosage, and chlorine consumption as model inputs, and the THM4 generation target as the model prediction target (i.e., output). After training the model, use R... 2 The model performance is evaluated using RMSE, and the calculation method is as follows: ; in, These are actual observed values; These are the model's predicted values. This is the average of the actual observed values. The number of samples; ; in, These are actual observed values; These are the model's predicted values. This represents the number of samples.
[0035] The XGboost algorithm has high R-value. 2 The XGBoost algorithm was chosen as the final THM4 generation prediction model due to its low RMSE value and high THM4 generation rate. The predicted THM4 generation rate and the measured value are shown below. Figure 3 As shown.
[0036] Step S4: Establish a multi-objective optimization loss function. ; in, It is the output value of the multi-objective optimization function, for any chlorination amount ( Each of these will yield a numerical value. The purpose of this optimization algorithm is to find a way to make Minimum dosage; This is a predicted value for THM4 formation under the current chlorination level; This is a residual chlorine penalty item. When the residual chlorine does not meet the standard, a penalty value is applied. When the residual chlorine is within the target range, no penalty is applied. As a weighting factor, to ensure disinfection safety and ensure that residual chlorine meets the standards, Set to 300.
[0037] The target residual chlorine range is set to 0.5-1 mg / L (which can be adjusted flexibly according to actual needs); the chlorine dosage search range is set to 3-8 mg / L (which can be adjusted flexibly according to actual needs). An algorithm combining global search and local refinement is used to retrieve and optimize the chlorine dosage.
[0038] Step S5: Integrate the chlorine consumption prediction model, the THM4 generation prediction model, and the chlorination dosage optimization algorithm, and determine the chlorination dosage that satisfies the target residual chlorine and minimizes THM4 generation through iterative calculation.
[0039] After inputting the water quality parameters, the optimal chlorination dosage under the current water quality conditions can be obtained through the steps in this embodiment. This ensures that the residual chlorine remains within the target range (0.5-1 mg / L) while effectively controlling the formation of THM4. Figure 4 and Figure 5 The results were validated using external experiments to verify the model's predictive performance.
[0040] In the description of this invention, it should be understood that the terms "center," "longitudinal," "lateral," "length," "width," "thickness," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," "outer," "clockwise," and "counterclockwise," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are only for the convenience of describing this invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on this invention.
[0041] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.
[0042] The above description is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any equivalent substitutions or modifications made by those skilled in the art within the scope of the technology disclosed in the present invention, based on the technical solution and inventive concept of the present invention, should be covered within the scope of protection of the present invention.
Claims
1. A machine learning driven water disinfection optimization method, characterized in that, The method comprises the following steps: Step S1: Establishing a water quality-disinfection by-product standard dataset: collecting water samples, conducting simulated pipe network end disinfection experiments, and establishing a standard dataset containing water quality, chlorine dosage, and disinfection by-product generation amount key indicators; Step S2: Chlorine consumption prediction: developing a machine learning-based chlorine consumption prediction model, training the model based on the standard dataset established in step S1, and establishing a nonlinear relationship between water quality, disinfectant dosage, and chlorine consumption to predict chlorine consumption; Step S3: Trihalomethane generation amount prediction: developing a machine learning-based trihalomethane generation amount prediction model, establishing a complex relationship between water quality, disinfectant dosage, chlorine consumption, and trihalomethane generation amount, and using it to predict trihalomethane generation amount; Step S4: Optimizing the chlorine dosage algorithm: constructing a loss function that combines the "target residual chlorine" and "trihalomethane generation amount" dual objectives, setting the residual chlorine range and chlorine dosage search range, and using a combination of global search and local refinement strategies to find the optimal chlorine dosage; Step S5: Algorithm integration: integrating the above chlorine consumption and trihalomethane generation amount prediction models with the optimized chlorine dosage algorithm, and through iterative calculation, outputting a chlorine dosage that can meet the target residual chlorine requirement and simultaneously calculating the trihalomethane generation amount under this chlorine dosage.
2. The machine learning driven water disinfection optimization method of claim 1, wherein, In step S1, the effluent of the disinfection end process of the drinking water plant is collected as the sample of the water sample.
3. The machine learning driven water disinfection optimization method of claim 1, wherein, In step S2, the machine learning-based chlorine consumption prediction model algorithm includes Random Forest algorithm, CatBoost algorithm, LightGBM algorithm, and XGBoost algorithm.
4. The machine learning driven water disinfection optimization method of claim 1, wherein, In step S2, the water quality parameters and chlorine dosage are used as inputs for the chlorine consumption prediction model.
5. The machine learning driven water disinfection optimization method of claim 1, wherein, In step S3, the machine learning algorithm in step S3 includes Random Forest algorithm, CatBoost algorithm, LightGBM algorithm, XGBoost algorithm, and model stacking algorithm based on the above tree algorithms.
6. The machine learning driven water disinfection optimization method of claim 1, wherein, In step S3, the water quality parameters, chlorine consumption, and chlorine dosage are used as inputs for the trihalomethane generation amount prediction model.
7. The machine learning driven water disinfection optimization method of claim 1, wherein, In the step S2 and step S3, the coefficient of determination R 2 and the root mean square error RMSE are used to evaluate the model performance, the coefficient of determination R 2 and the root mean square error RMSE are calculated as follows: ; wherein, is the actual observed value; is the model predicted value, is the average of the actual observed values, is the number of samples; ; wherein, is the actual observed value; is the model predicted value, is the number of samples.
8. The machine learning driven water disinfection optimization method of claim 1, wherein, In step S4, the loss function uses a multi-objective optimization function that combines the target residual chlorine and trihalomethane generation amount, and the target optimization function formula is as follows: ; wherein, is the output value of the multi-objective optimization function, for any one chlorine dosage ( ), a numerical value will be obtained The purpose of the optimization algorithm is to find the dosage that makes the minimum; is the residual chlorine penalty term, when the residual chlorine does not meet the standard, a penalty value is applied, when the residual chlorine is within the target range, no penalty is applied; is the weight factor, to ensure disinfection safety and ensure that the residual chlorine meets the standard, set 300.
9. The machine learning driven water disinfection optimization method of claim 1, wherein, In step S4, the residual chlorine range is set to 0-4 mg / L, and the chlorine dosage search range is set to 0-10 mg / L; the optimized chlorine dosage algorithm uses a combination of global search and local refinement strategies to calculate the candidate values within the chlorine dosage search range, compares and selects the calculation results based on the dual-objective loss function, and selects the final candidate value as the output chlorine dosage.
10. The machine learning driven water disinfection optimization method of claim 1, wherein, In step S5, the chlorine consumption prediction model, trihalomethane generation amount prediction model, and optimized chlorine dosage algorithm are integrated, with water quality parameters as model inputs, through iterative calculation, outputting a chlorine dosage that meets the target residual chlorine requirement and suppresses trihalomethane generation, and simultaneously obtaining the corresponding residual chlorine and trihalomethane generation amount prediction values under the output chlorine dosage.
Citation Information
Patent Citations
Drinking water disinfection by-product generation prediction method based on reaction kinetic model
CN120833862A
Modification method for saving operation cost of water treatment plant supplied with water from low turbidity water source
CN105399247A
Water treatment method based on ozone disinfection / ultraviolet disinfection / chlorine disinfection
CN109002688A
Long-distance water distribution pipe network secondary chlorination system based on disinfection by-product control
CN119461629A
Chlorine consumption prediction method and system based on BP neural network model, and medium
CN120763900A
