Defect processing method and device of line loss monitoring software and storage medium

By constructing graph neural networks and syntax trees to transform undirected graphs, defects in line loss monitoring software can be quickly located and repaired. This solves the problem that it is difficult to locate and repair defects during operation in existing technologies, thus ensuring the safety and stability of the power grid.

CN120429150BActive Publication Date: 2025-11-18INTELLIGENT DISTRIBUTION NETWORK CENT OF STATE GRID JIBEI ELECTRIC POWER CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510516391.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-23
Publication Date
2025-11-18
Estimated Expiration
2045-04-23

AI Technical Summary

Technical Problem

Existing line loss monitoring software has difficulty quickly locating and repairing defects during operation, especially when it is not shut down, which affects the safety and stability of the power grid.

Method used

By monitoring power grid data, a graph neural network is constructed. The source code is transformed using syntax trees and undirected graphs. Based on the type of line loss, defects are quickly located and corresponding source code modifications are made.

Benefits of technology

It enables rapid location and repair of defects without stopping the line loss monitoring software, improving the safety and stability of the power grid and reducing the false alarm rate.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120429150B_ABST
    Figure CN120429150B_ABST
Patent Text Reader

Abstract

The application provides a defect processing method and device of line loss monitoring software and a storage medium. The method comprises the following steps: processing power grid data collected by the line loss monitoring software in real time, determining whether there is an abnormal line loss and a type of the abnormal line loss; determining that the abnormal line loss is caused by defects of the line loss monitoring software; determining a candidate defect set of the line loss monitoring software based on the type of the abnormal line loss; converting source code of the line loss monitoring software into a syntax tree, converting the syntax tree into an undirected graph according to conditional statements and memory operation statements in the source code, mapping each defect in the candidate defect set to a corresponding node of the undirected graph, and then determining a defect of the line loss monitoring software, and modifying source code corresponding to the node mapped by the defect. The application can quickly locate the defect of the software, so that the normal monitoring function of the line loss software can be quickly recovered.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer program vulnerability detection and processing technology, specifically to a defect processing method, device, and storage medium for line loss monitoring software. Background Technology

[0002] After the line loss monitoring software is deployed, it is necessary to determine whether the software has defects, i.e., whether there are bugs, without stopping its operation. This can be done when the line loss monitoring software detects abnormal line losses based on real-time collected power grid data (mainly voltage, current, real-time power, etc.). If it is determined that the problem is not due to a faulty sensor or human theft of electricity, then the line loss monitoring software has defects. However, line loss monitoring software generally consists of hundreds of thousands of lines of code, and how to quickly locate defects for repair is a technical challenge. Summary of the Invention

[0003] In view of one or more technical defects in the prior art, the present invention proposes the following technical solution.

[0004] A defect handling method for line loss monitoring software, the method comprising:

[0005] The monitoring steps involve processing the power grid data collected in real time by the line loss monitoring software to determine whether there are abnormal line losses and the type of such abnormal line losses.

[0006] The steps determined that the abnormal line loss was caused by a defect in the line loss monitoring software.

[0007] The detection step involves determining a set of candidate defects for the line loss monitoring software based on the type of abnormal line loss.

[0008] The processing steps are as follows: the source code of the line loss monitoring software is converted into a syntax tree; the syntax tree is converted into an undirected graph based on the conditional statements and memory operation statements in the source code; each defect in the candidate defect set is mapped to a corresponding node in the undirected graph; it is determined whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph; if so, the defect is regarded as a defect of the line loss monitoring software, and the source code corresponding to the node mapped to the defect is modified.

[0009] Furthermore, the monitoring step involves: obtaining historical normal line loss values ​​from the database of the line loss monitoring software; calculating the current line loss value based on the power grid data collected in real time by the line loss monitoring software; processing the current line loss value and the historical normal line loss value to determine whether there is abnormal line loss; and if so, determining whether the current line loss type is high line loss or low line loss.

