Water quality anomaly detection method and system based on graph neural network
By building a graph relationship network in the water supply pipeline network and using the graph neural network algorithm, the problem of insufficient water quality detection of water supply points without water quality sensors in the water supply pipeline network is solved, and the water quality detection and prediction of all water supply points is realized.
Patent Information
- Application Number
- CN202510245130.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-04
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2045-03-04
AI Technical Summary
The prior art is difficult to effectively detect and predict the water quality of water supply points in the water supply pipeline without water quality sensors, resulting in insufficient functionality.
A graph neural network is used to extract the water supply points in the water supply pipeline network as graph nodes, and a graph relationship network is built based on the connection relationship of nodes, and the water quality level of the water supply points without water quality sensors is calculated through an aggregation algorithm.
The water quality detection of all water supply points in the water supply network is realized, including water supply points without water quality sensors, improving the functionality and accuracy of water quality prediction.
Smart Images

Figure CN119720063A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to a water quality prediction technology, and more specifically to a water quality anomaly detection method and system based on graph neural network. Background Art
[0002] The water supply network is a complex network system that covers all aspects from the water source to the end user. Due to the complexity of the network system, water quality may be affected by many factors, such as pipeline aging, pollution source intrusion, changes in hydraulic conditions, etc. The hydraulic model of the network can simulate the dynamic behavior of water flow, water pressure and water quality, so it is widely used in the direction of water quality prediction. However, hydraulic models usually involve a large amount of input information such as network topology, pipeline characteristics and operating conditions, and the construction and calibration of the model requires a lot of time and effort. In addition, due to the complexity of the water supply network, model maintenance is also quite difficult, especially when the network structure or pipeline roughness coefficient changes, the model needs to be recalibrated. The traditional deep learning model only predicts the future water quality of a single node based on the historical data of a single water quality monitoring point, ignoring the potential correlation and mutual influence between the various sensors in the system.
[0003] To this end, there is an invention patent in the prior art with publication number CN119129857A, entitled Water Quality Prediction Method and Software System for Water Supply Network Based on Spatiotemporal Graph Neural Network. The invention patent discloses that the water quality of the water supply network is predicted by using the spatiotemporal graph neural network by utilizing the correlation between different water quality monitoring points in the water supply network. Since there are many nodes in the existing water supply network, it is impossible for all nodes to have water quality sensors. The prior art only predicts the water quality of nodes with water quality sensors, so there is still a problem of insufficient functionality. Summary of the invention
[0004] In view of the shortcomings of the prior art, the purpose of the present invention is to provide a water quality anomaly detection method and system based on graph neural network, which can effectively realize water quality detection for water supply points without water quality sensors.
[0005] To achieve the above object, the present invention provides the following technical solution: a water quality anomaly detection method based on graph neural network, characterized in that it comprises the following steps: Step 1: extract each water supply point in the water supply network as a graph node, and build a graph relationship network based on the connection relationship of the nodes in the water supply network as an edge, and determine the flow direction between the nodes to construct a directed edge; Step 2: Extract the water quality data detected by the water supply point equipped with a water quality sensor, perform local processing and analysis, determine the water quality level of the water supply point, and attach the water quality level as a feature vector to the graph node corresponding to the water supply point. The node feature vector corresponding to the water supply point without a water quality sensor is None, completing the construction of the graph relationship network; Step 3: present the graph relationship network constructed in step 2 on the display screen with the city map corresponding to the water supply network as the background, and display the feature vector information of each water supply point; Step 4, aggregating the nodes whose feature vectors are none in step 2, obtaining the feature vectors of the nodes regarding the water quality level, and presenting them on the display screen after updating; The water quality level determined in step 2 includes a normal level and an abnormal level, and all nodes of the abnormal level are highlighted on the display screen.
[0006] As a further improvement of the present invention, the specific steps of determining the flow direction between nodes and constructing directed edges in step 1 are as follows: Step 1, extract the water flow data of each node for a period of time, and calculate the change of water flow of each node during this period of time; Step 1 and 2: cluster each node based on the value of water flow data, and group nodes with similar water flow during this period into one group; Step 13, dividing the time period in step 12 into multiple moments, extracting the flow data at each moment, and analyzing the flow data to extract the moment when the flow data changes; Step 14: compare the time when the traffic data in each node in a group changes, and then sort them in time order, select the nodes corresponding to the earlier time sequence as the downstream, and the later nodes as the upstream, and then add the direction of the edge to each node in the upstream to downstream manner to complete the construction of the directed edge.
[0007] As a further improvement of the present invention, the specific steps of aggregating the nodes whose characteristic vectors are none in step 2 in step 4 and obtaining the characteristic vectors of the nodes with respect to the water quality grade are as follows: Step 41, determining the upstream nodes to be aggregated in the initial node, extracting the water quality grade characteristics of the upstream nodes, and obtaining the water quality grade feature vector of each upstream node; Step 42, selecting an aggregation function, and aggregating the water quality grade feature vector obtained in step 41 through the aggregation function to obtain an aggregated water quality grade feature vector; Step 43, replace the feature vector with the feature vector of the aggregated water quality grade, so that the feature vector of the node whose original feature vector is none is the water quality grade after aggregation; Among them, in step 41, when the feature vectors of all upstream nodes and downstream nodes are all None, one of the upstream nodes is selected to obtain the feature vectors of the upstream node of the previous level and other downstream nodes of the upstream node. If the feature vectors are still None, traverse other upstream nodes to obtain the feature vectors of the upstream nodes of the previous level and other downstream nodes of other upstream nodes. If the feature vectors obtained after traversing other upstream nodes are all None, traverse the upstream nodes of the previous level until the water quality grade feature vector is obtained, and then execute steps 42 and 43 for multi-layer aggregation until the initial node feature vector is the aggregated water quality grade.
[0008] As a further improvement of the present invention, if the water quality level after aggregation of the node feature vector in step 43 is an abnormal level, the abnormal level is directly used as the feature vector of the node; if the water quality level after aggregation is a normal level, the downstream node to be aggregated in the initial node is determined, and then steps 41 to 43 are executed in sequence to complete the aggregation of the downstream nodes, and the water quality level feature vector of the aggregation result is updated and replaced; Among them, the aggregation function selected in the aggregation of upstream nodes in step 42 is set aggregation, that is, all feature vectors are collected into a set, and then the set is traversed to determine whether there is an abnormal water quality level in the set. If so, the aggregation result is the abnormal water quality level, if not, the aggregation result is the normal water quality level. The aggregation function selected in the aggregation of downstream nodes in step 42 is set aggregation, that is, all feature vectors are collected into a set, and then the set is traversed to determine whether the set is all abnormal water quality levels. If so, the aggregation result is the abnormal water quality level, if not, the aggregation result is the normal water quality level.
[0009] As a further improvement of the present invention, the step 2 also extracts whether the water supply point is equipped with a water purification device. If the water supply point is equipped with a water purification device, the node feature vector corresponding to the water supply point is determined as the normal water quality level, and after traversing the set of downstream node feature vector combinations, the nodes with water purification devices in the set are first removed, and then it is determined whether all of them are at abnormal water quality levels.
[0010] As a further improvement of the present invention, the specific method of performing local processing and analysis in step 2 is: using the historical water quality data of the water supply point as a training set and inputting it into the algorithm model for training to obtain a water quality grade judgment model, then inputting the currently detected water quality data into the water quality grade judgment model, and finally outputting the water quality grade through the water quality grade judgment model.
[0011] As a further improvement of the present invention, in the aggregation calculation process in step 4, the nodes whose upstream nodes or downstream nodes have water quality sensors are preferentially aggregated and calculated.
[0012] Another aspect of the present invention provides a system, comprising: The server platform is connected to each water supply point, builds a graph relationship network based on the water supply point, extracts the water quality data detected by the water supply point equipped with a water quality sensor, and performs aggregation calculation on the nodes with no feature vector in the graph relationship network to obtain the feature vector corresponding to the node; The display screen is connected to the server platform for displaying the graph relationship network constructed by the server platform.
[0013] The beneficial effect of the present invention is that, through the setting of step one, each water supply point in the water supply network in the display can be used as a graph node, and then the relationship graph of the interconnected pipes is the edge of the relationship network, and finally a directed graph is formed according to the water flow direction between the water supply points. In this way, when it is necessary to detect the water quality level of the water supply point without a water quality sensor, the existing graph neural network algorithm can be used to simply and effectively realize the use of the aggregation algorithm to calculate the water quality level of the water supply point without a water quality sensor, and finally it can be displayed on the display screen, ensuring sufficient functionality. BRIEF DESCRIPTION OF THE DRAWINGS
[0014] Figure 1 This is a node schematic diagram of the water quality anomaly detection method based on graph neural network of the present invention. DETAILED DESCRIPTION
[0015] The present invention will be further described below in detail with reference to the embodiments shown in the accompanying drawings.
[0016] Reference Figure 1 As shown, a water quality anomaly detection method based on a graph neural network in this embodiment includes the following steps: Step 1: extract each water supply point in the water supply network as a graph node, and build a graph relationship network based on the connection relationship of the nodes in the water supply network as an edge, and determine the flow direction between the nodes to construct a directed edge; Step 2: Extract the water quality data detected by the water supply point equipped with a water quality sensor, perform local processing and analysis, determine the water quality level of the water supply point, and attach the water quality level as a feature vector to the graph node corresponding to the water supply point. The node feature vector corresponding to the water supply point without a water quality sensor is None, completing the construction of the graph relationship network; Step 3: present the graph relationship network constructed in step 2 on the display screen with the city map corresponding to the water supply network as the background, and display the feature vector information of each water supply point; Step 4, aggregating the nodes whose feature vectors are none in step 2, obtaining the feature vectors of the nodes regarding the water quality level, and presenting them on the display screen after updating; Among them, the water quality level determined in step 2 includes a normal level and an abnormal level, and all nodes of abnormal levels are highlighted on the display screen. In the process of using the water quality anomaly detection method in this embodiment, it is only necessary to construct a graph relationship network equivalent to the water supply network to be detected. In this way, the water quality level of each node can be detected by adding feature vectors to the nodes, and the city map can also be combined with the graph relationship network for display through the display screen. When the water quality is abnormal, the water supply point with abnormal water quality can be located more quickly.
[0017] In the process of determining the water flow direction between the water supply points, on the one hand, the existing registered and determined directions can be directly input into the graph neural network, and on the other hand, the neural network can be used for real-time calculation and acquisition. Compared with the registered method, the real-time calculation and acquisition is real-time, which can avoid the problem of inaccurate water flow direction caused by the failure to update the registration in time. Therefore, the following method is used in this embodiment to realize the real-time calculation of the water flow direction between the water supply points: Step 1, extract the water flow data of each node for a period of time, and calculate the change of water flow of each node during this period of time; Step 1 and 2: cluster each node based on the value of water flow data, and group nodes with similar water flow during this period into one group; Step 13, dividing the time period in step 12 into multiple moments, extracting the flow data at each moment, and analyzing the flow data to extract the moment when the flow data changes; Step 14: compare the time when the traffic data in each node in a group changes, and then sort them in time order, select the nodes corresponding to the earlier time sequence as the downstream, and the later nodes as the upstream, and then add the direction of the edge to each node in the upstream to downstream manner to complete the construction of the directed edge.
[0018] In reality, however, water quality sensors cannot be accurately set at every water supply point. At the same time, based on the characteristics of water flow, the water quality of upstream nodes is strongly correlated with downstream nodes, and the water quality of downstream nodes is weakly correlated with upstream nodes. In this embodiment, two methods are selected to aggregate upstream nodes and downstream nodes respectively, and then the two aggregation results are combined to determine the water quality level of the node. In addition, the supply of water sources is basically a way of gradually diffusing outward through water plants. Therefore, the number of nodes involved in the aggregation of upstream nodes is much smaller than the number of nodes of downstream nodes. In addition, based on the principle that upstream nodes are strongly correlated with downstream nodes, when the water quality level of upstream nodes is abnormal, downstream nodes will basically be abnormal. Therefore, in this embodiment, the upstream nodes are aggregated first, and the water quality level of downstream nodes is aggregated on the premise that the aggregation result of upstream nodes is a normal water quality level, so as to finally determine the water quality level of the initial node. Therefore, the following upstream node aggregation scheme is provided in this embodiment: Step 41, determining the upstream nodes to be aggregated in the initial node, extracting the water quality grade characteristics of the upstream nodes, and obtaining the water quality grade feature vector of each upstream node; Step 42, selecting an aggregation function, and aggregating the water quality grade feature vector obtained in step 41 through the aggregation function to obtain an aggregated water quality grade feature vector; Step 43, replace the feature vector with the feature vector of the aggregated water quality grade, so that the feature vector of the node whose original feature vector is none is the water quality grade after aggregation; Among them, in step 41, when the feature vectors of all upstream nodes and downstream nodes are obtained to be none, one of the upstream nodes is selected to obtain the feature vectors of the upstream node of the previous level and other downstream nodes of the upstream node. If the feature vectors are still all none, then traverse other upstream nodes to obtain the feature vectors of the upstream node of the previous level and other downstream nodes of other upstream nodes. If the feature vectors obtained after traversing other upstream nodes are all none, then traverse the upstream nodes of the previous level until the water quality grade feature vector is obtained, and then execute steps 42 and 43 for multi-layer aggregation until the initial node feature vector is the aggregated water quality grade, which can effectively ensure that the initial node can obtain the water quality grade of the upstream node, and in the process of aggregation, Due to the characteristics that the upstream nodes are strongly correlated with the downstream nodes, and the downstream nodes are weakly correlated with the upstream nodes, this embodiment provides different aggregation methods, specifically, the aggregation function selected in the aggregation of the upstream nodes is set aggregation, that is, all the feature vectors are collected into a set, and then the set is traversed to determine whether there is an abnormal water quality level in the set. If so, the aggregation result is the abnormal water quality level, if not, the aggregation result is the normal water quality level. In step 4, the aggregation function selected in the aggregation of the downstream nodes is set aggregation, that is, all the feature vectors are collected into a set, and then the set is traversed to determine whether the set is all abnormal water quality levels. If so, the aggregation result is the abnormal water quality level, if not, the aggregation result is the normal water quality level.
[0019] In an actual water supply network, some water supply points will be equipped with water purifiers. The water supply points with water purifiers installed have a strong correlation with their downstream nodes in normal water quality levels. Therefore, they need to be given priority in aggregation to avoid misjudgment of the water quality level of an initial node when there are multiple upstream nodes because one of the upstream nodes has a water purifier installed. Therefore, in this embodiment, after traversing the set of downstream node feature vector combinations, the nodes with water purifiers in the set are first removed, and then it is determined whether all of them have abnormal water quality levels to avoid the influence of the water purifier on the aggregation results.
[0020] However, since the water quality grade needs to be obtained by calculating a large number of water quality parameters, it has a high amount of calculation. Therefore, in this embodiment, the water quality grade detection adopts the local calculation method, and the local calculation uses a neural network to calculate the water quality grade, which can accurately and effectively complete the calculation of the water quality grade, and also reduces the corresponding communication cost.
[0021] Furthermore, in the process of aggregation calculation, this embodiment prioritizes aggregation calculation of upstream nodes or downstream nodes with water quality sensors, so that a single-layer calculation can obtain the water quality level of the corresponding initial node, and after obtaining the water quality level of the initial node, when the aggregation calculation of other nodes involves this node, the characteristic vector of the node is directly noted as the calculated water quality level, thereby realizing step-by-step calculation from the edge to the central node without characteristic vectors, which effectively saves computing resources compared to the method of randomly selecting nodes for calculation.
[0022] This embodiment uses a combination of a server platform and a display screen to carry the above-mentioned detection method, so as to realize the detection of the water quality level of the water supply point, and through the display screen combined with the intuitive display of the city map, it is further convenient for people to detect and observe the water quality level of each water supply point in the city, and quickly locate the water supply point with abnormal water quality level.
[0023] To summarize, the graph neural network-based water quality anomaly detection method of this embodiment, through the settings of steps one to four, can effectively implement water quality level detection for all water supply points based on water quality sensors in the water supply network.
[0024] The above is only a preferred embodiment of the present invention, and the protection scope of the present invention is not limited to the above embodiments. All technical solutions under the concept of the present invention belong to the protection scope of the present invention. It should be pointed out that for ordinary technicians in this technical field, some improvements and modifications without departing from the principle of the present invention should also be regarded as the protection scope of the present invention.
Claims
1. A water quality anomaly detection method based on graph neural network, characterized by: The steps include: Step 1: extract each water supply point in the water supply network as a graph node, and build a graph relationship network based on the connection relationship of the nodes in the water supply network as an edge, and determine the flow direction between the nodes to construct a directed edge; Step 2: Extract the water quality data detected by the water supply point equipped with a water quality sensor, perform local processing and analysis, determine the water quality level of the water supply point, and attach the water quality level as a feature vector to the graph node corresponding to the water supply point. The node feature vector corresponding to the water supply point without a water quality sensor is None, completing the construction of the graph relationship network; Step 3: present the graph relationship network constructed in step 2 on the display screen with the city map corresponding to the water supply network as the background, and display the feature vector information of each water supply point; Step 4, aggregating the nodes whose feature vectors are none in step 2, obtaining the feature vectors of the nodes regarding the water quality level, and presenting them on the display screen after updating; The water quality level determined in step 2 includes a normal level and an abnormal level, and all nodes of the abnormal level are highlighted on the display screen.
2. The water quality anomaly detection method based on graph neural network according to claim 1 is characterized in that: The specific steps of determining the flow direction between nodes and constructing directed edges in step 1 are as follows: Step 1, extract the water flow data of each node for a period of time, and calculate the change of water flow of each node during this period of time; Step 1 and 2: cluster each node based on the value of water flow data, and group nodes with similar water flow during this period into one group; Step 13, dividing the time period in step 12 into multiple moments, extracting the flow data at each moment, and analyzing the flow data to extract the moment when the flow data changes; Step 14: compare the time when the traffic data in each node in a group changes, and then sort them in time order, select the nodes corresponding to the earlier time sequence as the downstream, and the later nodes as the upstream, and then add the direction of the edge to each node in the upstream to downstream manner to complete the construction of the directed edge.
3. The water quality anomaly detection method based on graph neural network according to claim 2 is characterized in that: In step 4, the nodes whose characteristic vectors are none in step 2 are aggregated to obtain the characteristic vectors of the nodes with respect to the water quality level. The specific steps are as follows: Step 41, determining the upstream nodes to be aggregated in the initial node, extracting the water quality grade characteristics of the upstream nodes, and obtaining the water quality grade feature vector of each upstream node; Step 42, selecting an aggregation function, and aggregating the water quality grade feature vector obtained in step 41 through the aggregation function to obtain an aggregated water quality grade feature vector; Step 43, replace the feature vector with the feature vector of the aggregated water quality grade, so that the feature vector of the node whose original feature vector is none is the water quality grade after aggregation; Among them, in step 41, when the feature vectors of all upstream nodes and downstream nodes are all None, one of the upstream nodes is selected to obtain the feature vectors of the upstream node of the previous level and other downstream nodes of the upstream node. If the feature vectors are still None, traverse other upstream nodes to obtain the feature vectors of the upstream nodes of the previous level and other downstream nodes of other upstream nodes. If the feature vectors obtained after traversing other upstream nodes are all None, traverse the upstream nodes of the previous level until the water quality grade feature vector is obtained, and then execute steps 42 and 43 for multi-layer aggregation until the initial node feature vector is the aggregated water quality grade.
4. The water quality anomaly detection method based on graph neural network according to claim 3 is characterized in that: If the node feature vector in step 43 is an abnormal water quality level after aggregation, the abnormal level is directly used as the feature vector of the node; if the water quality level after aggregation is a normal level, the downstream node to be aggregated in the initial node is determined, and then steps 41 to 43 are executed in sequence to complete the aggregation of the downstream nodes, and the water quality level feature vector of the aggregation result is updated and replaced; Among them, the aggregation function selected in the aggregation of upstream nodes in step 42 is set aggregation, that is, all feature vectors are collected into a set, and then the set is traversed to determine whether there is an abnormal water quality level in the set. If so, the aggregation result is the abnormal water quality level, if not, the aggregation result is the normal water quality level. The aggregation function selected in the aggregation of downstream nodes in step 42 is set aggregation, that is, all feature vectors are collected into a set, and then the set is traversed to determine whether the set is all abnormal water quality levels. If so, the aggregation result is the abnormal water quality level, if not, the aggregation result is the normal water quality level.
5. The water quality anomaly detection method based on graph neural network according to claim 4 is characterized in that: In the step 2, it is also extracted whether the water supply point is equipped with a water purification device. If the water supply point is equipped with a water purification device, the node feature vector corresponding to the water supply point is determined as the normal water quality level, and after traversing the set of downstream node feature vector combinations, the nodes with water purification devices in the set are first removed, and then it is determined whether all of them are at abnormal water quality levels.
6. The water quality anomaly detection method based on graph neural network according to claim 5 is characterized in that: The specific method of performing local processing and analysis in the step 2 is: using the historical water quality data of the water supply point as a training set to input into the algorithm model for training to obtain a water quality grade judgment model, then inputting the currently detected water quality data into the water quality grade judgment model, and finally outputting the water quality grade through the water quality grade judgment model.
7. The water quality anomaly detection method based on graph neural network according to claim 6 is characterized in that: In the aggregation calculation process in step 4, the nodes with water quality sensors at the upstream nodes or downstream nodes are prioritized for aggregation calculation.
8. A system using the water quality anomaly detection method based on graph neural network according to any one of claims 1 to 6, characterized in that: include: The server platform is connected to each water supply point, builds a graph relationship network based on the water supply point, extracts the water quality data detected by the water supply point equipped with a water quality sensor, and performs aggregation calculation on the nodes with no feature vector in the graph relationship network to obtain the feature vector corresponding to the node; The display screen is connected to the server platform for displaying the graph relationship network constructed by the server platform.
Citation Information
Patent Citations
Water supply network water quality prediction method and software system based on space-time diagram neural network
CN119129857A
Graph neural network water supply network sensor optimization arrangement method and system
CN117436218A
Water quality index prediction method based on mixed space-time diagram convolutional neural network
CN117874618A
Water quality influence factor importance measuring method, system and equipment and storage medium
CN118606650A
Water quality monitoring method, device and equipment based on multi-dimensional parameters and storage medium
CN118624851A