Water supply amount prediction method and device based on water quantity-water pressure coupling, and storage medium

By using an improved IAMformer network and water pressure calculation model, the problem of water quantity-water pressure coupling error propagation in traditional water supply prediction methods is solved, achieving higher accuracy and robustness in water supply prediction.

CN120355042BActive Publication Date: 2025-12-05SHANDONG FENGSHI INFORMATION TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510846155.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-06-24
Publication Date
2025-12-05
Estimated Expiration
2045-06-24

AI Technical Summary

Technical Problem

Traditional water supply forecasting methods struggle to effectively handle multi-dimensional nonlinear coupled data such as meteorological factors and user behavior patterns, leading to a chain propagation of errors in the water volume-pressure coupled system. Furthermore, existing deep learning technologies have failed to effectively decouple the dynamic coupling relationship between water volume and pressure.

Method used

An improved IAMformer network based on the transformer architecture is adopted, combined with the multi-head sparse attention mechanism of EMD distance and the master-slave attention layer. Water supply is predicted through a water pressure calculation model. The model parameters are optimized using a composite loss function to reduce the indirect impact of water pressure prediction error on water supply prediction.

Benefits of technology

It improves the accuracy of water supply prediction and the robustness of the model, reduces algorithm complexity, enhances the ability to capture long-term dependencies, and decouples the dynamic coupling relationship between water volume and water pressure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120355042B_ABST
    Figure CN120355042B_ABST
Patent Text Reader

Abstract

The present application relates to a water supply amount prediction method and device based on water volume-water pressure coupling and a storage medium, belonging to the technical field of water supply amount prediction and deep learning. By constructing an IAMformer network, a multi-head sparse attention layer based on EMD distance is introduced in the encoder and decoder, the historical data of water supply amount and instantaneous flow and holiday information are input into the encoder to obtain the main feature Q of water supply amount prediction; the pressure data is input into the decoder to obtain the pressure auxiliary feature that can be fused A The two features are input into the main and auxiliary attention layers in the decoder for main and auxiliary attention matrix calculation and fusion to obtain the fused feature, the fused feature is output through the full connection layer to predict the water supply amount, and the model parameters are updated through the backward propagation of the compound loss function of the water supply amount loss and the pressure loss. The present application can reduce the indirect influence of water pressure prediction error on water supply amount prediction, and can reduce the complexity of the algorithm model and improve the robustness of the model.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application relates to a water supply amount prediction method based on water amount-water pressure coupling, a device and a storage medium, and belongs to the technical field of water supply amount prediction and deep learning. BACKGROUND

[0002] The water supply amount and water pressure data have periodicity and randomness, and the randomness makes such data more difficult to predict than traditional data, and the complexity is high when predicting the water consumption for a long time.

[0003] Traditional water supply amount prediction methods mainly rely on artificial experience formula or statistical time series analysis (such as ARIMA model), but it is difficult to effectively process multi-dimensional nonlinear coupling data such as meteorological factors and user behavior patterns. In recent years, although deep learning technology (such as LSTM recurrent neural network) has improved the prediction accuracy to a certain extent, it still regards water supply amount prediction and water pressure calculation as independent tasks, or uses 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 chain propagation of errors in the water amount-water pressure coupling system. Therefore, a new prediction framework is needed that can decouple the dynamic coupling relationship between water amount and water pressure and can realize error compensation, while ensuring the lightweight of the model and improving the overall prediction accuracy and robustness of the system. SUMMARY

[0004] The purpose of the present application is to overcome the above-mentioned deficiencies and provide a water supply amount prediction method based on water amount-water pressure coupling, which can reduce the indirect influence of water pressure prediction error on water supply amount prediction, and at the same time reduce the complexity of the algorithm model and improve the robustness of the model.

[0005] The technical scheme adopted by the present application is:

[0006] The water supply amount prediction method based on water amount-water pressure coupling comprises the following steps:

[0007] S1. Obtain historical data of water supply amount, instantaneous flow and pressure, preprocess into time series, and construct a data set;

[0008] S2. Construct an IAMformer network improved based on a transformer architecture, including an encoder and a decoder, wherein the encoder comprises an embedding layer, a multi-head sparse attention layer based on EMD distance, an addition & normalization layer, a distillation layer, and a feedforward neural network layer, and the decoder comprises an embedding layer, a multi-head sparse attention layer based on EMD distance, an addition & normalization layer, a main-aid attention layer, and a full connection layer.

[0009] S3. The water supply amount, the historical data of the instantaneous flow and the holiday information are input 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 to perform attention calculation to distinguish important features, then the addition and normalization operations are performed, then the redundant features are filtered through the distillation layer, and then the main features of the water supply amount prediction are obtained through the feedforward neural network layer Q ;

