A single-node flow prediction method for water supply network based on wavelet real-time decomposition and iTransformer model

Through the combination of wavelet real-time decomposition and iTransformer model, the problems of data leakage and feature capture in the prediction of high-frequency data of short-term fluctuations in water supply networks are solved, and the prediction accuracy of single-node flow in water supply networks is improved, which is suitable for the refined management of large-scale water supply networks.

CN120234615BActive Publication Date: 2025-09-30ANHUI UNIVERSITY OF ARCHITECTURE
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510370855.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-03-27
Publication Date
2025-09-30
Estimated Expiration
2045-03-27

AI Technical Summary

Technical Problem

The existing technology has problems in predicting high-frequency data of short-term fluctuations in water supply networks, such as overall decomposition, which easily leads to data leakage and difficulty in accurately capturing data features, affecting the prediction accuracy.

Method used

A combination method of wavelet real-time decomposition and iTransformer model is adopted. The data is decomposed into high-frequency detail components and low-frequency approximate components through sliding window and wavelet decomposition technology, and prediction models are constructed for each component. The iTransformer model is used to capture the correlation of water use behavior between nodes, and single-feature and multi-feature neural network models are constructed for prediction.

Benefits of technology

It avoids the problem of data leakage, improves the prediction accuracy of high-frequency detail components, and enhances the prediction ability of single-node flow in the water supply network, making it suitable for the refined management of large-scale water supply networks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120234615B_ABST
    Figure CN120234615B_ABST
Patent Text Reader

Abstract

The present invention belongs to the technical field of water demand forecasting for water supply networks, and specifically relates to a single-node flow forecasting method for water supply networks based on real-time wavelet decomposition and an iTransformer model. This method first obtains historical flow data for all nodes in the water supply network and selects similar node clusters using a correlation coefficient method. The flow data is then decomposed into local approximate components and detail components using a sliding window and wavelet decomposition technique, and the single-node data is subjected to global wavelet decomposition. Subsequently, single-feature and multi-feature iTransformer models are constructed to predict the approximate and detail components, respectively. Finally, the prediction results are summed to obtain a single-node flow forecast value. This method improves the accuracy and adaptability of water supply network flow forecasting, effectively resolving the issues of data leakage and limited prediction accuracy in existing technologies, and is therefore suitable for the technical field of water demand forecasting for water supply networks.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of water demand prediction for water supply pipe networks, and in particular relates to a single-node flow prediction method for water supply pipe networks based on wavelet real-time decomposition and an iTransformer model. Background Art

[0002] With the continuous acceleration of urbanization, the operational load of water supply networks is increasing. Water demand forecasting plays a leading role in the operation, management, and scheduling of water supply networks. However, water use behavior is influenced by multiple factors, such as seasonal variations, weather conditions, and resident habits. This makes water demand data highly random and uncertain. Furthermore, water demand data often exhibits complex nonlinear and chaotic characteristics, posing significant challenges to forecasting. Therefore, establishing accurate forecasting models is crucial for improving the accuracy of water demand forecasting.

[0003] Water demand forecasting models for water supply networks are primarily categorized into three types: physical models, statistical models, and machine learning methods. Physical models abstract influencing factors such as water pressure, flow rate, and flow velocity into corresponding mathematical models. These parameters are monitored in real time through sensors deployed throughout the water supply network, enabling real-time water demand forecasting. Statistical models leverage statistical knowledge to estimate future water demand by analyzing, fitting, and trend-forecasting historical water usage data. Common statistical models include the differential autoregressive moving average model. However, due to the non-stationary and seasonal variations in water demand data, accurate forecasts can be difficult to obtain using traditional time series models alone. In addition to traditional physical and statistical models, while machine learning algorithms have improved forecasting accuracy to some extent, their ability to handle short-term, high-frequency data and adaptability to real-time data still needs improvement. Existing methods, particularly for large-scale water supply networks, often struggle to accurately forecast flow at individual nodes, failing to meet the demands of refined network operation and management. Summary of the Invention

[0004] The purpose of the present invention is to provide a single-node flow prediction method for a water supply network based on real-time wavelet decomposition and iTransformer model, so as to solve the problem in the prior art that when predicting high-frequency data of short-term fluctuations in the water supply network, the overall decomposition easily leads to data leakage and it is difficult to accurately capture data features, thereby affecting the prediction accuracy.

[0005] The present invention achieves the above-mentioned purpose through the following technical solutions:

[0006] The present invention proposes a single-node flow prediction method for a water supply network based on real-time wavelet decomposition and an iTransformer model. The method comprises the following steps:

[0007] S1. Obtain historical flow data of all nodes in the water supply network;

[0008] S2. Select a single node and calculate the correlation between the node and other nodes to obtain a cluster of similar nodes;

[0009] S3. Divide the traffic data in the similar node cluster into a training set and a test set;

[0010] S4. Decompose the training set and test set using sliding window and wavelet decomposition technology to obtain local approximate components and detail components of all nodes, and perform global wavelet decomposition on the data of a single node in the training set to obtain the global approximate component and global detail component of the single node;

[0011] S5. Construct a single-feature iTransformer model, use the local and global approximate components of a single node in the training set as training sample inputs, and predict the approximate component; and construct a multi-feature iTransformer model, use the local detail components of all nodes in the training set and the global detail component of a single node as training sample inputs, and predict the detail component;

[0012] S6. Sum the approximate component prediction value and the detail component prediction value to obtain the traffic prediction value of a single node.

[0013] Furthermore, step S2 includes:

[0014] S201, randomly selecting a single node, and sequentially calculating the Pearson correlation coefficient of historical traffic data between the single node and all other nodes;

