Unsupervised Leak Detection Method for Water Pipe Networks Based on Discrete-Time Dynamic Graph Networks

By employing an unsupervised method based on discrete-time dynamic graph networks, this paper utilizes graph network models and SOS flow models for water pipe network leakage detection. This solves the problem of existing methods relying on labeled data and achieves efficient and low-cost leakage detection and location.

CN119272450BActive Publication Date: 2026-01-06XIAN UNIV OF TECH +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411247623.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2026-01-06
Estimated Expiration
2044-09-06

AI Technical Summary

Technical Problem

Existing methods for detecting leaks in water pipe networks rely on labeled data, which is difficult to obtain in practical applications. Furthermore, traditional methods are complex and costly to maintain in large-scale and outdated water supply networks, and traditional unsupervised methods are insufficient in terms of detection accuracy and adaptability.

Method used

An unsupervised method based on discrete-time dynamic graph networks is adopted. The water pipe network structure is represented by a graph network model. Unsupervised leakage detection is performed using graph attention network and SOS flow model. The graph parameters are evolved by combining RNN model to realize automatic detection of leakage problems.

Benefits of technology

It enables efficient leakage detection without the need for data labeling, improves detection accuracy and adaptability, reduces costs, and adapts to dynamically changing pipeline conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119272450B_ABST
    Figure CN119272450B_ABST
Patent Text Reader

Abstract

The application discloses an unsupervised water pipe network leakage detection method based on a discrete time dynamic graph network, and specifically comprises the following processes: firstly, a graph structure is defined according to a pipe network node space topology structure; secondly, data collected by pressure sensors arranged in the water pipe network are divided into graph snapshots according to a time sequence length; then, graph embedding representation learning is carried out in the graph snapshots by using a graph attention network, the graph embedding representation is sent into an SOS flow model to carry out unsupervised positive sample density estimation and online leakage detection, and a RNN model is used to realize dynamic updating of the graph model by evolving graph parameters between the graph snapshots. The method provided by the application can represent the structure of the water pipe network by using a graph network model, capture changes of the pipe network state by using dynamically updated graph information, and realize unsupervised detection of the leakage problem.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of pipeline leakage detection technology, and relates to an unsupervised water pipeline leakage detection method based on discrete-time dynamic graph networks. Background Technology

[0002] Ensuring a stable supply of water in terms of both quality and quantity is crucial in urban water supply systems. However, due to the vastness and complexity of water pipe networks, leakage problems can severely impact water resource waste and service interruptions, leading to negative social and economic consequences. Leakage can be caused by factors such as pipe aging, changes in the external environment, or construction damage, all of which pose a direct threat to the safety and efficiency of the water supply system. Therefore, effective leak detection and location in water pipe networks is a key challenge for water management departments.

[0003] Existing technologies for leak detection in water pipe networks face several challenges. Hardware-based methods, including both internal and external leak detection technologies, while non-invasive, often rely on prototypes still under development. Furthermore, external devices, though easy to install, are costly, time-consuming, and require specialized personnel for operation and leak location assessment. These devices may fail when detecting leaks in deeply buried underground pipelines, limiting their application. Software-based methods, particularly model-driven approaches, depend on accurate network models, including parameters such as network topology, service life, pipe material, and diameter. Calibration of these parameters is complex and limited by data availability. Maintaining the hydraulic model is particularly difficult for large and aging water transmission networks.

[0004] In contrast, data-driven methods demonstrate a powerful ability to model pipeline nonlinearities by deeply mining historical data patterns. Compared to hardware-based and model-based methods, this approach offers fewer limitations and greater flexibility and convenience. However, most existing methods rely on supervised learning, requiring large amounts of labeled data for training, which is often difficult to obtain in practical applications. Therefore, developing an unsupervised learning method that does not require labeled data is crucial for improving the efficiency and accuracy of water pipeline network leakage detection. Unsupervised methods can automatically learn patterns from data without human intervention, thereby reducing costs, increasing detection speed, and adapting to constantly changing pipeline network conditions. Summary of the Invention

[0005] The purpose of this invention is to provide an unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks. This method can use a graph network model to represent the structure of the water pipe network and capture changes in the pipe network state through dynamically updated graph information, thereby achieving unsupervised detection of leakage problems.

[0006] The technical solution adopted in this invention is an unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks, which specifically includes the following process: First, a graph structure is defined according to the spatial topology of the pipe network nodes; second, the data collected by pressure sensors deployed in the water pipe network are divided into graph snapshots according to the time series length; then, graph embedding representation learning is performed using a graph attention network within the graph snapshots, and the graph embedding representation is fed into the SOS flow model for unsupervised positive sample density estimation and online leakage detection; and between graph snapshots, an RNN model is used to perform graph parameter evolution to achieve dynamic updating of the graph model.

[0007] The invention is further characterized by:

[0008] Specifically, the steps include the following:

[0009] Step 1: Download the LeakDB dataset for water pipe network leakage testing, and divide the dataset into an m:n partitioning set for pressure training of leak-free water pipe networks, F. train Pressure test set F for leaky water pipe network test The truth set of the test set is GTest, and the set of pressure sensors deployed in the water supply network corresponding to the LeakDB dataset is V = {v1, v2, ..., v...}. n ,…,v N}, where v n This represents the sensor at the nth node, where 1 ≤ n ≤ N, and N is the total number of pressure sensors. in, and F respectively train and F test The nth pressure sensor v n The pressure value at time t, 1≤t≤T, where T is the time series length of the pressure time series signal;

[0010] Step 2: Define a graph structure G = (V, E) based on the spatial topology of the pressure sensors deployed in the water supply network, where V and E are the sets of nodes and edges of the graph, respectively, and E = {v...} i ,v j Given the graph structure G, where |1≤i≤N, 1≤j≤N, i≠j}, we can represent G using an adjacency matrix A. δ i,j Indicates whether two nodes are connected;

