Urban water supply prediction method based on non-stationary perception Transform-BiLSTM model

By using a non-stationary sensing Transformer-BiLSTM model, combined with multi-method fusion anomaly detection and frequency domain modeling, the modeling challenge of the long-term trend and local dynamic relationship in urban water supply forecasting was solved, achieving higher accuracy and more stable water supply forecasting.

CN121543827APending Publication Date: 2026-02-17HENGYANG NORMAL UNIV
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202511773419.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-11-28
Publication Date
2026-02-17

AI Technical Summary

Technical Problem

Existing urban water supply forecasting methods struggle to coordinate the modeling of long-term trends and local dynamic relationships when faced with non-stationary water supply sequences, resulting in insufficient forecast accuracy.

Method used

We employ a non-stationary sensing Transformer-BiLSTM model and use a multi-method fusion anomaly detection approach, combining STL decomposition residual method, Isolation Forest method, and sliding window Z-score method. We also combine Reversible Instance Normalization RevIN technique and Discrete Cosine Transform DCT to construct an encoder and decoder, capturing long-term global dependencies and local details. We use mean squared error (MSE) as the loss function for optimization.

Benefits of technology

It significantly improves the stability and accuracy of urban water supply forecasting, effectively alleviates the problem of time series distribution drift, and collaboratively models trend terms, periodicity and abrupt change points, thereby improving the accuracy and robustness of forecasting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121543827A_ABST
    Figure CN121543827A_ABST
Patent Text Reader

Abstract

The invention discloses an urban water supply prediction method based on a non-stationary perceptual Transform-BiLSTM model, and the method comprises the steps: independently calculating the mean value and variance of each sequence sample as non-stationary statistical information through introducing a reversible normalization mechanism, enabling a sequence to depend on weight learning reversible mapping on the basis of maintaining the original distribution characteristics of data, and carrying out the calculation of the mean value and variance of each sequence sample as the non-stationary statistical information; and the perception capability of non-stationary components is enhanced, and the training stability is improved. In addition, discrete cosine transform (DCT) is adopted for frequency domain modeling, and the feature extraction capacity of the model for the periodicity and trend of the urban water supply sequence is enhanced. In the aspect of feature modeling, the model fuses the global attention mechanism of Transform and the time sequence modeling capability of BiLSTM, cooperatively captures the long-term dependency relationship and local time sequence dependency features in urban water supply data, and has a remarkable capturing capability effect on the change of a non-stationary structure under the background of multi-scale fluctuation of an urban water supply sequence.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of urban water supply, and in particular to an urban water supply prediction method based on a non-stationary sensing Transformer-BiLSTM model. Background Technology

[0002] Urban water supply systems are a vital lifeline for ensuring the normal operation of society and economic development. With the acceleration of urbanization and the intensification of the impacts of climate change, water supply systems face increasing operational pressure. Achieving accurate short-term and long-term water supply forecasts is a key prerequisite for intelligent scheduling, optimizing pump energy consumption, and ensuring stable water pressure, and is of great significance for achieving water conservation and efficiency in cities.

[0003] In existing technologies, researchers have proposed various data-driven methods to address the problem of urban water consumption forecasting. Existing urban water supply forecasting methods can be mainly categorized into traditional statistical methods, machine learning methods, and deep learning methods. Traditional statistical methods, such as Autoregressive Moving Average (ARMA) and Autoregressive Integrated Moving Average (ARIMA), are typically based on assumptions about data stationarity. While they perform well when these assumptions are met, their applicability is poor when dealing with non-stationary water supply series, easily leading to decreased accuracy or even distortion. Machine learning methods, such as Support Vector Machines (SVM), Random Forests (RF), and Decision Trees, while possessing strong mathematical foundations, have limited capabilities in processing unstructured data and suffer from low computational efficiency with massive datasets. Deep learning methods, such as Convolutional Neural Networks (CNN), Long Short-Term Memory (LSTM), and Transformers, have become mainstream, capable of learning more complex hidden features in data. However, single models often struggle to collaboratively model long-term trends and local dynamic relationships, limiting further improvements in forecast accuracy. Therefore, it is necessary to develop a novel forecasting method that can perceive non-stationary characteristics and consider both long-term dependencies and local fluctuations. Summary of the Invention

[0004] To address the aforementioned technical problems, this invention provides a simple and highly accurate urban water supply prediction method based on a non-stationary sensing Transformer-BiLSTM model.

[0005] The technical solution of this invention to solve the above-mentioned technical problems is: a method for predicting urban water supply based on a non-stationary sensing Transformer-BiLSTM model, comprising the following steps:

[0006] S1: Collect historical daily water consumption data of the water supply network and perform preprocessing, including using STL decomposition residual method, Isolation Forest method and sliding window Z-score method to perform multi-method fusion anomaly detection on the data. If any two methods determine that the data is abnormal, the data is marked as an outlier and removed.

[0007] S2: Perform nonstationarity analysis on the preprocessed historical daily water consumption data;