[0015] S202 , setting a correlation coefficient threshold, grouping nodes whose correlation coefficients with the single node are greater than the threshold with the single node as the center, and obtaining historical traffic data of similar node clusters of the single node.

[0016] Furthermore, step S4 includes:

[0017] S401, defining a sliding window of length l, and using the sliding window to obtain multiple sets of data from the training set and the test set of all nodes in the similar node cluster;

[0018] S402, using the db2-based wavelet and determining its low-pass filter coefficient h0 and high-pass filter coefficient g0;

[0019] S403: Perform convolution operation to calculate the approximate components of each set of data and detail content Where i represents the current position index of the input signal in the convolution operation, k represents the index of the filter coefficient, and * represents the convolution operation;

[0020] S404: Downsampling is performed on the approximate component cA[i] and the detail component cD[i]. The formula includes:

[0021] cA[j]=cA[2j+1], cD[j]=cD[2j+1]

[0022] Where j represents the index after downsampling;

[0023] S405 , after performing the above S402 - S404 decomposition once, obtain the local approximate components and detail components of all nodes, as well as the overall approximate components and overall detail components of a single node.

[0024] Furthermore, in step S5, the single-feature iTransformer model is constructed, and the local and global approximate components of a single node in the training set are used as training sample inputs to predict the approximate components, including:

[0025] S501, constructing a single-feature neural network model including an embedding layer, a coding layer, and a projection layer connected in sequence;

[0026] S502: Using the local approximate component of a single node in the training set as a training sample input and the overall approximate component of the single node as a training sample label to train a single-feature neural network model;

[0027] S503: Input the local approximate component of a single node in the test set into a trained single-feature neural network model to obtain a predicted value of the approximate component of the single node.

[0028] Furthermore, in step S5, the multi-feature iTransformer model is constructed, and the local detail components of all nodes in the training set and the global detail components of a single node are used as training sample inputs to predict the detail components, including:

[0029] S511, constructing a multi-feature neural network model including an embedding layer, an encoding layer, and a projection layer connected in sequence;

[0030] S512, using the local detail components of all nodes in the training set and the global detail components of a single node as training sample inputs, and the global detail components of a single node as training sample labels, to train a multi-feature neural network model;

[0031] S513: Input the local detail components of all nodes in the test set into the trained multi-feature neural network model to obtain the predicted value of the detail component of the single node.

[0032] Furthermore, in the single-feature neural network model, constructing the encoding layer includes constructing a self-attention layer, a residual connection layer, a normalization layer, a feedforward network layer, and a residual connection layer, and constructing the self-attention layer includes using the output of the embedding layer as the input of the self-attention layer:

[0033]

[0034] output2=softmax(scores1)*Values1

[0035] Among them, Queries1, Keys1 and Values1 are output1, which represents the input data of the self-attention layer, and output2 represents the output of the self-attention layer.

[0036] Furthermore, in the multi-feature neural network model, constructing the encoding layer includes constructing a multi-head self-attention layer, a residual connection layer, a normalization layer, a feedforward network layer, and a residual connection layer. The multi-head self-attention layer is used to capture the association between different feature variables. Constructing the multi-head self-attention layer includes:

[0037] Use the output of the embedding layer as the input of the multi-head self-attention layer;

[0038] Compute the attention scores for each head and calculate the output:

[0039]

[0040] V=softmax(scores 1 )*Values 1

[0041] Finally merge the inputs of all heads:

[0042] MultiHead=Concat(head1,head2...,head8)*W

[0043] Queries 1 、Keys 1 , and Values 1 Represents the input data of each header, output 2 , V represents the weighted value matrix, that is, the output of a single head, W represents the weight matrix, and MultiHead represents the output of the multi-head self-attention layer.

[0044] The beneficial effects of the present invention are:

[0045] (1) Compared with traditional holistic decomposition prediction methods, the training strategy adopted by this invention avoids the data leakage problem that may be caused by premature exposure of information in the test dataset by using a specific wavelet decomposition. While maintaining data integrity, the data can be subdivided into subsets with independent characteristics, thereby processing and using the data more securely.

[0046] (2) The present invention uses a single wavelet decomposition to decompose the sequence into high-frequency detail components and low-frequency approximation components, and then establishes a prediction model. The high-frequency component generally contains short-term fluctuations in the data, while the low-frequency component represents the long-term trend and cyclical components of the data. Constructing the prediction model separately allows the prediction model to focus on the most important features in the data, thereby improving prediction accuracy.

[0047] (3) To address the difficulty in predicting high-frequency data containing short-term fluctuations, the present invention takes similar nodes in the same water supply network as the node to be predicted based on spatial correlation as input, and adopts the advanced iTransformer model to capture the correlation of water use behaviors between different nodes, thereby improving the prediction accuracy of high-frequency detail components.

[0048] (4) The iTransformer model used in this paper is an improvement on the Transformer model. It considers different node inputs separately, and each node input is independently encoded. Then, a multi-head self-attention mechanism is used to model the correlation between different node inputs. Finally, a feedforward network is used to model the temporal correlation of different node inputs. Compared with LSTM or TCN, which rely on recursive computation, the model used in this paper can capture the complex interdependencies between nodes and is more suitable for water demand forecasting at different nodes in the water supply network. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 A flow chart of a single-node flow prediction method for a water supply network based on real-time wavelet decomposition and iTransformer model provided in an embodiment of the present application;

[0050] Figure 2 A schematic diagram of another flow chart of a single-node flow prediction method for a water supply network based on real-time wavelet decomposition and an iTransformer model provided in an embodiment of the present application;