[0011] Step 3, sort F according to the length of the time series. train Perform graph snapshot partitioning to obtain a graph snapshot set G. train =[g1,g2,…,g k ,…,g K Each snapshot signal has a length of ΔT, g kThis is the k-th graph snapshot, 1≤k≤K, where K is the total number of graph snapshots, K=int(T / ΔT), and int(·) represents the floor function. k =(F k A), F k It is the k-th snapshot g k The corresponding training set F train medium-pressure time series signal set,

[0012] Step 4: Construct the discrete-time dynamic graph network structure Net;

[0013] Step 5: Train the network model (Model);

[0014] Step 6, in test set F test Model testing was performed to obtain unsupervised water pipe network leakage detection results.

[0015] In step 4, the discrete-time dynamic graph network structure is Net = {(NG1,NS1),RNN} 1→2 ,…(NG k NS k ), RNN k→k+1 ,…(NG K NS K )}; where NG k NS k and RNN k→k+1 Represents a snapshot of the graph. k The graph attention network, SOS flow network, and g k and g k+1 RNNRNN between image snapshots k-1→k ;

[0016] Graph Attention Network (NG) k Divided into graph space attention network NGS k Graph-Time Attention Network (NGT) k SOS Streaming Network NS k This includes the SOS() forward transform, the SOS_inverse() backward transform, and the FNN subnetwork. k RNN k-1→k Includes two fully connected layers;

[0017] Graph Spatial Attention Network NGS k The Graph Temporal Attention Network (NGT) consists of three fully connected layers. k It consists of causal convolution, dilated convolution, and 1D convolution;

[0018] The graph spatial attention network performs mutual attention computation (Attention()) after three fully connected layers to enhance features. The graph temporal attention network enhances features through gated activation units after convolution operations to obtain graph embedding representations. The SOS flow network transforms the input data into a normal distribution through the SOS() forward transformation and inversely transforms the normally distributed data back to the input data space through the SOS_inverse() inverse transformation. The RNN updates the graph attention network parameters between snapshots through fully connected layers.

[0019] The specific steps for step 5 are as follows:

[0020] Step 5.1: Define the number of snapshots variable k, initialize it to 1, and define the condition variable C. k Define the overall network parameters as Model = {W1, WR1, ..., W} k ,WR k …,W K}, the k-th snapshot g k Network parameters in and Represent the k-th snapshot g respectively k Learnable graph parameters and flow parameters, WR k G represents an inter-snapshot RNN. k The flow distribution parameters are expressed as (μ k ,σ k ), randomly initialize g1 according to a uniform distribution. Initialize the flow distribution parameters of g1 to μ1 = 0, σ1 = 1, and the graph network parameters. Graph space attention subnetwork parameters Graph Temporal Attention Subnetwork Parameters Composition, that is Initialize the network model Model, Model = W1;

[0021] Step 5.2, F train g of the k-th graph snapshot k As input, it is fed into the graph space attention network NG. k Graph Time Attention Network (NS) k Using parameters and Forward computation yields the graph embedding representation X k ;

[0022] Step 5.3, initialize condition variable C1 = X1, and set X... k With C k After being concatenated, the data is fed into the k-th SOS stream network NS. k Perform SOS forward transformation on the stream, calculate the stream model loss, and obtain the transformed data Z.k ;

[0023] Step 5.4, from conditional distribution Data Z with a sampling length of ΔT is processed. k ′ -1 , put Z k ′ -1 Send to SOS stream network NS k Inverse transformation yields make Put C k+1 The input is fed into an FNN layer, and the output mean μ is calculated. k+1 and variance σ k+1 ;

[0024] Step 5.5, set the graph network parameters The data is fed into a recurrent neural network (RNN) to predict g. k Graph network parameters

[0025] Step 5.6: Update Model, check if k equals K. If yes, Model = Model + W k Otherwise, Model = Model + W k +WR k ;

[0026] Step 5.7: Let k = k + 1, and determine whether k is less than or equal to K. If yes, proceed to step 5.2; otherwise, end the training and output the network model.

[0027] The specific steps of step 5.2 are as follows:

[0028] Step 5.2.1, for snapshot g k =(F k A), extract g k Inner current node v n Neighboring nodes Current node v n and neighboring nodes The features are respectively represented as f n (t) and

[0029] Step 5.2.2, put f n (t) is taken as input, and after passing through the fully connected FC1 layer of the graph space attention network, the mutual attention mechanism is obtained. As in formula (1); As input, the data is transformed through the fully connected FC2 layer of a graph spatial attention network, and then the transpose() function from the open-source torch library is called to obtain the final result. and As in formula (2); As input, after passing through the fully connected FC3 layer of the graph space attention network, we obtain... As in formula (3); where Query k Represents the query vector, Key k Represents a key vector, Value k Value vector:

[0030] Queryk = FC1(f n (t)) (1)

[0031]

[0032]

[0033] Step 5.2.3, Query k Key k and Value k As input, the mutual attention calculation formula Attention(), as shown in formula (4), is used to enhance the features of the current node, where d Key Key features k The dimension size; Softmax() is an open-source torch data activation library function that calculates the current node v. n Enhanced features (f) n (t))':

[0034]

[0035] Step 5.2.4, transfer the features (f) n (t))' is used as input, and after transformation by the fully connected FC3 layer of the graph space attention network, the output feature (f) of the graph space attention subnetwork is obtained. n (t))”=FC3((f n (t))');

