Water supply network whole-flow water demand prediction method based on space-time diagram neural network
The water demand prediction method for water supply pipeline network is constructed through the spatio-temporal graph neural network, which solves the problem of insufficient modeling of spatial dependence between sensor nodes, and realizes efficient water demand prediction of water supply system, improving prediction accuracy and system adaptability.
Patent Information
- Application Number
- CN202510874899.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-27
- Publication Date
- 2025-08-08
AI Technical Summary
Existing water volume prediction methods are difficult to accurately model non-stationary fluctuations and complex periodic patterns in water supply systems, and the lack of effective modeling of the spatial dependence between sensor nodes leads to insufficient prediction accuracy and adaptability.
Using a method based on a spatiotemporal graph neural network, a full connection adjacency matrix of sensor nodes is constructed through a multi-scale time feature extraction module, an adaptive graph learning module, a spatiotemporal fusion module and a multi-scale fusion module, and combined with Mix-hop graph convolution, the full process prediction of the water demand of the water supply pipeline network is achieved.
It improves the overall accuracy of water demand forecast and the operating efficiency of the water supply system, and can be flexibly applied to water supply pipelines in different regions to adapt to complex water supply system changes.
Smart Images

Figure CN120450158A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of water demand prediction for water supply networks, and specifically relates to a method for predicting water demand for the entire process of a water supply network based on a spatiotemporal graph neural network. Background Art
[0002] In recent years, with the continuous development of water supply network monitoring technology, sensors deployed at various locations in the water supply network can generate data with fine temporal resolution, facilitating near-real-time water demand monitoring. Based on this high-frequency spatiotemporal data, water demand forecasting has gradually become a key technical link in smart water systems, playing an important data support role in scenarios such as optimized scheduling, anomaly detection, and water supply planning. For example, a water plant's water supply plan can be dynamically formulated based on predicted future water demand to optimize resource allocation. At the same time, by comparing predicted water volume with actual monitored water volume, it can assist in identifying potential leaks in the water supply pipeline, improving the stability and reliability of system operation.
[0003] Existing water demand prediction methods mainly include: (1) Statistical methods, such as linear regression and autoregressive models, are widely used due to their simplicity and low computational overhead. They are suitable for processing small amounts of randomly distributed observational data. (2) Machine learning methods, including support vector machines, random forests, and artificial neural networks, can introduce nonlinear modeling mechanisms but usually rely on tedious feature engineering to achieve ideal prediction results; (3) Deep learning methods, including recurrent neural networks, long short-term memory networks, and convolutional neural networks, achieve automatic feature extraction and end-to-end prediction through multi-layer nonlinear mapping, improving the ability to model historical observation sequences of a single sensor.
[0004] However, existing methods still have the following shortcomings: (1) Statistical methods are limited by the assumptions of stationarity and linear trends, making it difficult to accurately model the non-stationary fluctuations, emergencies, and complex periodic patterns commonly found in water supply systems. (2) Machine learning methods are highly dependent on manual feature extraction and lack adaptability and generalization capabilities; (3) Deep learning methods mainly focus on the internal features of single-node time series and lack effective modeling of the spatial dependencies between different sensor nodes.
[0005] With the continuous expansion of sensor numbers and coverage, water demand forecasting in water supply networks faces increasingly complex challenges. There is an urgent need to develop methods with global modeling capabilities that can cover the entire water supply network's operational processes and meet the needs of dynamic prediction and optimization support for the entire process, from water plant production and distribution to terminal water use. Existing water demand forecasting methods are unable to effectively model both temporal and spatial structural characteristics, and have significant deficiencies in prediction accuracy and adaptability. This not only makes it difficult to effectively capture the dynamic dependencies between sensor nodes, but also leads to low overall modeling efficiency and limited prediction performance.
[0006] Therefore, there is an urgent need to introduce advanced methods that can jointly model spatiotemporal correlation characteristics and adapt to the collaborative prediction needs of large-scale sensor networks to improve the overall accuracy of water demand forecasting and the operating efficiency of the water supply system. Summary of the Invention
[0007] The present invention provides a method for predicting water demand in the entire process of a water supply network based on a spatiotemporal graph neural network. This method can significantly improve the overall accuracy of water demand prediction and the operating efficiency of the water supply system.
[0008] The present invention provides a method for predicting water demand in the entire process of a water supply network based on a spatiotemporal graph neural network, comprising: Preprocessing the historical observation data set collected by each sensor node in the water supply network to obtain a training set, a validation set, and a test set, and obtaining training samples from the training set. The training samples include input data and labels. The labels are preprocessed data sets corresponding to the time step to be measured, and the input data are preprocessed data sets for multiple time steps before the time step to be predicted. Constructing a training model, the training model includes a multi-scale time feature extraction module, an adaptive graph learning module, a spatiotemporal fusion module and a multi-scale fusion module, wherein the multi-scale time feature extraction module performs multi-scale extraction on the input data to obtain time features of multiple scales, the adaptive graph learning module constructs a fully connected adjacency matrix of each sensor node at different scales, retains the Top-k strong neighbors of the fully connected adjacency matrix to obtain sparse adjacency matrices of different scales, the spatiotemporal fusion module fuses the time features of multiple scales with the sparse adjacency matrices of corresponding scales to obtain multi-scale time dynamic features, the multi-scale fusion module assigns weights to each scale time dynamic feature and fuses them to obtain a multi-scale spatiotemporal feature representation, and the multi-scale spatiotemporal feature representation is convolved multiple times to obtain the predicted water demand at the time step to be measured; The training model is trained based on the training set through the loss function to obtain the water demand prediction model for each time step to be tested, and the time step to be tested is input into the corresponding water demand prediction model to obtain the corresponding predicted water demand.
[0009] Preferably, the method for obtaining the fully connected adjacency matrix of the current scale includes: The adaptive graph learning module includes a shared node embedding and a current-scale node embedding, performs element-wise multiplication on the shared node embedding and the current-scale node embedding to obtain a current-scale embedding representation of the node, introduces two sets of learnable parameters into the current-scale embedding representation of the node, and then constructs two different node representation matrices through a nonlinear activation function; An asymmetric matrix in a single direction is constructed based on two different node representation matrices, and the fully connected adjacency matrix of the current scale is obtained based on the asymmetric matrix in a single direction through an activation function.
[0010] Preferably, j Scaled fully connected adjacency matrix : , ,in, N is the number of sensors, To convert a single-direction asymmetric matrix Normalized to the activation function between [-1,1], is the activation function, and Respectively j Two different node representation matrices for each scale.
[0011] Preferably, the multi-scale extraction of the input data is performed based on the multi-scale time feature extraction module to obtain time features of multiple scales, including: The multi-scale time feature extraction module includes multiple scale time feature extraction sub-modules, which perform a one-dimensional convolution operation on the input data and map the single channel input to a high-dimensional feature space to obtain an initial feature tensor; The initial feature tensor is sequentially passed through multiple scale time feature extraction submodules to obtain multiple scale time features; Among them, each scale time feature extraction submodule includes a one-dimensional convolution branch and a maximum pooling branch. The time features of the previous scale are passed through the one-dimensional convolution branch and the maximum pooling branch respectively, and the convolution results and the maximum pooling results are added to obtain the time features of the current scale.
[0012] Preferably, a multi-scale spatiotemporal feature representation is obtained by assigning weights to each scale temporal dynamic feature through a multi-scale fusion module, and then fusing the weights to obtain the multi-scale spatiotemporal feature representation, including: The multi-scale fusion module is used to compress the temporal dynamic features of each scale to obtain the corresponding weight, and based on the obtained weight, the temporal dynamic features of each scale are weightedly aggregated to obtain a multi-scale spatiotemporal feature representation.
[0013] Preferably, the time dynamic features of each scale are compressed by a multi-scale fusion module to obtain corresponding weights, including: Multiple scale-time dynamic features are concatenated, and then average pooling is performed in the sensor node dimension to obtain a scale-feature pooling matrix. The scale-feature pooling matrix is input into a fully connected network for full connection, and then the weight of each scale-time dynamic feature is obtained through an activation function.
[0014] Preferably, the multi-scale spatiotemporal feature representation is convolved multiple times to obtain the predicted water demand at the time step to be measured, including: The fused multi-scale spatiotemporal feature representation is input into the first layer of 1×1 convolution to transform the feature dimension. Subsequently, the predicted water demand for the time step to be measured is generated through the 1×1 convolution layer.
[0015] Preferably, the method for obtaining the current scale time dynamic characteristics includes: Perform the first Mix-hop graph convolution on the sparse adjacency matrix of the current scale and the temporal features of the current scale; Perform a second Mix-hop graph convolution on the transpose of the sparse adjacency matrix of the current scale and the temporal features of the current scale; The results of the two Mix-hop graph convolutions are added together, and the features of the summed results are extracted along the time dimension through one-dimensional convolution to obtain the current scale time dynamic features.
[0016] Preferably, the j The result of the first Mix-hop graph convolution of the sparse adjacency matrix of the scale and the time feature of the current scale for: ,in, For the l The MLP weight matrix corresponding to the jump, β is a hyperparameter, For the j The diagonal matrix of scales, For the j The sparse adjacency matrix of scales, is the identity matrix, N is the number of sensor nodes, For the j The time features of the scale are L, and L is the maximum number of hops in the Mix-hop graph convolution.
[0017] Preferably, the historical observation data set collected by each sensor node in the water supply network is preprocessed to obtain a training set, a validation set, and a test set, including: Based on triple standard deviation, abnormal observation values of the traffic data of each sensor node are detected, and the abnormal observation values are marked as missing values. The missing values are completed using linear interpolation method and low-rank matrix tensor completion method. The completed data set is divided into initial training set, validation set and test set through sliding window, and the initial training set, validation set and test set are standardized to obtain training set, validation set and test set.
[0018] Compared with the prior art, the present invention has the following beneficial effects: The present invention utilizes an adaptive graph learning module to construct a fully connected adjacency matrix of sensor nodes of corresponding scales based on the time step to be measured and the input data during the training process. Compared with the prior art method of manually constructing a fully connected graph adjacency matrix, the present invention saves manpower while more accurately obtaining fully connected graphs at different scales, thereby accurately obtaining the strong connection relationship between sensor nodes at different time scales. It can also be flexibly applied to the full-process water demand prediction of water supply networks in different regions.
[0019] The present invention utilizes a multi-scale time feature extraction module to obtain time features at different time scales, and assigns weights to time features at different time scales through a multi-scale fusion module, thereby coordinating short-term fluctuation features and long-term dependency features for different time steps to be measured, thereby enabling a more accurate prediction of the corresponding water demand. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 This is an overall flow chart of a method for predicting water demand for the entire water supply network based on a spatiotemporal graph neural network, provided as a specific embodiment of the present invention.
[0021] Figure 2 The following is an architecture diagram of a method for predicting water demand in the entire water supply network based on a spatiotemporal graph neural network according to a specific embodiment of the present invention, wherein: Figure 2 (a) is the multi-scale time feature extraction module, Figure 2 (b) in the figure is the adaptive graph learning module. Figure 2 (c) in the figure is the spatiotemporal graph convolution module. Figure 2 (d) in the figure is a multi-scale fusion module. Figure 2 (e) in the figure is the prediction output module.
[0022] Figure 3 A flowchart of the Mix-hop graph convolution operation provided for a specific embodiment of the present invention.
[0023] Figure 4 This is a trend chart comparing the prediction performance of different models provided in a specific embodiment of the present invention at prediction steps (Horizon) from 1 to 24, where: Figure 4(a) in the figure is the relative root mean square error curve of each model. Figure 4 (b) is the correlation coefficient curve of each model. Figure 4 (c) in the figure is the mean absolute error curve of each model. DETAILED DESCRIPTION
[0024] The following will further illustrate the embodiments of the present invention with reference to the accompanying drawings and examples. It should be understood that the following examples and drawings are merely illustrative of the technical solutions of the present invention, intended to help understand its principles and implementations, and do not constitute a limitation on the scope of protection of the present invention. The scope of protection of the present invention shall be based on the content defined in the claims, and is not limited to the content described in the following specific embodiments.
[0025] The specific embodiment of the present invention provides a method for predicting water demand of the whole process of water supply network based on spatiotemporal graph neural network, such as Figure 1 and Figure 2 Shown, including: S1. Preprocess the historical observation data set collected by each sensor node in the water supply network to obtain the training set, validation set, and test set. The specific steps are as follows: S11, outlier removal and missing value processing; This embodiment collects historical observation data of each sensor node, that is, historical water flow data, recorded as ,in N Indicates the number of sensors, T Represents the length of the historical observation data set. For each sensor node, abnormal observation values are detected based on the principle of three times the standard deviation, that is, data that exceeds the range of three times the standard deviation above and below the mean is marked as abnormal and regarded as missing values. For missing data, a differentiated processing strategy is adopted according to the missing characteristics, that is, when the missing ratio is small and the missing pattern is randomly distributed, the linear interpolation method is used to fill in the missing data to maintain the continuity and simplicity of the data; when the missing ratio is large or there is a long time period and spatially continuous structural missing, the low-rank matrix / tensor completion method is used to make full use of the low-rank characteristics of the water supply network observation data in the time and space dimensions to restore the missing values. After processing the abnormal values and missing values, the preprocessed data set is obtained. .
[0026] S12, use sliding window to process the processed data set in chronological order Divide the data into training set, validation set and test set to ensure the rationality and time continuity of the data set division.
[0027] This embodiment can maintain the continuity of the time series by setting a sliding window, ensuring that the model can fully learn the dynamic evolution law of water demand changes. In one embodiment, the ratio of the training set, validation set and test set is 6:2:2.
[0028] S13. To improve the stability of model training, the observation sequence of each sensor node is standardized.
[0029] In this embodiment, for traffic data with positive and negative symmetric characteristics, the present invention adopts symmetric normalization to normalize the observation values of each node to The standardized formula is: ,in, Indicates the n sensor nodes at time step t The observed value of and where represents the absolute maximum and minimum values of the node during the observation period. Normalization parameters are fitted on the training set, and the fitted parameters are used to transform the training, validation, and test sets, respectively. After training, the model predictions need to be denormalized back to the original data range for subsequent evaluation.
[0030] S2. Based on the processed training data set, build a training model, such as Figure 2 As shown in the figure, the training model includes a multi-scale time feature extraction module, an adaptive graph learning module, a spatiotemporal fusion module, a multi-scale fusion module and a prediction output module. Through the synergistic effect of each module, the temporal evolution characteristics and spatial dependence characteristics of the sensor nodes in the water supply network are fully extracted, and the dynamic modeling and high-precision prediction of the water demand change process of the water supply network are realized.
[0031] Among them, the multi-scale time feature extraction module provided by this embodiment is as follows: Figure 2 As shown in (a) in the figure, it is used to extract the characteristics of water demand changes at multiple time scales; Adaptive graph learning module: Figure 2 As shown in (b), it is used to dynamically learn the spatial structural relationship between nodes; spatiotemporal fusion module: Figure 2 As shown in (c), it is used to jointly model the local characteristics of space and time; multi-scale fusion module: Figure 2 As shown in (d) in the figure, it is used to enhance the collaboration between features of different scales; prediction output module: Figure 2 As shown in (e) in the figure, the full-process water demand prediction for the specified step size in the future is completed.
[0032] like Figure 2As shown in (a), the multi-scale time feature extraction module provided by this embodiment includes multiple scale time feature extraction sub-modules, which perform a one-dimensional convolution operation on the input data, map the single-channel input to the high-dimensional feature space to obtain an initial feature tensor; the initial feature tensor is sequentially passed through multiple scale time feature extraction sub-modules to obtain time features of multiple scales; wherein, each scale time feature extraction sub-module includes a one-dimensional convolution branch and a maximum pooling branch, and the time features of the previous scale are respectively passed through the one-dimensional convolution branch and the maximum pooling branch, and the convolution results and the maximum pooling results are summed to obtain the time features of the current scale.
[0033] The input data of the multi-scale time feature extraction module provided in this embodiment is ,in N is the number of sensors, To input the time window length, in order to adapt to the three-dimensional input format required by the one-dimensional convolutional network (Conv1D), a channel dimension needs to be added to the front end to expand it to , then, a one-dimensional convolution operation with a 1×1 convolution kernel is performed to map the single-channel input to a high-dimensional feature space to obtain the initial feature tensor ,in is the number of feature channels at the initial scale. This process realizes the conversion from original observation to high-dimensional representation, providing a basis for subsequent multi-scale feature extraction.
[0034] The multi-scale temporal feature extraction module provided in this embodiment adopts a feature pyramid in a bottom-up manner, stacking multiple layers of one-dimensional convolution units in sequence, gradually expanding from a smaller temporal receptive field to a larger receptive field, and extracting local features at different time scales layer by layer to achieve temporal representation modeling from small scale to large scale. In one embodiment, each layer uses a convolution kernel of different sizes (such as 1×7, 1×6, 1×3), and sets the convolution stride to 2, and achieves downsampling of the time dimension through convolution operations. The feature extraction process of each layer can be expressed as: in, and Respectively j The convolution weights and bias parameters of the layer, is a nonlinear activation function, and Respectively j The input and output feature tensors of the layer, and Indicates the j The number of input and output channels of the layer, N Indicates the number of sensors, Indicates passing After the convolution layer To achieve multi-scale temporal feature extraction, each convolution operation uses a stride of 2, combined with an appropriate zero-filling strategy, so that the temporal resolution is halved at each layer. According to this rule, satisfy .
[0035] To enhance feature representation and avoid the loss of feature richness caused by a single convolution operation, this paper further introduces a parallel max-pooling branch at each scale. The max-pooling branch uses the same convolution kernel size and stride as the main convolution branch, and fuses the outputs of the two paths through a feature point addition operation. The feature extraction of each layer is updated as follows: ,in, Represents an element-by-element addition fusion operation. After the max pooling branch output, a 1×1 convolution kernel is used to adjust the channel dimension to match the main branch output to ensure fusion consistency.
[0036] This embodiment adopts the above-mentioned pyramid-like time feature extraction structure, which can fully adapt to the multi-time-scale water demand variation characteristics existing in the water supply network. On the one hand, a smaller receptive field helps to capture the short-term fluctuation characteristics caused by sudden water use behavior; on the other hand, a larger receptive field can extract long-term dependent characteristics such as periodic scheduling rules and trend changes. Through layer-by-layer downsampling and cross-scale modeling mechanisms, this structure can achieve collaborative modeling of short-term and long-term dynamics, significantly improving the generalization ability and accuracy of the model under different prediction ranges, and is particularly suitable for the whole process water demand prediction task from water plant outlet, scheduling valves to end users.
[0037] Compared to traditional single-scale modeling, this module can simultaneously capture both the short-term fluctuation characteristics and long-term trend information of water demand series at different time perception ranges, significantly enhancing the richness and expressiveness of temporal features. Furthermore, compared to methods based on recurrent neural networks such as RNN and LSTM, this module's multi-scale extraction architecture based on one-dimensional convolution has the following advantages: (1) Faster training speed, avoiding the gradient vanishing and exploding problems in long sequence processing; (2) It can extract the variation patterns at multiple time scales in parallel, improving the ability to capture complex periodicity and hydraulic fluctuation patterns; (3) The structure is simple and easy to expand, the number of parameters is small, and the reasoning efficiency is high.
[0038] In this embodiment, through the construction of a multi-scale time feature extraction module, the model can extract key time series information from short to long time periods from different time perception ranges, and gradually capture the multi-level evolution characteristics of the water demand series from local fluctuations to global trends. The resulting multi-scale time feature representation set It has good flexibility and expressiveness, and can comprehensively characterize the potential complex temporal pattern characteristics in the input data, providing rich and stable temporal feature support for subsequent spatial modeling and multi-step prediction tasks.
[0039] S22, such as Figure 2 As shown in (b), the fully connected adjacency matrix of each sensor node at different scales is constructed through the adaptive graph learning module, and the Top-k strong neighbors of the fully connected adjacency matrix are retained to obtain sparse adjacency matrices of different scales.
[0040] To further enhance the model's ability to model multi-scale dynamic structures, this step constructs scale-specific spatial graph structures based on the temporal features at different scales extracted by the temporal pyramid module. Because the dependencies between sensor nodes can differ significantly at different time scales (e.g., short-term correlations tend to be influenced by physical connections, while long-term correlations are more likely to reflect the influence of hydraulic scheduling or consumer habits), a separate adjacency matrix must be learned for each scale.
[0041] This step first uses the shared node embedding representation , combined with scale-specific temporal embedding representations , thereby perceiving the spatial differences in node behavior at different time scales and building a more accurate scale-specific graph structure. N Indicates the number of sensors, Represents the embedding dimension, for each scale j , the scale-specific node embedding is expressed as: ,in, Represents an element-by-element multiplication operation. By introducing a scale embedding mechanism, we can characterize the differences in node dependence on spatial structure at different time scales, thereby generating a more discriminative graph structure representation and avoiding the limitations of static adjacency matrices in modeling multi-scale features.
[0042] Next, we use scale-specific node embedding representations , calculate the similarity between sensor nodes to build a fully connected adjacency matrix. Specifically, it includes the following two steps: (1) Introducing two sets of learnable parameters and , the following expressions are used to construct the heterogeneous representation of nodes as the "sender" and "receiver" of information: ,in, and Respectively represent two different node representation matrices after nonlinear transformation, is a non-linear activation function.
[0043] (2) Construct scale by difference calculation and nonlinear normalization operation jThe fully connected adjacency matrix under : ,in, N Indicates the number of sensors, The function normalizes the difference to interval, The function retains the positive correlation and suppresses noise interference, and the final output is normalized to The fully connected adjacency matrix of the interval.
[0044] This construction method can effectively capture the asymmetric similarity structure between nodes. It is more flexible than traditional methods based on static correlation or distance measurement and can adapt to the graph structure modeling needs in complex dynamic hydraulic scenarios.
[0045] In order to reduce the computational complexity, Perform sparseness and keep each node Top-k Strong neighbors, get scale j The sparse graph adjacency matrix under : , , and finally obtain a set of scale-specific adaptive adjacency matrices , used for subsequent multi-scale spatial modeling.
[0046] The adaptive graph learning mechanism proposed in a specific embodiment of the present invention can automatically model the dynamic spatial relationships between nodes based on water demand observation data, avoiding reliance on static prior topological structures. Compared with traditional methods, this mechanism can more flexibly perceive the frequently changing time-varying flow patterns in water supply networks and is particularly suitable for spatial modeling needs in multi-node, complex operating states, and high-frequency disturbance scenarios. Through scale-specific adjacency matrix learning, the adaptive graph can also perform fine-grained modeling of spatial dependency characteristics at different time scales, further improving the model's generalization and robustness in water demand forecasting.
[0047] S23, such as Figure 2 As shown in (c), it is represented by multi-scale time features and scale-specific adaptive adjacency matrix sets The spatial structure characteristics and time evolution characteristics of the modeling nodes are jointly modeled to further extract rich spatiotemporal feature representations.
[0048] First, for the scale j , represented by features and the corresponding adjacency matrix As input, Mix-hop graph convolution is used to extract node spatial features, and the following two information propagation paths are executed in parallel: ,in, Representation scalej The graph convolution output features below, is the number of output channels, N is the number of sensors, is the time step. express Graph convolution operation, represents the element-wise additive fusion of the features of the two paths, Indicates information aggregation from "neighbor node → current node", emphasizing the influence of neighbors on the current node; Represents the reverse path from "current node → neighbor node", which can characterize the impact of a node on its neighbors. In real applications, sensor nodes in a water supply system may have asymmetric dependencies due to the upstream and downstream relationships of the water supply path (for example, the impact of water flow from A to B is not the same as from B to A). Therefore, unidirectional graph convolution cannot capture this relationship, and introduces and Can complete two-way information.
[0049] like Figure 3 As shown in the figure, the present invention uses Mix-hop graph convolution operations in the graph convolution process to replace the traditional single-order neighbor aggregation method, thereby enhancing the model's ability to represent high-order adjacency structures. Unlike traditional graph convolution that relies only on a fixed number of hops, Mix-hop graph convolution supports parallel execution of multi-hop message propagation in a single layer and integrates the feature information of neighbors of different orders through a fusion mechanism. Each hop propagation process consists of two steps: (1) Information propagation: The features of a node and its neighboring nodes are weighted and aggregated, and then fused with its own features to avoid the over-smoothing problem in traditional GCN. The propagation rules are as follows: ,in, Preserve the scale hyperparameter for the original features, Indicates the l The output feature representation of the jump, , , represents the identity matrix, Denotes the diagonal matrix, 𝑝 denotes the target node index, and 𝑞 denotes the neighbor node index connected to it. By summing the edge weights of all adjacent nodes 𝑞, the degree value of node 𝑝 is obtained, and the diagonal matrix required for normalization is constructed. .
[0050] (2) Information selection: The multi-layer perceptron (MLP) is used to perform weighted screening on each hop feature, highlighting key information and suppressing redundant features, thereby improving the generalization ability and stability of the model. The screening mechanism is as follows: ,in, For the l The MLP weight matrix corresponding to the jump, Indicates the j The output hidden state of the scale is L, the maximum number of hops in the Mix-hop graph convolution, and l represents the graph convolution layer corresponding to the l-th hop, which is used to capture the information of the l-th order neighbor nodes.
[0051] After the spatial feature extraction is completed, in order to further compress the time dimension and unify the feature dimension, one-dimensional convolution (Conv1D) is used to extract temporal dynamic features along the time dimension: , where the convolution kernel size is set to , that is, covering all time steps of the current scale, and realizing the dimensionality reduction operation from time series to single time point features. The final output feature , is the number of output feature channels.
[0052] Through the aforementioned spatiotemporal convolution module, specific embodiments of the present invention can fully extract the complex spatial structural characteristics and historical temporal evolution patterns between sensor nodes, establish multi-granular spatiotemporal correlations at different time scales, and provide rich information support for subsequent multiscale fusion and accurate prediction. Compared with traditional methods based on static adjacency matrices or single-scale modeling, the proposed spatiotemporal convolution structure has greater adaptability and predictive accuracy, especially in scenarios with frequent changes in water supply demand and dynamic changes in spatial topology.
[0053] S24, such as Figure 2 As shown in (d) in the figure, the multi-scale spatiotemporal feature representation is obtained by fusion of the time dynamic features at each scale by assigning weights to them through the multi-scale fusion module. This embodiment integrates the spatiotemporal feature information extracted at different time scales to further improve the modeling capability of multi-period water demand variation patterns in the water supply network, including: First, the spatiotemporal features extracted at each scale are represented as Splicing is performed along the newly introduced scale dimension to form a preliminary multi-scale feature tensor: , where the concatenated tensor is H With size , J is the scale number, is the number of output channels, N is the number of nodes. Then, average pooling is performed along the node dimension (i.e., sensor dimension) to extract the global features of each scale in space and obtain the scale feature pooling matrix Next, Input to a fully connected neural network (Linear Layer), output a scale importance score vector, that is, the weight of each scale , normalized to Range: ,in, Representation scale j The corresponding feature contribution weight.
[0054] Finally, using the obtained scale weights , the feature representation of each scale Perform weighted aggregation to form the final fused feature representation : ,in, Represents the fused multi-scale representation.
[0055] In the present invention, the introduction of the multi-scale fusion module has the following significant advantages: (1) It effectively integrates the short-term local fluctuation characteristics and the long-term trend change characteristics to comprehensively model the multi-period dynamic pattern in the water demand series; (2) By introducing a scale importance scoring mechanism (Soft Gating), the assumption of uniform scale contribution caused by traditional simple splicing or average fusion is overcome, and the contribution ratio of each scale feature can be dynamically adjusted according to actual needs; (3) The model’s adaptability to the dynamic characteristics of the water supply network at different times is enhanced, and the accuracy and robustness of water demand prediction under complex supply and demand changing environments are improved.
[0056] S25. Perform multiple convolutions on the multi-scale spatiotemporal feature representation to obtain the predicted water demand at the time step to be measured, and generate the water demand prediction results of each sensor node in the future time step.
[0057] First, the fused multi-scale spatiotemporal features are represented as The input is sent to the first layer of 1×1 convolution (Conv1D), the feature dimension is transformed, and it is projected to the target output channel number. Then, the final prediction result is generated through the 1×1 convolution layer. , that is, predict the future h The water demand value of the step.
[0058] S3. After completing the construction of the training model, in order to achieve multi-step prediction of future water demand, a direct multi-step prediction strategy is adopted to gradually train and optimize the model parameters to improve the prediction accuracy and generalization ability of the system.
[0059] First, for each future prediction step , the present invention constructs training models respectively and performs corresponding independent training on them. Each training model is based on historical P Step observation data sequence As input, output is the predicted value for the next ℎ steps: ,in, represents the prediction function at step ℎ, For the first hThe learnable parameters are optimized in one step.
[0060] During the training process, the training model of each prediction step is optimized independently. h Step prediction, define the corresponding loss function It is the L2 loss (mean square error) form of the corresponding prediction error, which is used to measure the deviation between the prediction result and the true observation value: ,in, represents the number of training samples, N represents the number of sensor nodes, and Respectively h Step prediction sensor n At the moment t The predicted value and the true value of each sub-model. The mini-batch gradient descent method is used for optimization. The optimizer is Adam, the initial learning rate is 0.001, the batch size is 8, the maximum number of training rounds is 100, and an early stopping mechanism is introduced. When the validation set loss does not improve significantly for 15 consecutive rounds, the training process is terminated early.
[0061] To further improve the overall prediction performance, after training is completed, the present invention identifies and optimizes the key hyperparameters that have a significant impact on the prediction effect. A grid search strategy is used to jointly tune the following core parameters: (1) Input sequence length : Determine the historical observation time range that the model relies on, and set the candidate range as {96, 128, 168, 192}; (2) Convolution channel size C : Controls the expressiveness of multi-scale temporal and spatial features, with a setting range of {32, 64, 128}; (3) Number of neighbor nodes k : The number of spatial connections retained by each node during the influence graph learning process, the setting range is {10, 15, 20, 30}; (4) Graph convolution depth L : Controls the number of information propagation layers of Mix-hop GCN, and the setting range is {2, 3, 4}.
[0062] Through the joint tuning of the above-mentioned key hyperparameters, the present invention can flexibly configure the model structure according to different prediction step sizes and pipeline network operating environments, take into account both local dynamics and overall trends in complex scenarios, and improve overall prediction accuracy and model robustness.
[0063] After training is completed, the model obtained in the training set is used for validation set testing, and the model parameters that achieve the best effect on the validation set are selected as the final model for actual deployment and prediction.
[0064] S4. After completing the training and parameter optimization of the training model at each time step, dynamic prediction of future water demand is performed based on the trained water demand prediction model set.
[0065] During the entire inference process, the model structure and parameters remain frozen, no gradient updates are performed, and only forward inference operations are performed. Specifically, for each future prediction step , respectively call the trained model to make predictions and obtain the corresponding output ,in N is the number of sensors. H After the prediction of the future steps, the output results of each step are spliced in sequence to obtain a complete future multi-step water demand prediction sequence: Through this step, it is possible to accurately predict the water demand change trend of each sensor node in multiple time steps in the future based on the current water supply network observation data, providing real-time and forward-looking data support for the production scheduling, operation optimization and anomaly identification of the water supply system.
[0066] The effectiveness and superiority of the present invention are verified by a water demand dataset from an actual water supply network in a city in northern China. The dataset covers observation data from 54 sensor nodes for one consecutive year (the time span is from September 1, 2023 to August 31, 2024), and collects instantaneous flow rate / water demand values at intervals of 15 minutes. The sensors cover the entire process of the water supply network, including 4 water plant outlet flow meters, 3 regulating valve flow meters, 18 pipeline flow meters and 29 end-user flow meters. In order to fully verify the water demand prediction model proposed in this invention, namely the prediction performance of the multi-scale spatiotemporal graph neural network (hereinafter referred to as MSTGNN) method, we selected the following typical comparative methods to carry out experiments, including: A statistical method, namely the Autoregressive Integrated Moving Average (ARIMA) model; a traditional machine learning method, namely the K-Nearest Neighbors algorithm (KNN); a univariate deep learning method, namely the Long Short-Term Memory (LSTM) network; and three advanced multivariate deep learning methods based on graph structures, namely the Spatio-Temporal Graph Convolutional Network (STGCN), the Attention-based Spatio-Temporal Graph Convolutional Network (ASTGCN), and the Adaptive Graph Convolutional Recurrent Network (AGCRN).
[0067] Based on existing research results, we constructed a static adjacency graph based on the Pearson correlation coefficient between historical sensor observation sequences, which was used as the input graph structure of STGCN and ASTGCN. During the training process, we fitted the model on the training set, tuned the hyperparameters of each method on the validation set, and finally uniformly evaluated its prediction performance on the test set. The prediction accuracy evaluation indicators used are relative root mean square error (RRSE), empirical correlation coefficient (CORR) and mean absolute error (MAE). The experiment covers prediction steps of 1 to 24 steps, corresponding to the water demand prediction task for the next 15 minutes to 6 hours. We further counted and analyzed the indicator values of different methods under 8 key prediction steps (see Table 1 for details), and Figure 4 (a) in the equation, Figure 4 (b) and Figure 4 (c) shows the overall prediction trend and performance of various deep learning methods within the range of all 24 prediction steps.
[0068] Table 1 Comparison of prediction performance of different prediction methods
[0069] Note: The bold and underlined columns in the table indicate the methods that achieve the optimal and suboptimal prediction performance, respectively, at the corresponding prediction step size. Smaller RRSE and MAE values indicate lower prediction errors and better performance, while larger CORR values indicate stronger correlation between the model and the true value and better prediction results.
[0070] From Table 1 and Figure 4(a) in the equation, Figure 4 (b) and Figure 4 The results in (c) show that the proposed method, MSTGNN, outperforms the comparison methods across most forecast step sizes, demonstrating high accuracy and stability in short-, medium-, and long-term forecasting tasks, demonstrating excellent spatiotemporal modeling capabilities. Specifically, MSTGNN generally outperforms the static graph-based STGCN, ASTGCN, and graph-learning-based AGCRN in error metrics such as RRSE and MAE, demonstrating the advantages of its integration of multi-scale modeling and graph adaptation. During multi-step forecasting, compared to time series models such as LSTM, MSTGNN exhibits a slower performance decline in medium- and long-term forecasting, demonstrating stronger generalization and long-term dependency modeling capabilities. Furthermore, traditional statistical models (such as ARIMA) and machine learning methods (such as KNN) exhibit poor overall forecasting performance, demonstrating their significant shortcomings in accommodating the complex nonlinear dependencies and multi-sensor coupling characteristics of water supply systems. Comprehensive evaluation demonstrates that the proposed method improves forecast accuracy while also exhibiting excellent cross-temporal stability and model adaptability.
Claims
1. A method for predicting water demand in the entire process of a water supply network based on a spatiotemporal graph neural network, characterized in that: include: Preprocessing the historical observation data set collected by each sensor node in the water supply network to obtain a training set, a validation set, and a test set, and obtaining training samples from the training set. The training samples include input data and labels. The labels are preprocessed data sets corresponding to the time step to be measured, and the input data are preprocessed data sets for multiple time steps before the time step to be predicted. Constructing a training model, the training model includes a multi-scale time feature extraction module, an adaptive graph learning module, a spatiotemporal fusion module and a multi-scale fusion module, wherein the multi-scale time feature extraction module performs multi-scale extraction on the input data to obtain time features of multiple scales, the adaptive graph learning module constructs a fully connected adjacency matrix of each sensor node at different scales, retains the Top-k strong neighbors of the fully connected adjacency matrix to obtain sparse adjacency matrices of different scales, the spatiotemporal fusion module fuses the time features of multiple scales with the sparse adjacency matrices of corresponding scales to obtain multi-scale time dynamic features, the multi-scale fusion module assigns weights to each scale time dynamic feature and fuses them to obtain a multi-scale spatiotemporal feature representation, and the multi-scale spatiotemporal feature representation is convolved multiple times to obtain the predicted water demand at the time step to be measured; The training model is trained based on the training set through the loss function to obtain the water demand prediction model for each time step to be tested, and the time step to be tested is input into the corresponding water demand prediction model to obtain the corresponding predicted water demand.
2. The method for predicting water demand of the entire water supply network based on spatiotemporal graph neural network according to claim 1 is characterized in that: The method for obtaining the fully connected adjacency matrix of the current scale includes: The adaptive graph learning module includes a shared node embedding and a current-scale node embedding, performs element-wise multiplication on the shared node embedding and the current-scale node embedding to obtain a current-scale embedding representation of the node, introduces two sets of learnable parameters into the current-scale embedding representation of the node, and then constructs two different node representation matrices through a nonlinear activation function; An asymmetric matrix in a single direction is constructed based on two different node representation matrices, and the fully connected adjacency matrix of the current scale is obtained based on the asymmetric matrix in a single direction through an activation function.
3. The method for predicting water demand of the entire water supply network based on spatiotemporal graph neural network according to claim 2 is characterized in that: No. j Scaled fully connected adjacency matrix : , ,in, N is the number of sensors, To convert a single-direction asymmetric matrix Normalized to the activation function between [-1,1], is the activation function, and Respectively j Two different node representation matrices for each scale.
4. The method for predicting water demand of the entire water supply network based on spatiotemporal graph neural network according to claim 1 is characterized in that: Based on the multi-scale temporal feature extraction module, the input data is subjected to multi-scale extraction to obtain temporal features of multiple scales, including: The multi-scale time feature extraction module includes multiple scale time feature extraction sub-modules, which perform a one-dimensional convolution operation on the input data and map the single channel input to a high-dimensional feature space to obtain an initial feature tensor; The initial feature tensor is sequentially passed through multiple scale time feature extraction submodules to obtain multiple scale time features; Among them, each scale time feature extraction submodule includes a one-dimensional convolution branch and a maximum pooling branch. The time features of the previous scale are passed through the one-dimensional convolution branch and the maximum pooling branch respectively, and the convolution results and the maximum pooling results are added to obtain the time features of the current scale.
5. The method for predicting water demand of the entire water supply network based on spatiotemporal graph neural network according to claim 1 is characterized in that: The multi-scale spatiotemporal feature representation is obtained by assigning weights to each scale temporal dynamic feature through the multi-scale fusion module, including: The multi-scale fusion module is used to compress the temporal dynamic features of each scale to obtain the corresponding weight, and based on the obtained weight, the temporal dynamic features of each scale are weightedly aggregated to obtain a multi-scale spatiotemporal feature representation.
6. The method for predicting water demand in the entire water supply network based on spatiotemporal graph neural network according to claim 5 is characterized in that: The multi-scale fusion module compresses the temporal dynamic features of each scale to obtain the corresponding weights, including: Multiple scale-time dynamic features are concatenated, and then average pooling is performed in the sensor node dimension to obtain a scale-feature pooling matrix. The scale-feature pooling matrix is input into a fully connected network for full connection, and then the weight of each scale-time dynamic feature is obtained through an activation function.
7. The method for predicting water demand of the entire water supply network based on spatiotemporal graph neural network according to claim 1 is characterized in that: The multi-scale spatiotemporal feature representation is convolved multiple times to obtain the predicted water demand at the time step to be tested, including: The fused multi-scale spatiotemporal feature representation is input into the first layer of 1×1 convolution to transform the feature dimension. Subsequently, the predicted water demand for the time step to be measured is generated through the 1×1 convolution layer.
8. The method for predicting water demand of the entire water supply network based on spatiotemporal graph neural network according to claim 1 is characterized in that: Methods for obtaining the current scale temporal dynamic characteristics include: Perform the first Mix-hop graph convolution on the sparse adjacency matrix of the current scale and the temporal features of the current scale; Perform a second Mix-hop graph convolution on the transpose of the sparse adjacency matrix of the current scale and the temporal features of the current scale; The results of the two Mix-hop graph convolutions are added together, and the features of the summed results are extracted along the time dimension through one-dimensional convolution to obtain the current scale time dynamic features.
9. The method for predicting water demand in the entire process of a water supply network based on a spatiotemporal graph neural network according to claim 8 is characterized in that: The first j The result of the first Mix-hop graph convolution of the sparse adjacency matrix of the scale and the time feature of the current scale for: ; ; ; in, For the l The MLP weight matrix corresponding to the jump, β is a hyperparameter, For the j The diagonal matrix of scales, For the j The sparse adjacency matrix of scales, is the identity matrix, N is the number of sensor nodes, For the j The time features of the scale are L, and L is the maximum number of hops in the Mix-hop graph convolution.
10. The method for predicting water demand of the entire water supply network based on spatiotemporal graph neural network according to claim 1 is characterized in that: The historical observation data sets collected by each sensor node in the water supply network are preprocessed to obtain training sets, validation sets, and test sets, including: Based on triple standard deviation, abnormal observation values of the traffic data of each sensor node are detected, and the abnormal observation values are marked as missing values. The missing values are completed using linear interpolation method and low-rank matrix tensor completion method. The completed data set is divided into initial training set, validation set and test set through sliding window, and the initial training set, validation set and test set are standardized to obtain training set, validation set and test set.
Citation Information
Cited By
Non-metering residential area water demand prediction method and device based on adversarial domain adaptive neural network
CN121981421A
A collaborative verification method for water demand at nodes in a water supply network that integrates graph neural networks and mechanistic models
CN122572740A