[0051] Figure 3 A diagram of the single-feature iTransformer architecture based on real-time wavelet decomposition and the iTransformer model provided in an embodiment of the present application;

[0052] Figure 4A diagram of the multi-feature iTransformer architecture based on real-time wavelet decomposition and the iTransformer model provided in an embodiment of the present application;

[0053] Figure 5 This is a water demand forecast result diagram provided in the case section of the specific implementation method of this application. DETAILED DESCRIPTION

[0054] The present application is described in further detail below in conjunction with the accompanying drawings. It is necessary to point out that the following specific implementation methods are only used to further illustrate the present application and cannot be understood as limiting the scope of protection of the present application. Technicians in this field can make some non-essential improvements and adjustments to the present application based on the above application content.

[0055] Example 1

[0056] like Figure 1-2 As shown, this embodiment proposes a single-node flow prediction method for a water supply network based on real-time wavelet decomposition and an iTransformer model (a deep learning model based on a self-attention mechanism), and the method includes the following steps:

[0057] S1. Obtain historical flow data of all n nodes at m times in the water supply network Where a represents the ath node in the water supply network, j represents the jth moment, n represents the number of n nodes in the water supply network, and m represents the mth moment of the node.

[0058] S2, randomly select a node Xi from n nodes = (x i1 ,x i2 ,x ij ,…,x im ) as a single node, calculate the Pearson correlation coefficient between the single node and other n-1 nodes in turn, set the correlation coefficient threshold k, and combine the nodes with high correlation coefficients greater than the coefficient threshold k with the single node as the center to obtain the historical traffic data of similar node clusters of the single node Where c represents the cth node in the cluster, and z represents all z nodes in the cluster.

[0059] S3, dividing the traffic data in the similar node cluster into training set and test set;

[0060] Specifically, in the obtained historical traffic data of all nodes in the similar node cluster of a single node, the historical traffic data from time 1 to q is divided into the training set The historical traffic data at the moment is divided into the test set

[0061] Among them, the data of a single node in the training set is Xi_train=(x i1 ,x i2 ,x ij1 ,…,x iq ), the data of a single node in the test set is Xi_test=(x i(q+1) ,x i(q+2) ,x ij2 ,…,x im ).

[0062] S4. Decompose the training set and test set using sliding window and wavelet decomposition technology to obtain local approximate components and detail components of all nodes, and perform global wavelet decomposition on the data of a single node in the training set to obtain the global approximate component and global detail component of the single node;

[0063] In a specific embodiment, step S4 includes:

[0064] Create sliding windows of length l on the training set and test set of all nodes in the cluster to obtain multiple sets of training set data for all nodes in the cluster. Test set multiple sets of data It contains multiple sets of data for the training set of a single node (L i1 ,L i2 ,L iw ,…,L i(q-l) ), test set multiple groups of data (L i(q+1) ,L i(q+2) ,L iu ,…,L i(m-l) ).

[0065] The wavelet decomposition technology is used to decompose the multiple sets of data in the training set and the test set respectively to obtain the local approximate components of all nodes in the training set. and detail content Local approximation component of all nodes in the test set and detail content This includes the local approximation component Xi_Atrain of a single node in the training set = {A i1 ,A i2 ,A iw ,…,A i(q-l)}、The local approximate component of a single node in the test set Xi_Atest={A i(q+1) ,A i(q+2) ,A iu ,…,A i(m-l )}. Then, the wavelet decomposition technology is used to decompose the data Xi_train of a single node in the training set as a whole, and the overall approximate component Yi_Atrain = (a1, a2, a j1 ,…,aq ), the overall detail component of a single node Yi_Dtrain=(d1,d2,d j1 ,…,d q )(j1=1,2,…,q).

[0066] Wavelet decomposition technology is used to decompose multiple sets of data in the training set and the test set respectively. The specific steps are as follows:

[0067] A. Determine the type of base wavelet and its low-pass filter coefficient and high-pass filter coefficient. The present invention selects the db2 base wavelet, and its low-pass filter coefficient h0 and high-pass filter coefficient g0 are as follows:

[0068]

[0069] B. Perform convolution operations to calculate the approximate component and detail component of each set of data. The formula is as follows:

[0070] Approximate Components

[0071] Detail

[0072] Where i represents the current position index of the input signal in the convolution operation, k represents the index of the filter coefficient, and * represents the convolution operation.

[0073] C. Perform downsampling on the approximate component and the detail component, the formula is as follows:

[0074] cA[j]=cA[2j+1], cD[j]=cD[2j+1]

[0075] Where j represents the index after downsampling.

[0076] After one decomposition, the local approximate components of all nodes in the training set are obtained and local detail components Local approximation component of all nodes in the test set and local detail components This includes the local approximation component Xi_Atrain of a single node in the training set = {A i1 ,A i2 ,A iw ,…,A i(q-l)}、The local approximate component of a single node in the test set Xi_Atest={A i(q+1) ,A i(q+2) ,A iu ,…,A i(m-l)}.

[0077] Use wavelet decomposition technology to decompose the data Xi_train of a single node in the training set as a whole. The specific steps are as follows:

[0078] A. Determine the type of base wavelet and its low-pass filter coefficient and high-pass filter coefficient. The present invention selects the db2 base wavelet, and its low-pass filter coefficient h0 and high-pass filter coefficient g0 are as follows:

[0079]

[0080] B. Perform convolution operation to calculate the approximate component and detail component of each data. The formula is as follows:

[0081] Approximate Components

[0082] Detail