[0036] Step 5.2.5, transfer feature F' k ={(f n (t))”|t∈[(k-1)×ΔT,k×ΔT],n∈[1,N]} is used as input, and the causal convolutional layer CauConv of the time-graph temporal attention network outputs the feature F. k ";

[0037] Step 5.2.6: Define the total number of residual network layers as L, the number of residual layers as l, and initialize l to 1 (l = 1). The feature variable of the l-th residual layer is h. l h 1 Initialized to F k ", i.e. h 1=F k ";

[0038] Step 5.2.7, transfer the l-th layer features h l The hyperbolic tangent activation function tanh() and the sigmoid activation function σ() are fed into the graph temporal attention network, respectively, and then fed into the unit-gated linear unit to obtain h. l Enhanced features (h) l )';

[0039] (h l )'=GLU(tanh(h l ),σ(h l (5)

[0040] Step 5.2.8, enhance the features (h) l )' and the l-th layer feature h l The summation yields the input features h of the (l+1)th layer. l+1 ,h l+1 =(h l )'+h l ;

[0041] Step 5.2.9: Let l = l + 1, and determine whether l is less than L. If the condition is met, proceed to step 5.2.7.

[0042] Step 5.2.10, accumulate the feature h 1 +…+h l +…+h L The feature X is obtained by sequentially passing it through the convolutional layers Conv4 and Conv5 of the graph temporal attention network. k As shown in formula (6):