[0008] S3: Perform non-stationary information processing, use the Reversible Instance Normalization (RevIN) technique to standardize the input sequence at the instance level, and use Discrete Cosine Transform (DCT) to convert the original daily water consumption data in the time domain to the frequency domain and filter out high-frequency noise components.

[0009] S4: Construct a non-stationary sensing Transformer-BiLSTM model, which consists of an encoder and a decoder;

[0010] S5: Divide the historical daily water consumption data after non-stationary information processing into training set and validation set, and input them into the non-stationary perception Transformer-BiLSTM model for supervised training.

[0011] S6: Input the historical daily water consumption data preprocessed in step S1 into the trained non-stationary perception Transformer-BiLSTM model, and output the predicted daily water consumption of the city in the future for a specified time window.

[0012] In the above-mentioned urban water supply prediction method based on the non-stationary perception Transformer-BiLSTM model, the specific strategy for multi-method fusion anomaly detection in step S1 is as follows: first, the data is detected by the STL decomposition residual method to obtain a first set of anomalies; then, the data is detected by the Isolation Forest method to obtain a second set of anomalies; finally, the data is detected by the sliding window Z-score method to obtain a third set of anomalies; for each data point, if it appears more than or equal to twice in the three sets of anomalies, it is finally determined to be an anomaly.

[0013] The above-mentioned urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model, in step S1, uses the STL decomposition residual method... The output at time t is:

[0014]

[0015]

[0016] in, For seasonal items, It is a trend item. For the residual term, for Output at any moment for The median of a set;

[0017] The calculated residual statistic is compared with the critical value. If it exceeds the critical value, it is considered an outlier. The calculation formula is:

[0018]

[0019] in, For the sample size, The lag order is... Describing the degrees of freedom as The lower confidence level is of Distribution critical value.

[0020] In the aforementioned urban water supply prediction method based on the non-stationary perception Transformer-BiLSTM model, step S1 involves anomaly scoring in the Isolation Forest method. The calculation formula is:

[0021]

[0022] in, These are sample values. It is the sample size. yes The average value, It is the path length normalization constant. , yes The harmonic number of order, Through The number of edges is measured by traversing the iTree from the root node.

[0023] In the above-mentioned urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model, the formula for calculating the standard score in the sliding window Z-score method in step S1 is as follows:

[0024]

[0025] in, Represents standard scores. Let be the observation value at time t. The sample mean. This represents the sample standard deviation.

[0026] The above-mentioned urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model, specifically step S2, is as follows:

[0027] S21: Using Local Fast Fourier Transform (FFT) analysis, the spectrum of the data sequence is calculated within a sliding window, and the non-stationarity of the data is qualitatively judged by the change in the dominant frequency distribution;

[0028] S22: Further, the KPSS test method is used to quantitatively determine the stationarity of the data series by judging whether the test statistic exceeds the critical value at the significance level. The calculation formula is as follows:

[0029]

[0030] in, Let be the cumulative residual at time t. It is an estimator of the long-term variance. This represents the sample length.

[0031] In the urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model described above, step S3 uses the Reversible Instance Normalization (RevIN) technique to normalize the input sequence at the instance level, and performs the inverse operation after the model output. The normalization formula is as follows:

[0032]

[0033] in, It is the normalized value. Let k be the k-th feature of the i-th sequence in the mini-batch at time t. and The mean and variance are calculated along the time dimension. For learnable affine parameters, It is the numerical stability constant;

[0034] The inverse normalization formula is as follows:

[0035]

[0036] in, These are the model's predicted values. Output for the model.

[0037] The aforementioned urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model, in step S3, introduces Discrete Cosine Transform (DCT) and the basis functions of the one-dimensional DCT. for:

[0038]

[0039] in, It is the basis vector index. ∈{0,1,…, }, It is the total number of data points. It is the position number;

[0040] Then the one-dimensional DCT is:

[0041]

[0042] in, For one-dimensional DCT spectrum, ∈ , For output, ∈ , for Length;

[0043] Correspondingly, the inverse one-dimensional DCT is:

[0044]

[0045] in, The spectrum of inverse one-dimensional DCT;

[0046] DCT is performed on the sequence of each channel to obtain frequency domain features. First, the spectral features are normalized layer by layer. Then, a nonlinear feature reconstruction capability is introduced through a two-layer fully connected neural network. Finally, the Sigmoid activation function is used to generate frequency domain weights to achieve adaptive adjustment of the response of each frequency channel. The frequency domain weights are modulated by multiplying the inverse one-dimensional DCT sequence element by element.

[0047] In the above-mentioned urban water supply prediction method based on the non-stationary perception Transformer-BiLSTM model, in step S4, the encoder adopts the Transformer architecture and uses the self-attention mechanism to capture the complex long-term global dependencies in the daily water consumption data; the decoder adopts the Bi-directional long short-term memory network BiLSTM architecture and integrates forward and backward context information to capture the local details and short-term trends of the data.