[0083] Where i represents the current position index of the input signal in the convolution operation, k represents the index of the filter coefficient, and * represents the convolution operation.

[0084] C. Perform downsampling on the approximate component and the detail component, the formula is as follows:

[0085] cA[j]=cA[2j+1], cD[j]=cD[2j+1]

[0086] Where j represents the index after downsampling.

[0087] Get the overall approximate component of a single node Yi_Atrain=(a1,a2,a j1 ,…,a q ), the overall detail component of a single node Yi_Dtrain=(d1,d2,d j1 ,…,d q ).

[0088] S5. Construct a single-feature iTransformer neural network model, use the local approximate component of a single node in the training set as the training sample input of the single-feature iTransformer neural network model, and use the overall approximate component of a single node Yi_Atrain=(a1, a2, a j1 ,…,a q ) as training sample labels, train the above single-feature iTransformer neural network model, input the local approximate component Xi_Atest of a single node in the test set into the trained single-feature iTransformer model, and obtain the approximate component prediction value A of the single node = (a i(q+1) ,a i(q+2) ,a iv ,…,a im )(v=q+1,q+2,v,…,m);

[0089] And build a multi-feature iTransformer model to obtain the local detail components of all nodes in the training set As the training sample input of the multi-feature iTransformer neural network model, the obtained overall detail component Yi_Dtrain=(d1,d2,d j1 ,…,d q ) as the last ql element training sample labels of the multi-feature model, and train the multi-feature iTransformer neural network model. The local detail components Xc_Dtest of all nodes in the test set are input into the trained multi-feature iTransformer model, and the detail component prediction value of each node is obtained. i(q+1) ,d i(q+2) ,d iv ,…,di m )(v=q+1,q+2,v,…,m).

[0090] S6. Sum the obtained approximate component prediction value A and the detailed component prediction value D obtained in step 4 to obtain the traffic prediction value of the single node I = (p i(q+1) ,p i(q+2) ,p iv ,…,p im )(v=q+1,q+2,v,…,m).

[0091] In a specific embodiment, in step 1, historical flow data of all n nodes in the water supply network at m moments are obtained. Randomly select a single node Xi=(x i1 ,x i2 ,x ij ,…,x im ), calculate the correlation coefficient between a single node and the other n-1 nodes in turn, the calculation formula is as follows:

[0092]

[0093] where X j is the observed value of the historical traffic data of a single node, Y j is the observation value of the remaining n-1 nodes, is the mean of the node's historical traffic data. Calculate the correlation coefficient array r between a single node and other nodes ia =(r i1 ,r i2 ,r ib ,…,r i(n-1) )(b=1,2,…,n-1), set the correlation coefficient threshold k, take a single node as the center and group the nodes with high correlation greater than the coefficient threshold k with the single node, that is, r ib≥k, get the historical traffic data of similar node clusters of a single node Where c represents the cth node in the cluster, and z represents all z nodes in the cluster.

[0094] In a specific embodiment, in step S5, a single-feature iTransformer model is constructed, and the local and global approximate components of a single node in the training set are used as training sample inputs to predict the approximate components, including:

[0095] S501, constructing a single-feature neural network model including an embedding layer, a coding layer, and a projection layer connected in sequence;

[0096] S502: Using the local approximate component of a single node in the training set as a training sample input and the overall approximate component of the single node as a training sample label to train a single-feature neural network model;

[0097] S503: Input the local approximate component of a single node in the test set into the trained single-feature neural network model to obtain a predicted value of the approximate component of the single node.

[0098] In a specific embodiment, in step S5, a multi-feature iTransformer model is constructed, and the local detail components of all nodes in the training set and the global detail components of a single node are used as training sample inputs to predict the detail components, including:

[0099] S511, constructing a multi-feature neural network model including an embedding layer, an encoding layer, and a projection layer connected in sequence;

[0100] S512, using the local detail components of all nodes in the training set and the global detail components of a single node as training sample inputs, and the global detail components of a single node as training sample labels, to train a multi-feature neural network model;

[0101] S513. Input the local detail components of all nodes in the test set into the trained multi-feature neural network model to obtain the detail component prediction value of a single node.

[0102] In a specific embodiment, the single-feature neural network model includes an embedding layer, an encoding layer, and a projection layer connected in sequence, which includes the following steps:

[0103] A. Build the embedding layer:

[0104] The embedding layer is a linear layer, and the dimension of the linear mapping is 64.

[0105] ouput1=A1 T *input1+b1

[0106] Where A1 represents the weight matrix, b1 represents the bias vector, input1 represents the input vector of the linear layer, and output1 represents the output of the linear layer.

[0107] B. Construct the encoding layer, which includes the self-attention layer, residual connection layer, normalization layer, feedforward network layer, residual connection layer and normalization layer connected in sequence.

[0108] 1) Build the self-attention layer:

[0109] Construct a fully connected self-attention mechanism layer and use the output of the embedding layer as the input of the self-attention layer:

[0110]

[0111] output2=softmax(scores1)*Values1

[0112] Among them, Queries1, Keys1 and Values1 are output1, which represents the input data of the self-attention layer, and output2 represents the output of the self-attention layer.

[0113] 2) Construct residual connection layer and normalization layer:

[0114] L1 regularization is introduced in the residual connection, and the regularization factor is 0.001.

[0115] output3=output2+drop(output1)

[0116] output1 and output2 represent the input of the residual connection layer, and output3 represents the output of the residual connection layer.

[0117] Normalization layer:

[0118] ouput4=Laynorm(output3)

[0119] output3 represents the input of the normalization layer, and output4 represents the output of the normalization layer.

[0120] 3) Build the feedforward network layer

