# A hybrid leak detection framework using variational autoencoder surrogates

Prasanna Mohan Doss, David B Steffelbauer, Olivier Piller, Marius Møller

Rokstad, Franz Tscheikner-Gratl

► To cite this version:

Prasanna Mohan Doss, David B Steffelbauer, Olivier Piller, Marius Møller Rokstad, Franz Tscheikner-Gratl. A hybrid leak detection framework using variational autoencoder surrogates. WaterLoss2022, IWA Water Loss Specialist Group, Jun 2022, Prague, Czech Republic. hal-03749707

HAL Id: hal-03749707

https://hal.inrae.fr/hal-03749707

Submitted on 11 Aug 2022

HAL is a multi-disciplinary open access
archive for the deposit and dissemination of sci-
entific research documents, whether they are pub-
lished or not. The documents may come from
teaching and research institutions in France or
abroad, or from public or private research centers.

L'archive ouverte pluridisciplinaire HAL, est
destinée au dépôt et à la diffusion de documents
scientifiques de niveau recherche, publiés ou non,
émanant des établissements d'enseignement et de
recherche français ou étrangers, des laboratoires
publics ou privés.

<figure><img src="image_1.png" /></figure>

Distributed under a Creative Commons Attribution 4.0 International License
# A hybrid leak detection framework using variational autoencoder surrogates

P. Mohan Doss<fnref n="1" />, D. Steffelbauer<fnref n="1" />, O. Piller<fnref n="2" />, M. M. Rokstad<fnref n="1" />, F. Tscheikner-Gratl<fnref n="1" />*

## Brief abstract summary: (Limit – Max 100 words)

Traditionally, model-based approaches are widely used for leak detection in Water Distribution Networks (WDNs). However, these methods are computationally expensive for larger networks and are highly dependent on the model accuracy. In this work, we propose a hybrid modelling framework for leak detection, wherein, a surrogate model using a variational autoencoder (VAE) neural network is trained with a calibrated hydraulic model. The statistical measures on the performance of VAEs are then used for leak detection. The efficacy of the proposed framework is tested on a theoretical WDN and a real-world WDN using data from steady-state hydraulic simulations and sensor measurements.

**Keywords:** Water distribution networks, Generative models, Leak detection

<footnote n="1">¹Department of Civil and Environmental Engineering, NTNU, S.P. Andersens Veg 5, 7031 Trondheim, Norway</footnote>

<footnote n="2">²INRAE, ETBX Research Unit, Aqua Department, F-33612 Cestas, France</footnote>

<footnote>*Corresponding author e-mail: prasanna.m.doss@ntnu.no</footnote>
# A hybrid leak detection framework using variational autoencoder surrogates

P. Mohan Doss<fnref n="1" />, D. Steffelbauer<fnref n="1" />, O. Piller<fnref n="2" />, M. M. Rokstad<fnref n="1" />, F. Tscheikner-Gratl<fnref n="1" />*

Leak detection in Water Distribution Networks (WDN) has been researched extensively in recent decades due to its significance in the sustainable management of water resources. In addition to the amount of water lost during transportation to the consumers via pipe networks, leaky WDNs are also a cause for energy wastage and contaminant intrusion. The leak detection and localization techniques can be broadly classified into three categories: (i) Conventional methods involving direct site inspection using acoustic logging, step testing, and ground penetrating radar (Puust et al. 2010). These methods are time-consuming, expensive, and may not be suitable for all types of networks. (ii) Model-based methods are based on response to changes in the state of hydraulic behavior of a network due to the presence of leak(s). This class of approach is essentially an inverse problem, wherein, the network parameters such as pipe roughness, diameters, and demands are known, and the location of the leak(s) and their flowrates are estimated by solving an optimization problem. Despite being one of the widely used techniques, the optimization problem becomes complex and computationally expensive for applications in larger networks. (iii) Data-driven methods are gaining traction in recent years due to the advent of low-cost measuring devices and efficient computational techniques. Most of the existing studies are limited to small-scale networks and require a large number of sensors to be installed in real-world networks. We propose a hybrid modelling framework in which a deep neural network in form of a variational autoencoder is trained on a calibrated hydraulic model for data generation and fault detection – allowing for decoupling hydraulics in determining solutions to the leak detection problem. Model calibration is done in two stages – demand calibration followed by pipe roughness calibration. Next, a surrogate model is developed from the calibrated model using variational autoencoder for anomaly detection. The steps followed in the proposed framework are described in more detail in the following sections.

## MODEL CALIBRATION

The accuracy of a hydraulic model determines the validity of its intended use in network analysis. The calibration of demand and pipe roughness parameters to approximately match the observed and computed pressure or flow rates are critical in improving the model accuracy (Ormsbee and Lingireddy 1997). Data from Automatic Meter Reading (AMR) meters are utilized for demand calibration by identifying and generating demand patterns for unmeasured locations as described in Steffelbauer et al. (2021) & Steffelbauer et al. (2020).