[0048] The non-stationary perceptual Transformer-BiLSTM model introduces a reversible normalization mechanism at both the input processing and encoder design levels. Before the original input sequence enters the backbone network, it is first normalized through the RevIN module. The RevIN module normalizes each sample independently on an instance-by-instance basis, extracting the mean and standard deviation of each sequence in the time dimension. Subsequently, the output after model processing is restored to the original data distribution through a matching inverse normalization step.

[0049] A DCT transform module is introduced at the front end of the encoder to explore the potential frequency domain junctions in the time series. The DCT transform module projects the input time series signal onto a set of cosine bases, which enables the effective separation of periodic fluctuations and high and low frequency components in the sequence. By screening and selectively retaining the spectrum after DCT, the model focuses more on the trend part with long-term dependence characteristics and significant periodic terms.

[0050] After normalization and frequency domain transformation, the feature sequence is first input into the encoder. The Transformer models long-distance dependent features in the sequence through a global attention mechanism and further improves the ability to recognize periodic patterns by combining the introduced periodic-aware position encoding. Subsequently, BiLSTM further explores local temporal patterns and dynamic change trends. Its bidirectional structure makes full use of contextual information, which helps to model short-term fluctuations in detail.

[0051] In the above-mentioned urban water supply prediction method based on the non-stationary perception Transformer-BiLSTM model, in step S5, the model uses the mean square error (MSE) between the predicted value and the true value as the main loss function, uses the Adam optimizer to optimize the parameters, and uses an early stopping mechanism to prevent overfitting until the model's performance on the validation set reaches its optimal level.

[0052] The beneficial effects of this invention are as follows: This invention organically integrates frequency domain modeling, instance normalization, and attention mechanisms to construct a unified end-to-end prediction framework. This model not only alleviates the problem of temporal distribution drift, but also has the ability to collaboratively model multiple types of non-stationary structures such as trend terms, periodicity, and abrupt change points, significantly enhancing the prediction stability in complex urban water supply scenarios. Attached Figure Description

[0053] Figure 1 This is the overall flowchart of the present invention.

[0054] Figure 2 This is a visualization diagram of the preprocessed water supply dataset of water plant A in the example.

[0055] Figure 3 This is a visualization diagram of the preprocessed water supply dataset from water plant B in the example.

[0056] Figure 4 This is a comparison diagram of the local window spectrum of waterworks A in the embodiment.

[0057] Figure 5 This is a comparison diagram of the local window spectrum of waterworks B in the embodiment.

[0058] Figure 6 A schematic diagram of generating frequency domain weights for DCT transform.

[0059] Figure 7 The RevIN normalization flowchart.

[0060] Figure 8 This is a framework diagram of the non-stationary sensing Transformer-BiLSTM model.

[0061] Figure 9 This is a comparison chart of the test set model for water plant A.

[0062] Figure 10 A visualization of the prediction results of water supply data from water plant A under the BiLSTM model.

[0063] Figure 11 A visualization of the predicted water supply data from water plant A under the Transformer model.

[0064] Figure 12 A visualization of the predicted water supply data from water plant A under the Transformer-BiLSTM model.

[0065] Figure 13 This is a visualization of the predicted water supply data of water plant A under the model of this invention.

[0066] Figure 14 This is a comparison chart of the test set model for water plant B.

[0067] Figure 15 A visualization of the prediction results of water supply data from water plant B under the BiLSTM model.

[0068] Figure 16 A visualization of the predicted water supply data from water plant B under the Transformer model.

[0069] Figure 17 A visualization of the predicted water supply data from water plant B under the Transformer-BiLSTM model.

[0070] Figure 18 This is a visualization of the predicted water supply data of water plant B under the model of this invention. Detailed Implementation

[0071] The present invention will be further described below with reference to the accompanying drawings and embodiments.

[0072] like Figure 1 As shown, a method for predicting urban water supply based on a non-stationary sensing Transformer-BiLSTM model includes the following steps:

[0073] S1: Collect historical daily water consumption data of the water supply network and perform preprocessing, including using the STL decomposition residual method, the Isolation Forest method and the sliding window Z-score method to perform multi-method fusion anomaly detection on the data. If any two methods determine that the data is abnormal, it is marked as an outlier and removed. This integrated judgment mechanism combines trend denoising ability, density anomaly identification and local fluctuation perception, which improves the overall detection stability.

[0074] The experimental dataset for this example comes from the daily water supply of two water plants, A and B (ignoring other influencing factors). The data represents the total readings of the water plant's outflow meters. Water plant A collected water supply data from January 8, 2001 to December 5, 2016, totaling 5853 samples. The first 4097 days were used for model training, the subsequent 1171 days for validation, and the remaining 585 days for testing. Water plant B collected water supply data from January 1, 2002 to November 30, 2016, totaling 5450 samples. The first 3815 days were used for model training, the subsequent 1090 days for validation, and the remaining 545 days for testing.

[0075] Historical water demand data for cities usually comes from metering infrastructure. Due to human input errors or instrument malfunctions, there may be missing data points and outliers in the historical water demand time series.