[0121] The feedforward network layer includes the first conv1d layer, the activation layer and the second conv1d layer. The input and output channels of the first conv1d layer are 32 and 64, the size of the convolution kernel is 1, and the activation function of the activation layer is Relu. The input and output channels of the second conv1d layer are 64 and 32, the size of the convolution kernel is 1, and L1 regularization is introduced in the two convolution layers with a regularization factor of 0.001.

[0122]

[0123] output6=Relu(output5)

[0124]

[0125] Where w represents the weight matrix of the convolution kernel, and its dimension is (c out ,c in ,k), output4 represents the input of the first conv1d layer, b represents the bias term, and the dimension is (c out ), k is 0, output5 represents the output of the first conv1d layer, output6 represents the output of the activation layer, and output7 represents the output of the second conv1d layer.

[0126] 4) Constructing the residual connection layer:

[0127] L1 regularization is introduced in the residual connection, and the regularization factor is 0.001.

[0128] output8=output7+drop(output4)

[0129] output4 and output7 represent the input of the residual connection layer, and output8 represents the output of the residual connection layer.

[0130] C. Build the projection layer

[0131] The projection layer includes two linear layers, and the dimensions of the linear mapping are 64, 1.

[0132] ouput9=A T *output8+b

[0133] Where A represents the weight matrix, b represents the bias vector, output8 represents the input of the projection layer, and output9 represents the output of the projection layer.

[0134] In a specific embodiment, the multi-feature neural network model includes an embedding layer, an encoding layer, and a projection layer connected in sequence, including the following steps:

[0135] A. Build the embedding layer:

[0136] The embedding layer consists of a transpose layer and a linear layer, and the dimension of the linear mapping is 64.

[0137] Transpose layer:

[0138] output 1 =permute(input 1 )

[0139] The input 1 Represents the input of the transpose operation, output 1 Represents the output of a transpose operation.

[0140] Linear layer:

[0141] ouput 2 =A 1T *output 1 +b 1

[0142] Among them A 1 represents the weight matrix, b 1 Represents the bias vector, output 1 represents the input vector of the linear layer, output 2 represents the output of the linear layer.

[0143] B. Construct two encoding layers. A single encoding layer includes a multi-head self-attention layer, a residual connection layer, a normalization layer, a feedforward network layer, and a residual connection layer connected in sequence.

[0144] 1) Constructing a multi-head self-attention layer:

[0145] A fully connected multi-head self-attention layer is constructed, and the output of the embedding layer is used as the input of the multi-head self-attention layer. The number of heads is 8. The iTransformer model eliminates the decoding layer in the Transformer model to simplify the model structure. Unlike the multi-head attention mechanism in the Transformer model that operates on the time dimension, the multi-head self-attention layer's multi-head attention mechanism is used to capture the associations between different feature variables, that is, it operates on the feature dimension.

[0146] Compute the attention scores for each head and calculate the output:

[0147]

[0148] V=softmax(scores 1 )*Values 1

[0149] Finally merge the inputs of all heads:

[0150] MultiHead=Concat(head1,head2...,head8)*W

[0151] Queries 1 (Query), Keys 1 (Keys), and Values 1 (value) represents the input data of each header, and output2 , V represents the weighted value matrix, that is, the output of a single head, W represents the weight matrix, and MultiHead represents the output of multi-head self-attention.

[0152] 2) Construct residual connection layer and normalization layer:

[0153] L1 regularization is introduced in the residual connection, and the regularization factor is 0.001.

[0154] output 3 =MultiHead+drop(input 3 )

[0155] input 3 Represents the input of the residual connection layer, V represents the output of the self-attention layer, output 3 Represents the output of the residual connection layer.

[0156] Normalization layer:

[0157] output 4 =Laynorm(output 3 )

[0158] 3) Construct the feedforward network layer:

[0159] The feedforward network layer includes the first conv1d layer, the activation layer and the second conv1d layer. The input and output channels of the first conv1d layer are 64 and 512, the size of the convolution kernel is 1, and the activation function of the activation layer is Relu. The input and output channels of the second conv1d layer are 512 and 64, the size of the convolution kernel is 1, and L1 regularization is introduced in the two convolution layers with a regularization factor of 0.001.

[0160]

[0161] ouput 6 =Re lu(output 5 )

[0162]

[0163] Where w represents the weight matrix of the convolution kernel, and its dimension is (c out ,c in ,k),output 4 Represents the input of the first conv1d layer, b represents the bias term, and the dimension is (c out ), k is 0, output 5 Represents the output of the first conv1d layer, output 6Represents the output of the activation layer, output 7 Represents the output of the second conv1d layer.

[0164] 4) Constructing the residual connection layer:

[0165] L1 regularization is introduced in the residual connection, and the regularization factor is 0.001.

[0166] output 8 =output 7 +drop(output 4 )

[0167] output4 and output7 represent the input of the residual connection layer, and output8 represents the output of the residual connection layer.

[0168] C. Build the projection layer

[0169] The projection layer includes two linear layers, and the dimensions of the linear mapping are 64, 1.

[0170] ouput 9 =A T *output 8 +b

[0171] Where A represents the weight matrix, b represents the bias vector, and output 7 Represents the input of the projection layer, output 9 Represents the output of the projection layer.

[0172] It should be noted that the multi-feature iTransformer model constructed by inputting the training sample and training sample label of the multi-feature model selects MSE as the loss function of the model, and uses the Adam optimizer to optimize the model parameters. The batch_size is 32, the epochs is 50, and the learning rate is 0.001 to train the multi-feature iTransformer model.

