Water supply quantity prediction method and device based on water quantity-water pressure coupling and storage medium
Through the method of IAMformer network and EMD distance screening characteristics based on transformer architecture, combined with the water pressure calculation model, the error propagation problem in water supply and water pressure coupling prediction is solved, and efficient and accurate water supply prediction is achieved.
Patent Information
- Application Number
- CN202510846155.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-24
- Publication Date
- 2025-07-22
- Estimated Expiration
- 2045-06-24
AI Technical Summary
The existing water supply and water pressure prediction methods are difficult to effectively process multi-dimensional nonlinear coupled data, resulting in chain propagation in the water volume-water pressure coupling system, and the traditional methods are highly complex and have insufficient robustness.
Using the IAMformer network based on the transformer architecture, combining the multi-head sparse attention layer and the main and auxiliary attention layer of EMD distance, a coupled prediction model of water supply volume and water pressure is constructed, important features are screened through EMD distance, a water pressure calculation model is introduced for error compensation, and a composite loss function is used to optimize the model parameters.
It reduces the indirect effect of water pressure prediction error on water supply prediction, reduces model complexity, improves prediction accuracy and robustness, and enhances the long-term dependency capture capability of the model.
Smart Images

Figure CN120355042A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a water supply prediction method, device and storage medium based on water volume - water pressure coupling, belonging to the technical fields of water supply prediction and deep learning. Background Art
[0002] The water supply and water pressure data have the characteristics of periodicity and randomness. The randomness makes such data more difficult to predict compared with traditional data, and the complexity is relatively high when predicting long - term water consumption.
[0003] Traditional water supply prediction methods mainly rely on empirical formulas by humans or time - series analysis based on statistics (such as ARIMA models), but it is difficult to effectively process multi - dimensional non - linear coupling data such as meteorological factors and user behavior patterns. In recent years, although deep learning technologies (such as LSTM recurrent neural networks) have improved the prediction accuracy to a certain extent, they still regard water supply prediction and water pressure calculation as independent tasks, or use a simple multi - task learning framework for joint modeling. This processing method ignores the reverse regulation effect of water pressure dynamics on water supply demand, resulting in the formation of chain - like propagation of errors in the water volume - water pressure coupling system. Therefore, there is an urgent need for a new prediction framework that can decouple the dynamic coupling relationship between water volume and water pressure and achieve error compensation, while ensuring the light weight of the model and improving the overall prediction accuracy and robustness of the system. Summary of the Invention
[0004] The object of the present invention is to overcome the above - mentioned deficiencies and provide a water supply prediction method based on water volume - water pressure coupling, which can reduce the indirect influence of water pressure prediction error on water supply prediction, and at the same time can reduce the complexity of the algorithm model and improve the robustness of the model.
[0005] The technical solution adopted by the present invention is as follows: A water supply prediction method based on water volume - water pressure coupling, including the following steps: S1. Obtain historical data of water supply, instantaneous flow rate and pressure, pre - process them into time series, and construct a data set; S2. Construct an IAMformer network improved based on the transformer architecture, including an encoder and a decoder. The encoder includes an embedding layer, a multi - head sparse attention layer based on EMD distance, an addition & normalization layer, a distillation layer, and a feed - forward neural network layer. The decoder includes an embedding layer, a multi - head sparse attention layer based on EMD distance, an addition & normalization layer, a primary - auxiliary attention layer, and a fully - connected layer; S3. Input the historical data of water supply volume, instantaneous flow rate, and holiday information into the embedding layer of the encoder to form an embedding matrix. The embedding matrix is input into the multi-head sparse attention layer based on the EMD distance for attention calculation to distinguish important features, followed by addition and normalization operations. Then, redundant features are screened out through the distillation layer, and the main features for water supply volume prediction are obtained through the feed-forward neural network layer. Q ; S4. Input the historical pressure data into the decoder embedding layer. Through the attention calculation of the multi-head sparse attention layer based on the EMD distance to distinguish important features and the gradient disappearance and explosion prevention processing of the addition & normalization layer, the pressure auxiliary features that can be fused are obtained. A ; S5. Input the obtained main water supply volume feature Q and pressure auxiliary feature A into the main-auxiliary attention layer in the decoder for main-auxiliary attention matrix calculation and fusion to obtain the fused feature. The fused feature passes through the fully connected layer to output the predicted water supply volume; S6. Calculate the water supply volume loss, construct a water pressure calculation model that can calculate the pressure value based on the water supply volume, calculate the pressure value using the water pressure calculation model according to the predicted water supply volume and compare it with the true value to calculate the pressure loss. Optimize and update the model parameters through backpropagation based on the composite loss function of the water supply volume loss and pressure loss; S7. Use the trained IAMformer network model to predict the validation set and test set respectively, and use the final model to predict the future water supply volume.
[0006] In the above method, the multi-head sparse attention layer based on the EMD distance described in step S3 uses the EMD distance function to measure the similarity between the query vector and the uniform distribution, and selects the query vector with a large contribution degree for attention operation. The process is as follows: (1) For the query vector Q, define the attention calculation formula for the i-th query vector q i as follows: , where represents the exponential kernel function operation between the i-th query vector q i and the j-th key vector k j , v j represents the j-th value vector. Use the calculation method of scaled dot product to obtain the attention probability distribution p of the i-th query vector. The process is as follows: First, calculate the similarity score between the query vector and the key vector, , where sij Represents the query vector q i and the key vector k j The similarity score between them Rescaling operation , Is the dimension of the query vector and the key vector Finally, use the softmax function to convert the score into a probability distribution score , p ij Represents the i-th query vector q i For the j-th key vector k j The attention probability score of, all p ij (j = 1, 2,..., n) constitutes the attention probability distribution p of the i-th query vector q i =(p i1 , p i2 ,..., p in ); Subsequently, define L k To represent the length of the query vector, and assume To represent the uniform distribution of the query vector. If the attention probability distribution p of the i-th query vector q i Is far from this uniform distribution q, it indicates that the query vector q i Has a large contribution to the attention weight. The formula for using the EMD distance to measure the similarity between the query vector and this uniform distribution is as follows: , Where d(x, y) represents the cost from x to y γ Represents the joint probability distribution, whose marginal distribution is the cost of q and p. inf represents the infimum, that is, the minimum value among all joint distributions, indicating the minimum cost required for the distribution q to transform into the distribution p. W(q||p) is the distance between the two distributions; the greater the distance, the greater the contribution to the attention weight (2)Screen out the query vectors with a large contribution to the attention weight matrix through the method of EMD calculation and threshold setting, and form a new query vector matrix with these query vectors And perform attention calculation. Its attention calculation formula is: , Among them, K represents the key vector, and V represents the value vector. represents the new query vector matrix. d k is the dimension of Q and K. X EMD is the output matrix calculated by EMD.
[0007] Select the L query vectors with the largest contribution degree and continue to perform the attention operation; the remaining query vectors will no longer participate in the calculation, and the value vectors will be directly filled with the mean value to ensure that the output sequence is of the same length as the input sequence.
[0008] For the addition & normalization layer, the addition layer (residual connection) adds the input of the multi-head sparse attention layer based on the EMD distance to its output; the normalization layer is after the addition layer and normalizes the input data.
[0009] The described distillation layer includes a conv1d convolutional layer, an ELU activation layer, and a Maxpool layer to screen out redundant features, and its calculation process is as follows: , where represents the output of the distillation layer, represents the output of the previous layer's residual normalization layer, convld is a one-dimensional convolution operation, Maxpool is a max convolution operation, and ELU is the activation function.
[0010] The main and auxiliary attention layer described in step S5 includes an EMD attention layer, a normalization layer, a fine-grained attention layer, and a fine-tuning layer. The main features of the water supply volume Q and the pressure auxiliary features A are first subjected to correlation calculation through the EMD attention layer to form an attention matrix, and then normalized. The normalized output and the pressure auxiliary features A are subjected to correlation calculation through the fine-grained attention layer to output the fine-grained attention. The main features of the water supply volume Q and the fine-grained attention are added and fine-tuned using a normalization and non-linear transformation network to obtain the fused features.
[0011] The construction process of the water pressure calculation model described in step S6 is as follows: (1) Collect the water supply network attribute data and network monitoring data, including network structure information, regulating pool information, and information on pump power and head. (2) Use the collected data information to calculate the pipe section specific resistance and construct a network hydraulic calculation model. (3) Determine the most unfavorable water supply point, key nodes, and end-users. Along the route from the water plant outlet to the most unfavorable water supply point, install automatic monitoring equipment for pipe network pressure and flow at the positions of key nodes and end-users to automatically collect the flow operation data of each node and pipe section in the pipe network. (4) According to the historical flow data of the collected nodes, use the method of regression analysis to establish a water supply flow prediction model to predict the flow data of the main pipes, branch pipes, and end-users in the future time period between the water plant and the most unfavorable point. (5) According to the pipe network hydraulic calculation model, input the predicted water supply flow data of the main pipes, branch pipes, and end-users between the water plant and the most unfavorable point. Based on the minimum pressure P required by the most unfavorable point user, calculate the pressure of the previous node and predict the pressure data P0 required for the water plant to supply water in the future time period. The calculation steps and formulas are as follows: a. Conduct the conversion between flow and pressure difference of the pipe section. The conversion formula is: , where Q 流量 is the flow of the calculated pipe section, L is the length of the pipe section, h is the water pressure difference between the start and end of the pipe section, S is the pipe resistance ratio of the pipe section; b. Based on the minimum pressure required by the most unfavorable point user, deduce the pressure of the previous node and the theoretical pressure required for the water plant to supply water. The pressure calculation formula is: , where, P is the minimum pressure required at the end node of the most unfavorable pipeline (i.e., the most unfavorable point user), P n is the theoretical pressure required for the water plant to supply water, P i is the pressure difference of the i pipe section before the most unfavorable point along the most unfavorable pipeline, ([[]] i = 1, 2,... n - 1, n is the number of pipe sections along the route from the most unfavorable water supply point to the water plant outlet), (MPa); c. Combine the ground elevation difference to calculate the actual required water plant outlet pressure. The calculation formula is: P0 = P n + Δh + h0, where, P0 is the actual required water plant outlet pressure, P n is the theoretical pressure required for the water plant to supply water, Δh is the elevation difference between upstream and downstream, and h0 is the safety head.
[0012] For the composite loss function described in step S6, the root mean square error (RMSE) of the water supply loss is used to evaluate the prediction accuracy. The formula is: , wherein is the true value, is the predicted value, and n is the sequence length; The pressure loss uses the Huber loss function to calculate the loss generated by the pressure and the true pressure obtained by the pressure model according to the predicted water supply. A hyperparameter δ is introduced, and its magnitude is used to control the trade-off between the mean absolute error and the mean square error of the loss function. The formula is: , wherein α is the perturbation coefficient, is the true value, is the predicted value, δ is a hyperparameter that can be determined by artificial experience; Composite loss function , n is the number of loss values, and L Final is used for backpropagation to update the model parameters and the perturbation coefficient.
[0013] Another object of the present invention is to provide a water supply prediction device based on water volume - water pressure coupling, including a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, the water supply prediction method based on water volume - water pressure coupling as described above is implemented.
[0014] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the water supply prediction method based on water volume - water pressure coupling as described above can be implemented.
[0015] The beneficial effects of the present invention are: 1. By improving the EMD attention mechanism, the present invention can effectively reduce the time complexity and improve the model's ability to capture long-term dependence relationships when predicting long-term water consumption and water pressure data.
[0016] 2. The decoder uses the main and auxiliary attention mechanisms, which can realize the influence of pressure characteristics on the water supply by fusing pressure characteristics and strengthen their correlation degree.
[0017] 3. The present invention introduces a water pressure calculation model, corrects the model parameters by calculating the loss between the predicted pressure and the true pressure and combining the loss function of water supply prediction, and can decouple the dynamic coupling relationship between water volume and water pressure, making the prediction result of the model more accurate when fully considering the pressure.
[0018] 4. The method of the present invention predicts the water volume by improving the attention mechanism of the transformer and constructs a water supply prediction model through adversarial learning with the help of a water pressure calculation model, which can reduce the indirect influence of water pressure prediction error on water supply prediction, and at the same time reduce the complexity of the algorithm model and improve the robustness of the model. Description of the Drawings
[0019] Figure 1 It is the network model architecture diagram of the present invention; Figure 2 It is the flowchart of the method of the present invention; ① represents the input of the true value of water pressure, and ② represents the water pressure calculated by the water pressure calculation model according to the predicted value of water supply for loss calculation; Figure 3 It is the schematic diagram of the main and auxiliary feature fusion process of the present invention; Figure 4 It is the schematic diagram of the construction process of the water pressure calculation model of the present invention. Detailed Embodiments
[0020] The present invention will be further described below with specific embodiments.
[0021] Embodiment 1 A water supply prediction method based on water volume - water pressure coupling, including the steps (as Figure 2 ) are as follows: S1. Obtain historical data of water supply, instantaneous flow rate and pressure, preprocess them into time series, and construct a data set: Preprocess the water supply data and pressure data, and perform stationarity and missing value processing on the time series of features such as water supply, instantaneous flow rate and pressure.
[0022] (1) Data cleaning ① Flow rate data: Eliminate outliers where the instantaneous flow rate > theoretical maximum flux ( Q max =πr 2 v max ) ② Pressure data: Exclude data where the pressure value < 0 MPa (sensor failure) or > the pressure bearing limit of the pipe network.
[0023] (2) Filling missing values ① Linear interpolation: Applicable to short - time (<1 hour) data loss; ② Periodic filling: Use historical data of the same period (such as the same working day, time period) to fill the gap of pressure and flow rate values.
[0024] Construct a data set according to the best pre - processed data, and the data set includes a training set, a validation set and a test set, with a ratio of 8:1:1.
[0025] S2. Construct the improved IAMformer network based on the transformer architecture (such as Figure 1 ), including an encoder and a decoder. The encoder contains an embedding layer, a multi-head sparse attention layer based on the EMD distance, an addition & normalization layer, a distillation layer, and a feed-forward neural network layer. The decoder contains an embedding layer, a multi-head sparse attention layer based on the EMD distance, an addition & normalization layer, a primary and secondary attention layer, and a fully connected layer.
[0026] S3. Input the historical data of water supply volume, instantaneous flow rate, and holiday information into the embedding layer of the encoder to form an embedding matrix. The embedding matrix is input into the multi-head sparse attention layer based on the EMD distance for attention calculation to distinguish important features, followed by addition and normalization operations. Subsequently, redundant information is filtered out through the distillation layer, and the main features Q for water supply volume prediction are obtained through the feed-forward neural network layer: (1) Embedding layer: Use the LSTM time series model for embedding operations, , , Among them, represents the vector representation of the i-th feature, represents the -th sequence information of the feature.
[0027] (2) Multi-head sparse attention layer based on the EMD distance: The multi-head sparse attention layer based on the EMD distance uses the EMD distance function to measure the similarity between the query vector and the uniform distribution, and selects the query vector with a large contribution for attention calculation. The process is as follows: a. We define the attention calculation formula for the i-th query vector q i as follows: , In the formula, represents the exponential kernel function operation between the i-th query vector q i and the j-th key vector k j , v j represents the j-th value vector; Use the scaled dot product calculation method to obtain the attention probability distribution p of the i-th query vector. The process is as follows: , In the formula, s ij represents the query vector q i and the key vector k jThe similarity score between , To avoid the problem that the result of the above dot product operation is too large, leading to unstable gradients, a scaling operation is performed. is the dimension of the query vector and the key vector. , Finally, the softmax function is used to convert the score into a probability distribution score. p ij represents the i-th query vector q i for the j-th key vector k j The attention probability score of all p ij (j = 1, 2,..., n) constitutes the attention probability distribution p of the i-th query vector q i The attention probability distribution p = (p i1 , p i2 ,..., p in ); Subsequently, define L k to represent the length of the query vector, and assume to represent the uniform distribution of the query vector. If the attention probability distribution p of the i-th query vector q i is far from this uniform distribution q, it indicates that the query vector q i has a large contribution to the attention weight. The formula for using the EMD distance to measure the similarity between the query vector and this uniform distribution is as follows: , where d(x, y) represents the cost from x to y, γ represents the joint probability distribution, whose marginal distributions are the costs of q and p. inf represents the infimum, that is, the minimum value among all joint distributions, indicating the minimum cost required for the distribution q to transform into the distribution p. W(q||p) is the distance between the two distributions, and the larger the distance, the greater the contribution to the attention weight; b. After calculating the query vectors with a large contribution to the attention weight matrix through EMD, these query vectors need to be composed into a new query vector matrix and perform attention calculation. The attention calculation formula is: , where K represents the key vector, V represents the value vector, represents the new query vector matrix, dk are the dimensions of Q and K, X EMD is the output matrix calculated by EMD.
[0028] When selecting query vectors with greater contribution, we screen them by setting the threshold T. When the EMD value of a certain query vector exceeds this threshold, it is determined that this query vector is a query vector with greater contribution. Through multiple experiments, it is found that the best effect is achieved when the EMD threshold is set between 0.40 and 0.55. Taking 0.5 as an example, when the EMD value is greater than 0.5, the corresponding query vector plays a key role in adjusting the attention weight matrix.
[0029] Select the L query vectors with the greatest contribution and continue with the attention operation; the remaining query vectors will no longer participate in the calculation, and the value vectors will be directly filled with the mean value to ensure that the output sequence is the same length as the input sequence.
[0030] When the sequence length is N, the multi-head sparse attention mechanism based on the EMD distance is adopted, and the time complexity of calculating the attention probability matrix is O(NlnN). Compared with the time complexity O(N 2 ) of the traditional attention mechanism, while ensuring the model performance, the calculation efficiency of the model is further improved.
[0031] (3) Addition & Normalization Layer It is divided into an addition layer and a normalization layer. The function of the addition layer is to add two or more tensors element-wise, which is often used to implement residual connections to avoid gradient disappearance during model training; the role of the normalization layer is to standardize the input data and adjust its distribution (mean is 0, variance is 1), usually following the addition layer, which can avoid gradient explosion during model training.
[0032] (4) Distillation Layer In order to better reduce the memory overhead and calculation time of the model, we introduce a distillation layer to perform important feature extraction operations, such as introducing a conv1d convolutional layer, an ELU activation layer, and a Maxpool layer to filter out redundant features. The calculation process is as follows: , where represents the output of the distillation layer, represents the output of the previous residual normalization layer, convld is a one-dimensional convolution operation, Maxpool is the maximum convolution operation, and ELU is the activation function.
[0033] (5) Feed-Forward Neural Network The feedforward neural network is the most basic neural network structure. Information flows unidirectionally (from the input layer → hidden layer → output layer), without loops or feedback connections. It can perform further feature extraction and non-linear transformation on the input data, thereby improving the expressive ability and performance of the model.
[0034] After the calculation of the EMD multi-head attention layer, different weight coefficients are assigned to different features to distinguish the importance of features. At the same time, the EMD distance calculation can reduce the time consumption of attention calculation and accelerate model training. Summation and normalization are to avoid problems such as gradient disappearance and gradient explosion during model training. Subsequently, feature screening is performed through the distillation layer to select important features.
[0035] S4. Input the pressure history data into the decoder embedding layer, and through the attention calculation of the multi-head sparse attention layer based on the EMD distance, and the prevention of gradient disappearance and gradient explosion processing of the summation & normalization layer, obtain the pressure auxiliary features that can be fused. A : Similarly, in the early stage of the decoder, the multi-head sparse attention layer based on the EMD distance and the residual normalization layer are used for calculation. We input the water pressure data into the decoder, and through the attention calculation of the multi-head self-attention layer based on the EMD distance, and the prevention of gradient disappearance and gradient explosion processing of the summation & normalization layer, obtain the auxiliary features that can be fused. A 。
[0036] S5. Input the obtained main features of the water supply volume Q and the pressure auxiliary features A into the main-auxiliary attention layer in the decoder to perform main-auxiliary attention matrix calculation and fusion to obtain the fused features. The fused features pass through the fully connected layer to output the predicted water supply volume: Introduce the main-auxiliary attention layer to perform main-auxiliary attention matrix calculation on the output of the encoder and the pressure features. During the main-auxiliary attention calculation, we regard feature sequences such as water supply volume, instantaneous flow rate, and holidays as the main features, and the water pressure feature as the auxiliary feature. Its main-auxiliary feature fusion structure is as Figure 3 shown.
[0037] The main-auxiliary attention layer includes an EMD attention layer, a normalization layer, a fine-grained attention layer, and a fine-tuning layer. Input the obtained main features of the water supply volume Q and the pressure auxiliary features A First, perform correlation calculation through the EMD attention layer to form an attention matrix, and then perform normalization processing. The output after normalization and the pressure auxiliary features A perform correlation calculation through the fine-grained attention layer to output the fine-grained attention. Add the main features of the water supply volume Q and the fine-grained attention and use normalization and non-linear transformation network for fine-tuning to obtain the fused features. The specific calculation process is as follows: We formally define the attention matrix M, M ij which represents Q the correlation degree between the i th eigenvector in A and the j th eigenvector in the pressure feature matrix M ij The calculation method of
[0038] Then, the Softmax function is used to normalize each row in M as shown in formula (2). Further, we can obtain the output of fine-grained attention through formula (3).
[0039] To further optimize the feature distribution, we use a normalization and non-linear transformation network for fine-tuning, including: using a single-layer MLP to optimize the main feature distribution, and the calculation method is shown in formula (4). Among them, W f and b f are trainable parameters. The fused feature is obtained through normalization and a feed-forward network.
[0040] (1), (2), (3), (4), F gi represents the fine-grained attention representation of the
[0041] th vector. The melted features are input into the fully connected layer for prediction, and the content of the masked part in the sequence is predicted based on the water supply sequence features, holiday features, and water pressure features. The formula is:
[0042] is the flow prediction value, ReLU is the activation function, W t is the weight, b is the bias term, F D is the fused feature.
[0043] S6. Calculate the water supply loss, construct a water pressure calculation model that can calculate the pressure value based on the water supply, calculate the pressure value using the water pressure calculation model according to the predicted water supply and compare it with the true value to calculate the pressure loss, and optimize and update the model parameters by backpropagation based on the composite loss function of the water supply loss and the pressure loss: The water pressure calculation model can adopt existing technologies (such as patent CN117432941A). For example, the construction process (such as Figure 4 is as follows: (1) Collect the water supply network attribute data and network monitoring data, including the network structure information, the information of the regulating reservoir, and the information of the pump power and head; (2) Use the collected data information to calculate the pipe specific resistance and construct a network hydraulic calculation model; (3) Determine the most unfavorable water supply point, key nodes and end users. Along the water plant outlet to the most unfavorable water supply point, install network pressure and flow automatic monitoring equipment at the key nodes and end user positions to automatically collect the flow operation data of each node and pipe section in the network; (4) According to the historical flow data of the collected nodes, use the method of regression analysis to establish a water supply flow prediction model to predict the flow data of the main pipes, branch pipes and end users in the future time period between the water plant and the most unfavorable point; (5) According to the network hydraulic calculation model, input the predicted water supply flow data of the main pipes, branch pipes and end users between the water plant and the most unfavorable point. Taking the minimum pressure P required by the end user at the most unfavorable point as the benchmark, calculate the pressure of the previous node and predict the pressure data P0 required for the water plant to supply water in the future time period. The calculation steps and formulas are as follows: a. Perform the conversion between the flow and the pressure difference of the pipe section. The conversion formula is: , where Q 流量 is the flow of the calculated pipe section, L is the pipe section length, h is the water pressure difference between the start and end of the pipe section, S is the pipe specific resistance of the pipe section; b. Derive the pressure of the previous node and the theoretical pressure required for the water plant to supply water based on the minimum pressure required by the end user at the most unfavorable point. The pressure calculation formula is: , where, P is the minimum pressure required at the end node of the most unfavorable pipeline (i.e., the end user at the most unfavorable point), P n is the theoretical pressure required for the water plant to supply water, P i is the pressure difference of the i th pipe section before the most unfavorable point along the most unfavorable pipeline, (i = 1, 2, … n - 1, where n is the number of pipeline segments along the line from the most unfavorable water supply point to the water plant outlet), (MPa); c. Calculate the actual required water plant outlet pressure in combination with the ground elevation difference. The calculation formula is: P0 = P n + Δh + h0, where P0 is the actual required water plant outlet pressure, P n is the theoretical pressure required for water supply by the water plant, Δh is the elevation difference between upstream and downstream, and h0 is the safety head.
[0044] The water supply loss is evaluated using the RMSE root mean square error to assess the prediction accuracy. The formula is: , In the formula is the true value, is the predicted value, and n is the sequence length.
[0045] To improve the robustness of the model, by introducing a water pressure calculation model, calculate the corresponding pressure based on the predicted water supply volume, and calculate the difference with the actual pressure to generate new loss samples, and add them to the input samples in this way of slight perturbation. Set α as the perturbation coefficient added to the samples. We use the Huber loss function to calculate the loss generated by the pressure model according to the predicted water supply volume and the actual pressure. Huber will introduce a hyperparameter δ , and its size is used to control the trade-off between the mean absolute error and the mean square error of the loss function. The formula is: , In the formula α is the perturbation coefficient, δ is a hyperparameter that can be determined by manual experience. A larger δ makes the loss function closer to the MSE at large errors, and a smaller δ makes the loss function closer to the MAE. By adding slight perturbations to the pressure and water supply volume features in the decoder, the model fully considers the pressure error when predicting the water supply volume. After forward and backward propagation, continuously minimize the loss (error) function , n is the number of loss values, and use L Final for backward propagation to update the model parameters θ and the perturbation coefficient α .
[0046] S7. Use the trained IAMformer network model to predict the validation set and the test set respectively, and use the final model to predict the future water supply volume: The trained IAMformer network model is used to predict the validation set, the test set, and the future respectively, obtaining the predicted values of the validation set, the test set, and the future; by plotting the line graphs of the original data, the validation set and its predicted values, the test set and its predicted values, and the future predicted values on the same graph, the prediction effect is visually presented.
[0047] Embodiment 2 A water supply prediction device based on water volume - water pressure coupling, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor. When the processor executes the program, it implements the water supply prediction method based on water volume - water pressure coupling as described in Embodiment 1 above.
[0048] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it can implement the steps of the water supply prediction method based on water volume - water pressure coupling as described in Embodiment 1 above.
[0049] The above are only specific embodiments of the present invention and are not used to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection scope of the present invention.
Claims
1. A water supply prediction method based on water volume - water pressure coupling, characterized in that, The steps are as follows: S1. Obtain the historical data of water supply volume, instantaneous flow rate, and pressure, preprocess it into a time series, and construct a data set; S2. Construct an IAMformer network improved based on the transformer architecture, including an encoder and a decoder. The encoder contains an embedding layer, a multi-head sparse attention layer based on the EMD distance, an addition & normalization layer, a distillation layer, and a feed-forward neural network layer. The decoder contains an embedding layer, a multi-head sparse attention layer based on the EMD distance, an addition & normalization layer, a primary and secondary attention layer, and a fully connected layer; S3. Input the historical data of water supply volume and instantaneous flow rate and holiday information into the embedding layer of the encoder to form an embedding matrix. The embedding matrix is input into the multi-head sparse attention layer based on the EMD distance for attention calculation to distinguish important features, followed by addition and normalization operations. Then, redundant features are filtered out through the distillation layer, and the main features Q for water supply volume prediction are obtained through the feed-forward neural network layer; S4. Input the pressure history data into the decoder embedding layer, and distinguish important features through the attention calculation of the multi-head sparse attention layer based on the EMD distance, and perform anti-gradient disappearance and gradient explosion processing on the addition & normalization layer to obtain the pressure auxiliary features that can be fused A ; S5. Input the obtained main water supply volume feature Q and pressure auxiliary feature A into the main and auxiliary attention layers in the decoder to calculate and fuse the main and auxiliary attention matrices to obtain the fused feature, and the fused feature passes through the fully connected layer to output the predicted water supply volume; S6. Calculate the water supply loss, construct a water pressure calculation model that can calculate the pressure value based on the water supply volume, calculate the pressure value using the water pressure calculation model according to the predicted water supply volume and compare it with the true value to calculate the pressure loss, and backpropagate and optimize the update of the model parameters according to the composite loss function of the water supply loss and the pressure loss; S7. Use the trained IAMformer network model to predict the validation set and the test set respectively, and use the final model to predict the future water supply volume.
2. The water supply prediction method based on water volume - water pressure coupling according to claim 1, wherein The multi-head sparse attention layer based on the EMD distance described in step S3 uses the EMD distance function to measure the similarity between the query vector and the uniform distribution, and selects the query vector with a large contribution for the attention operation. The process is as follows: (1) For the query vector Q, the attention calculation formula for the i-th query vector q i is as follows: , In the formula, represents the i-th query vector q i and the exponential kernel function operation with the j-th key vector k j . v j represents the j-th value vector. Use the calculation method of scaled dot product to obtain the attention probability distribution p of the i-th query vector. The process is as follows: First, calculate the similarity score between the query vector and the key vector, , wherein s ij represents the query vector q i and the key vector k j is the similarity score therebetween Then perform a scaling operation, , is the dimension of the query vector and the key vector, Finally, use the softmax function to convert the score into a probability distribution score, , p ij denote the i-th query vector q i for the j-th key vector k j of the attention probability scores, all p ij , j = 1, 2, ..., n form the attention probability distribution p of the i-th query vector q i ; Subsequently, define L k to represent the length of the query vector, and assume to represent the uniform distribution of the query vector. If the attention probability distribution p of the i-th query vector q i is far from this uniform distribution q, it indicates that the query vector q i makes a large contribution to the attention weight. The formula for using the EMD distance to measure the similarity between the query vector and this uniform distribution is as follows: , where d(x, y) represents the cost from x to y, γ represents the joint probability distribution, whose marginal distributions are the costs of q and p. inf represents the infimum, that is, the minimum value among all joint distributions, indicating the minimum cost required to transform the distribution q into the distribution p. W(q||p) is the distance between the two distributions; the greater the distance, the greater the contribution to the attention weight; (2) Screen out the query vectors that contribute greatly to the attention weight matrix through the EMD calculation and threshold setting method, and form a new query vector matrix with these query vectors And perform attention calculation, and its attention calculation formula is: , Among them K represents the key vector, V represents the value vector, represents the vector matrix, d k is Q and K the dimension of, X EMD is the output matrix after EMD calculation.
3. The water supply prediction method based on water volume - water pressure coupling according to claim 1, characterized in that, For the addition & normalization layer described in step S3, the addition layer adds the input of the multi-head sparse attention layer based on the EMD distance to its output; The normalization layer is after the addition layer and normalizes the input data.
4. The water supply prediction method based on water volume - water pressure coupling according to claim 1, characterized in that, The distillation layer described in step S3 includes a conv1d convolutional layer, an ELU activation layer, and a Maxpool layer to filter out redundant features. The calculation process is as follows: , Among them represents the output of the distillation layer, represents the output of the previous residual normalization layer, convld is a one-dimensional convolution operation, Maxpool is a max convolution operation, and ELU is the activation function.
5. The water supply prediction method based on water volume - water pressure coupling according to claim 1, characterized in that, The main and auxiliary attention layer described in step S5 includes an EMD attention layer, a normalization layer, a fine-grained attention layer, and a fine-tuning layer. The main characteristics of the water supply volume obtained Q and the pressure auxiliary characteristics A are first subjected to correlation calculation by the EMD attention layer to form an attention matrix, and then normalized. The normalized output and the pressure auxiliary characteristics A are subjected to correlation calculation by the fine-grained attention layer to output fine-grained attention. The main characteristics of the water supply volume Q and the fine-grained attention are added together and fine-tuned using a normalization and non-linear transformation network to obtain the fused characteristics.
6. The water supply prediction method based on water volume - water pressure coupling according to claim 1, characterized in that, The construction process of the water pressure calculation model described in step S6 is as follows: (1) Collect the water supply network attribute data and network monitoring data, including network structure information, regulating reservoir information, and information on pump power and head; (2) Use the collected data information to calculate the pipe section specific resistance and construct a network hydraulic calculation model; (3) Determine the most unfavorable water supply point, key nodes, and end users. Along the outlet of the water plant to the most unfavorable water supply point, install automatic monitoring equipment for network pressure and flow at the positions of key nodes and end users to automatically collect the flow operation data of each node and pipe section of the network; (4)Based on the historical flow data of the collected nodes, a regression analysis method is used to establish a water supply flow prediction model to predict the flow data of the main pipes, branch pipes, and end users between the water plant and the most unfavorable point in the future time period. (5)According to the pipe network hydraulic calculation model, input the predicted water supply flow data of the main pipes, branch pipes, and end users between the water plant and the most unfavorable point. Taking the minimum pressure P required by the users at the most unfavorable point as the benchmark, calculate the pressure of the previous node and predict the pressure data P0 required for the water plant to supply water in the future time period. The calculation steps and formulas are as follows: a. Perform the conversion between flow and pipe section pressure difference. The conversion formula is: , Among them Q 流量 is the calculated flow rate of this pipe section, L is the pipe section length, h is the water pressure difference between the starting end and the terminal end of the pipe section, S is the pipe specific resistance of the pipe section; b. Based on the minimum pressure required by the users at the most unfavorable point, deduce the pressure of the previous node and the theoretical pressure required for the water plant to supply water. The pressure calculation formula is: , Among them, P is the minimum required pressure at the end node of the most unfavorable pipeline, P n is the theoretical pressure required for the water plant to supply water, P i is the pressure difference of the i th pipeline segment before the most unfavorable point along the most unfavorable pipeline, i = 1, 2, … n - 1, where n is the number of pipeline segments along the line from the most unfavorable water supply point to the water plant outlet; c. Combine the ground elevation difference to calculate the actual required outlet pressure of the water plant. The calculation formula is: P0 = P n + Δh + h0, Among them, P0 is the actual required outlet pressure of the water plant, P n is the theoretical pressure required for the water supply of the water plant, Δh is the elevation difference between upstream and downstream, and h0 is the safety head.
7. The water supply prediction method based on water volume - water pressure coupling according to claim 1, characterized in that, For the composite loss function described in step S6, the root mean square error (RMSE) of the water supply loss is used to evaluate the prediction accuracy. The formula is: , where is the true value, is the predicted value, and n is the sequence length; The pressure loss uses the Huber loss function to calculate the loss generated by the pressure model based on the predicted water supply volume and the true pressure. A hyperparameter is introduced δ , and its magnitude is used to control the trade-off between the mean absolute error and the mean squared error of the loss function. The formula is as follows: , where α is the perturbation coefficient, is the true value, is the predicted value, δ is a hyperparameter that can be determined by manual experience; Composite loss function , where n is the number of loss values, and use L Final to perform backpropagation to update the model parameters and perturbation coefficients.
8. A water supply prediction device based on water volume - water pressure coupling, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the water supply prediction method based on water quantity - water pressure coupling as described in any one of claims 1 - 7.
9. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it can implement the steps of the water supply prediction method based on water quantity - water pressure coupling as described in any one of claims 1 - 7.
Citation Information
Patent Citations
Implementation method of adaptive protein prediction framework, device and equipment
CN113257361A
Chinese relation extraction method and system based on multi-modal semantic fusion
CN115270809A
Water quality prediction method based on Transform sparse attention mechanism
CN116050571A
Time sequence prediction method fusing data enhancement and deep learning
CN116187197A
Optimized adjustment method and system for water supply pressure of water plant
CN117432941A