[0010] Furthermore, the determination step involves: locating the location of the abnormal line loss based on the abnormal line loss; determining the identifier of the corresponding sensor that collects power grid data based on the location; obtaining the historical and current data of the sensor from the database of the line loss monitoring software based on the sensor identifier; determining whether the sensor is faulty based on the historical and current data; if not, checking whether there is any human-caused electricity theft at the location; if not, determining that the line loss monitoring software has a defect.

[0011] Furthermore, the detection step involves determining a candidate defect set for the line loss monitoring software based on the relationship between the constructed line loss type and the defects in the line loss monitoring software, and based on the type of abnormal line loss.

[0012] Furthermore, the operation of determining whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph is as follows: constructing a graph of the graph neural network, using the nodes corresponding to the conditional statement and memory operation statement as key nodes of the graph of the graph neural network, and using other nodes in the undirected graph as secondary nodes of the graph of the graph neural network.

[0013] Furthermore, the feature values ​​of the key nodes for:

[0014] ;

[0015] in, This represents the shortest path hop count from the critical node to the node mapped to the defect;

[0016] The eigenvalues ​​of the secondary node for:

[0017] ;

[0018] in, This represents the number of hops in the shortest path from the secondary node to the node mapped to the defect. This represents the number of hops in the shortest path from the secondary node to the critical node.

[0019] Furthermore, the weights of the edges in the graph of the graph neural network are set as follows: 1> weight of the edge between key nodes> weight of the edge between key nodes and secondary nodes> weight of the edge between secondary nodes> 0.

[0020] This invention also proposes a defect handling device for line loss monitoring software, the device comprising:

[0021] The monitoring unit processes the power grid data collected in real time by the line loss monitoring software to determine whether there is abnormal line loss and the type of abnormal line loss.

[0022] The determining unit determines that the abnormal line loss is caused by a defect in the line loss monitoring software;

[0023] The detection unit determines a set of candidate defects for the line loss monitoring software based on the type of abnormal line loss.

[0024] The processing unit converts the source code of the line loss monitoring software into a syntax tree, converts the syntax tree into an undirected graph based on the conditional statements and memory operation statements in the source code, maps each defect in the candidate defect set to a corresponding node in the undirected graph, determines whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph, and if so, treats the defect as a defect of the line loss monitoring software and modifies the source code corresponding to the node mapped to the defect.

[0025] Furthermore, the operation of the monitoring unit is as follows: obtain historical normal line loss values ​​from the database of the line loss monitoring software, calculate the current line loss value based on the power grid data collected in real time by the line loss monitoring software, process the current line loss value and the historical normal line loss value to determine whether there is abnormal line loss, and if so, determine whether the current line loss type is high line loss or low line loss.

[0026] Furthermore, the operation of the determining unit is as follows: based on the abnormal line loss, locate the location of the abnormal line loss; based on the location, determine the identifier of the corresponding sensor that collects power grid data; based on the sensor identifier, obtain the historical data and current data of the sensor from the database of the line loss monitoring software; based on the historical data and current data, determine whether the sensor is faulty; if not, check whether there is any human electricity theft at the location; if not, determine that the line loss monitoring software has a defect.

[0027] Furthermore, the operation of the detection unit is as follows: based on the relationship between the constructed line loss type and the defects of the line loss monitoring software, and based on the type of abnormal line loss, determine the candidate defect set of the line loss monitoring software.

[0028] Furthermore, the operation of determining whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph is as follows: constructing a graph of the graph neural network, using the nodes corresponding to the conditional statement and memory operation statement as key nodes of the graph of the graph neural network, and using other nodes in the undirected graph as secondary nodes of the graph of the graph neural network.

[0029] Furthermore, the feature values ​​of the key nodes for:

[0030] ;

[0031] in, This represents the shortest path hop count from the critical node to the node mapped to the defect;

[0032] The eigenvalues ​​of the secondary node for:

[0033] ;

[0034] in, This represents the number of hops in the shortest path from the secondary node to the node mapped to the defect. This represents the number of hops in the shortest path from the secondary node to the critical node.