[0043] X k =Conv5(Conv4((h 1 +…+h l +…+h L (6).

[0044] The specific steps of step 5.3 are as follows:

[0045] Step 5.3.1, input X k With condition C k Send to SOS stream network NS k Obtain the data Z after the forward flow transformation. k And Jacobian matrix determinant logdet k As shown in formula (7):

[0046] (Z k ,logdet k ) = SOS(Xk C k (7)

[0047] Where SOS() represents the forward transformation of the flow model;

[0048] Step 5.3.2, calculate Z k Conditional distribution Maximum likelihood estimate logprobs k As shown in formula (8), calculate the loss. k As in formula (9);

[0049]

[0050] Loss k =-(logprobs) k +logdet k (9).

[0051] The specific steps of step 5.4 are as follows:

[0052] Step 5.4.1, from conditional distribution Randomly sample data of length ΔT Z k ′, send it into the SOS stream for inverse transformation, and obtain As in formula (10), let

[0053]

[0054] Where SOS_inverse() represents the reverse transformation of the SOS stream;

[0055] Step 5.4.2, put C k+1 The input is fed into an FNN layer, and the output mean μ is calculated. k+1 and variance σ k+1 As shown in formula (11):

[0056] μ k+1 ,σ k+1 =FNN(C k+1 (11)

[0057] Here, FNN() represents the fully connected transformation.

[0058] The specific steps of step 5.5 are as follows:

[0059] Step 5.5.1, Input the parameters of the graph spatial attention network. After passing through an RNN, and using the open-source GRU, we obtain the updated graph space attention network parameters. As in formula (12);

[0060]

[0061] Step 5.5.2, Input the parameters of the graph temporal attention network. After passing through GRU, the updated graph space attention network parameters are obtained. As in formula (13);

[0062]

[0063] The specific steps for step 6 are as follows:

[0064] Step 6.1, test set F test And truth label GT test Input into the trained network model;

[0065] Step 6.2, sort F according to the time series length test Perform graph snapshot partitioning to obtain a graph snapshot set G. test =[g1,g2,…,g m ,…,g M Each snapshot signal has a length of ΔT, g m This is the m-th snapshot of the graph, 1≤m≤M, where M is the total number of snapshots, M=int(T / ΔT), and int(·) represents the floor function. m =(D m A), D m It is the test set F corresponding to the m-th graph snapshot. test medium-pressure time series signal set, Define a variable m to count the number of snapshots, initialize m = 1, and define a snapshot g. m condition variable C m and flow distribution parameters (μ) m ,σ m Initialize μ1 = 0, σ1 = 0;

[0066] Step 6.3, take a snapshot of the m-th test image g. m Feed the trained graph attention network structure NG k Using the model Forward transformation yields the graph embedding representation X m Initialize C1 = X1, then set C m and X m After being concatenated, the data is fed into the trained SOS stream network structure NS. k Using the model Forward transform yields Z m Jacobian matrix determinant logdet m Using flow model For Z m Inverse transformation yields Otherwise, let Put C m+1 The input is fed into an FNN layer, and the output mean μ is calculated. m+1 and variance σ m+1 ;

[0067] Step 6.4, calculate snapshot g using KL divergence. m In distribution The following leakage anomaly score η m As shown in formula (14), η m Write it into the detection result set PTest, i.e., PTest = PTest + η m ;

[0068]

[0069] Step 6.5, set the threshold θ, η m If it is greater than θ, then g is considered to be m That is, leakage occurred within the time period t∈[(m-1)×ΔT,m×ΔT];

[0070] Step 6.6: Let m = m + 1, and determine if m is less than or equal to M. If yes, proceed to step 6.3; otherwise, end the test and output the abnormal score set PTest. Call the AUC score calculation function roc_auc_score from the open-source library sklearn to calculate PTest and GT. test The differences between them are used to evaluate the model performance;

[0071] AUC = roc_auc_score(PTest, GT) test (15).

[0072] The beneficial effects of this invention are that the unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks overcomes the shortcomings of traditional detection methods that require leakage labels for leakage detection by addressing the difference in distribution between normal data and leakage data through unbiased estimation of the embedded distribution of conditional flow and SOS flow computation graphs. Furthermore, to avoid the model size increasing with time and to reduce the impact of model size on inference latency, the unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks employs a model parameter evolution strategy to adapt the model to dynamically evolving real-world scenarios. Attached Figure Description

[0073] Figure 1 This is an overall flowchart of the unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks of the present invention;

[0074] Figure 2 This is a training flowchart of the unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks in this invention;

[0075] Figure 3 This is a test flowchart of the unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks of the present invention;

[0076] Figure 4 This is a schematic diagram of the spatial topology of the water supply network used in the unsupervised water network leakage detection method based on discrete-time dynamic graph networks of this invention.

[0077] Figure 5 This is a schematic diagram of normal, leak-free water pipe network data collected by the unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks of this invention.

[0078] Figure 6 This is a schematic diagram of water pipe network data with weak leakage collected by the unsupervised water pipe network leakage detection method based on discrete-time dynamic graph network of the present invention.

[0079] Figure 7 This is a schematic diagram of water network data with strong leakage collected by the unsupervised water network leakage detection method based on discrete-time dynamic graph network of the present invention.

[0080] Figure 8 This is the subjective result of the detection of the unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks of this invention. Detailed Implementation

[0081] The present invention will now be described in detail with reference to the accompanying drawings and specific embodiments.

[0082] This invention relates to an unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks. The overall process is as follows: Figure 1 As shown, please follow these steps:

[0083] Step 1: Download the LeakDB dataset for water pipe network leakage testing, and divide the dataset into an m:n partitioning set for pressure training of leak-free water pipe networks, F. train Pressure test set F for leaky water pipe network test The truth set of the test set is GTest, and the set of pressure sensors deployed in the water supply network corresponding to the LeakDB dataset is V = {v1, v2, ..., v...}. n ,…,v N}, where v n This represents the sensor at the nth node, where 1 ≤ n ≤ N, and N is the total number of pressure sensors. in, and F respectively train and F test The nth pressure sensor v nThe pressure value at time t, 1≤t≤T, where T is the time series length of the pressure time series signal;

[0084] Step 2: Define a graph structure G = (V, E) based on the spatial topology of the pressure sensors deployed in the water supply network, where V and E are the sets of nodes and edges of the graph, respectively, and E = {v...} i ,v j Given the graph structure G, where |1≤i≤N, 1≤j≤N, i≠j}, we can represent G using an adjacency matrix A. δ i,j Indicates whether two nodes are connected;

[0085] Step 3, sort F according to the length of the time series. train Perform graph snapshot partitioning to obtain a graph snapshot set G. train =[g1,g2,…,g k ,…,g K Each snapshot signal has a length of ΔT, g k This is the k-th graph snapshot, 1≤k≤K, where K is the total number of graph snapshots, K=int(T / ΔT), and int(·) represents the floor function. k =(F k A), F k It is the k-th snapshot g k The corresponding training set F train medium-pressure time series signal set,

[0086] Step 4: Construct the discrete-time dynamic graph network structure Net, which is Net = {(NG1,NS1),RNN}. 1→2 ,…(NG k NS k ), RNN k→k+1 ,…(NG K NS K )}, where NG k NS k and RNN k→k+1 Represents a snapshot of the graph. k The graph attention network, SOS flow network, and g k and g k+1 RNN (Recurrent Neural Network) between image snapshots k-1→k ;

[0087] Graph Attention Network (NG) k Divided into graph space attention network NGS k Graph-Time Attention Network (NGT) k ;

[0088] SOS Streaming Network NSk This includes the SOS() forward transform, the SOS_inverse() backward transform, and the FNN (fully connected) subnetwork. k ;

[0089] RNN (Recurrent Neural Network) k-1→k Includes two fully connected layers

[0090] Graph Spatial Attention Network NGS k The Graph Temporal Attention Network (NGT) consists of three fully connected layers. k It consists of causal convolution, dilated convolution, and 1D convolution;

[0091] The graph spatial attention network uses three fully connected layers to perform mutual attention computation (Attention()) to enhance features. The graph temporal attention network uses convolutional operations followed by gated activation units to enhance features and obtain graph embedding representations. The SOS flow network transforms the input data into a normal distribution using the SOS() forward transformation and then uses the SOS_inverse() inverse transformation to transform the normally distributed data back into the input data space. The RNN (Recurrent Neural Network) updates the graph attention network parameters between snapshots through fully connected layers.

[0092] Step 5, train the network model; such as Figure 2 The diagram shows the entire training process of the network model.

[0093] The specific process of step 5 is as follows:

[0094] Step 5.1: Define the number of snapshots variable k, initialize it to 1, and define the condition variable C. k Define the overall network parameters as Model = {W1, WR1, ..., W}. k ,WR k …,W K}, the k-th snapshot g k Network parameters in and Represent the k-th snapshot g respectively k Learnable graph parameters and flow parameters, WR k This represents the parameters of the RNN (Recurrent Neural Network) between snapshots. k The flow distribution parameters are expressed as (μ k ,σ k ), initialize g1 randomly according to a uniform distribution. Initialize the flow distribution parameters of g1 to μ1 = 0, σ1 = 1, and the graph network parameters. Graph space attention subnetwork parameters Graph Temporal Attention Subnetwork Parameters Composition, that is Initialize the network model Model, Model = W1, The network layers and parameter settings involved are shown in Table 1. The network layers and parameter settings involved are shown in Table 2.

[0095] Table 1. Parameters of the spatial attention network

[0096]

[0097] Table 2 shows the parameters of the time attention network.

[0098]

[0099] Snapshot Inter-Graph Network Parameters The RNN (Gated Recurrent Unit) network is updated, and the RNN network layers and parameter settings are shown in Table 3.

[0100] Table 3. RNN (Gated Recurrent Unit) Network Parameters

[0101]

[0102] Step 5.2, F train g of the k-th graph snapshot k As input, it is fed into the graph space attention network NG. k Graph Time Attention Network (NS) k Using parameters and Forward computation yields the graph embedding representation X k The specific process of step 5.2 is as follows:

[0103] Step 5.2.1, for snapshot g k =(F k A), extract g k Inner current node v n Neighboring nodes Current node v n and neighboring nodes The features are respectively represented as f n (t) and

[0104] Step 5.2.2, put f n (t) is taken as input, and after passing through the fully connected FC1 layer of the graph space attention network, the mutual attention mechanism is obtained. As in formula (1); As input, the data is transformed through the fully connected FC2 layer of a graph spatial attention network, and then the transpose() function from the open-source torch library is called to obtain the final result. and As in formula (2); As input, after passing through the fully connected FC3 layer of the graph space attention network, we obtain... As in formula (3); where Query k Represents the query vector, Key k Represents a key vector, Value k Value vector:

[0105] Query k =FC1(f n (t)) (1)

[0106]

[0107]

[0108] Step 5.2.3, Query k Key k and Value k As input, the mutual attention calculation formula Attention(), as shown in formula (4), is used to enhance the features of the current node, where d Key Key features k The dimension size; Softmax() is an open-source torch data activation library function that calculates the current node v. n Enhanced features (f) n (t))':

[0109]

[0110] Step 5.2.4, transfer the features (f) n (t))' is used as input, and after transformation by the fully connected FC3 layer of the graph space attention network, the output feature (f) of the graph space attention subnetwork is obtained. n (t))”=FC3((f n (t))');