[0076] The specific strategy for multi-method fusion anomaly detection is as follows: First, the data is detected by STL decomposition residual method to obtain the first set of anomalies; then, the data is detected by Isolation Forest method to obtain the second set of anomalies; finally, the data is detected by sliding window Z-score method to obtain the third set of anomalies; for each data point, if it appears more than twice in the three sets of anomalies, it is finally determined to be an anomaly.

[0077] Firstly, residual analysis based on STL decomposition identifies anomalous fluctuations beyond trends and seasonality. The STL decomposition residual method... The output at time t is:

[0078]

[0079]

[0080] in, For seasonal items, It is a trend item. For the residual term, for Output at any moment for The median of a set;

[0081] The calculated residual statistic is compared with the critical value. If it exceeds the critical value, it is considered an outlier. The calculation formula is:

[0082]

[0083] in, For the sample size, The lag order is... Describing the degrees of freedom as The lower confidence level is of Distribution critical value.

[0084] Secondly, the Isolation Forest anomaly detection method is adopted. Its core idea is to construct a tree structure by randomly partitioning the feature space. Because anomalies are sparsely distributed, they can usually be isolated at a shallower level. The Isolation Forest method uses anomaly scoring... The calculation formula is:

[0085]

[0086] in, These are sample values. It is the sample size. yes The average value, It is the path length normalization constant. , yes The harmonic number of order, Through The number of edges is measured by traversing the iTree from the root node.

[0087] Finally, the sliding window Z-score method is used to enhance the model's ability to detect short-term abnormal fluctuations. This method standardizes the sequence based on local statistics, and anomalies are considered when the standard score exceeds a threshold. This method requires no prior assumptions and is suitable for non-stationary time series data. The Z-value at each time point is standardized by dynamically calculating the mean and standard deviation within the local window. The formula for calculating the standard score in the sliding window Z-score method is:

[0088]

[0089] in, Represents standard scores. Let be the observation value at time t. The sample mean. This represents the sample standard deviation.

[0090] After handling outliers in the dataset, Kalman filtering is used to smooth the dataset and remove noise. Subsequently, to accelerate model training, minimax normalization is employed to reduce computational complexity. The preprocessed data is shown below. Figure 2 , Figure 3 As shown, the daily water supply data of the water plant is significantly affected by seasonal changes, exhibiting typical annual cyclical fluctuations, mainly manifested as cyclical changes in water supply demand with the changing seasons. Compared with water plant A, the daily water supply sequence of water plant B shows a more stable trend, with smaller long-term fluctuations and weaker overall volatility, exhibiting relatively mild dynamic characteristics.

[0091] S2: Perform nonstationarity analysis on the preprocessed historical daily water consumption data.

[0092] The specific process of step S2 is as follows:

[0093] S21: Using Local Fast Fourier Transform (FFT) analysis, the spectrum of the data sequence is calculated within a sliding window, and the non-stationarity of the data is qualitatively judged by the change in the dominant frequency distribution;

[0094] S22: Further, the KPSS test method is used to quantitatively determine the stationarity of the data series by judging whether the test statistic exceeds the critical value at the significance level. The calculation formula is as follows:

[0095]

[0096] in, Let be the cumulative residual at time t. It is an estimator of the long-term variance. This represents the sample length.

[0097] like Figure 4 and Figure 5 As shown, the water supply sequence was divided into multiple sliding time windows, and local FFT analysis was performed on each window. Comparing the spectrograms of different time periods reveals that the energy distribution and dominant frequencies of the frequency components changed significantly over time, indicating a significant frequency drift phenomenon in the data.

[0098] The higher the KPSS value, the more the sequence deviates from stationarity. The test results are shown in Table 1. The test statistics for water plant A and water plant B significantly exceeded the critical values ​​for each test, and the p-value of 0.01 was statistically significant. This provides decisive evidence to reject the null hypothesis of trend stationarity at the conventional significance level. The diagnostic results indicate the existence of a unit root process, meaning that random shocks have a sustained impact on the sequence trajectory. Therefore, the two water plant datasets exhibit different degrees of nonstationarity, and appropriate differencing or detrending transformation of the sequences is necessary before implementing conventional time series modeling methods.

[0099]

[0100] The above analysis reveals that urban water supply data exhibits typical non-stationarity, characterized by fluctuations in mean and variance over time, as well as changes in frequency structure. Therefore, traditional time-series forecasting methods struggle to fully capture its complex evolutionary patterns. To improve forecast accuracy, it is crucial to introduce deep learning structures with frequency domain modeling capabilities and adaptive normalization mechanisms to more effectively extract potential periodic variations and disturbances.

[0101] S3: Perform non-stationary information processing, use the Reversible Instance Normalization (RevIN) technique to standardize the input sequence at the instance level, and use Discrete Cosine Transform (DCT) to convert the original daily water consumption data in the time domain to the frequency domain and filter out high-frequency noise components.