[0010] S4. The pressure historical data are input into the embedding layer of the decoder, important features are distinguished through the attention calculation of the multi-head sparse attention layer based on the EMD distance, the gradient disappearance and gradient explosion are prevented through the addition & normalization layer, and the pressure auxiliary features that can be fused are obtained A ;

[0011] S5. The obtained main features Q of the water supply amount and the pressure auxiliary features A are input into the main and auxiliary attention layer in the decoder to perform main and auxiliary attention matrix calculation and fusion to obtain fusion features, and the fusion features are output through the fully connected layer to predict the water supply amount

[0012] S6. The water supply amount loss is calculated, the water pressure calculation model that can calculate the pressure value according to the water supply amount is constructed, the pressure value is calculated by using the water pressure calculation model according to the predicted water supply amount, and the pressure loss is calculated by comparing with the true value, and the model parameters are updated through the reverse propagation optimization according to the composite loss function of the water supply amount loss and the pressure loss

[0013] S7. The IAMformer network model trained is used to predict the verification set and the test set respectively, and the final model is used to predict the future water supply amount.

[0014] In the above method, the multi-head sparse attention layer based on the EMD distance in step S3 uses the EMD distance function to measure the similarity of the query vector and the uniform distribution, and the query vectors with large contribution degrees are selected to perform attention operation, and the process is as follows:

[0015] (1) For the query vector Q, the attention calculation formula of the i th query vector q i is as follows:

[0016] ,

[0017] In the formula, the exponential kernel function operation of the i th query vector and the j th key vector q i is denoted as k j , the j th value vector v j is denoted as

[0018] The attention probability distribution p of the i-th query vector is obtained by calculating the scaled dot product, as follows:

[0019] First, calculate the similarity score between the query vector and the key vector.

[0020] ,

[0021] In the formula s ij Represents the query vector q i and key vector k j Similarity score between them

[0022] Then scale the calculation.

[0023] ,

[0024] To query the dimensions of the vector and key vector,

[0025] Finally, the softmax function is used to convert the scores into probability distribution scores.

[0026] ,

[0027] p ij Represents the i-th query vector q i For the j-th key vector k j Attention probability score, all p ij (j=1,2,...,n) constitute the i-th query vector q i The attention probability distribution p=(p i1 ,p i2 ,...,p in );

[0028] Subsequently, the definition L k Used to represent the length of the query vector, and assuming Used to represent a uniform distribution of query vectors, if the i-th query vector... q i If the attention probability distribution p deviates from the uniform distribution q, it indicates that the query vector q i The EMD distance metric, which contributes significantly to attention weights, is used to measure the similarity between the query vector and this uniform distribution. The formula is as follows:

[0029] ,

[0030] where d(x, y) represents the cost from x to y, gamma represents the joint probability distribution, whose marginal distribution is the cost of q and p, inf represents the infimum, that is, the minimum value in all joint distributions, represents the minimum cost required for distribution q to transform into distribution p, and W(q||p) is the distance between the two distributions; the greater the distance, the greater the contribution to the attention weight;

[0031] (2) The query vectors with large contribution to the attention weight matrix are screened out by the EMD calculation and threshold setting method, and these query vectors are combined to form a new query vector matrix and the attention calculation is performed, and the attention calculation formula is:

[0032] ,

[0033] where K represents the key vector, 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.

[0034] The L query vectors with the largest contribution are selected, and the attention operation is continued; the remaining query vectors will not participate in the calculation, and the value vector is directly filled by averaging to ensure that the output sequence and the input sequence are equal in length.

[0035] The addition & normalization layer, the addition layer (residual connection) is based on the input of the multi-head sparse attention layer of the EMD distance added to the output thereof; the normalization layer is after the addition layer, which is a standardization processing to the input data.

[0036] The distillation layer includes a conv1d convolution layer, an ELU activation layer and a Maxpool layer to filter out redundant features, and the calculation process is as follows:

[0037] ,

[0038] 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 a maximum convolution operation, and ELU is an activation function.

[0039] The main and auxiliary attention layer in step S5 includes an EMD attention layer, a normalization layer, a fine-grained attention layer and a fine-tuning layer, and the obtained main features of the water supply Q and the pressure auxiliary features AThe correlation degree is calculated through the EMD attention layer to form an attention matrix, and then normalized, and the output after normalization is combined with the pressure auxiliary features A The correlation degree is calculated through the fine-grained attention layer to output fine-grained attention, and the water supply amount main features Q The fine-grained attention is added to the main features, and a normalization and nonlinear transformation network is used for fine-tuning to obtain the fused features.