[0173] In order to more clearly illustrate the present invention and its advantages, the method provided by the present invention will be further explained below in conjunction with specific embodiments and related partial figures.

[0174] This paper presents a short-term flow prediction method for water supply networks based on real-time wavelet decomposition and the iTransformer model. The experimental research used a dataset from the Deepwater Cloud Brain "Residential Community Secondary Water Supply Demand Forecasting" competition. This dataset provides hourly flow data for 20 residential communities within the same water supply network. Specifically, the cumulative flow rate for the past hour was collected at hourly intervals from 20 flow monitoring points in the same area. A total of 2714 time points were selected from each monitoring point from 1:00 AM on January 1, 2022, to 1:00 AM on April 24, 2022, as the experimental dataset.

[0175] This embodiment discloses a method for predicting short-term flow in a water supply network based on real-time wavelet decomposition and the iTransformer model, which specifically includes the following steps:

[0176] Step 1: Obtain historical flow data for all 20 nodes in the water supply network for 2714 moments

[0177] Select a single node X1 = (29.7, 21.9, 16.9, ..., 28.6) from the 20 nodes, and calculate the correlation coefficients between the single node and the remaining 19 nodes in turn, and get the correlation coefficient array: (0.88, 0.86, 0.83, 0.86, 0.88, 0.79, 0.41, 0.87, 0.24, 0.41, 0.26, 0.39, 0.49, 0.40, 0.40, 0.41, 0.25, 0.25, 0.75)

[0178] Set the correlation coefficient threshold to 0.85, and combine the monitoring points with high correlation coefficients greater than the coefficient threshold of 0.80 with a single node as the center, namely monitoring points 2, 3, 5, 6, and 9, to obtain the historical traffic data of similar node clusters of a single node:

[0179] Step 2: In the historical traffic data of all nodes in the similar node cluster of monitoring point 1 obtained in step 1, the historical traffic data from time 1 to 2171 is divided into a training set:

[0180] The historical traffic data from 2172 to 2714 is divided into the test set The data of a single node in the training set is Xi_train = (29.7, 21.9, 16.8, ..., 49.1), and the data of a single node in the test set is Xi_test = (48.1, 46.8, 40.1, ..., 28.6). Create a sliding window of length 24 on the training set and test set of all nodes in the cluster to obtain multiple sets of training set data for all nodes in the cluster. Test set multiple sets of data The data includes multiple sets of training data {(29.7,…,38.9), (21.9,…,25.4),…, (47.2,…,51.1)} and multiple sets of test data {(48.1,…,45.5), (46.8,…,45.1),…, (33.2,…,35.4)} for a single node. The db2-based wavelet is selected and the wavelet decomposition technique is used to decompose the training and test data sets respectively. After performing a decomposition, the local approximate components of all nodes in the training set are obtained.

[0181] Local detail component

[0182] Local approximation component of all nodes in the test set Local detail component These include the local approximate components of a single node in the training set, Xi_Atrain = {(25.5,…,40.1), (19.1,…,21.9),…, (47.7,…,53.5)}, and the local approximate components of a single node in the test set, Xi_Atest = {(47.6,…,46.1), (42.9,…,44.7),…, (17.7,…,24.4)}. Subsequently, wavelet decomposition was used to decompose the single-node data Xi_train in the training set as a whole, resulting in the global approximate component Yi_Atrain = (25.5, 23.9, 17.7,…, 35.2) and the global detail component Yi_Dtrain = (4.2, -1.9, -0.8,…, 0.46).

[0183] Step 3: Build a single-feature iTransformer model to predict the approximate component. The specific steps are as follows:

[0184] S1. Use the last 2147 elements of the local approximation component Xi_Atrain = {(25.5,…,40.1), (19.1,…,21.9),…, (47.7,…,53.5)} and the overall approximation component Yi_Atrain = (25.5, 23.9, 17.7,…, 35.2) of the single node of the training set obtained in step 2 as the training input and training label of the single-feature iTransformer model.

[0185] It includes the following steps:

[0186] A. Build the embedding layer:

[0187] The embedding layer is a linear layer, and the dimension of the linear mapping is 64.

[0188] ouput1=A T *input1+b

[0189] Where A represents the weight matrix, b represents the bias vector, input1 represents the input vector of the linear layer, and output1 represents the output of the linear layer.

[0190] B. Construct the encoding layer, which includes the self-attention layer, residual connection layer, normalization layer, feedforward network layer and residual connection layer connected in sequence.

[0191] 1) Build the self-attention layer:

[0192] Construct a fully connected self-attention mechanism layer and use the output of the embedding layer as the input of the self-attention layer:

[0193]

[0194] output2=softmax(scores)*Values

[0195] Among them, Queries, Keys, and Values ​​are output1, which represents the input data of the self-attention layer, and output2 represents the output of the self-attention layer.

[0196] 2) Construct residual connection layer and normalization layer:

[0197] L1 regularization is introduced in the residual connection, and the regularization factor is 0.001.

[0198] output3=output2+drop(output1)

[0199] output1 and output2 represent the input of the residual connection layer, and output3 represents the output of the residual connection layer.

[0200] Normalization layer:

[0201] ouput4=Laynorm(output3)

[0202] output3 represents the input of the normalization layer, and output4 represents the output of the normalization layer.

[0203] 3) Build the feedforward network layer

[0204] The feedforward network layer includes the first conv1d layer, the activation layer and the second conv1d layer. The input and output channels of the first conv1d layer are 32 and 64, the size of the convolution kernel is 1, and the activation function of the activation layer is Relu. The input and output channels of the second conv1d layer are 64 and 32, the size of the convolution kernel is 1, and L1 regularization is introduced in the two convolution layers with a regularization factor of 0.001.