[0102] RevIN (Reversible Instance Normalization) is used to normalize the input sequence at the instance level and performs the inverse operation after the model output to address the distribution drift problem caused by non-stationarity in time series. RevIN, through its unique symmetric structure, removes non-stationarity information from the data at the input layer and restores this information at the output layer, thus significantly improving the accuracy of time series prediction. RevIN normalizes the input data by calculating the mean and standard deviation of each time series instance, effectively reducing the distribution difference between training and test data. The normalization formula is as follows:

[0103]

[0104] in, It is the normalized value. Let k be the k-th feature of the i-th sequence in the mini-batch at time t. and The mean and variance are calculated along the time dimension. For learnable affine parameters, It is the numerical stability constant;

[0105] The inverse normalization formula is as follows:

[0106]

[0107] in, These are the model's predicted values. Output for the model.

[0108] This process not only enables the model to more accurately capture patterns and trends in time series but also enhances its adaptability to different prediction lengths. In the output layer, RevIN uses inverse normalization to add the previously removed non-stationarity information back to the model's output, ensuring that the prediction results can restore the distribution of the original data. The implementation process is as follows: Figure 6 As shown.

[0109] Reversible normalization consists of a normalization layer and a denormalization layer. It uses the same statistical data to transform the model's input and output. This symmetric structure allows RevIN to remove and recover non-stationary information while avoiding information loss caused by normalization, thus maintaining data integrity and consistency.

[0110] This invention systematically optimizes the original RevIN algorithm. Through structural constraints, temporal dimension normalization, and gradient co-optimization, it provides an efficient solution to the non-stationarity problem in time series forecasting. It forces the input tensor to be B×L×C, explicitly distinguishing between batches, time steps, and feature channels to avoid dimensionality confusion. Furthermore, based on the original RevIN, it performs dynamic statistics calculations for each sample, calculating the mean and variance of each sample in the time dimension to eliminate heterogeneity interference between samples, and then uses affine parameters... An inverse transform is performed on the normalized features to preserve the amplitude information of the original sequence, ensuring the recovery of non-stationary characteristics during the decoding stage and avoiding information loss. The model only needs to learn the local dynamics of the normalized data, reducing non-stationary interference. For the heterogeneous distribution of different channels, channel-level affine parameters are used to achieve fine-grained control. This is manifested in two aspects: first, the affine parameters automatically adapt to any time length, avoiding explicit reshaping operations and improving computational robustness; second, each channel is independently learned. The model can adaptively calibrate the numerical range of variables with different dimensions (such as temperature and pressure) to alleviate the gradient imbalance problem.

