1. Introduction
Increasing water demands caused by growing urbanization, coupled with water scarcity driven by climate change, make accurate water demand forecasting essential. Predicting demands is crucial for designing water distribution systems, allocating resources effectively, enhancing leakage detection, reducing supply costs, and ensuring that they can meet the needs of the users [
1]. However, this prediction is not simple; there is an intricate and nonlinear relationship between demand and its numerous driving factors. Previous approaches for demand prediction can generally be categorized as either statistical or machine learning methods.
Although traditional statistical techniques such as Autoregressive Integrated Moving Average (ARIMA) and seasonal ARIMA, i.e., SARIMA, mostly have a simple structure and can identify general patterns, they are ineffective at capturing nonlinear interactions, important for demand forecasting [
2]. Patrick F. Perry (1981) utilized a Fourier series to model the periodic demand component and ARIMA to describe the residual demand for 24 h predictions in the United Kingdom [
3].
Data-driven approaches to forecasting water demand have been established in order to deal with this problem and provide more robust prediction. Ghiassi et. al. (2008) developed dynamic artificial neural networks for different time horizons, including hourly, daily, weekly, and monthly. The model demonstrated a more accurate result for daily, weekly, and monthly in comparison to hourly. Moreover, comparing the results of DAN2 with ARIMA, concluded superior performance for DAN2 [
4]. Another approach in demand forecasting is support vector regression (SVR). M. Braun et. al. (2014) compared SVR and SARIMA for a 24 h forecast of Berlin’s residential water consumption. The SARIMA model did not perform as well as the support vector regression model. This can be attributed to the fact that the SVR model analyzes nonlinear effects using Gaussian kernels, whereas the SARIMA model relies on linear regression [
5]. Chen et al. (2017) introduced a regression model based on random forests aimed at tackling the nonlinear relationship of factors affecting water demand series [
6].
Recent advancements in predictive modeling have leveraged Long Short-Term Memory (LSTM) networks [
7], a type of Recurrent Neural Network (RNN), to improve time-series analysis, particularly in water demand forecasting using historical data [
8]. LSTMs excel in capturing long-range sequences, outperforming traditional models like ARIMA and SVM by effectively capturing temporal dependencies within water usage patterns. This capability to understand seasonal trends and irregular patterns without extensive feature engineering has revolutionized water demand forecasting. However, challenges persist in integrating external factors with seasonal variations and optimizing loss functions for improved accuracy.
Given the promising results of previous LSTM models and the opportunities for improving these models with feature engineering, the present study seeks to develop an LSTM-based hourly water demand prediction model that accounts for weather and user behavior. The input data incorporates feature engineering, particularly sinusoidal and cosine functions for modeling seasonal variations [
9] along with calendar features [
10].
2. Materials and Methods
The proposed procedure in this paper focuses on predicting water demands within a Water Distribution Network (WDN) situated in the northeast of Italy. This entails consumption forecasting for ten District Metered Areas (DMAs) within the WDN to define optimal system operation over both the upcoming day and week. The DMAs (named A to J) demonstrate a diverse array of area characteristics, spanning residential, suburban, commercial, and industrial zones, each presenting distinct challenges and opportunities for demand prediction. Notably, DMA E, situated near the city center, serves the highest number of users with a significant net inflow, while DMA I, positioned by the port, has the fewest users with a comparatively lower net inflow. Historical data on net inflows and weather records were made available for analysis, spanning a total of 81 weeks.
Beginning with importing the raw data, we ensured consistent date–time formatting to facilitate temporal analysis. Additional contextual information, such as holidays and weekends, was integrated to account for temporal variations in water inflow patterns. Addressing missing values was critical, and we employed LSTM neural networks to accurately predict and impute missing data, aligning closely with underlying inflow dynamics. Feature engineering included computing the mean inflow over the preceding four weeks and transforming the day of the week and time of day into sine and cosine representations to capture cyclic patterns effectively. Finally, systematic data reordering enhanced clarity and consistency, preparing the dataset for insightful conclusions regarding water demand prediction.
Iterative testing was conducted to optimize the performance of LSTM networks through hyperparameter tuning. Different values for hyperparameters such as the number of LSTM units (50, 64, 128), learning rate (0.0025, 0.002, 0.0015, 0.001), batch size (32, 64, 128), and dropout rate (0.1, 0.2, 0.3) were systematically tested. This fine-tuning process aimed to identify the optimal configuration for each DMA. The number of weeks used for training varied for each DMA, based on trial and error, to maximize learning efficacy and predictive accuracy.
In the evaluation of the models’ effectiveness and accuracy, three Performance Indicators (PIs) were utilized. These indicators include the mean absolute error (MAE) computed for the first 24 h of each evaluation week, the maximum absolute error within the same 24 h period, and the MAE calculated for the period between the second and final days of each evaluation week. To facilitate a fair comparison of the LSTM model’s performance across the varied DMAs, the error metrics were also normalized by the average net inflow of each DMA. Thus, normalized MAE (N MAE) and Max AE (N Max AE) for the first 24 h, along with the MAE for the remaining days, were computed. The final week, week 81, was reserved as the testing set, while the rest was utilized as the training set. Accordingly, performance metrics were computed for hyperparameter tuning as well as identifying the most effective predictive model. Once the best model was selected, predictions were made for week 81.
3. Results
Considering the diverse characteristics of each DMA, unique LSTM models were trained individually for each of them. Details regarding the training period and hyperparameters are presented in
Table 1. The models’ effectiveness was assessed by testing them on the last week of available data. For all DMAs, the window size was set at 24 h. The training period and hyperparameters were determined through trial and error to minimize errors. The performance of each model is presented in
Table 2. The performance of the LSTM model displayed notable variation across the different DMAs, reflecting the impact of area characteristics on water demand patterns. A particularly notable observation is DMA E, which, despite having the highest average net inflow, shows the lowest normalized errors across all metrics, suggesting that the model’s performance is quite robust for areas with higher demand. Conversely, DMAs with lower average net inflows, such as DMA A, C, and F, exhibit higher normalized errors. This suggests that the model has difficulties in capturing demand patterns in DMAs with lower demand, pointing to opportunities for model refinement or inclusion of more data.
4. Conclusions
This study presents a comprehensive approach to water demand forecasting using LSTM networks within a WDS in northeast Italy. By integrating hourly water demand data from diverse DMAs with weather information and temporal features, the LSTM models demonstrated promising accuracy in predicting demand patterns. The models’ effectiveness was evident across various DMAs, with notable performance in areas with higher average net inflows. The normalized mean absolute error (MAE) for the first 24 h ranged from 0.0224 to 0.1308 for different DMAs, with DMA E exhibiting the lowest error. Furthermore, the study emphasizes the importance of advanced feature engineering techniques, including sinusoidal and cosine transformations, along with the integration of contextual data such as holidays, in enhancing prediction accuracy.
Author Contributions
Methodology, F.B.a., M.K.V., M.N.H., N.H.M. and R.D.; validation, F.B.a., M.K.V., M.N.H., N.H.M. and R.D.; writing—original draft preparation, F.B.a., M.K.V., M.N.H., N.H.M. and R.D. All authors have read and agreed to the published version of the manuscript.
Funding
This research was funded by the Natural Sciences and Engineering Research Council, grant number RGPIN-2022-04664.
Institutional Review Board Statement
Not applicable.
Informed Consent Statement
Not applicable.
Data Availability Statement
Conflicts of Interest
The authors declare no conflicts of interest.
References
- Billings, R.B.; Jones, C.V. Forecasting Urban Water Demand, 2nd ed.; America Water Works Association: Washington, DC, USA, 2011. [Google Scholar]
- Pu, Z.; Yan, J.; Chen, L.; Li, Z.; Tian, W.; Tao, T.; Xin, K. A hybrid Wavelet-CNN-LSTM deep learning model for short-term urban water demand forecasting. Front. Environ. Sci. Eng. 2023, 17, 22. [Google Scholar] [CrossRef]
- Perry, P.F. Demand Forecasting in Water Supply Networks. J. Hydraul. Div. 1981, 107, 1077–1087. [Google Scholar] [CrossRef]
- Ghiassi, M.; Zimbra, D.K.; Saidane, H. Urban Water Demand Forecasting with a Dynamic Artificial Neural Network Model. J. Water Resour. Plan. Manag. 2008, 134, 138–146. [Google Scholar] [CrossRef]
- Braun, M.; Bernard, T.; Piller, O.; Sedehizade, F. 24-hours demand forecasting based on SARIMA and support vector machines. Procedia Eng. 2014, 89, 926–933. [Google Scholar] [CrossRef]
- Chen, G.; Long, T.; Xiong, J.; Bai, Y. Multiple Random Forests Modelling for Urban Water Consumption Forecasting. Water Resour. Manag. 2017, 31, 4715–4729. [Google Scholar] [CrossRef]
- Hochreiter, S.; Schmidhuber, J. Long short-term memory. Neural Comput. 1997, 9, 1735–1780. [Google Scholar] [CrossRef] [PubMed]
- Mu, L.; Zheng, F.; Tao, R.; Zhang, Q.; Kapelan, Z. Hourly and daily urban water demand predictions using a long short-term memory based model. J. Water Resour. Plan. Manag. 2020, 146, 05020017. [Google Scholar] [CrossRef]
- Stolwijk, A.M.; Straatman, H.; Zielhuis, G.A. Studying seasonality by using sine and cosine functions in regression analysis. J. Epidemiol. Community Health 1999, 53, 235–238. [Google Scholar] [CrossRef]
- Bakker, M.; Vreeburg, J.H.; Rietveld, L.C.; Blom, T. The use of an adaptive water demand prediction model. In Proceedings of the WDSA 2012: 14th Water Distribution Systems Analysis Conference, Adelaide, SA, Australia, 24–27 September 2012. [Google Scholar]
Table 1.
Training period and hyperparameters of each LSTM model.
Table 1.
Training period and hyperparameters of each LSTM model.
DMA | A | B | C | D | E | F | G | H | I | J |
---|
Training Period (weeks) | 40 | 6 | 10 | 20 | 40 | 4 | 10 | 20 | 40 | 20 |
Hyperparameters | # layers | 4 | 4 | 5 | 4 | 4 | 3 | 4 | 3 | 4 | 4 |
# units | 128 | 128, 64 | 128, 65 | 128 | 128 | 256, 128, 64 | 128, 64 | 128, 65 | 50 | 64 |
Optimizer | Adam | Adam | Adam | Adam | Adam | Adam | Adamax | Adam | Adam | Adam |
Learning rate | 0.0015 | 0.001 | 0.0025 | 0.0025 | 0.002 | 0.001 | 0.001 | 0.001 | 0.0025 | 0.001 |
Dropout rate | 0.1 | 0.2 | 0.2 | 0.1 | 0.2 | 0.3 | 0.3 | 0.3 | 0.3 | 0.3 |
Batch size | 32 | 16 | 32 | 32 | 32 | 32 | 32 | 32 | 64 | 32 |
Table 2.
Performance metrics of each LSTM model.
Table 2.
Performance metrics of each LSTM model.
DMA | A | B | C | D | E | F | G | H | I | J |
---|
MAE 1st day | 1.29 | 0.48 | 0.56 | 2.38 | 1.75 | 0.69 | 1.39 | 0.91 | 1.25 | 1.46 |
Max AE 1st day | 3.32 | 1.41 | 1.44 | 6.29 | 3.71 | 2.27 | 3.26 | 2.10 | 3.16 | 4.28 |
MAE other days | 1.34 | 0.93 | 0.83 | 2.20 | 2.30 | 0.93 | 1.68 | 1.31 | 1.20 | 1.31 |
N. MAE 1st day | 0.1537 | 0.0500 | 0.1308 | 0.0724 | 0.0224 | 0.0856 | 0.0552 | 0.0438 | 0.0608 | 0.0553 |
N. Max AE 1st day | 0.3957 | 0.1474 | 0.3358 | 0.1912 | 0.0474 | 0.2807 | 0.1301 | 0.1010 | 0.1533 | 0.1620 |
MAE other days | 0.1601 | 0.0970 | 0.1934 | 0.0669 | 0.0294 | 0.1150 | 0.0669 | 0.0630 | 0.0584 | 0.0496 |
| 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. |
© 2024 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 (https://creativecommons.org/licenses/by/4.0/).