[0111] Step 5.2.5, transfer feature F' k ={(f n (t))”|t∈[(k-1)×ΔT,k×ΔT],n∈[1,N]} is used as input, and the causal convolutional layer CauConv of the time-graph temporal attention network outputs the feature F. k ";

[0112] Step 5.2.6: Define the total number of residual network layers as L, the number of residual layers as l, and initialize l to 1 (l = 1). The feature variable of the l-th residual layer is h. l h 1 Initialized to Fk ", i.e. h 1 =F k ";

[0113] Step 5.2.7, transfer the l-th layer features h l The hyperbolic tangent activation function tanh() and the sigmoid activation function σ() of the graph temporal attention network are fed into the network respectively, and then fed into the gated linear unit (GLU) to obtain h. l Enhanced features (h) l )';

[0114] (h l )'=GLU(tanh(h l ),σ(h l (5)

[0115] Step 5.2.8, enhance the features (h) l )' and the l-th layer feature h l The summation yields the input features h of the (l+1)th layer. l+1 ,h l+1 =(h l )'+h l ;

[0116] Step 5.2.9: Let l = l + 1, and determine whether l is less than L. If the condition is met, proceed to step 5.2.7.

[0117] Step 5.2.10, accumulate the features (h) 1 +…+h l +…+h L The feature X is obtained by sequentially passing it through the convolutional layers Conv4 and Conv5 of the graph temporal attention network. k As shown in formula (6):