[0111] The optimized RevIN retention statistic of this invention ( and The gradient path allows for dynamic adjustment of normalization behavior during backpropagation. The normalization process is jointly optimized with network parameters, enabling the model to adaptively adjust feature distribution alignment strategies according to task requirements. In complex scenarios (such as abrupt changes or periodic drift), gradient signals guide the model to balance the weights of stationary modeling and original distribution recovery, enhancing the model's ability to perceive non-stationary sequences.

[0112] To effectively address the impact of frequency drift on prediction accuracy and fully extract potential information from the sequence, this invention introduces Discrete Cosine Transform (DCT). Compared to Discrete Fourier Transform (DFT), DCT uses only real numbers, resulting in better frequency domain energy concentration. Unimportant frequency regions and coefficients can be directly pruned. Since signal energy is concentrated in the gently changing low-frequency region, DCT can concentrate this region, facilitating the extraction of low-frequency information. In the frequency domain, low-frequency components of a time series typically carry the main trend information, while high-frequency components may contain noise or details. DCT can separate these components, emphasizing important periodic features while suppressing noise, thereby improving the accuracy and robustness of the prediction model.

[0113] Basis functions of one-dimensional DCT for:

[0114]

[0115] in, It is the basis vector index. ∈{0,1,…, }, It is the total number of data points. It is the position number;

[0116] Then the one-dimensional DCT is:

[0117]

[0118] in, For one-dimensional DCT spectrum, ∈ , For output, ∈ , for Length;

[0119] Correspondingly, the inverse one-dimensional DCT is:

[0120]

[0121] in, The spectrum of inverse one-dimensional DCT;

[0122] Non-stationary time series often exhibit complex trends, with these changes displaying different characteristics across different frequency components. DCT can decompose these complex changes into the frequency domain, making the non-stationary characteristics, which are difficult to handle in the time domain, more clearly apparent in the frequency domain. It decomposes complex non-stationary sequences into relatively stationary frequency components while extracting rich frequency domain information.

[0123] For each channel's sequence, a DCT is performed to obtain frequency domain features. First, the spectral features are normalized layer by layer. Then, a two-layer fully connected neural network is used to introduce nonlinear feature reconstruction capabilities. Finally, a sigmoid activation function is used to generate frequency domain weights, achieving adaptive adjustment of the response of each frequency channel. The frequency domain weights are modulated by element-wise multiplication with the inverse one-dimensional DCT sequence, such as... Figure 7 As shown.

[0124] S4: Construct a non-stationary sensing Transformer-BiLSTM model, which consists of an encoder and a decoder.

[0125] In step S4, the encoder adopts the Transformer architecture and uses a self-attention mechanism to capture the complex long-term global dependencies in the daily water consumption data; the decoder adopts the Bi-Short Memory Network (BiLSTM) architecture and fuses forward and backward context information to capture the local details and short-term trends of the data.

[0126] like Figure 8 As shown, the non-stationary perceptual Transformer-BiLSTM model (NSP-Tr-BiLSTM) introduces a reversible normalization mechanism at both the input processing and encoder design levels. Before the original input sequence enters the backbone network, it is first normalized through the RevIN module. The RevIN module normalizes on an instance-by-instance basis, meaning each sample is normalized independently, extracting the mean and standard deviation of each sequence in the time dimension. Subsequently, the output after model processing is restored to the original data distribution through a matching inverse normalization step. This mechanism effectively alleviates non-stationary features such as distribution drift and mean / variance changes in time series, helps improve the model's generalization ability at different time periods, and avoids the problem of inconsistent statistical distributions between the training and prediction phases.

[0127] A DCT transform module is introduced at the front end of the encoder to uncover potential frequency domain junctions in the time series. The DCT transform module projects the input time series signal onto a set of cosine bases, which effectively separates the periodic fluctuations and high- and low-frequency components in the sequence. By filtering and selectively retaining the spectrum after DCT (such as high-frequency suppression or low-frequency enhancement), the model focuses more on the trend part with long-term dependence characteristics and significant periodic terms. This enhancement of frequency domain information enables the Transformer encoder to extract key features related to periodicity and water volume fluctuations more efficiently, avoiding overfitting to local high-frequency noise, thereby improving the overall prediction accuracy and stability.

[0128] After normalization and frequency domain transformation, the feature sequence is first input to the encoder. The Transformer models long-distance dependent features in the sequence through a global attention mechanism and further enhances the ability to recognize periodic patterns by combining it with the introduced periodic-aware positional encoding. Subsequently, the BiLSTM further mines local temporal patterns and dynamic trends. Its bidirectional structure makes full use of contextual information, which helps to model short-term fluctuations in detail. This hybrid structure achieves collaborative perception of global structure and local dynamics, ensuring both the extraction of periodic patterns and the ability to respond to short-term changes.

[0129] S5: Divide the historical daily water consumption data after non-stationary information processing into training and validation sets, and input them into the non-stationary perception Transformer-BiLSTM model for supervised training.

[0130] The model uses the mean squared error (MSE) between the predicted and true values ​​as the main loss function, employs the Adam optimizer for parameter optimization, and uses an early stopping mechanism to prevent overfitting until the model achieves optimal performance on the validation set.

[0131] S6: Input the historical daily water consumption data preprocessed in step S1 into the trained non-stationary perceptual Transformer-BiLSTM model, and output the predicted daily water consumption for the city in the future within a specified time window. Experiments and Results

[0132] The experimental environment is shown in Table 2. All experiments were conducted on an NVIDIA GeForce RTX 4050 Lapto GPU. All models were trained using PyTorch 2.1.1 in Python 3.10. The model optimizer used was AdamW, an adaptive weight decay optimization algorithm with an initial learning rate of 1e-3. Combined with the StepLR learning rate scheduler, the learning rate was multiplied by a decay coefficient γ=0.95 after every 10 epochs to implement a stepwise annealing learning strategy to stabilize the model convergence process. During training, the batch size was set to 16. To prevent overfitting, Early Stopping was introduced with a patience of 30 epochs; training was terminated when the validation set loss did not decrease for 30 consecutive epochs. The maximum number of training epochs was set to 500 to ensure sufficient convergence of the model under the early stopping mechanism.

[0133]

[0134] This invention employs four evaluation metrics. RMSE (Root Mean Square Error) enhances sensitivity to larger errors by squaring the error, better reflecting the dispersion of predicted values. R² (Coefficient of Determination) assesses the model's ability to explain data variability; its value ranges from 0 to 1, with values ​​closer to 1 indicating better model fit. MAE (Mean Absolute Error) measures the average absolute deviation between predicted and actual values, directly reflecting the magnitude of the prediction error. MAPE (Mean Absolute Percentage Error) further normalizes the error to the actual order of magnitude, evaluating the model's relative accuracy as a proportion, suitable for comparing data at different scales. Generally, smaller values ​​for MAE, MAPE, and RMSE indicate higher prediction accuracy.

[0135] To verify the effectiveness of the proposed NSP-Tr-BiLSTM model for urban water supply prediction, two preprocessed datasets were used for analysis and prediction. Experiments were conducted using three models: Transformer, BiLSTM, and Transformer-BiLSTM, to verify the superiority of the proposed model. The predictive performance of the models was evaluated from different perspectives using four metrics: RMSE, R², MAE, and MAPE. All four models demonstrated good predictive performance, and the predicted curves closely matched the changes in the actual water supply curves. However, when sudden changes occurred in water supply from water plants, the models struggled to accurately and promptly adjust to the changes in the actual water supply value, easily leading to increased prediction errors. Figure 9 The predicted visualization results of water supply data from water plant A under different models were compared. A randomly selected peak value in the graph was magnified, revealing that the actual water supply on day 243 of the test set was 35.47 × 10⁻⁶. 3 m 3 The NSP-Tr-BiLSTM model predicted 35.79 × 10⁻⁶ on that day. 3 m 3 Compared to the other three models, the NSP-Tr-BiLSTM model proposed in this invention is closer to the true value at the peak. This can also be qualitatively observed in the magnified local plot, where the predicted value of the NSP-Tr-BiLSTM model (represented by the red line) is closer to the true value (represented by the cyan line). Figures 10-13 The figure shows a scatter plot of the predictions from each model on the water supply data of water plant A. It depicts the scatter plot of the actual values ​​and predicted values ​​on the test set. The scatter points form a tight linear cluster along the prediction line with a slope of y = x. The experimental results on the two water supply datasets are shown in the figure. Figure 14 The predicted visualization results of water supply data from water plant B under different models were compared. A randomly selected peak value in the graph was magnified, revealing that the actual water supply on day 354 of the test set was 151.74 × 10⁻⁶. 3 m3 The NSP-Tr-BiLSTM model predicted 153.52 × 10⁻⁶ units on that day. 3 m 3 Compared to the other three models, the NSP-Tr-BiLSTM model predicts values ​​that are closer to the true values ​​at the peak. Figures 15-18 This is a scatter plot of predictions from each model based on the water supply data from water plant B.

[0136] The model was compared with three classic prediction models on two water supply datasets. The RMSE, MAE, MAPE, and R² values ​​for water plants A and B under different models are shown in Tables 3 and 4, respectively. As can be seen from the tables, the non-stationary sensing Transformer-BiLSTM model outperforms the original Transformer-BiLSTM model and individual models in all metrics, especially in terms of root mean square error (RMSE) and mean absolute percentage error (MAPE), showing significant performance improvements. Table 3 shows that in the test results for water plant A dataset, NSP-Tr-BiLSTM improved RMSE, MAE, and MAPE by 27.5%, 6.2%, and 4.5% compared to Tr-BiLSTM, respectively. Furthermore, the R² coefficient of NSP-Tr-BiLSTM was also higher than the other three models. Table 4 shows that in the test results for water plant B dataset, NSP-Tr-BiLSTM improved RMSE, MAE, and MAPE by 16.6%, 10.9%, and 0.9% compared to Tr-BiLSTM, respectively. Meanwhile, the R-coefficient of NSP-Tr-BiLSTM is also higher than that of the other three models.

[0137]

[0138]

[0139] Experimental results show that the NSP-Tr-BiLSTM model proposed in this invention consistently outperforms traditional Transformer, LSTM, and the original Transformer-BiLSTM models on both urban water supply datasets. Visualized prediction results and scatter plots demonstrate that this model can more accurately capture actual water usage trends. In multiple evaluation metrics, NSP-Tr-BiLSTM achieves significant improvements compared to Tr-BiLSTM, particularly in RMSE and MAPE. Improvements of 27.5% and 4.5% are achieved on water plant A data, respectively, and improvements of 16.6% and 0.9% are achieved on water plant B data, respectively. Furthermore, the higher R² value further indicates its stronger fitting ability.

Claims

1. A city water supply prediction method based on a non-stationary perception Transformer-BiLSTM model, characterized in that, Includes the following steps: S1: Collect historical daily water consumption data of the water supply network and perform preprocessing, including using STL decomposition residual method, Isolation Forest method and sliding window Z-score method to perform multi-method fusion anomaly detection on the data. If any two methods determine that the data is abnormal, the data is marked as an outlier and removed. S2: Perform nonstationarity analysis on the preprocessed historical daily water consumption data; S3: Perform non-stationary information processing, use the Reversible Instance Normalization (RevIN) technique to standardize the input sequence at the instance level, and use Discrete Cosine Transform (DCT) to convert the original daily water consumption data in the time domain to the frequency domain and filter out high-frequency noise components. S4: Construct a non-stationary sensing Transformer-BiLSTM model, which consists of an encoder and a decoder; S5: Divide the historical daily water consumption data after non-stationary information processing into training set and validation set, and input them into the non-stationary perception Transformer-BiLSTM model for supervised training. S6: Input the historical daily water consumption data preprocessed in step S1 into the trained non-stationary perception Transformer-BiLSTM model, and output the predicted daily water consumption of the city in the future for a specified time window.

2. The urban water supply prediction method based on the non-stationary perception Transformer-BiLSTM model according to claim 1, characterized in that, In step S1, the specific strategy for multi-method fusion anomaly detection is as follows: first, the data is detected using the STL decomposition residual method to obtain a first set of anomalies; then, the data is detected using the Isolation Forest method to obtain a second set of anomalies; finally, the data is detected using the sliding window Z-score method to obtain a third set of anomalies. For each data point, if it appears more than or equal to twice in the three outlier sets, it is ultimately determined to be an outlier.

3. The urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model according to claim 2, characterized in that, The step S1, STL decomposition residual method in The output at the moment is: ; ; wherein, is a seasonal term, is a trend term, is a residual term, is the output at time t, is the median of the set of The statistics of the residual error is calculated and compared with a critical value. If the statistics is greater than the critical value, the value is determined to be an outlier. The critical value The calculation formula is: ; wherein, is the number of samples, is the lag order, denotes the degrees of freedom is the lower confidence level, is the distribution critical value.

4. The urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model according to claim 2, characterized in that, In step S1, anomaly scoring in the Isolation Forest method The calculation formula is: ; wherein, is a sample value, is a number of samples, is an average value of is a path length normalization constant, , is a harmonic number of order is measured by the number of edges traversed from the root node to the iTree. is measured by the number of edges traversed from the root node to the iTree.

5. The urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model according to claim 2, characterized in that, In step S1, the formula for calculating the standard score in the sliding window Z-score method is as follows: ; in, Represents standard scores. Let be the observation value at time t. The sample mean. This represents the sample standard deviation.

6. The urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model according to claim 1, characterized in that, The specific process of step S2 is as follows: S21: Using Local Fast Fourier Transform (FFT) analysis, the spectrum of the data sequence is calculated within a sliding window, and the non-stationarity of the data is qualitatively judged by the change in the dominant frequency distribution; S22: Further, the KPSS test method is used to quantitatively determine the stationarity of the data series by judging whether the test statistic exceeds the critical value at the significance level. The calculation formula is as follows: ; in, Let be the cumulative residual at time t. It is an estimator of the long-term variance. This represents the sample length.

7. The urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model according to claim 1, characterized in that, In step S3, the Reversible Instance Normalization (RevIN) technique is used to normalize the input sequence at the instance level, and the inverse operation is performed after the model output. The normalization formula is as follows: ; in, It is the normalized value. Let k be the k-th feature of the i-th sequence in the mini-batch at time t. and The mean and variance are calculated along the time dimension. For learnable affine parameters, It is the numerical stability constant; The inverse normalization formula is as follows: ; in, These are the model's predicted values. Output for the model.

8. The urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model according to claim 7, characterized in that, In step S3, a Discrete Cosine Transform (DCT) is introduced, along with the basis functions of the one-dimensional DCT. for: ; in, It is the basis vector index. ∈{0,1,…, }, It is the total number of data points. It is the position number; Then the one-dimensional DCT is: ; in, For one-dimensional DCT spectrum, ∈ , For output, ∈ , for Length; Correspondingly, the inverse one-dimensional DCT is: ; in, The spectrum of inverse one-dimensional DCT; DCT is performed on the sequence of each channel to obtain frequency domain features. First, the spectral features are normalized layer by layer. Then, a nonlinear feature reconstruction capability is introduced through a two-layer fully connected neural network. Finally, the Sigmoid activation function is used to generate frequency domain weights to achieve adaptive adjustment of the response of each frequency channel. The frequency domain weights are modulated by multiplying the inverse one-dimensional DCT sequence element by element.

9. The urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model according to claim 8, characterized in that, In step S4, the encoder adopts the Transformer architecture and uses a self-attention mechanism to capture the complex long-term global dependencies in the daily water consumption data; the decoder adopts the Bi-Short Memory Network (BiLSTM) architecture and fuses forward and backward context information to capture the local details and short-term trends of the data. The non-stationary perceptual Transformer-BiLSTM model introduces a reversible normalization mechanism at both the input processing and encoder design levels. Before the original input sequence enters the backbone network, it is first normalized through the RevIN module. The RevIN module normalizes on an instance-by-instance basis, that is, each sample is normalized independently, and the mean and standard deviation of each sequence in the time dimension are extracted. Subsequently, the output after model processing is restored to the original data distribution through a matching inverse normalization step. A DCT transform module is introduced at the front end of the encoder to explore the potential frequency domain junctions in the time series. The DCT transform module projects the input time series signal onto a set of cosine bases, which enables the effective separation of periodic fluctuations and high and low frequency components in the sequence. By screening and selectively retaining the spectrum after DCT, the model focuses more on the trend part with long-term dependence characteristics and significant periodic terms. After normalization and frequency domain transformation, the feature sequence is first input into the encoder. The Transformer models long-distance dependent features in the sequence through a global attention mechanism and further improves the ability to recognize periodic patterns by combining the introduced periodic-aware position encoding. Subsequently, BiLSTM further explores local temporal patterns and dynamic change trends. Its bidirectional structure makes full use of contextual information, which helps to model short-term fluctuations in detail.

10. The urban water supply prediction method based on the non-stationary sensing Transformer-BiLSTM model according to claim 1, characterized in that, In step S5, the model uses the mean squared error (MSE) between the predicted and true values ​​as the main loss function, employs the Adam optimizer for parameter optimization, and uses an early stopping mechanism to prevent overfitting until the model achieves optimal performance on the validation set.

Citation Information

Cited By

  • Intelligent cooperative regulation and control method and system for coal mine underground water treatment and refilling

    CN121948588A