[0035] Furthermore, the weights of the edges in the graph of the graph neural network are set as follows: 1> weight of the edge between key nodes> weight of the edge between key nodes and secondary nodes> weight of the edge between secondary nodes> 0.

[0036] The present invention also proposes a computer-readable storage medium storing computer program code, which, when executed by a computer, performs any of the methods described above.

[0037] The technical advantages of this invention are as follows: The present invention provides a defect handling method, apparatus, and storage medium for line loss monitoring software. The method includes a monitoring step S101, which processes real-time power grid data collected by the line loss monitoring software to determine whether abnormal line loss exists and its type; a determination step S102, which determines that the abnormal line loss is caused by a defect in the line loss monitoring software; a detection step S103, which determines a candidate defect set for the line loss monitoring software based on the type of abnormal line loss; and a processing step S104, which converts the source code of the line loss monitoring software into a syntax tree, converts the syntax tree into an undirected graph based on conditional statements and memory operation statements in the source code, maps each defect in the candidate defect set to a corresponding node in the undirected graph, determines whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph, and if so, treats the defect as a defect of the line loss monitoring software and modifies the source code corresponding to the node mapped to the defect. This invention proposes a method to determine a candidate defect set for line loss monitoring software based on the type of line loss. Then, the source code of the line loss monitoring software is converted into a syntax tree. Based on the conditional statements and memory operation statements in the source code, the syntax tree is converted into an undirected graph. Each defect in the candidate defect set is mapped to a corresponding node in the undirected graph. It is then determined whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph. If so, the defect is considered a defect of the line loss monitoring software, and the source code corresponding to the node mapped to the defect is modified.After converting the source code into a syntax tree, the conditional statements and memory operation statements in the source code are converted into an undirected graph. During the conversion of the syntax tree into an undirected graph, these two types of nodes are treated as key nodes. Subsequently, a graph neural network is constructed to perform graph reasoning calculations. This allows for the determination of whether logical errors exist between the node corresponding to the defect and other nodes in the undirected graph, thus quickly locating software defects and rapidly restoring the normal monitoring function of the line loss monitoring software. Another key aspect of this invention is the construction of a graph neural network to determine software defects through graph operations. In this invention, the main causes of defects in line loss monitoring software are attributed to unexpected errors that may occur during the execution of conditional statements and memory operation statements, leading to memory errors, memory leaks, suspension of acquisition threads, and discrepancies in acquisition threads. Therefore, when constructing the graph of the graph neural network, the nodes corresponding to conditional statements and memory operation statements are designated as key nodes, and the remaining nodes are designated as secondary nodes. The feature values ​​of key nodes and secondary nodes are calculated based on the shortest path hop count from key nodes to nodes mapped to defects, the shortest path hop count from secondary nodes to nodes mapped to defects, and the shortest path hop count from secondary nodes to key nodes (if a secondary node can reach multiple key nodes, the shortest path hop count is selected). Specific calculation formulas are provided. The graph construction method, node weight calculation method, and edge weight setting method of this graph neural network have been tested in a local power grid line loss monitoring software. They can accurately detect defects in the line loss monitoring software, reduce the false alarm rate of the line loss monitoring software, and ensure the safe operation of the power grid. Attached Figure Description

[0038] Other features, objects, and advantages of this application will become more apparent from the following detailed description of non-limiting embodiments with reference to the accompanying drawings.

[0039] Figure 1 This is a flowchart of a defect handling method for line loss monitoring software according to an embodiment of the present invention.

[0040] Figure 2 This is a structural diagram of a defect handling device for line loss monitoring software according to an embodiment of the present invention. Detailed Implementation

[0041] The present application will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the accompanying drawings.

[0042] It should be noted that, unless otherwise specified, the embodiments and features described in this application can be combined with each other. This application will now be described in detail with reference to the accompanying drawings and embodiments.

[0043] Figure 1 This invention illustrates a defect handling method for line loss monitoring software, the method comprising:

[0044] In monitoring step S101, the power grid data collected in real time by the line loss monitoring software is processed to determine whether there is abnormal line loss and the type of abnormal line loss.