[0040] The water pressure calculation model construction process in step S6 is as follows:

[0041] (1) Collect water supply network attribute data, network monitoring data, including network structure information, reservoir information, and pump power and head information;

[0042] (2) Calculate the pipe section resistance using the collected data information and construct a pipe network hydraulic calculation model;

[0043] (3) Determine the most unfavorable point, key node and end user of water supply, install pipe network pressure and flow automatic monitoring equipment at the key node and end user position along the outlet of the water plant to the most unfavorable point, and automatically collect the flow operation data of each node and pipe section of the pipe network;

[0044] (4) According to the collected node flow historical data, a regression analysis method is used to establish a water supply flow prediction model to predict the flow data of the main pipe, branch pipe and end user between the water plant and the most unfavorable point in the future time period;

[0045] (5) According to the pipe network hydraulic calculation model, input the water supply flow prediction data of the main pipe, branch pipe and end user between the water plant and the most unfavorable point, take the minimum pressure P required by the most unfavorable point user as the reference, and calculate the previous node pressure and predict the pressure data P0 required by the water plant in the future time period, and the calculation steps and formulas are as follows:

[0046] a. Perform flow and pipe section pressure difference conversion, and the conversion formula is:

[0047] ,

[0048] Wherein Q 流量 is the calculated flow of the 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 of the pipe section;

[0049] b. Take the minimum pressure required by the most unfavorable point user as the reference to derive the previous node pressure and the theoretical pressure required by the water plant, and the pressure calculation formula is:

[0050] ,