[0205]

[0206] output6=Relu(output5)

[0207]

[0208] Where w represents the weight matrix of the convolution kernel, and its dimension is (c out ,c in ,k), output4 represents the input of the first conv1d layer, b represents the bias term, and the dimension is (c out ), k is 0, output5 represents the output of the first conv1d layer, output6 represents the output of the activation layer, and output7 represents the output of the second conv1d layer.

[0209] 5) Construct the residual connection layer:

[0210] L1 regularization is introduced in the residual connection, and the regularization factor is 0.001.

[0211] output8=output7+drop(output4)

[0212] output4 and output7 represent the input of the residual connection layer, and output8 represents the output of the residual connection layer.

[0213] C. Build the projection layer

[0214] The projection layer includes two linear layers, and the dimensions of the linear mapping are 64, 1.

[0215] ouput9=A T *output8+b

[0216] Where A represents the weight matrix, b represents the bias vector, output8 represents the input of the projection layer, and output9 represents the output of the projection layer.

[0217] S3. Input the training sample input and training sample label of the single-feature model into the single-feature iTransformer model, select MSE as the loss function of the model, and use the Adam optimizer to optimize the model parameters with batch_size of 32, epochs of 50, and learning rate of 0.001.

[0218] S4. Input the local approximate component Xi_Atest of a single node in the test set into the trained single-feature model to obtain the predicted value of the approximate component of the single node A = (45.2, 44.3, 35.9, ..., 28.2).

[0219] Step 4: Build a multi-feature iTransformer model to predict detail components. The specific steps are as follows:

[0220] S1, the detail components of all nodes in the cluster in the training set obtained in step 2 The last 2174 elements in the overall detail component Yi_Dtrain = (4.2, -1.9, -0.8, ..., 0.46) of the single node are used as the training sample input and training sample label of the multi-feature iTransformer model.

[0221] S1. Constructing a multi-feature neural network model includes sequentially connected embedding layers, encoding layers, and projection layers, including the following steps:

[0222] A. Build the embedding layer:

[0223] The embedding layer consists of a transpose layer and a linear layer, and the dimension of the linear mapping is 64.

[0224] Transpose layer:

[0225] output 1 =permute(input 1 )

[0226] The input 1 Represents the input of the transpose operation, output 1 Represents the output of a transpose operation.

[0227] Linear layer:

[0228] ouput 2 =A T *output 1 +b

[0229] Where A represents the weight matrix, b represents the bias vector, and output 1 represents the input vector of the linear layer, output 2 represents the output of the linear layer.

[0230] D. Construct two encoding layers. A single encoding layer includes a multi-head self-attention layer, a residual connection layer, a normalization layer, a feedforward network layer, and a residual connection layer connected in sequence.

[0231] 1) Constructing a multi-head self-attention layer:

[0232] Construct a fully connected multi-head self-attention layer and use the output of the embedding layer as the input of the multi-head self-attention layer with 8 heads.

[0233] Compute the attention scores for each head and calculate the output:

[0234]

[0235] V=softmax(scores)*Values

[0236] Finally merge the inputs of all heads:

[0237] MultiHead=Concat(head1,head2...,head8)*W

[0238] Among them, Queries, Keys, and Values ​​represent the input data of each header, and output 2 , V represents the weighted value matrix, that is, the output of a single head, W represents the weight matrix, and MultiHead represents the output of multi-head self-attention.

[0239] 2) Construct residual connection layer and normalization layer:

[0240] L1 regularization is introduced in the residual connection, and the regularization factor is 0.001.

[0241] output 3 =MultiHead+drop(input 3 )

[0242] input 3 Represents the input of the residual connection layer, V represents the output of the self-attention layer, output 3 Represents the output of the residual connection layer.

[0243] Normalization layer:

[0244] output 4 =Laynorm(output 3 )

[0245] 3) Construct the feedforward network layer:

[0246] The feedforward network layer includes the first conv1d layer, the activation layer and the second conv1d layer. The input and output channels of the first conv1d layer are 64 and 512, the size of the convolution kernel is 1, and the activation function of the activation layer is Relu. The input and output channels of the second conv1d layer are 512 and 64, the size of the convolution kernel is 1, and L1 regularization is introduced in the two convolution layers with a regularization factor of 0.001.

[0247]

[0248] ouput 6 =Re lu(output 5 )

[0249]

[0250] Where w represents the weight matrix of the convolution kernel, and its dimension is (c out ,c in ,k),output 4 Represents the input of the first conv1d layer, b represents the bias term, and the dimension is (c out ), k is 0, output 5 Represents the output of the first conv1d layer, output 6 Represents the output of the activation layer, output 7 Represents the output of the second conv1d layer.

[0251] 5) Construct the residual connection layer:

[0252] L1 regularization is introduced in the residual connection, and the regularization factor is 0.001.

[0253] output 8 =output 7 +drop(output 4 )

[0254] output4 and output7 represent the input of the residual connection layer, and output8 represents the output of the residual connection layer.

[0255] E. Build the projection layer

[0256] The projection layer includes two linear layers, and the dimensions of the linear mapping are 64, 1.

[0257] ouput 9 =A T *output 8 +b

[0258] Where A represents the weight matrix, b represents the bias vector, and output 7 Represents the input of the projection layer, output 9 Represents the output of the projection layer.

[0259] S3. Input the training sample input and training sample label of the multi-feature model into the multi-feature iTransformer model, select MSE as the loss function of the model, and use the Adam optimizer to optimize the model parameters with batch_size of 32, epochs of 50, and learning rate of 0.001.