[0045] In step S102, it is determined that the abnormal line loss is caused by a defect in the line loss monitoring software.

[0046] In detection step S103, based on the type of abnormal line loss, a candidate defect set for the line loss monitoring software is determined;

[0047] In processing step S104, the source code of the line loss monitoring software is converted into a syntax tree. Based on the conditional statements and memory operation statements in the source code, the syntax tree is converted into an undirected graph. Each defect in the candidate defect set is mapped to a corresponding node in the undirected graph. It is determined whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph. If so, the defect is regarded as a defect of the line loss monitoring software, and the source code corresponding to the node mapped to the defect is modified.

[0048] This invention addresses the challenge of determining whether line loss monitoring software has defects (Bugs) after deployment without halting its operation. Specifically, when the software detects abnormal line losses based on real-time collected power grid data (primarily voltage, current, and real-time power), and it's determined that the issue isn't due to sensor malfunction or human-caused electricity theft, a defect is identified. However, software defects are difficult to locate. After years of technical research, this invention proposes a method to determine a candidate defect set for the line loss monitoring software based on the type of line loss. Then, the software's source code is converted into a syntax tree. Based on conditional statements and memory operation statements in the source code, the syntax tree is converted into an undirected graph. Each defect in the candidate defect set is mapped to a corresponding node in the undirected graph. The system then checks for logical errors between the node corresponding to the defect and other nodes in the undirected graph. If an error is found, the defect is identified as a defect in the line loss monitoring software, and the source code corresponding to the mapped node is modified. The invention involves converting source code into syntax and then converting conditional statements and memory operation statements in the source code into an undirected graph. This involves using nodes of these two types as key nodes when converting a syntax tree into an undirected graph. Subsequently, a graph neural network is constructed to perform graph reasoning calculations. This allows for the determination of whether logical errors exist between the defective node and other nodes in the undirected graph. This enables rapid location of software defects, quickly restoring the normal monitoring function of the line loss software, and ensuring the safe operation of the power grid. This is a key inventive concept of the present invention.

[0049] In one embodiment, the operation of the monitoring step S101 is as follows: obtain historical normal line loss values ​​from the database of the line loss monitoring software, calculate the current line loss value based on the power grid data collected in real time by the line loss monitoring software, process the current line loss value and the historical normal line loss value to determine whether there is abnormal line loss, and if so, determine whether the current line loss type is high line loss or low line loss.

[0050] In one embodiment, the operation of the determination step S102 is as follows: based on the abnormal line loss, locate the location of the abnormal line loss; based on the location, determine the identifier of the corresponding sensor that collects power grid data; based on the sensor identifier, obtain the historical data and current data of the sensor from the database of the line loss monitoring software; based on the historical data and current data, determine whether the sensor is faulty; if not, check whether there is any human electricity theft at the location; if not, determine that the line loss monitoring software has a defect.

[0051] In monitoring step S101 and determination step S102, the current line loss value is calculated based on the power grid data collected in real time by the line loss monitoring software. The current line loss value is compared with the historical normal line loss value to determine whether there is abnormal line loss. If so, the current line loss type is determined to be high line loss or low line loss. The sensor is also judged to be faulty based on the historical data and the current data. Predictive processing can be performed by LSTM or improved LSTM, or SVM can be used, etc.

[0052] In one embodiment, the operation of the detection step S103 is as follows: based on the relationship between the constructed line loss type and the defects of the line loss monitoring software, and based on the type of abnormal line loss, determine the candidate defect set of the line loss monitoring software.

[0053] In this invention, defects corresponding to high line loss are defined as follows: thread asynchrony caused by the collection of current and voltage data in the power grid data by the line loss monitoring software, memory errors caused by excessive data collection, and errors caused by abnormal judgment statement flow in the software itself, etc.

[0054] The defects corresponding to low line loss are defined as follows: one of the threads collecting power grid data is suspended, resulting in no data being collected; software memory leaks; errors caused by abnormal judgment statement flow in the software itself, etc.