[0051] in, P The minimum pressure required at the most unfavorable end node of the pipeline (i.e., the most unfavorable user point). P n The theoretical pressure required to supply water to the water plant P i The first point before the most unfavorable point along the most unfavorable pipeline. i Pressure difference in the pipe section, ( i =1,2,…n-1, where n is the number of pipe sections along the route from the most unfavorable water supply point to the water plant outlet (MPa);

[0052] c. Calculate the actual required outlet pressure of the water plant based on the ground elevation difference. The calculation formula is as follows:

[0053] P0 = P n +Δh+ h0,

[0054] Where P0 is the actual required outlet pressure of the water plant, P n The theoretical pressure required for water supply to the water plant is given by Δh, which is the elevation difference between the upstream and downstream sides, and h0 is the safe head.

[0055] The composite loss function described in step S6 uses the root mean square error (RMSE) to assess the prediction accuracy of water supply loss. The formula is as follows:

[0056] ,

[0057] In the formula For the true value, The predicted value is n, where n is the sequence length.

[0058] Pressure loss is calculated using the Huber loss function, which compares the pressure model's prediction of water supply with the actual pressure. A hyperparameter δ is introduced to control the trade-off between the mean absolute error and the mean square error of the loss function. The formula is as follows:

[0059] ,

[0060] In the formula α The disturbance coefficient is... For the true value, For predicted values, delta A hyperparameter can be determined by human experience;

[0061] Composite loss function n is the number of loss values, and is used as... L Final Backpropagation is performed to update the model parameters and perturbation coefficients.

[0062] Another object of the present application is to provide a water supply amount prediction device based on water quantity-water pressure coupling, comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the processor implements the water supply amount prediction method based on water quantity-water pressure coupling as described above when executing the program.

[0063] A computer readable storage medium storing a computer program, wherein the computer program is executable by a processor to implement the steps of the water supply amount prediction method based on water quantity-water pressure coupling as described above.

[0064] The present application has the following beneficial effects:

[0065] 1. The present application improves the EMD attention mechanism, which can effectively reduce the time complexity when predicting long-term water consumption and water pressure data, and improve the ability of the model to capture long-term dependencies.

[0066] 2. The decoder uses the main and auxiliary attention mechanism, which can realize the influence of pressure features on water supply by fusing pressure features and strengthen their correlation.

[0067] 3. The present application introduces a water pressure calculation model, which corrects the model parameters by calculating the loss of predicted pressure and real pressure and combining the loss function of water supply prediction, decouples the dynamic coupling relationship between water quantity and water pressure, and makes the prediction result more accurate under the condition of fully considering the pressure.

[0068] 4. The method of the present application predicts water quantity by improving the attention mechanism of the transformer and constructs a water supply prediction model by means of the water pressure calculation model for adversarial learning, 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. BRIEF DESCRIPTION OF DRAWINGS

[0069] Figure 1 The network model architecture of the present application is shown in the figure;

[0070] Figure 2 The flowchart of the method of the present application is shown in the figure, ① represents the real value of water pressure input, and ② represents the water pressure calculated by the water pressure calculation model for loss calculation according to the water supply prediction value;

[0071] Figure 3 The main and auxiliary feature fusion process diagram of the present application is shown in the figure;

[0072] Figure 4 The construction flowchart of the water pressure calculation model of the present application is shown in the figure. DETAILED DESCRIPTION

[0073] The present application will be further described below in conjunction with specific embodiments.

[0074] The water supply amount prediction method based on water amount-water pressure coupling of embodiment 1 comprises the following steps (such as Figure 2 ):

[0075] S1. Obtain the historical data of water supply amount, instantaneous flow and pressure, preprocess into time series, and construct a data set:

[0076] The preprocessing of water supply amount data and pressure data stabilizes the time series of water supply amount, instantaneous flow and pressure, and processes missing values.

[0077] (1) Data cleaning

[0078] ① Flow data: remove abnormal values of instantaneous flow > theoretical maximum flux ( Q max =πr 2 v max

[0079] ② Pressure data: exclude data with pressure value <0 MPa (sensor failure) or > pipe network pressure limit.

[0080] (2) Missing value filling

[0081] ① Linear interpolation: suitable for short time (<1 hour) data loss;

[0082] ② Periodic filling: use historical data of the same period (such as the same working day, period) to fill the gap of pressure and flow values.

[0083] According to the best preprocessed data, a data set is constructed, which includes a training set, a validation set and a test set, with a ratio of 8:1:1.

[0084] S2. Construct an IAMformer network based on the improved transformer architecture (such as Figure 1 ), including an encoder and a decoder, wherein the encoder contains an embedding layer, a multi-head sparse attention layer based on EMD distance, an addition & normalization layer, a distillation layer and a feedforward neural network layer, and the decoder contains an embedding layer, a multi-head sparse attention layer based on EMD distance, an addition & normalization layer, a main auxiliary attention layer and a fully connected layer.

[0085] S3. Input the historical data of water supply amount, instantaneous flow and holiday information into the embedding layer of the encoder to form an embedding matrix, input the embedding matrix into the multi-head sparse attention layer based on EMD distance for attention calculation to distinguish important features, then perform addition and normalization operation, then pass through the distillation layer to remove redundancy, and then pass through the feedforward neural network layer to obtain the main features Q of water supply amount prediction:

[0086] ​(1) Embedding layer: using LSTM time series model for embedding operation,

[0087] , ,

[0088] where, represents the vector representation of the i-th feature, represents the sequence information of the i-th feature.

[0089] (2) Multi-head sparse attention layer based on EMD distance:

[0090] The multi-head sparse attention layer based on 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 high contribution to do attention operation. The process is as follows:

[0091] a. We define the attention calculation formula of the i-th query vector q i as follows:

[0092] ,

[0093] where represents the exponential kernel function operation of the i-th query vector q i and the j-th key vector k j , v j represents the j-th value vector;

[0094] The attention probability distribution p of the i-th query vector is obtained by using the scaled dot product calculation method, and the process is as follows:

[0095] ,

[0096] where s ij represents the similarity score between the query vector q i and the key vector k j ,

[0097] ,

[0098] In order to avoid the above dot product operation result too large, resulting in unstable gradient, therefore, scaling operation, is the dimension of the query vector and the key vector,

[0099] ,

[0100] ​Finally, the softmax function is used to convert the scores into probability distribution scores. p ij Represents the i-th query vector q i For the j-th key vector k j Attention probability score, all p ij (j=1,2,...,n) constitute the i-th query vector q i The attention probability distribution p=(p i1 ,p i2 ,...,p in );

[0101] Subsequently, the definition L k Used to represent the length of the query vector, and assuming Used to represent a uniform distribution of query vectors, if the i-th query vector... q i If the attention probability distribution p deviates from the uniform distribution q, it indicates that the query vector q i The EMD distance significantly contributes to the attention weights. The formula for measuring the similarity between the query vector and this uniform distribution is as follows:

[0102] ,

[0103] Where d(x,y) represents the cost from x to y. gamma represents the joint probability distribution, whose marginal distributions are the costs of q and p. inf denotes the infimum, which is the minimum value among all joint distributions, representing the minimum cost required to transform distribution q into distribution p. W(q||p) is the distance between the two distributions, and the greater the distance, the greater the contribution to the attention weights.

[0104] b. After calculating the query vectors that contribute significantly to the attention weight matrix using EMD, these query vectors need to be combined into a new query vector matrix. Attention is calculated, and the formula for attention calculation is as follows:

[0105] ,

[0106] in K Represents the key vector. V Represents a value vector. Represents the new query vector matrix. d k For the dimensions of Q and K, X EMD This is the output matrix calculated using EMD.

[0107] In selecting the query vector with greater contribution, we filter through the threshold setting T. When the EMD value of a query vector exceeds the threshold, it is determined that the query vector has greater contribution. After multiple experiments, it is found that the EMD threshold set between 0.40-0.55 has the best effect. 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.

[0108] Select the L query vectors with the greatest contribution to continue attention operation; the remaining query vectors will no longer participate in the calculation, and the value vector is directly filled with mean value to ensure that the output sequence and the input sequence are equal in length.

[0109] When the sequence length is N, the multi-head sparse attention mechanism based on EMD distance has a time complexity of O(NlnN) in calculating the attention probability matrix, compared with the time complexity O(N 2 ) of the traditional attention mechanism. The model performance is ensured while the computational efficiency of the model is further improved.

[0110] (3) Addition & Normalization Layer

[0111] It is divided into addition layer and normalization layer. The function of the addition layer is to add two or more tensors element by element, which is commonly used to realize residual connection to avoid gradient disappearance in the training process of the model; the function of the normalization layer is to standardize the input data and adjust its distribution (mean value is 0 and variance is 1), which is usually connected after the addition layer to avoid gradient explosion in the training process of the model.

[0112] (4) Distillation Layer

[0113] In order to better reduce the memory overhead and calculation time of the model, we introduce a distillation layer for important feature extraction operation, such as introducing a conv1d convolution layer, an ELU activation layer and a Maxpool layer to filter out redundant features, and its calculation process is as follows:

[0114] ,

[0115] 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 maximum convolution operation, and ELU is an activation function.

[0116] (5) Feedforward Neural Network

[0117] Feedforward neural network is the most basic neural network structure, one-way flow of information (from input layer → hidden layer → output layer), no loop or feedback connection. It can realize further feature extraction and nonlinear transformation of input data, thereby improving the expression ability and performance of the model.

[0118] After the EMD multi-head attention layer calculation, different weight coefficients are assigned to different features to distinguish the importance of the features. At the same time, the EMD distance calculation can reduce the time consumption of attention calculation and speed up the model training. The addition and normalization are to avoid the problems such as gradient disappearance and gradient explosion in the model training process, and then the features are screened through the distillation layer to select important features.

[0119] S4. The pressure history data is input into the decoder embedding layer, and the important features are distinguished through the attention calculation of the multi-head sparse attention layer based on the EMD distance, and the gradient disappearance and gradient explosion are prevented through the addition & normalization layer, to obtain the pressure auxiliary features that can be fused A :

[0120] Similarly, the multi-head sparse attention layer based on EMD distance and residual normalization layer are used in the early stage of the decoder. We input the water pressure data into the decoder, and the important features are distinguished through the attention calculation of the multi-head self-attention layer based on EMD distance, and the gradient disappearance and gradient explosion are prevented through the addition & normalization layer, to obtain the auxiliary features that can be fused A .

[0121] S5. The obtained main features of water supply Q and pressure auxiliary features A are input into the main and auxiliary attention layer in the decoder to calculate and fuse the main and auxiliary attention matrix to obtain the fusion features, and the fusion features are output through the full connection layer to predict the water supply:

[0122] The main and auxiliary attention layer is introduced to calculate the main and auxiliary attention matrix of the output of the encoder and the pressure features. In the main and auxiliary attention calculation, we regard the feature sequences of water supply, instantaneous flow, holiday, etc. as main features, and the water pressure features as auxiliary features, and the main and auxiliary feature fusion structure is as shown in Figure 3 .

[0123] The main and auxiliary attention layer includes EMD attention layer, normalization layer, fine-grained attention layer and fine-tuning layer. The obtained main features of water supply Q and pressure auxiliary features A are first calculated by the EMD attention layer to form the attention matrix, and then normalized. The output after normalization and the pressure auxiliary features A are calculated by the fine-grained attention layer to output the fine-grained attention, and the main features of water supply QThe fused feature is obtained by adding the fine-grained attention and fine-tuning using a normalization and nonlinear transformation network. The specific calculation process is as follows:

[0124] We formally define the attention matrix M, M ij represents Q the correlation degree between the i-th feature vector in the stress feature matrix i and the i-th feature vector in the stress feature matrix A . j M ij The calculation method of is shown in formula (1).

[0125] Then, the Softmax function is used to normalize each row in M , as shown in formula (2). Further, we can obtain the output of the fine-grained attention through formula (3).

[0126] In order to further optimize the feature distribution, we fine-tune using a normalization and nonlinear transformation network, including: using a single-layer MLP to optimize the main feature distribution, the calculation method is shown in formula (4). Wherein, W f and b f are trainable parameters. The fused feature is obtained by normalization and feedforward network.

[0127] (1),

[0128] (2),

[0129] (3),

[0130] (4),

[0131] F gi represents the fine-grained attention representation of the i-th vector.

[0132] The fused feature is input into the fully connected layer for prediction, and based on the water supply sequence feature, holiday feature and water pressure feature, the content of the masked part in the sequence is predicted, and the formula is:

[0133]

[0134] is the flow prediction value, ReLU is the activation function, W t is the weight, b is the bias term,​F D To fuse features.

[0135] S6. Calculate the water supply loss, construct a water pressure calculation model that can calculate the pressure value according to 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 according to the compound loss function of the water supply loss and the pressure loss, the model parameters are updated and optimized by back propagation:

[0136] The water pressure calculation model can use existing technologies (such as patent CN117432941A), for example, the construction process (such as Figure 4 ) is as follows:

[0137] (1) Collect water supply network attribute data, network monitoring data, including network structure information, storage tank information, and pump power and lift information;

[0138] (2) Calculate the pipe section resistance using the collected data information and construct a pipe network hydraulic calculation model;

[0139] (3) Determine the most unfavorable point of water supply, key nodes and end users, install pipe network pressure and flow automatic monitoring equipment at key nodes and end user locations along the water plant outlet to the most unfavorable point of water supply, and automatically collect flow data of each node and pipe section of the pipe network;

[0140] (4) According to the collected node flow historical data, a regression analysis method is used to establish a water supply flow prediction model to predict the flow data of the main pipe, branch pipe and end user between the water plant and the most unfavorable point in the future time period;

[0141] (5) According to the pipe network hydraulic calculation model, input the water supply flow prediction data of the main pipe, branch pipe and end user between the water plant and the most unfavorable point, take the minimum pressure P required by the most unfavorable point user as the reference, and calculate the pressure of the previous node and predict the pressure data P0 required by the water plant in the future time period, and the calculation steps and formulas are as follows:

[0142] a. Perform flow and pipe section pressure difference conversion, and the conversion formula is:

[0143] ,

[0144] Wherein Q 流量 is the calculated flow of the 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 of the pipe section;

[0145] b. Take the minimum pressure required by the most unfavorable point user as the reference to derive the pressure of the previous node and the theoretical pressure required by the water plant, and the pressure calculation formula is:

[0146] ,

[0147] in, P The minimum pressure required at the most unfavorable end node of the pipeline (i.e., the most unfavorable user point). P n The theoretical pressure required to supply water to the water plant P i The first point before the most unfavorable point along the most unfavorable pipeline. i Pressure difference in the pipe section, ( i =1,2,…n-1, where n is the number of pipe sections along the route from the most unfavorable water supply point to the water plant outlet (MPa);

[0148] c. Calculate the actual required outlet pressure of the water plant based on the ground elevation difference. The calculation formula is as follows:

[0149] P0 = P n +Δh+ h0,

[0150] Where P0 is the actual required outlet pressure of the water plant, P n The theoretical pressure required for water supply to the water plant is given by Δh, which is the elevation difference between the upstream and downstream sides, and h0 is the safe head.

[0151] The accuracy of water supply loss predictions is assessed using the root mean square error (RMSE), and the formula is as follows:

[0152] ,

[0153] In the formula For the true value, is the predicted value, and n is the sequence length.

[0154] To improve the robustness of the model, a water pressure calculation model is introduced. This model calculates the corresponding pressure by predicting the generated water supply and then calculates the difference between the predicted and actual pressures to generate new loss samples. These new samples are added to the input samples in a small perturbation manner. α To calculate the perturbation coefficients added to the sample, we use the Huber loss function to compute the loss generated by the pressure model based on the predicted water supply and actual pressure. Huber introduces a hyperparameter. delta Its magnitude is used to control the trade-off between the mean absolute error and the mean squared error of the loss function, and its formula is:

[0155] ,

[0156] In the formula α The disturbance coefficient is... delta A hyperparameter can be determined by human experience; a larger one... deltaSo that the loss function is closer to MSE at large errors, and closer to MAE at small errors delta So that the loss function is closer to MAE. By adding a tiny perturbation to the pressure and supply features in the decoder, the model takes into account the pressure error when predicting the supply, and through forward and backward propagation, it constantly minimizes the loss (error) function , n is the number of loss values, and L Final Backpropagation is performed to update the model parameters theta And the perturbation coefficient α .

[0157] 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:

[0158] Apply the trained IAMformer network model to predict the validation set, the test set and the future respectively, and obtain the validation set prediction value, the test set prediction value and the future prediction value; draw a line chart of the original data, the validation set and the validation set prediction value, the test set and the test set prediction value, and the future prediction value on the same graph, which intuitively shows the prediction effect.

[0159] Embodiment 2 A water supply prediction device based on water quantity-water pressure coupling, comprising a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to realize the water supply prediction method based on water quantity-water pressure coupling as described in Embodiment 1.

[0160] A computer readable storage medium stores a computer program, which can realize the steps of the water supply prediction method based on water quantity-water pressure coupling as described in Embodiment 1 when executed by a processor.

[0161] The above is only a specific embodiment of the present application and is not used to limit the protection scope of the present application, and any modification, equivalent replacement, improvement, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A water supply amount prediction method based on water amount-water pressure coupling, characterized by, The steps include the following: S1. Obtain the historical data of water supply, instantaneous flow and pressure, preprocess into time series, and construct a data set; S2. Construct an IAMformer network based on the improved transformer architecture, including an encoder and a decoder, wherein 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 feedforward neural network layer, and the decoder includes an embedding layer, a multi-head sparse attention layer based on EMD distance, an addition & normalization layer, a main-aid attention layer, and a fully connected layer; The multi-head sparse attention layer based on EMD distance uses an EMD distance function to measure the similarity of the query vector and the uniform distribution, and performs attention operation on the query vector with high contribution, and the process is as follows: For a query vector Q, define the i-th query vector q i The attention computation formula for the i-th query vector is as follows: , wherein denotes the ith query vector q i and the exponential kernel function operation k j with the jth key vector v j denotes the jth value vector, The attention probability distribution p of the i-th query vector is obtained by using the scaling dot product calculation method, and the process is as follows: First, calculate the similarity score of the query vector and the key vector, , wherein s ij represents a similarity score between a query vector q i and a key vector k j ​ Then, scaling operation, , For the dimensions of the query vector and the key vector, Finally, use the softmax function to convert the score into a probability distribution score, , p ij denotes the i-th query vector q i the attention probability score for the j-th key vector k j all p ij constitutes the i-th query vector q i the attention probability distribution p, j = 1, 2,..., n; 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 i-th query vector q i The attention probability distribution p of is far from the uniform distribution q, which indicates that the query vector q i has a large contribution to the attention weight. The formula for measuring the similarity between the query vector and the uniform distribution using the EMD distance 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 lower bound, that is, the minimum value in all joint distributions, represents the minimum cost required for distribution q to be transformed into distribution p, and W(q||p) is the distance between the two distributions; the greater the distance, the greater the contribution to the attention weight; (2) The query vectors with high contribution to the attention weight matrix are screened out by the EMD calculation and threshold setting method, and these query vectors are combined to form a new query vector matrix and attention calculation, and the attention calculation formula is: , wherein K a representative key vector, V a representative value vector, a representative vector matrix, d k is Q and K a dimension, X EMD is an output matrix calculated by EMD; S3. The historical data of water supply and instantaneous flow and holiday information are input 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 EMD distance for attention calculation to distinguish important features, then addition and normalization operation is performed, then redundant features are filtered through the distillation layer, and then the main features Q of water supply prediction are obtained through the feedforward neural network layer; S4. The pressure history data is input into the decoder embedding layer, the important features are distinguished through attention calculation based on the multi-head sparse attention layer of EMD distance, the gradient disappearance and gradient explosion are prevented through the addition & normalization layer, and the pressure auxiliary features that can be fused are obtained A ; S5. The resulting water supply amount primary feature Q and pressure auxiliary feature A The main auxiliary attention layer in the input decoder performs main auxiliary attention matrix calculation and fusion to obtain the fused feature, The fusion features output prediction water supply through a full connection layer; the main and auxiliary attention layer includes an EMD attention layer, a normalization layer, a fine-grained attention layer and a fine-tuning layer, and the obtained water supply main features Q and pressure auxiliary features A First, the correlation degree is calculated through the EMD attention layer to form an attention matrix, and then normalized processing is performed; the output after normalization and the pressure auxiliary features A The correlation degree is calculated through the fine-grained attention layer to output fine-grained attention, and the water supply main features Q and fine-grained attention are added and fine-tuned by using a normalization and nonlinear transformation network to obtain the fused features; S6. Calculate the water supply loss, construct a water pressure calculation model capable of calculating the pressure value according to 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 update the model parameters according to the composite loss function of the water supply loss and the pressure loss for back propagation optimization; 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.

2. The water supply amount prediction method based on water amount-water pressure coupling according to claim 1, characterized by, The addition & normalization layer in step S3, the addition layer is the input of the multi-head sparse attention layer based on EMD distance added to its output; The normalization layer is after the addition layer, which is a standardization processing of the input data.

3. The water supply amount prediction method based on water amount-water pressure coupling according to claim 1, characterized by, The distillation layer in step S3 includes a conv1d convolution layer, an ELU activation layer and a Maxpool layer to filter out redundant features, and the calculation process is as follows: , wherein x t layer+1 denotes the output of the distillation layer, x t layer denotes the output of the preceding residual normalization layer, convld is a one-dimensional convolution operation, Maxpool is a max-pooling operation, and ELU is an activation function.

4. The water supply amount prediction method based on water amount-water pressure coupling according to claim 1, wherein The water pressure calculation model in step S6 is constructed as follows: (1) Collect the attribute data of the water supply network, the monitoring data of the network, including the structure information of the network, the information of the storage tank, and the information of the pump power and lift; (2) Calculate the pipe resistance and construct the pipe network hydraulic calculation model using the collected data information; (3) Determine the most unfavorable point of water supply, the key node and the end user, install the pipe network pressure flow automatic monitoring equipment at the key node and the end user position along the outlet of the water plant to the most unfavorable point of water supply, and automatically collect the flow operation data of each node and pipe section of the pipe network; (4) According to the collected flow history data of the nodes, a regression analysis method is used to establish a water supply flow prediction model to predict the flow data of the main pipe, branch pipe and end user between the water plant and the most unfavorable point in the future time period; (5) According to the pipe network hydraulic calculation model, the predicted flow data of the main pipe, branch pipe and end user between the water plant and the most unfavorable point are input, and the minimum pressure P required by the most unfavorable point user is taken as the benchmark to calculate the pressure of the previous node and predict the pressure data P0 required by the water plant in the future time period, and the calculation steps and formula are as follows: a. Conversion of flow and pipe section pressure difference, conversion formula is: , wherein Q 流量 is the calculated flow rate of the pipe section, L is the length of the pipe section, h is the difference in water pressure between the start and end of the pipe section, S is the pipe friction of the pipe section; b. The minimum pressure required by the most unfavorable point user is taken as the benchmark to derive the pressure of the previous node and the theoretical pressure required by the water plant, and the pressure calculation formula is: , wherein, P Pminis the minimum pressure required at the most disadvantaged end node of the pipeline, P c Ptheor is the theoretical pressure required for water supply from the water plant, P m Pdiff is the pressure difference across the pipe section preceding the most disadvantaged point along the pipeline, m Pdiff is the pressure difference across the pipe section preceding the most disadvantaged point along the pipeline, m = 1, 2,... c - 1, c - 1 is the number of pipe sections along the pipeline from the most disadvantaged supply point to the water plant outlet. c. The actual required outlet pressure of the water plant is calculated in combination with the ground elevation difference, and the calculation formula is: P0 = P c + Ah + h0, where P0 is the actual required water plant outlet pressure, P c is the theoretical pressure required for water plant supply, Δh is the elevation difference between upstream and downstream, and h0 is the safety water head.

5. The water supply amount prediction method based on water amount-water pressure coupling according to Claim 1, wherein The composite loss function in step S6 uses RMSE root mean square error to evaluate the prediction accuracy of the water supply loss, and the formula is: , In the formula is the true value, is the predicted value; The pressure loss uses Huber loss function to calculate the loss generated by the pressure model according to the predicted water supply and the real pressure, and introduces a hyperparameter The processor executes the program to realize the water quantity-water pressure coupled water supply quantity prediction method in any one of claims 1-5. whose size controls the trade-off between the mean absolute error and the mean squared error of the loss function, which is formulated as: , In the formula α is a disturbance coefficient, is a true value, is a predicted value, The computer program is executed by the processor to realize the steps of the water quantity-water pressure coupled water supply quantity prediction method in any one of claims 1-5. is a hyperparameter which can be determined by human experience; Composite loss function N is the number of composite loss values, and L Final The model parameters and perturbation coefficients are updated by backpropagation.

6. A water supply amount prediction device based on water amount-water pressure coupling, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized by, ​ 7. A computer-readable storage medium storing a computer program, characterized in that, ​

Citation Information

Patent Citations

  • Implementation method of adaptive protein prediction framework, device and equipment

    CN113257361A

  • Optimized adjustment method and system for water supply pressure of water plant

    CN117432941A