[0118] X k =Conv5(Conv4((h 1 +…+h l +…+h L (6)

[0119] Step 5.3, initialize condition variable C1 = X1, and set X... k With C k After being concatenated, the data is fed into the k-th SOS stream network NS. k Perform SOS forward transformation on the stream, calculate the stream model loss, and obtain the transformed data Z. k ;

[0120] The specific process of step 5.3 is as follows:

[0121] Step 5.3.1, input X k With condition C k Send to SOS stream network NS k Obtain the data Z after the forward flow transformation. k And Jacobian matrix determinant logdet k As shown in formula (7):

[0122] (Z k ,logdet k ) = SOS(X k C k (7)

[0123] Where SOS() represents the forward transformation of the flow model;

[0124] Step 5.3.2, calculate Z k Conditional distribution Maximum likelihood estimate logprobs k As shown in formula (8), calculate the loss. k As in formula (9);

[0125]

[0126] Loss k =-(logprobs) k +logdet k (9)

[0127] Step 5.4, Step 5.4, from conditional distribution Data Z with a sampling length of ΔT is processed. k ′ -1 , put Z k ′ -1 Send to SOS stream network NS k Inverse transformation yields make Put C k+1 The input is fed into an FNN layer, and the output mean μ is calculated. k+1 and variance σ k+1 The specific process of step 5.4 is as follows:

[0128] Step 5.4.1, from conditional distribution Randomly sample data of length ΔT Z k ′, send it into the SOS stream for inverse transformation, and obtain As in formula (10), let

[0129]

[0130] Where SOS_inverse() represents the reverse transformation of the SOS stream;

[0131] Step 5.4.2, put C k+1 The input is fed into an FNN layer, and the output mean μ is calculated. k+1 and variance σ k+1 As shown in formula (11):

[0132] μ k+1 ,σ k+1 =FNN(C k+1 (11)

[0133] Here, FNN() represents the fully connected transformation.

[0134] Step 5.5, set the graph network parameters The data is fed into a recurrent neural network (RNN) to predict g. k Graph network parameters The specific process of step 5.5 is as follows:

[0135] Step 5.5.1, Input the parameters of the graph spatial attention network. After passing through an RNN (Recurrent Neural Network), specifically the open-source GRU (Gated Recurrent Unit), the updated graph space attention network parameters are obtained. As in formula (12);

[0136]

[0137] Step 5.5.2, Input the parameters of the graph temporal attention network. After passing through a GRU (Gated Recurrent Unit), the updated graph space attention network parameters are obtained. As in formula (13);

[0138]

[0139] Step 5.6: Update Model, check if k equals K. If yes, Model = Model + W k Otherwise, Model = Model + W k +WR k ;

[0140] Step 5.7: Let k = k + 1, and determine whether k is less than or equal to K. If yes, proceed to step 5.2; otherwise, end the training and output the network model.

[0141] Step 6, as follows Figure 3 The diagram shows the testing process for the network model, on test set F. test Model testing was performed to obtain unsupervised water pipe network leakage detection results.

[0142] The specific process of step 6 is as follows:

[0143] Step 6.1, test set F test And truth label GT test Input into the trained network model;

[0144] Step 6.2, sort F according to the time series length test Perform graph snapshot partitioning to obtain a graph snapshot set G. test =[g1,g2,…,g m ,…,g M Each snapshot signal has a length of ΔT, g m This is the m-th snapshot of the graph, 1≤m≤M, where M is the total number of snapshots, M=int(T / ΔT), and int(·) represents the floor function. m =(D m A), D m It is the test set F corresponding to the m-th graph snapshot. test medium-pressure time series signal set, Define a variable m to count the number of snapshots, initialize m = 1, and define a snapshot g. m condition variable C m and flow distribution parameters (μ) m ,σ m Initialize μ1 = 0, σ1 = 0;

[0145] Step 6.3, take a snapshot of the m-th test image g. m Feed the trained graph attention network structure NG k Using the model Forward transformation yields the graph embedding representation X m Initialize C1 = X1, then set C m and X m After being concatenated, the data is fed into the trained SOS stream network structure NS. k Using the model Forward transform yields Z m Jacobian matrix determinant logdet m Using flow model For Z m Inverse transformation yields Otherwise, let Put C m+1 The input is fed into an FNN layer, and the output mean μ is calculated. m+1 and variance σ m+1 ;

[0146] Step 6.4, calculate snapshot g using KL divergence. m In distribution The following leakage anomaly score η mAs shown in formula (14), η m Write it into the detection result set PTest, i.e., PTest = PTest + η m ;

[0147]

[0148] Step 6.5, set the threshold θ, η m If it is greater than θ, then g is considered to be m That is, leakage occurred within the time period t∈[(m-1)×ΔT,m×ΔT];

[0149] Step 6.5: Let m = m + 1, and determine whether m is less than or equal to M. If yes, proceed to step 6.3; otherwise, end the test and output the abnormal score set PTest.

[0150] Step 6.6: Call the `roc_auc_score` function from the open-source library sklearn to calculate the AUC score and the ground truth (PTest) and ground truth (GT). test The differences between them are used to evaluate the model performance;

[0151] AUC = roc_auc_score(PTest, GT) test (15)

[0152] Example 1

[0153] This invention presents an unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks, and the invention is tested using a standard dataset (LeakDB dataset).

[0154] The LeakDB dataset is a simplified representation of a real-world water pipeline network in Hanoi, Vietnam. The pipeline is 38.1 kilometers long and comprises 32 nodes and 34 main pipes, with pressure sensors deployed at each node. The pipeline's structure is as follows: Figure 4 As shown, the numbers represent node numbers. Sensor data is sampled every 30 minutes in this dataset. The dataset is divided into normal data and leakage data. There are 238 normal data scenarios, used as training samples; there are 762 leakage data scenarios, each potentially containing one or more leakage segments. Each scenario simulates one year of data collection, with a data length of 17520. Figure 5 , 6 Figures 7 and 8 show the pressure data of five nodes in the LeakDB dataset under normal data, short leakage data, and long leakage data, respectively. The subscripts in the figures indicate the detection time.

[0155] Example 2

[0156] Objective evaluation indicators: The detection performance of the unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks constructed by the method of this invention was tested, and the detection results were objectively evaluated using the following indicators:

[0157] (1) Area Under Curve (AUC): Defined as the area under the ROC curve and the coordinate axis. Obviously, the value of this area will not be greater than 1. The closer the AUC is to 1.0, the higher the realism of the detection method; when it is equal to 0.5, the realism is the lowest and it has no application value. As a performance metric, AUC can be used to evaluate the model performance by calculating the probability that the model ranks all positive samples before negative samples.

[0158] (2) TPR (True Positive Rate), also known as recall or sensitivity, refers to the proportion of samples that are actually positive but are correctly predicted as positive by the model. Its calculation formula is (16):

[0159]

[0160] Here, TP represents the number of true positives, and FN represents the number of false negatives. A higher TPR indicates that the model identifies more actual positive examples, and the stronger the model's recall capability.

[0161] (3) FPR (False Positive Rate) refers to the proportion of samples that are actually negative but are incorrectly predicted as positive by the model. Its calculation formula is (17):

[0162]

[0163] Here, FP represents the number of false positives, and TN represents the number of true negatives. The lower the FPR, the fewer times the model mistakenly predicts negative examples as positive examples, and the lower the model's false positive rate.

[0164] Objective Evaluation: Table 4 shows the AUC, FPR, and TPR results of the proposed method on the LeakDB dataset, comparing the objective experimental results of the proposed method with other unsupervised leakage detection methods for water pipe networks on the LeakDB dataset. The data in the table shows that the proposed method achieved a TPR of 92.7%, an FPR of 9.5%, and an AUC of 0.901 on the LeakDB dataset. The comparative KNN-based leakage detection method achieved a TPR of 30.7% and an FPR of 16.1%. Compared to this method, the proposed method improved the TPR by 62.0% and reduced the FPR by 6.6%. The comparative GRU-based unsupervised detection method achieved a TPR of 42.9% and an FPR of 25.0%. Compared to this method, the proposed method improved the TPR by 43.0% and reduced the FPR by 15.5%. The comparative unsupervised detection method based on LSTM+RNN achieved a TPR of 90.4%, an FPR of 13.7%, and an AUC of 0.876. Compared with this method, the proposed method improves the TPR by 2.3%, reduces the FPR by 4.2%, and improves the AUC by 0.025. The comparative unsupervised leakage detection method LSTM-AE-WLDL achieved a TPR of 91.3%, an FPR of 11.8%, and an AUC of 0.891. The proposed method improves the TPR by 0.9%, reduces the FPR by 2.3%, and improves the AUC by 0.010. This demonstrates that the proposed unsupervised water pipe network leakage detection method based on graph attention networks and conditional flow has better detection capabilities for water pipe network leakage on the LeakDB dataset.

[0165] Table 4. Detection results of this invention on the LeakDB dataset.

[0166] method TPR (%) ↑ FPR (%) ↓ AUC↑ KNN 30.7 16.1 / GRU 42.9 25.0 / LSTM+RNN 90.4 13.7 0.876 LSTM-AE-WLDL 91.3 11.8 0.891 This invention 92.7 9.5 0.901

[0167] Example 3

[0168] Subjective evaluation: such as Figure 8 The presentation showcases the subjective results of an unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks. The subscripts indicate the number of input pressure data points. The first row represents the source data, the second row (green area) represents the ground truth values ​​for the leakage area, and the third row (red area) represents the detection results. It can be seen that the proposed method accurately detects the leakage periods in the pipe network. This method achieves unsupervised detection of water pipe network leaks while meeting the required detection accuracy and eliminating the need for dedicated collection or labeling of leakage data, thus reducing labor costs.

[0169] This invention presents an unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks. Addressing the problems of existing water pipe network leakage detection tasks, such as the need for manual collaboration, complex and expensive instruments, and high labor costs, this invention designs a method for unsupervised leakage detection by deploying pressure sensors at key nodes in the water pipe network. This method achieves graph structure construction, feature extraction, and positive sample distribution modeling of leak-free data. Leakage is detected by comparing the difference between the model and the positive sample distribution. Therefore, this invention collects node pressure data using pressure sensors, constructs the spatial topology of the water pipe network, extracts water pipe network features, evolves graph network parameters, and estimates the positive sample distribution of SOS flow for detection and localization. Compared to traditional detection methods, this method proposes a water pipe network leakage detection method based on graph neural networks. It divides the water pipe network data into graph snapshots, extracts node neighborhood features through graph spatial attention, and extracts node temporal information graph features using graph temporal attention, thereby improving the leakage detection accuracy of water pipe network graph snapshots. By computationally calculating unbiased estimates of the graph embedding distribution using conditional flow and SOS flow, and addressing the difference in distribution between normal and leak data, the drawback of requiring leak labels for leak detection is overcome. Furthermore, a model parameter evolution strategy adapts the model to dynamically evolving real-world scenarios.

Claims

1. An unsupervised water pipe network leakage detection method based on discrete-time dynamic graph networks, characterized in that: Specifically comprising the following processes: first, defining a graph structure according to the spatial topology of the pipe network nodes; second, dividing the data collected by the pressure sensors arranged in the water pipe network into graph snapshots according to the time series length; then, using a graph attention network for graph embedding representation learning within the graph snapshot, sending the graph embedding representation into a SOS flow model for unsupervised positive sample density estimation and online leakage detection, and using an RNN model for graph parameter evolution between graph snapshots to realize dynamic updating of the graph model; Specifically comprising the following steps: Step 1, download the water distribution network leakage test dataset LeakDB, according to The dataset is divided into a pressure training set of a water distribution network without leakage and a pressure test set of a water distribution network with leakage , the true value set of the test set is , and the pressure sensor set arranged in the water distribution network corresponding to the LeakDB dataset is , wherein represents the sensor of the th node, , is the total number of pressure sensors, , , wherein and are the pressure values of the th pressure sensor in and at the time , , , is the timing length of the pressure time series signal; Step 2, define graph structure according to the spatial topology of pressure sensors in water distribution network , and are the node and edge sets of the graph, respectively, where the graph structure is represented by an adjacency matrix , , indicates whether two nodes are connected or not. Step 3, divide the time series into Take the graph snapshot set by graph snapshot division Each graph snapshot signal length is , The first graph snapshot is , The total number of graph snapshots is , The floor function is represented by , The first graph snapshot is The corresponding training set The middle pressure time series signal set ; Step 4, Constructing the discrete-time dynamic graph network structure ; Step 5, training the network model ; Step 6, on the test set Modeling on the training set Testing, resulting in unsupervised water distribution network leak detection.

2. The method of claim 1, wherein, In step 4, the discrete-time dynamic graph network structure is as follows: ;in , and Snapshot of the diagram The graph attention network, SOS flow network, and and RNN in the image snapshot ; Graph attention networks are divided into graph spatial attention networks and graph temporal attention networks ; SOS flow networks include forward transformations, backward transformations, and FNN subnetworks ; include two fully connected layers; Graph space attention network consisting of three fully connected layers, graph temporal attention network consisting of causal convolution, dilated convolution and 1D convolution; The graph space attention network realizes mutual attention calculation after three full connections The graph time attention enhances the features through a gating activation unit to obtain a graph embedding representation after a convolution operation The forward transformation transforms the input data into a normal distribution, and the The inverse transformation inversely transforms the data in the normal distribution to the input data space The RNN updates the graph attention network parameters between snapshots through full connection.

3. The method of claim 2, wherein, The specific steps of the step 5 are as follows: Step 5.1, define the number of graph snapshot variables , initialize to 1, define condition variables as , define the overall network parameters as , the network parameters of the th snapshot , where and represent the learnable graph parameters and flow parameters of the th graph snapshot, respectively, the flow distribution parameters of the inter-snapshot RNN, are represented as , are randomly initialized according to a uniform distribution , the , the flow distribution parameters of the th snapshot are initialized as , the graph network parameters are composed of the graph space attention subnetwork parameters and the graph time attention subnetwork parameters , i.e. , the network model is initialized as , ;​ Step 5.2, send in the graph space attention network the middle of the graph snapshot as input, into the graph space attention network and the graph time attention network , using parameters and , forward computation to obtain the graph embedding representation ; Step 5.3, Initialize condition variables ,Will and After being connected in series, it is sent to the first SOS Stream Network Perform SOS forward transformation on the stream, calculate the stream model loss, and obtain the transformed data. ; Step 5.

4. Sampling from the conditional distribution Length of data Put into SOS flow network , inverse transform to get Let Put into layer, output mean and variance ;​ Step 5.5, send the graph network parameters into a recurrent neural network (RNN) to predict the graph network parameters ;​ Step 5.6, Update ,judge Is it equal to ,if, ,otherwise ; Step 5.7, let , judge whether it is less than or equal to , if yes, go to step 5.2, otherwise, end the training and output the network model .

4. The method of claim 3, wherein, The specific steps of the step 5.2 are as follows: Step 5.2.1, for the snapshot , extract the neighborhood nodes of the current node ; the current node and the neighborhood nodes are denoted as and respectively; and ; Step 5.2.2, put As input, after passing through the fully connected FC1 layer of the graph space attention network, the mutual attention mechanism is obtained. As shown in formula (1); As input, the signal is transformed through the fully connected FC2 layer of a graph space attention network, and then the open-source torch library function is called. The function obtains and , as in formula (2); As input, it passes through the fully connected layer of the graph space attention network. Transformation, to obtain , as in formula (3); where Represents the query vector. Represents the key vector. Value vector: (1) (2) (3) Step 5.2.3, taking , and as input, the mutual attention calculation formula is used to enhance the current node feature, where is the dimension size of the feature ; is an open source torch data activation library function, and the enhanced feature of the current node is calculated : (4) Step 5.2.4, the feature transformed by the fully connected layer of the graph spatial attention network as input, to obtain the output feature of the graph spatial attention subnetwork ; Step 5.2.5, the feature As input, the causal convolutional layers of the temporal attention network Output features ; Step 5.2.6, define the total number of residual network layers variable as , the number of residual layers variable as , initialized to 1, i.e. , the feature variable of the th residual layer as , initialized to , i.e. ; Step 5.2.7, the hyperbolic tangent activation function of the dual-attention network is inputted into the graph time attention network respectively Layer characteristics Hyperbolic tangent activation function of the dual-attention network is inputted into the graph time attention network respectively And Activation function , and then inputted into the unit-gated linear unit to obtain Enhanced enhanced features ; (5) Step 5.2.8, add enhanced features and the first layer features together to obtain the first layer input features , ; Step 5.2.9, let ,judge Is it less than If the conditions are met, proceed to step 5.2.7; Step 5.2.10, accumulate features convolutional layers of the graph temporal attention network in turn , obtain the reduced dimension features as formula (6): (6)。 5. The method of claim 4, wherein, The specific steps of the step 5.3 are as follows: Step 5.3.1, input with condition , send into SOS flow network get flow forward transformed data and Jacobian matrix determinant as equation (7): (7) wherein represents the forward transformation of the flow model; Step 5.3.2, computation with conditional distribution Maximum likelihood estimate value Loss is computed as formula (8) As formula (9); (8) (9)。 6. The method of claim 5, wherein, The specific steps of the step 5.4 are as follows: Step 5.4.1, from conditional distribution Down random sampling Data of length , into the SOS stream for inverse transform, get As formula (10), let : (10) wherein denotes the reverse transform of the SOS stream; Step 5.4.2, put into layer, output mean and variance as in equation (11): (11) wherein denotes a fully connected transformation.

7. The method of claim 6, wherein, The specific steps of the step 5.5 are as follows: Step 5.5.1, inputting parameters of graph space attention network , through RNN, here using open source GRU, to get updated graph space attention network parameters , as formula (12); (12) Step 5.5.2, inputting the parameters of the graph temporal attention network , passing through the GRU to obtain updated graph spatial attention network parameters , as formula (13); (13)。 8. The method of claim 7, wherein, The specific steps of the step 6 are as follows: The specific steps of the step 6 are as follows: Step 6.1, inputting the test set and true value labels into the trained network model ; Step 6.2, divide the graph snapshots according to the length of time series Take the graph snapshot division to obtain the graph snapshot set , and each graph snapshot signal length is , is the first graph snapshot, , is the total number of graph snapshots, , represents the floor function, , is the first graph snapshot corresponding to the test set Mid-pressure time series signal set, , define the snapshot number variable , initialize , define the snapshot condition variable and flow distribution parameters , initialize , ; Step 6.3, will the first Snapshot of a test graph Feed into the trained graph attention network structure Using the model Forward transformation yields graph embedding representation ,initialization Then and After being concatenated, the data is fed into the trained SOS stream network structure. Using the model Forward transformation Jacobian matrix determinant Using flow model right Inverse transformation yields Otherwise, let ,Bundle Send in Layer, output mean and variance ; Step 6.4: Calculate the snapshot using KL divergence. In distribution Leakage anomaly score As shown in formula (14), Write to the detection result set In, that is ; (14) Step 6.5, set threshold , greater than then consider i.e. a leak has occurred within the time period; Step 6.6, let , judge whether is less than or equal to , if yes, go to Step 6.3, otherwise, end the test and output the abnormal score set ; Call the function to calculate AUC score in the open source library sklearn , calculate and the difference between the two, evaluate the performance of the model; (15)。

Citation Information

Patent Citations

  • Water supply pipeline leakage detection method based on graph neural network

    CN115654381A

  • Internet of Things signal anomaly detection method and system based on graph neural network

    CN117009900A