[0055] This is a key point of the present invention. By determining the type of line loss, the set of defects can be quickly identified, thereby enabling rapid location of nodes that may have defects in the wireless graph. Subsequent graph neural network-based operations can accurately locate which node is the root cause of the defect, thereby modifying the source code corresponding to that node. This improves the accuracy of defect finding in line loss monitoring software, thus improving the rapid recovery of line loss software applications. This is one of the inventive points of the present invention, namely, determining the corresponding defect candidate set according to different types of line loss.

[0056] In one embodiment, the operation of determining whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph is as follows: constructing a graph of the graph neural network, using the nodes corresponding to the conditional statement and memory operation statement as key nodes of the graph of the graph neural network, and using other nodes in the undirected graph as secondary nodes of the graph of the graph neural network.

[0057] In one embodiment, the feature value of the key node for:

[0058] ;

[0059] in, This represents the shortest path hop count from the critical node to the node mapped to the defect;

[0060] The eigenvalues ​​of the secondary node for:

[0061] ;

[0062] in, This represents the number of hops in the shortest path from the secondary node to the node mapped to the defect. This represents the number of hops in the shortest path from the secondary node to the critical node.

[0063] In one embodiment, the weights of the edges in the graph neural network are set as follows: 1 > Weight of the edge between key nodes > Weight of the edge between key nodes and secondary nodes > Weight of the edge between secondary nodes > 0. For example, the weight of the edge between key nodes is set to 0.5-0.8, the weight of the edge between key nodes and secondary nodes is set to 0.3-0.5, and the weight of the edge between secondary nodes is set to 0.1-0.3. The theoretical basis for this setting is that the main causes of defects in line loss monitoring software are conditional statements and memory operation statements. Therefore, assigning larger values ​​to the weights of the edges between their corresponding nodes is sufficient. The weight of the edge between a key node and a secondary node is less than the weight between key nodes, and the weight of the edge between these nodes is the smallest. This method improves the computational efficiency and defect prediction accuracy of the graph neural network, which is an inventive concept of this invention.

[0064] Another key aspect of this invention is the construction of a graph neural network to identify software defects through graph operations. This invention attributes the main causes of defects in line loss monitoring software to unexpected errors during the execution of conditional statements and memory operation statements, leading to memory errors, memory leaks, suspended acquisition threads, and asynchronous acquisition threads. Therefore, when constructing the graph of the graph neural network, the nodes corresponding to conditional statements and memory operation statements are designated as key nodes, and the remaining nodes as secondary nodes. The feature values ​​of key nodes and secondary nodes are calculated based on the shortest path hop count from key nodes to defect-mapped nodes, the shortest path hop count from secondary nodes to defect-mapped nodes, and the shortest path hop count from secondary nodes to key nodes (if a secondary node can reach multiple key nodes, the shortest path hop count is selected). Specific calculation formulas are provided. This graph neural network's construction method, node weight calculation method, and edge weight setting method have been tested in a local power grid line loss monitoring software and have proven accurate in identifying defects in the software, reducing false alarm rates, and ensuring the safe operation of the power grid. This is one of the important inventive points of this invention.

[0065] Figure 2 This invention discloses a defect handling device for line loss monitoring software, the device comprising:

[0066] A defect handling method for line loss monitoring software, the method comprising:

[0067] The monitoring unit 201 processes the power grid data collected in real time by the line loss monitoring software to determine whether there is abnormal line loss and the type of abnormal line loss.

[0068] Unit 202 determines that the abnormal line loss is caused by a defect in the line loss monitoring software;

[0069] The detection unit 203 determines a set of candidate defects for the line loss monitoring software based on the type of abnormal line loss.

[0070] Processing unit 204 converts the source code of the line loss monitoring software into a syntax tree, converts the syntax tree into an undirected graph based on the conditional statements and memory operation statements in the source code, maps each defect in the candidate defect set to the corresponding node in the undirected graph, determines whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph, and if so, treats the defect as a defect of the line loss monitoring software and modifies the source code corresponding to the node mapped to the defect.

