Drinking water treatment has long depended on a difficult balancing act: disinfect water strongly enough to stop dangerous microbes, but not so aggressively that the treatment process creates harmful chemical by-products. A new study introduces an artificial-intelligence system designed to make that balance more precise. Called DISoptimizer, the framework uses machine learning to identify a chlorine dose suited to the chemical composition of a particular water supply. The system is intended to reduce the formation of four common trihalomethanes, or THM₄, while preserving a target level of residual chlorine that serves as an operational safeguard against microbial regrowth and contamination during distribution.
Chlorination remains one of the most widely used and effective methods for protecting public water supplies. When chlorine is added to water, it produces reactive chemical species that damage microbial membranes, proteins and genetic material. This inactivation process can neutralize bacteria, viruses and other pathogens before treated water reaches consumers. Yet chlorine also reacts with naturally occurring organic matter, including material derived from soils, vegetation and decaying organisms. Those reactions can generate disinfection by-products, a broad family of compounds that includes trihalomethanes. Several THMs are regulated or closely monitored because long-term exposure has been associated with potential health risks, including carcinogenic effects.
The central operational problem is that chlorine demand varies substantially from one water source to another and can change over time. Water containing high concentrations of organic carbon may consume chlorine rapidly, reducing the residual available to protect the distribution network. Increasing the initial dose can restore that residual, but it may also accelerate the formation of THM₄ during the hours water spends in storage or transit. Temperature, pH, bromide concentration, organic-matter composition and treatment history can all influence these reactions. A fixed chlorine dose therefore represents a compromise: it may be excessive under some conditions and insufficient under others. DISoptimizer was developed to replace that generalized approach with a water-quality-adaptive dosing strategy.
The framework uses machine learning models trained on experimental data collected across diverse water-quality conditions. Rather than predicting only the concentration of chemical by-products after treatment, the system is designed to make an operational recommendation. It estimates two outcomes over a 24-hour period: the residual chlorine concentration remaining in the water and the amount of THM₄ formed by the point of delivery. The 24-hour horizon is important because water chemistry continues to evolve after chlorine is added. A dose that appears acceptable immediately after treatment may produce too little residual protection or too much THM₄ by the time water reaches consumers.
DISoptimizer converts those predictions into an optimization problem. The system evaluates possible chlorine doses and identifies the option that best meets a user-defined residual chlorine target while minimizing predicted THM₄ formation. Maintaining a residual is not presented as a direct measurement of microbial safety, but as an operational surrogate for disinfection reliability. A persistent residual can indicate that disinfectant remains available to control microbial regrowth within pipes, tanks and other parts of the distribution system. At the same time, the optimizer recognizes that a higher residual is not automatically preferable if it substantially increases the chemical conditions that promote THM formation.
One of the framework’s key features is a weighting factor that allows utilities to define how strongly the optimization should prioritize residual chlorine margins relative to THM₄ reduction. In practice, this means that the system can be adjusted to reflect local conditions and management priorities. A utility facing elevated microbial risk or a vulnerable distribution network might choose a more conservative residual target. Another system, operating with different source-water chemistry and strong microbial controls, might place greater emphasis on limiting by-products. The weighting factor does not eliminate the underlying trade-off; instead, it makes that trade-off explicit and adjustable rather than leaving it hidden inside a fixed dosing rule.
According to the study, computational simulations and external validation showed that DISoptimizer reduced THM₄ formation by approximately 5 to 35 percent compared with empirical fixed-dosing strategies. The reported reductions varied with water quality and operating conditions, but the framework consistently maintained the specified residual chlorine margins. This result is significant because reducing chlorine use indiscriminately could undermine protection against microbial contamination. The proposed approach instead seeks to reduce unnecessary dosing while preserving the residual considered necessary by the operator. Its performance depends on the quality and representativeness of the training data, as well as on the accuracy of measurements describing the water entering the treatment process.
The machine learning approach also illustrates a broader change in the role of artificial intelligence in environmental engineering. Earlier predictive models often focused on estimating contaminant concentrations or forecasting treatment outcomes. DISoptimizer moves one step further by connecting prediction to a controllable decision: how much chlorine should be added under a particular set of conditions. Such systems could eventually draw on continuously updated measurements of parameters such as organic carbon, turbidity, pH, temperature and bromide. With suitable monitoring and validation, a treatment plant could adjust its dosing recommendations as source-water chemistry changes after rainfall, seasonal turnover or shifts in upstream pollution.
The framework does not remove the need for laboratory testing, regulatory oversight or engineering judgment. Machine learning models can fail when they encounter conditions outside the range of their training data, including unusual organic compounds, sudden contamination events or changes in treatment configuration. Residual chlorine is also an imperfect indicator of overall microbial safety, since pathogen survival depends on contact time, temperature, pH, hydraulics and the specific organisms present. For these reasons, an optimization tool would need to operate within established safety limits and be supported by independent water-quality surveillance. Even so, the study suggests that adaptive dosing could give utilities a more refined way to manage two competing risks rather than relying on a single chlorine dose for every situation.
By targeting the point of delivery rather than only the treatment plant outlet, DISoptimizer addresses a practical weakness in conventional dosing strategies. Drinking water may travel for hours through a complex network before it is consumed, and chemical reactions continue throughout that journey. Predicting both residual chlorine and THM₄ after 24 hours allows the framework to account for this delayed chemistry. The researchers describe the system as a step toward proactive disinfection management, in which treatment decisions are made using expected downstream conditions instead of immediate measurements alone. If validated across more regions and integrated with real-time plant operations, this approach could help reduce exposure to disinfection by-products without sacrificing one of the most effective defenses against waterborne disease.
Subject of Research: Machine learning-driven optimization of chlorine dosing in drinking water treatment to maintain residual chlorine targets while reducing trihalomethane formation.
Article Title: A machine learning-driven framework for optimizing disinfection in drinking water treatment.
Article References: Wang, P., Wu, Z., Yang, Y. et al. A machine learning-driven framework for optimizing disinfection in drinking water treatment. Nat Water (2026). https://doi.org/10.1038/s44221-026-00702-0
Image Credits: AI Generated
DOI: https://doi.org/10.1038/s44221-026-00702-0
Keywords: Drinking water disinfection, chlorine dosing, machine learning, artificial intelligence, trihalomethanes, disinfection by-products, residual chlorine, water treatment optimization, drinking water safety.

