Abstract
SWANP-AI (Smart Water Network Partitioning with Artificial Intelligence) is a web application with AI natively embedded in its core engines for automated Water Network Partitioning (WNP) of water distribution networks. It is presented as the web-based evolution of SWANP 4.0, whose computational routines have already been tested in operational and research applications. The paper clarifies the full development chain of the platform, from graph-based grouping of candidate District Metered Areas/pressure management Areas (DMA/PMA) to multi-objective boundary pipe optimization and operational decision support. The methodology combines spectral and multilevel k-way partitioning for district generation, NSGA-II for cost–resilience boundary selection, hydraulic simulation through EPANET/WNTR, and AI-supported modules for solution interpretation, sensor placement, natural language editing, and Bayesian leak localization. The application to a real water distribution network shows that SWANP-AI can transform natural language engineering requests into formal optimization tasks, identify hydraulically meaningful candidate interventions, and select balanced solutions through Utopia point analysis, thus reducing manual trial-and-error in DMA/PMA design. The main contribution is a structural generative AI workflow that supports engineers not only in analyzing a network as it is, but also in designing how the network should be partitioned and operated.
1. Introduction
The digital transformation of the water sector (“Water 4.0”) is pushing utilities beyond static hydraulic modeling toward workflows that are faster, scalable, and increasingly data-informed. In this context, Water Network Partitioning (WNP)—the design of District Metered Areas (DMAs) and their evolution into pressure management Areas (PMAs)—remains one of the most effective strategies to reduce real losses, improve pressure control, and support targeted monitoring and maintenance actions [1,2,3]. Yet, despite the maturity of the underlying engineering concept, the software ecosystem that supports WNP is still fragmented and often forces practitioners into time-consuming, manual trial-and-error procedures.
A critical review of current solutions shows a polarized landscape. Commercial desktop modeling suites provide robust simulation environments and design utilities [4], but their “intelligence” typically targets parameter-level optimization and what-if planning.
Conversely, cloud digital twins and operational platforms increasingly adopt machine learning to process telemetry streams, excelling at demand forecasting and anomaly detection. However, this intelligence is predominantly operational: it monitors the network “as it is” and supports event detection after instrumentation is installed, but it typically does not generate the partitioning layout or propose how the network “should be” structured for WNP.
Although algorithmic methods for DMA/PMA generation are available in the scientific literature [5,6], their practical adoption remains limited because they require graph theory, optimization, and hydraulic modeling expertise that is not always part of the daily background of water utility engineers. In practice, sectorization is still often developed through GIS-based editing, hydraulic trial-and-error, and heuristic decisions, with limited support for systematic exploration of cost–resilience alternatives.
Therefore—to the best of our knowledge—no widely adopted commercial solution currently offers an AI-powered, web-based environment where AI guides the user in the application of state-of-the-art methods for “structural” (topology-changing) generative WNP design.
This paper presents SWANP-AI (Smart Water Network Partitioning with Artificial Intelligence), a web-native platform that embeds AI in the core WNP workflow and introduces what we define as structural generative AI. In this context, “generative” does not refer to the production of text or images, but to the automatic generation of alternative network structures: software proposes district shapes, boundary devices, pressure management layouts, and supporting operational actions.
Beyond partitioning, SWANP-AI integrates complementary modules that connect design to operations, including topology- and sensitivity-driven sensor placement and probabilistic leak localization through Bayesian inverse analysis using pressure residuals and precomputed sensitivity matrices. The platform also supports visual analytics (radar and Pareto views) and an AI-assisted decision layer that helps engineers interpret trade-offs and rapidly select actionable solutions. SWANP-AI inherits from the previously released SWANP 4.0 [7,8,9] most of the already tested computational routines, extending them through a fully web-based architecture and deeper integration of AI modules.
The remainder of the paper is organized as follows: Section 2 outlines the system architecture; Section 3 describes the methodological workflow for clustering, boundary optimization, PMA regulation, sensor placement, and probabilistic leak localization; Section 4 reports the decision support metrics and visual analytics; Section 5 presents the real network application and the preliminary results produced by the AI agent; finally, Section 6 summarizes the main conclusions and future developments.
2. System Architecture
SWANP-AI adopts a microservices, full-stack architecture. The guiding principle is a clean separation between visualization, computation, and optimization/AI, enabling scalability and maintainability.
The resulting architecture is summarized in Table 1.
Table 1.
Main SWANP-AI architecture layers and their role in the workflow.
The client side is implemented as a Single Page Application (SPA) built with Svelte, selected for its compilation-based approach and efficient DOM updates, which maintains high rendering performance up to networks with tens of thousands of elements.
Geospatial visualization is provided through an integrated OpenLayers GIS engine supporting multiple vector layers (pipes, nodes, sensors) and dynamic styling driven by the hydraulic state (e.g., pipes colored by velocity, nodes by pressure). A centralized state store synchronizes the digital twin across modules, so edits performed during clustering or partitioning are immediately reflected in the hydraulics views and dashboards.
The back end is developed in Python (3.10+) and exposed via FastAPI as a high-performance REST API. Hydraulic computation wraps EPANET 2.2 and WNTR [4,10], while graph processing relies on NetworkX and iGraph for spectral decomposition and topological metrics (e.g., betweenness and shortest paths). Long-running simulations and optimizations are executed as asynchronous tasks to avoid blocking the interface.
Table 2 reports the main workflow outputs generated by the AI-supported modules and discussed in Section 5.
Table 2.
Workflow outputs and preliminary evidence reported in Section 5.
To preserve interactivity during intensive runs (e.g., evolutionary optimization), SWANP-AI streams progress updates to the browser through WebSockets, enabling continuous feedback (e.g., completed generations) and an experience closer to an interactive solver than a black-box batch execution.
The AI stack is organized into three complementary layers:
- Evolutionary computation (dividing): a multi-objective genetic optimizer (NSGA-II) [11] implemented with PyMoo. Candidate solutions are encoded as binary chromosomes over boundary pipes; the search explores the cost–performance trade-off by minimizing implementation cost (e.g., number of meters) while maximizing hydraulic resilience, with custom operators that preserve connectivity constraints.
- The platform includes a background pervasive learning mechanism that stores successful executions (e.g., converged clustering or completed dividing runs), filters out failed runs, and gradually aggregates a knowledge base of robust parameter ranges, such as mutation rates, population sizes, and clustering settings, for different network topologies. This mechanism supports self-tuning defaults over time and is complemented by the inclusion, among the AI training sources, of research papers documenting the proprietary computational methods.
- Probabilistic reasoning (leak localization): a Bayesian inverse analysis module updates prior leak probabilities into posterior estimates using pressure residuals and a precomputed Jacobian-based sensitivity matrix linking candidate leaks to sensor measurements.
SWANP-AI implements an end-to-end AI-driven workflow for Water Network Partitioning (WNP). The workflow is organized into five linked stages: (i) data import and graph construction from the hydraulic model; (ii) grouping, which discovers candidate district shapes; (iii) dividing, which selects boundary devices; (iv) operational simulation for PMA regulation, sensor placement, and leak localization; and (v) AI-assisted interpretation and reporting.
3. Methodology
SWANP-AI implements an end-to-end AI-driven workflow for Water Network Partitioning (WNP), structured into: (i) grouping (district shape discovery), (ii) dividing (optimal boundary selection), and a set of operational extensions (PMA regulation, sensor placement, and probabilistic leak localization).
In the grouping phase SWANP-AI treats the WDN as a graph and applies unsupervised learning/graph partitioning to identify coherent districts (candidate DMAs) that are not evident from purely geometric inspection. The platform provides multiple strategies to match different network sizes and topologies.
SWANP-AI computes the graph Laplacian and performs eigen decomposition to map nodes into a spectral embedding where cluster structure becomes explicit [12]; then k-means is applied to minimize a cut criterion (ratio cut), revealing “hydraulic communities” and bottlenecks.
For large networks (e.g., >5000 nodes), spectral decomposition can be computationally expensive. SWANP-AI therefore integrates GPMetis/METIS, using a multilevel scheme (coarsening → partitioning → uncoarsening with refinement) to obtain balanced partitions with near-linear complexity, suitable when district size balancing is a key requirement.
For smaller or strongly modular networks, SWANP-AI can apply an edge betweenness community approach (Girvan–Newman) [13], iteratively removing the most “bridge-like” pipes (highest edge betweenness) to uncover hierarchical community structure.
A distinctive aspect of SWANP-AI is the possibility to weight similarity/cuts using hydraulic/asset attributes (e.g., discouraging cuts on trunk mains via diameter weighting) and—importantly—an elevation-balanced strategy that clusters nodes with similar geodetic heads, minimizing intra-district elevation variance. This supports pressure management because “hydraulically flat” districts allow a single inlet PRV to reduce pressure more uniformly without penalizing high-elevation users.
Once district “shapes” are defined, SWANP-AI solves the dividing problem: determining which boundary pipes should host isolation valves, and which should be equipped with flow meters. This is formulated as an NP-hard combinatorial optimization and solved through a multi-objective evolutionary engine based on NSGA-II.
Candidate solutions are encoded as a binary chromosome, where each gene represents a candidate boundary pipe (e.g., “closed valve” vs. “open/metered boundary”). The algorithm evolves a population across generations using customized crossover/mutation operators that preserve connectivity (avoiding isolated “islands”).
During evolution, SWANP-AI enforces a minimum pressure constraint at critical nodes (e.g., service floor around 20 m) by applying strong penalties to infeasible candidates. The optimization simultaneously targets economic efficiency (e.g., minimizing the number of meters or total CAPEX, reflecting the cost difference between valves and electromagnetic meters) and hydraulic resilience maximization, producing a Pareto front that exposes the cost–safety trade-off for engineering decision-making.
Real networks may contain bottlenecks that make strict feasibility unattainable. SWANP-AI includes a Relaxed Mode: if no solution satisfies the strict pressure floor, the solver automatically relaxes the constraint to return the “least bad” partitioning. This prevents dead-end outcomes and helps identify where reinforcement is needed before sectorization.
For contamination detection (accidental or intentional), SWANP-AI adopts a topological defense strategy: it computes betweenness centrality to identify hydraulic crossroads (nodes that connect communities). Placing quality sensors at these vertices increases interception likelihood and reduces global time-to-detection under limited sensor budgets.
For water loss detection, SWANP-AI complements deterministic simulation with probabilistic AI. A Bayesian estimator updates a prior leak probability distribution (e.g., informed by asset attributes such as age/material) to a posterior distribution using measured pressure residuals. The update is driven by a precomputed Jacobian-based sensitivity matrix that maps a unit leak at each candidate node to pressure variations at sensors, enabling probabilistic ranking of likely leak locations.
4. Decision Support, Metrics, and Visual Analytics
SWANP-AI is designed to support decisions by translating algorithmic outputs into interpretable documentation, interactive dashboards, and AI-assisted recommendations. This section clarifies the solver feedback loop, the KPI set used to evaluate solutions, and the visual/AI tools used to guide the final selection.
Unlike traditional “run and wait” approaches, SWANP-AI streams the progress of evolutionary optimization to the browser in real time, including generation number, current cost, hydraulic resilience values, and feasibility status. This enables the engineer to pause, adjust weights or constraints, and resume the search. In parallel, the hydraulic module performs repeated feasibility checks through demand-driven and pressure-driven analyses, so that infeasible solutions are filtered or penalized during the design process rather than only after optimization. A key strength of SWANP-AI is the use of a structured set of indices to quantify both (i) the structural quality of the clustering outcome (grouping) and (ii) the hydraulic/economic quality of boundary selection (dividing).
SWANP-AI evaluates candidate district layouts through: modularity (strength of community separation), silhouette coefficient (cluster separability), balance index (uniformity of district size by demand/length/nodes), algebraic connectivity (robustness against disconnection), and hydraulic homogeneity (elevation variance within a district, linked to pressure management potential).
For each boundary configuration, SWANP-AI computes: the Todini index (surplus power/reserve to handle failures) [14], an adapted resilience index for partitioned networks that penalizes excessive head losses across boundary meters, and economic efficiency expressed as total CAPEX from unit costs of flow meters and boundary valves.
To enable rapid benchmarking across alternative algorithms and solutions, SWANP-AI provides an “Analyst View” that goes beyond tables.
- Radar (Spider) Charts: SWANP-AI standardizes five key metrics—modularity, silhouette, balance, resilience, cost—and maps them onto a single radial plot.
- Pareto Bubble Charts: A dynamic scatter plot showing the trade-off between cost (x-axis) and resilience (y-axis); bubble size represents modularity.
Beyond visualization, SWANP-AI includes an AI Agent that acts as an “active consultant” in two key tasks:
- Best Solution Finder (Utopia point selection): The agent scans the full Pareto front, normalizes objectives (cost vs. resilience), computes the Euclidean distance to the “Utopia point” (minimum cost, maximum resilience), and recommends the best mathematical compromise.
- Optimal K (Elbow Method): The system performs a sensitivity sweep over the number of clusters and uses a Laplacian eigenvalue scree plot to identify the elbow point—i.e., the number of districts that captures maximum structural information with minimum complexity.
5. Case Study and Preliminary Application Results
To demonstrate the practical value of SWANP-AI, the workflow was applied to the Parete (Italy) water distribution network. The application was structured as an operational test of the AI-supported workflow rather than as a generic hydraulic report. Three objectives were considered: (i) to select a suitable clustering strategy for the network topology; (ii) to generate cost–resilience alternatives for boundary device placement; and (iii) to test the agentic functions for natural language editing, pressure improvement, and probabilistic support to leak localization.
During the workflow, the user interacted with the model through the LLM interface for both explainability and rapid editing. When asked “Why did you close pipe P-45?”, the assistant provided an engineering-level justification based on the low flow of the link, its redundant topological role, the gain in modularity, and the absence of violation of the minimum pressure constraint at critical nodes.
The same interface supported linguistic network editing. For example, after the command “Convert node N-11 to a PRV set to 2.5 bar”, SWANP-AI parsed the request, updated the project structure, and re-ran the simulation in approximately 300 ms. This result shows how the AI interface reduces friction in iterative design by replacing a sequence of manual GIS and model editing operations with a validated engineering command.
A further test of the agentic module is reported in Figure 1. The user submitted the request: “Can you improve the pressure in node 46, increasing it by 5 m, changing some pipes? Answer in English.” SWANP-AI translated this natural language request into a formal multi-objective optimization problem.
Figure 1.
An example of using SWANP-AI agent to improve pressure in a network node.
First, AI performed upstream topological tracing to identify the candidate pipes most responsible for the local head losses. It then initialized an NSGA-II genetic algorithm to evaluate the trade-off between pressure increase and pipe upgrade cost. To avoid oversized and economically unrealistic interventions, the autonomous agent applied a post-processing selection based on the Utopia point method.
The Pareto-optimal solutions were normalized, and the Euclidean distance was penalized more strongly along the cost axis than along the hydraulic performance axis. This allowed the AI to filter out extreme solutions and select a balanced configuration that achieved a realistic piezometric improvement while respecting economic and engineering constraints.
The preliminary application therefore confirms three practical outcomes: software converts expert WNP algorithms into an accessible guided workflow; it produces explicit cost–resilience alternatives instead of a single opaque solution; and it enables engineers to interrogate, edit, and improve the model through natural language commands while maintaining hydraulic feasibility checks in the background.
6. Conclusions
This paper presented SWANP-AI, a web-native platform that embeds AI as a core engine for generative Water Network Partitioning, advancing beyond manual sectorization and beyond telemetry-only analytics. The most important finding is that SWANP-AI can translate natural language engineering requests into formal, hydraulically constrained optimization tasks and can then select balanced intervention scenarios through Pareto and Utopia point analysis. Building on the tested SWANP 4.0 lineage, the platform integrates graph-based unsupervised grouping, multi-objective evolutionary dividing, hydraulic simulation, PMA-oriented pressure regulation, sensor placement, Bayesian leak localization, visual analytics, and natural language interaction. The Parete application shows that the workflow reduces manual trial-and-error, makes the cost–resilience trade-off explicit and reproducible, and keeps the engineer in control of final validation. Future work will address broader validation on large-scale networks, tighter integration with real-time SCADA streams, quantitative benchmarking against commercial modeling workflows, and extended explainability of AI recommendations to support deployment in water utility environments.
For a successful application, SWANP-AI requires a connected and hydraulically consistent WDN model, including node identifiers and coordinates, pipe connectivity, pipe lengths and diameters, demand allocation or representative demand patterns, reservoir/tank or source heads, and at least a basic set of valve, pump, and boundary conditions. If pressure management or leak localization modules are used, additional information is required on node elevations, roughness coefficients, existing meters and sensors, pressure observations, and asset attributes such as pipe age, material, or failure history.
The current version is intended to support engineering decision-making rather than to replace hydraulic judgment. Its performance depends on the quality and completeness of the input hydraulic model, on the reliability of demand and pressure data, and on the correctness of the network topology. Very large networks may require simplified scenarios or longer optimization times, while sparse monitoring data can reduce the resolution of Bayesian leak localization. In addition, the solutions proposed by the AI agent must be checked against field constraints, operational rules, and utility-specific implementation costs before final adoption.
Author Contributions
Conceptualization, A.D.N., G.F.S. and M.I.; methodology, A.D.N., E.C., M.I., L.P. and G.F.S.; software, A.D.N. and G.F.S.; validation, A.D.M., M.I., L.P. and G.F.S.; supervision, A.D.N.; funding acquisition, A.D.N. All authors have read and agreed to the published version of the manuscript.
Funding
This research received no external funding.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
Data supporting the reported software workflow are available from the corresponding author upon reasonable request, subject to utility and operational data restrictions.
Acknowledgments
The authors acknowledge the academic MedHydro srl of the University of Campania Luigi Vanvitelli and the Water Utility GORI spa to support the development of SWANP©.
Conflicts of Interest
The authors declare no conflicts of interest. MedHydro srl has no commercial conflict of interest with this work.
References
- Di Nardo, A.; Di Natale, M.; Gargano, R.; Giudicianni, C.; Greco, R.; Santonastaso, G. Performance of partitioned water distribution networks under spatial-temporal variability of water demand. Environ. Model. Softw. 2018, 101, 128–136. [Google Scholar] [CrossRef] [Scilit]
- Savić, D.; Ferrari, G. Design and Performance of District Metering Areas in Water Distribution Systems. Procedia Eng. 2014, 89, 1136–1143. [Google Scholar] [CrossRef] [Scilit]
- Palma, L.; Hatam, F.; Di Nardo, A.; Prévost, M. Contaminations in water distribution systems: A critical review of detection and response methods. AQUA-Water Infrastruct. Ecosyst. Soc. 2024, 73, 1285–1302. [Google Scholar] [CrossRef] [Scilit]
- Rossman, L.A. EPANET 2. User’s Manual; National Risk Management Research Laboratory, Office of Research and Development, United States Environmental Protection Agency (USEPA): Cincinnati, OH, USA, 2000; p. 200.
- Di Nardo, A.; Di Natale, M.; Giudicianni, C.; Greco, R.; Santonastaso, G.F. Weighted spectral clustering for water distribution network partitioning. Appl. Netw. Sci. 2017, 2, 19. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Ferrari, G.; Savic, D.; Becciu, G. Graph-Theoretic Approach and Sound Engineering Principles for Design of District Metered Areas. J. Water Resour. Plan. Manag. 2014, 140, 04014036. [Google Scholar] [CrossRef] [Scilit]
- Di Nardo, A.; Di Natale, M.; Santonastaso, G.F.; Venticinque, S. An Automated Tool for Smart Water Network Partitioning. Water Resour. Manag. 2013, 27, 4493–4508. [Google Scholar] [CrossRef] [Scilit]
- Palma, L.; Creaco, E.; Iervolino, M.; Leopardi, A.; Santonastaso, G.F.; Di Nardo, A. SWANP: A comprehensive tool for optimized water network clustering. In Proceedings of the World Environmental & Water Resources Congress, Anchorage, Alaska, 21 May 2025. [Google Scholar]
- Di Nardo, A.; Di Natale, M.; Di Mauro, A.; Martínez Díaz, E.; Blázquez Garcia, J.A.; Santonastaso, G.F.; Tuccinardi, F.P. An advanced software to design automatically permanent partitioning of a water distribution network. Urban Water J. 2020, 17, 259–265. [Google Scholar] [CrossRef] [Scilit]
- Klise, K.; Murray, R.; Haxton, T. An overview of the water network tool for resilience (WNTR). In Proceedings of the 1st International WDSA/CCWI 2018 Joint Conference, Kingston, ON, Canada, 23–25 July 2018. [Google Scholar]
- Deb, K.; Pratap, A.; Agarwal, S.; Meyarivan, T. A fast and elitist multiobjective genetic algorithm: NSGA-II. IEEE Trans. Evol. Comput. 2002, 6, 182–197. [Google Scholar] [CrossRef] [Scilit]
- Di Nardo, A.; Giudicianni, C.; Greco, R.; Herrera, M.; Santonastaso, G.F. Applications of Graph Spectral Techniques to Water Distribution Network Management. Water 2018, 10, 45. [Google Scholar] [CrossRef] [Scilit]
- Girvan, M.; Newman, M.E.J. Community structure in social and biological networks. Proc. Natl. Acad. Sci. USA 2002, 99, 7821–7826. [Google Scholar] [CrossRef] [Scilit] [PubMed]
- Todini, E. Looped water distribution networks design using a resilience index based heuristic approach. Urban Water 2000, 2, 115–122. [Google Scholar] [CrossRef] [Scilit]
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2026 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license.