[0071] This invention addresses the challenge of determining whether line loss monitoring software has defects (Bugs) after deployment without halting its operation. Specifically, when the software detects abnormal line losses based on real-time collected power grid data (primarily voltage, current, and real-time power), and it's determined that the issue isn't due to sensor malfunction or human-caused electricity theft, a defect is identified. However, software defects are difficult to locate. After years of technical research, this invention proposes a method to determine a candidate defect set for the line loss monitoring software based on the type of line loss. Then, the software's source code is converted into a syntax tree. Based on conditional statements and memory operation statements in the source code, the syntax tree is converted into an undirected graph. Each defect in the candidate defect set is mapped to a corresponding node in the undirected graph. The system then checks for logical errors between the node corresponding to the defect and other nodes in the undirected graph. If an error is found, the defect is identified as a defect in the line loss monitoring software, and the source code corresponding to the mapped node is modified. The invention involves converting source code into syntax and then converting conditional statements and memory operation statements in the source code into an undirected graph. This involves using nodes of these two types as key nodes when converting a syntax tree into an undirected graph. Subsequently, a graph neural network is constructed to perform graph reasoning calculations. This allows for the determination of whether logical errors exist between the defective node and other nodes in the undirected graph. This enables rapid location of software defects, quickly restoring the normal monitoring function of the line loss software, and ensuring the safe operation of the power grid. This is a key inventive concept of the present invention.

[0072] In one embodiment, the operation of the monitoring unit 201 is as follows: obtain historical normal line loss values ​​from the database of the line loss monitoring software, calculate the current line loss value based on the power grid data collected in real time by the line loss monitoring software, process the current line loss value and the historical normal line loss value to determine whether there is abnormal line loss, and if so, determine whether the current line loss type is high line loss or low line loss.

[0073] In one embodiment, the operation of the determining unit 202 is as follows: locating the location of the abnormal line loss based on the abnormal line loss; determining the identifier of the corresponding sensor for collecting power grid data based on the location; obtaining the historical and current data of the sensor from the database of the line loss monitoring software based on the sensor identifier; determining whether the sensor is faulty based on the historical and current data; if not, checking whether there is any human electricity theft at the location; if not, determining that the line loss monitoring software has a defect.

[0074] In the monitoring unit 201 and the determination unit 202, the current line loss value is calculated based on the power grid data collected in real time by the line loss monitoring software. The current line loss value is processed with the historical normal line loss value to determine whether there is abnormal line loss. If so, the current line loss type is determined to be high line loss or low line loss. The sensor is also judged to be faulty based on the historical data and the current data. Predictive processing can be performed by LSTM or improved LSTM, or SVM can be used, etc.

[0075] In one embodiment, the operation of the detection unit 203 is as follows: based on the relationship between the constructed line loss type and the defects of the line loss monitoring software, and based on the type of abnormal line loss, determine the candidate defect set of the line loss monitoring software.

[0076] In this invention, defects corresponding to high line loss are defined as follows: thread asynchrony caused by the collection of current and voltage data in the power grid data by the line loss monitoring software, memory errors caused by excessive data collection, and errors caused by abnormal judgment statement flow in the software itself, etc.

[0077] The defects corresponding to low line loss are defined as follows: one of the threads collecting power grid data is suspended, resulting in no data being collected; software memory leaks; errors caused by abnormal judgment statement flow in the software itself, etc.

[0078] This is a key point of the present invention. By determining the type of line loss, the set of defects can be quickly identified, thereby enabling rapid location of nodes that may have defects in the wireless graph. Subsequent graph neural network-based operations can accurately locate which node is the root cause of the defect, thereby modifying the source code corresponding to that node. This improves the accuracy of defect finding in line loss monitoring software, thus improving the rapid recovery of line loss software applications. This is one of the inventive points of the present invention, namely, determining the corresponding defect candidate set according to different types of line loss.

[0079] In one embodiment, the operation of determining whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph is as follows: constructing a graph of the graph neural network, using the nodes corresponding to the conditional statement and memory operation statement as key nodes of the graph of the graph neural network, and using other nodes in the undirected graph as secondary nodes of the graph of the graph neural network.