[0260] S4. Input the local detail components Xc_Dtest of all nodes in the test set into the trained multi-feature model to obtain the detail component prediction value D = (-5.3, 2.9, -0.1, ..., 0.5) of a single node.

[0261] Step 5: Sum the approximate component prediction value A obtained in step 3 and the detail component prediction value D obtained in step 4 to obtain the single node traffic prediction value I = (39.9, 47.2, 35.8, ..., 28.7). 2 The results are evaluated using other performance evaluation indicators.

[0262] Figure 5 The water demand forecast result diagram provided for the case study. The horizontal axis in the figure is the time point of the single-step forecast, with a resolution of 1 hour, and the vertical axis is the interval flow of a single node, with a resolution of 1L. The mean absolute error (MAE) between the predicted flow and the actual flow is 2.92, and the correlation coefficient R 2 is 0.90, and the predicted flow curve can fit the actual flow curve well.

[0263] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0264] In addition, the functional modules in the various embodiments of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0265] The above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A real-time decomposition and iTransformer The single-node flow prediction method of the water supply network based on the model is characterized by: The method comprises the following steps: S1. Obtain historical flow data of all nodes in the water supply network; S2. Select a single node and calculate the correlation between the node and other nodes to obtain a cluster of similar nodes; S3. Divide the traffic data in the similar node cluster into a training set and a test set; S4. Decompose the training set and test set using sliding window and wavelet decomposition technology to obtain local approximate components and detail components of all nodes, and perform global wavelet decomposition on the data of a single node in the training set to obtain the global approximate component and global detail component of the single node; S5. Constructing a single feature iTransformer A model, taking the local and global approximate components of a single node in the training set as training sample inputs, and predicting the approximate components; And build multiple features iTransformer The model uses the local detail components of all nodes in the training set and the global detail components of a single node as training sample inputs to predict the detail components; S6. Sum the approximate component prediction value and the detailed component prediction value to obtain the traffic prediction value of the single node; Step S4 includes: S401, define the length as l A sliding window is used to obtain multiple sets of data on the training set and the test set of all nodes in the similar node cluster; S402, use db2 Base wavelet and determine its low-pass filter coefficient , high-pass filter coefficient ; S403: Perform convolution operation to calculate the approximate components of each set of data and detail content ;in Represents the current position index of the input signal in the convolution operation, Represents the index of the filter coefficient, Represents the convolution operation; S404, approximate components and detail content Perform downsampling, the formula includes: ; in Indicates the index after downsampling; S405, after performing the above S402-S404 decomposition once, obtain the local approximate components and detail components of all nodes, as well as the overall approximate components and overall detail components of a single node; In step S5, the single feature is constructed iTransformer The model uses the local and global approximate components of a single node in the training set as training sample inputs and predicts the approximate components, including: S501, constructing a single-feature neural network model including an embedding layer, a coding layer, and a projection layer connected in sequence; S502: Using the local approximate component of a single node in the training set as a training sample input and the overall approximate component of the single node as a training sample label to train a single-feature neural network model; S503: Input the local approximate component of a single node in the test set into a trained single-feature neural network model to obtain a predicted value of the approximate component of the single node.

2. A method based on wavelet real-time decomposition and iTransformer The single-node flow prediction method of the water supply network based on the model is characterized by: Step S2 includes: S201, randomly selecting a single node, and sequentially calculating the Pearson correlation coefficient of historical traffic data between the single node and all other nodes; S202 , setting a correlation coefficient threshold, grouping nodes whose correlation coefficients with the single node are greater than the threshold with the single node as the center, and obtaining historical traffic data of similar node clusters of the single node.

3. A method based on wavelet real-time decomposition and iTransformer The single-node flow prediction method of the water supply network based on the model is characterized by: In step S5, the multi-feature construction iTransformer The model uses the local detail components of all nodes in the training set and the global detail components of a single node as training sample inputs and predicts the detail components, including: S511, constructing a multi-feature neural network model including an embedding layer, an encoding layer, and a projection layer connected in sequence; S512, using the local detail components of all nodes in the training set and the global detail components of a single node as training sample inputs, and the global detail components of a single node as training sample labels, to train a multi-feature neural network model; S513: Input the local detail components of all nodes in the test set into the trained multi-feature neural network model to obtain the predicted value of the detail component of the single node.

4. A method based on wavelet real-time decomposition and iTransformer The single-node flow prediction method of the water supply network based on the model is characterized by: In the single-feature neural network model, constructing the encoding layer includes constructing a self-attention layer, a residual connection layer, a normalization layer, a feedforward network layer, and a residual connection layer. Constructing the self-attention layer includes using the output of the embedding layer as the input of the self-attention layer: ; in Queries 1. Keys 1 and Values 1 for , represents the input data of the self-attention layer, Represents the output of the self-attention layer.

5. A method based on wavelet real-time decomposition and iTransformer The single-node flow prediction method of the water supply network based on the model is characterized by: In the multi-feature neural network model, constructing the encoding layer includes constructing a multi-head self-attention layer, a residual connection layer, a normalization layer, a feedforward network layer, and a residual connection layer. The multi-head self-attention layer is used to capture the association between different feature variables. Constructing the multi-head self-attention layer includes: Use the output of the embedding layer as the input of the multi-head self-attention layer; Compute the attention scores for each head and calculate the output: ; Finally merge the inputs of all heads: ; in and Represents the input data of each head, , represents the weighted value matrix, i.e. the output of a single head, represents the weight matrix, MultiHead Represents the output of the multi-head self-attention layer.