Subsequently, pipe roughness calibration is formulated as a constrained weighted least squares problem as described in Piller (2019). The pipes are grouped based on prior knowledge and the roughness parameter for each group of pipes are determined from solving an optimization problem.

## SURROGATE MODEL FROM DEEP NEURAL NETWORKS

The calibrated hydraulic model is used to build a surrogate model based on variational autoencoders to circumvent the problem of high computational costs that stem from the inverse leak detection problem, especially for larger networks. Benefits and limitations of such an approach are then tested on two case study networks – (i) a part of the L-Town theoretical network model from the BattLeDIM competition (Vrachimis et al. 2020) and (ii) a real-world network in Bodø City in Northern Norway.

<footnote n="1">¹Department of Civil and Environmental Engineering, NTNU, S.P. Andersens Veg 5, 7031 Trondheim, Norway</footnote>

<footnote n="2">²INRAE, ETBX Research Unit, Aqua Department, F-33612 Cestas, France</footnote>

<footnote>*Corresponding author e-mail: prasanna.m.doss@ntnu.no</footnote>
## Variational Autoencoders

Variational autoencoders (VAEs) are a special type of deep neural network primarily used for image & signal compression and anomaly detection (Cody et al. 2020; Kingma and Welling 2014). VAEs have an input layer ($x$), an encoding dense neural network ($E$), a bottleneck layer ($Z$), and a decoder network ($D$) to reconstruct the inputs at output layer ($\hat{x}$). Instead of directly mapping original input data $x$ to the bottleneck layer ($Z$), VAE learns the parameters of the assumed prior distribution of input data. Hence a sample from the latent space($Z$) in reduced dimension can be used to generate new outputs ($\hat{x}$) which follows the same distribution as training input ($x$). In WDN applications, VAEs can generate unknown network states that are 'similar' to previously known states artificially within a finite error bound.

## Leak detection using VAEs:

With nodal pressures estimated from the calibrated model set as input $x \in \mathbb{R}^n$, the VAE is trained with gaussian as a prior distribution to learn the parameter vectors ($\mu$) and ($\sigma$). The latent vector $Z \in \mathbb{R}^{n_z}$ where $n_z < n$ is sampled from parameters vectors ($\mu$) and ($\sigma$). During the training phase, it is assumed that input data does not include leaky states. For the testing phase, a combination of leak and leak-free nodal pressures are used as inputs to determine the threshold for leak detection. If a leak is identified, integral squared error (ISE) is computed for each node in the input layer $x$ for a time window $t$ to $t + \Delta t$. The nodes ranked with the highest ISE will be the most likely leaky node in the network. The proposed framework and all its steps are shown in Figure 1 and the efficacy of the approach will be tested and discussed based on the performance measures of VAE.

<figure><img src="image_2.png" /><figcaption>Figure 1: Steps of leak detection in the proposed VAE surrogate framework</figcaption></figure>

## References

* Cody, R. A., Tolson, B. A., and Orchard, J. (2020). "Detecting Leaks in Water Distribution Pipes Using a Deep Autoencoder and Hydroacoustic Spectrograms." *Journal of Computing in Civil Engineering*, 34(2).

* Kingma, D. P., and Welling, M. (2014). "Auto-encoding variational bayes." *2nd International Conference on Learning Representations, ICLR 2014 - Conference Track Proceedings*.

* Ormsbee, L. E., and Lingireddy, S. (1997). "Calibrating hydraulic network models." *Journal - American Water Works Association*, 89(2).
Piller, O. (2019). "Water distribution system modeling and optimization." CNAM Paris (in French).

Puust, R., Kapelan, Z., Savic, D. A., and Koppel, T. (2010). "A review of methods for leakage management in pipe networks." *Urban Water Journal*, 7(1).

Steffelbauer, D. B., Blokker, E. J. M., Buchberger, S. G., Knobbe, A., and Abraham, E. (2021). "Dynamic Time Warping Clustering to Discover Socioeconomic Characteristics in Smart Water Meter Data." *Journal of Water Resources Planning and Management*, 147(6).

Steffelbauer, D. B., Deuerlein, J., Gilbert, D., Piller, O., and Abraham, E. (2020). "Dual Model for Leak Detection and Localization." *CCWI/WDSA 2020, pre-conference workshop BattleDIM*, Beijing, China.

Vrachimis, S. G., Eliades, D. G., Taormina, R., Ostfeld, A., Kapelan, Z., Liu, S., Kyriakou, M. S., Pavlou, P., Qiu, M., and Polycarpou, M. (2020). "Dataset of BattLeDIM: Battle of the Leakage Detection and Isolation Methods."