[0080] In one embodiment, the feature value of the key node for:

[0081] ;

[0082] in, This represents the shortest path hop count from the critical node to the node mapped to the defect;

[0083] The eigenvalues ​​of the secondary node for:

[0084] ;

[0085] in, This represents the number of hops in the shortest path from the secondary node to the node mapped to the defect. This represents the number of hops in the shortest path from the secondary node to the critical node.

[0086] In one embodiment, the weights of the edges in the graph neural network are set as follows: 1 > Weight of the edge between key nodes > Weight of the edge between key nodes and secondary nodes > Weight of the edge between secondary nodes > 0. For example, the weight of the edge between key nodes is set to 0.5-0.8, the weight of the edge between key nodes and secondary nodes is set to 0.3-0.5, and the weight of the edge between secondary nodes is set to 0.1-0.3. The theoretical basis for this setting is that the main causes of defects in line loss monitoring software are conditional statements and memory operation statements. Therefore, assigning larger values ​​to the weights of the edges between their corresponding nodes is sufficient. The weight of the edge between a key node and a secondary node is less than the weight between key nodes, and the weight of the edge between these nodes is the smallest. This method improves the computational efficiency and defect prediction accuracy of the graph neural network, which is an inventive concept of this invention.

[0087] Another key aspect of this invention is the construction of a graph neural network to identify software defects through graph operations. This invention attributes the main causes of defects in line loss monitoring software to unexpected errors during the execution of conditional statements and memory operation statements, leading to memory errors, memory leaks, suspended acquisition threads, and asynchronous acquisition threads. Therefore, when constructing the graph of the graph neural network, the nodes corresponding to conditional statements and memory operation statements are designated as key nodes, and the remaining nodes as secondary nodes. The feature values ​​of key nodes and secondary nodes are calculated based on the shortest path hop count from key nodes to defect-mapped nodes, the shortest path hop count from secondary nodes to defect-mapped nodes, and the shortest path hop count from secondary nodes to key nodes (if a secondary node can reach multiple key nodes, the shortest path hop count is selected). Specific calculation formulas are provided. This graph neural network's construction method, node weight calculation method, and edge weight setting method have been tested in a local power grid line loss monitoring software and have proven accurate in identifying defects in the software, reducing false alarm rates, and ensuring the safe operation of the power grid. This is one of the important inventive points of this invention.

[0088] The graph neural networks and LSTMs used in this invention need to be trained before use, and corresponding training parameters, such as learning rate, number of iterations, loss function, etc., need to be set.

[0089] One embodiment of the present invention provides a computer storage medium storing a computer program. When the computer program on the computer storage medium is executed by a processor, the above-described method is implemented. The computer storage medium may be a hard disk, DVD, CD, flash memory, or other storage device.

[0090] For ease of description, the above apparatus is described by dividing it into various functional units. Of course, in implementing this application, the functions of each unit can be implemented in one or more software and / or hardware.

[0091] As can be seen from the above description of the embodiments, those skilled in the art can clearly understand that this application can be implemented by means of software plus necessary general-purpose hardware platforms. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the apparatus described in various embodiments or some parts of the embodiments of this application.

[0092] Finally, it should be noted that the above embodiments are for illustration only and not for limiting the technical solutions of the present invention. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the present invention without departing from the spirit and scope of the present invention. Any modifications or partial substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A method for handling defects in line loss monitoring software, characterized in that, The method includes: The monitoring steps involve processing the power grid data collected in real time by the line loss monitoring software to determine whether there are abnormal line losses and the type of such abnormal line losses. The steps determined that the abnormal line loss was caused by a defect in the line loss monitoring software. The detection step involves determining a set of candidate defects for the line loss monitoring software based on the type of abnormal line loss. The processing steps are as follows: the source code of the line loss monitoring software is converted into a syntax tree; the syntax tree is converted into an undirected graph based on the conditional statements and memory operation statements in the source code; each defect in the candidate defect set is mapped to a corresponding node in the undirected graph; it is determined whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph; if so, the defect is regarded as a defect of the line loss monitoring software, and the source code corresponding to the node mapped to the defect is modified. The operation of determining whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph is as follows: construct the graph of the graph neural network, use the nodes corresponding to the conditional statement and memory operation statement as the key nodes of the graph neural network, use the other nodes in the undirected graph as the secondary nodes of the graph neural network, and determine whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph.

2. The method according to claim 1, characterized in that, The monitoring steps are as follows: obtain historical normal line loss values ​​from the database of the line loss monitoring software; calculate the current line loss value based on the power grid data collected in real time by the line loss monitoring software; process the current line loss value and the historical normal line loss value to determine whether there is abnormal line loss; if so, determine whether the current line loss type is high line loss or low line loss.

3. The method according to claim 2, characterized in that, The determination step is as follows: based on the abnormal line loss, locate the location of the abnormal line loss; based on the location, determine the identifier of the corresponding sensor that collects power grid data; based on the sensor identifier, obtain the historical and current data of the sensor from the database of the line loss monitoring software; based on the historical and current data, determine whether the sensor is faulty; if not, check whether there is any human electricity theft at the location; if not, determine that the line loss monitoring software has a defect.

4. The method according to claim 3, characterized in that, The detection step involves determining a set of candidate defects for the line loss monitoring software based on the relationship between the constructed line loss type and the defects of the line loss monitoring software, and based on the type of abnormal line loss.

5. A defect handling device for line loss monitoring software, characterized in that, The device includes: The monitoring unit processes the power grid data collected in real time by the line loss monitoring software to determine whether there is abnormal line loss and the type of abnormal line loss. The determining unit determines that the abnormal line loss is caused by a defect in the line loss monitoring software; The detection unit determines a set of candidate defects for the line loss monitoring software based on the type of abnormal line loss. The processing unit converts the source code of the line loss monitoring software into a syntax tree, converts the syntax tree into an undirected graph based on the conditional statements and memory operation statements in the source code, maps each defect in the candidate defect set to a corresponding node in the undirected graph, determines whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph, and if so, treats the defect as a defect of the line loss monitoring software and modifies the source code corresponding to the node mapped to the defect. The operation of determining whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph is as follows: construct the graph of the graph neural network, use the nodes corresponding to the conditional statement and memory operation statement as the key nodes of the graph neural network, use the other nodes in the undirected graph as the secondary nodes of the graph neural network, and determine whether there is a logical error between the node corresponding to the defect and other nodes in the undirected graph.

6. The apparatus according to claim 5, characterized in that, The operation of the monitoring unit is as follows: obtain historical normal line loss values ​​from the database of the line loss monitoring software, calculate the current line loss value based on the power grid data collected in real time by the line loss monitoring software, process the current line loss value and the historical normal line loss value to determine whether there is abnormal line loss, and if so, determine whether the current line loss type is high line loss or low line loss.

7. The apparatus according to claim 6, characterized in that, The operation of the determining unit is as follows: based on the abnormal line loss, locate the location of the abnormal line loss; based on the location, determine the identifier of the corresponding sensor that collects power grid data; based on the sensor identifier, obtain the historical data and current data of the sensor from the database of the line loss monitoring software; based on the historical data and current data, determine whether the sensor is faulty; if not, check whether there is any human electricity theft at the location; if not, determine that the line loss monitoring software has a defect.

8. The apparatus according to claim 7, characterized in that, The operation of the detection unit is as follows: based on the relationship between the constructed line loss type and the defects of the line loss monitoring software, and based on the type of abnormal line loss, determine the candidate defect set of the line loss monitoring software.

9. A computer storage medium, characterized in that, The computer storage medium stores a computer program, which, when executed by a processor, implements the method described in any one of claims 1-4.

Citation Information

Patent Citations

  • A Software Defect Localization Method Based on Graph Convolutional Neural Networks

    CN114936158A

  • Active power distribution network line loss monitoring method, device and equipment and readable storage medium

    CN115037039A