Anti-electricity-stealing identification method and system based on Floyd-Warshall algorithm
The power network topology structure is constructed through the Floyd-Warshall algorithm and combined with the analysis of power consumption data trends, the existing anti-power theft methods are insufficiently used in scenarios with scarcity of data or high real-time requirements, and efficient and accurate power theft identification and analysis are achieved.
Patent Information
- Application Number
- CN202510398774.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-01
- Publication Date
- 2025-08-15
AI Technical Summary
The existing anti-power stealing method relies on a large amount of historical data and complex model training, resulting in poor application results in scenarios where data is scarce or real-time requirements, and there are problems such as data quality and labeling difficulties, poor model interpretability, high computing resource requirements and long training cycles.
The Floyd-Warshall algorithm is used to construct the power network topology, calculate the shortest path between nodes, and combine the trend analysis of power consumption data and machine learning prediction to identify power theft behavior and generate anti-power theft analysis report.
Quickly identify potential power theft behavior in the power network, improve the efficiency of anti-power theft work, and is suitable for large-scale or small power systems, and discover power theft behavior in real time to avoid misjudgment or misjudgment.
Smart Images

Figure CN120492793A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of anti-electricity theft, and in particular to an anti-electricity theft identification method and system based on the Floyd-Warshall algorithm. Background Art
[0002] Currently, widespread electricity theft exists in the power system, causing significant economic losses to power companies and severely disrupting fair order in the electricity market. Traditional methods for combating electricity theft rely primarily on manual inspections and simple data analysis. However, this approach is time-consuming and labor-intensive, with limited accuracy, making it difficult to meet the current power system's anti-theft needs.
[0003] In recent years, with the rapid development of information technology, technologies such as machine learning and data mining have been widely used in the field of anti-electricity theft. However, these technologies often rely on large amounts of historical data and complex model training. Their application effect is not ideal in scenarios where data is scarce or real-time requirements are high. They have the following technical problems:
[0004] 1. Data quality and labeling issues
[0005] High data quality requirements:
[0006] Machine learning models require high-quality input data. In the field of anti-electricity theft, due to the complexity and diversity of electricity usage data, data often contains missing data, anomalies, or noise. These issues can affect model training and prediction accuracy.
[0007] Data labeling is difficult:
[0008] Data labeling is a crucial step in training machine learning models. However, in the field of anti-electricity theft, due to the concealment and diversity of electricity theft, labeling theft data requires specialized knowledge and experience. This makes data labeling difficult and time-consuming, hindering the efficiency and effectiveness of model training.
[0009] 2. Model interpretability and understandability
[0010] Poor model interpretability:
[0011] Complex machine learning models, such as deep learning, are poor at explaining their parameters. In the field of electricity theft prevention, in addition to prioritizing results, explaining the learning process is also crucial to better understand the characteristics and patterns of electricity theft. However, current machine learning models often lack sufficient explainability, making it difficult for anti-theft personnel to understand and trust the model's predictions.
[0012] Lack of comprehensibility:
[0013] Machine learning models often produce complex outputs, such as decision trees and neural networks. These outputs can be difficult for non-experts to understand and interpret. In the field of electricity theft prevention, this can lead to doubts about the model's predictions, thus affecting its effectiveness.
[0014] 3. Computing resources and training cycle
[0015] High computing resource requirements:
[0016] Machine learning models, especially deep learning models, typically require significant computing resources (such as GPUs) for training and inference. In the field of anti-electricity theft, the need to process massive amounts of electricity usage data further increases the demand for computing resources. This can lead to computational resource constraints in practical applications, impacting real-time performance and efficiency.
[0017] Long training cycle:
[0018] The training process for machine learning models typically takes a long time, especially when working with large datasets. In the field of anti-electricity theft, the need to constantly update and optimize models to adapt to new theft methods and data characteristics directly impacts the model's update speed and adaptability. Long training cycles can prevent the model from responding promptly to new theft behaviors. Summary of the Invention
[0019] In view of the above existing problems, the present invention is proposed.
[0020] Therefore, the present invention provides an anti-electricity theft identification method and system based on the Floyd-Warshall algorithm to solve the problem that the existing technology mainly relies on a large amount of historical data and complex model training, resulting in poor application effect in scenarios with scarce data or high real-time requirements.
[0021] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0022] In a first aspect, the present invention provides an anti-electricity theft identification method based on the Floyd-Warshall algorithm, comprising:
[0023] Obtain information about all nodes and power lines in the power system and construct the power network topology;
[0024] Obtain electricity consumption data of each node in the power system, and perform data cleaning and standardization;
[0025] Based on the pre-processed electricity consumption data and the power network topology, the Floyd-Warshall algorithm is used to calculate the shortest paths and their lengths between all node pairs in the power network.
[0026] Based on the results of the Floyd-Warshall algorithm, path reconstruction is performed to determine the actual shortest path between each pair of nodes;
[0027] Based on the actual shortest path, combined with trend analysis of electricity consumption data and machine learning prediction, electricity theft behavior is identified and confirmed, and an anti-electricity theft analysis report is generated.
[0028] As a preferred solution of the anti-electricity theft identification method based on the Floyd-Warshall algorithm described in the present invention, wherein:
[0029] The construction of the power network topology structure includes the following steps:
[0030] The nodes and their connection relationships are represented by the adjacency matrix, and the elements in the matrix represent the connection weights between the nodes;
[0031] Initialize the adjacency matrix;
[0032] Initialize the path matrix;
[0033] The initialization of the adjacency matrix comprises:
[0034] Define a two-dimensional array dist. For non-existent connections, dist[i][j] is set to infinity, where dist[i][j] represents the direct connection weight from node i to node j.
[0035] As a preferred solution of the anti-electricity theft identification method based on the Floyd-Warshall algorithm described in the present invention, wherein:
[0036] The initialization path matrix includes:
[0037] Define a matrix next of the same size as the adjacency matrix;
[0038] If dist[i][j] is not infinite, next[i][j] is set to i, indicating a direct connection;
[0039] If dist[i][j] is infinite, then next[i][j] is set to a special value, indicating that there is no path;
[0040] Among them, next[i][j] represents the previous node of j on the shortest path from node i to node j.
[0041] As a preferred solution of the anti-electricity theft identification method based on the Floyd-Warshall algorithm described in the present invention, wherein:
[0042] The Floyd-Warshall algorithm includes:
[0043] Calculate the shortest paths and their lengths between all pairs of nodes through three nested loops;
[0044] The three nested loops include an outer loop, a middle loop, and an inner loop;
[0045] The outer loop includes traversing all nodes k as intermediate vertices;
[0046] The middle loop includes traversing all nodes i as starting points;
[0047] The inner loop includes traversing all nodes j as end points and determining whether there is a shorter path through the intermediate vertex k in each loop check.
[0048] As a preferred solution of the anti - electricity - stealing identification method based on the Floyd - Warshall algorithm according to the present invention, wherein:
[0049] The determination of whether there is a shorter path through the intermediate vertex k in each loop check includes:[[ID=Z0]]
[0050] If dist[i][k]+dist[k][j]<dist[i][j], then update dist[i][j] and next[i][j].
[0051] As a preferred solution of the anti - electricity - stealing identification method based on the Floyd - Warshall algorithm according to the present invention, wherein:
[0052] The path reconstruction includes:
[0053] Reconstruct the shortest path between any two points through the shortest path matrix dist and the path matrix next calculated by the Floyd - Warshall algorithm;
[0054] For any pair of nodes i and j, starting from j, backtrack through the next matrix until returning to the starting point i, and record all the nodes passed through to obtain the shortest path from i to j.
[0055] As a preferred solution of the anti - electricity - stealing identification method based on the Floyd - Warshall algorithm according to the present invention, wherein:
[0056] The combination of trend analysis of electricity consumption data and machine learning prediction to identify and confirm electricity - stealing behavior includes:
[0057] Combine the specific shortest path information obtained by path reconstruction with the electricity consumption data, and analyze whether there are significant differences in the electricity consumption data on the path;
[0058] Use anomaly detection and classification algorithms to analyze electricity usage data and verify whether anomalies in path analysis results are related to electricity theft;
[0059] Combined with path information and electricity usage data characteristics, the specific location and scale of potential electricity theft can be confirmed and an anti-electricity theft analysis report can be generated.
[0060] In a second aspect, the present invention provides an anti-electricity theft identification system based on the Floyd-Warshall algorithm, comprising:
[0061] The power network topology construction module is used to obtain the power line information of all nodes and nodes in the power system and build the power network topology structure;
[0062] The data preprocessing module is used to obtain the electricity consumption data of each node in the power system and perform data cleaning and standardization;
[0063] The shortest path calculation module is used to calculate the shortest path and its length between all node pairs in the power network based on the pre-processed power consumption data and the power network topology using the Floyd-Warshall algorithm;
[0064] The path reconstruction module is used to reconstruct the path based on the results of the Floyd-Warshall algorithm and determine the actual shortest path between each pair of nodes;
[0065] The electricity theft behavior analysis module is used to identify and confirm electricity theft behaviors based on the actual shortest path, combined with trend analysis of electricity usage data and machine learning prediction, and generate anti-electricity theft analysis reports.
[0066] In a third aspect, the present invention provides a computing device, comprising:
[0067] Memory, used to store programs;
[0068] The processor is configured to execute the computer executable instructions, which, when executed by the processor, implement the steps of the anti-electricity theft identification method based on the Floyd-Warshall algorithm.
[0069] In a fourth aspect, the present invention provides a computer-readable storage medium, comprising: when the program is executed by a processor, the steps of implementing the anti-electricity theft identification method based on the Floyd-Warshall algorithm are implemented.
[0070] The beneficial effects of the present invention are as follows: By utilizing the Floyd-Warshall algorithm, the present invention can quickly identify potential electricity theft in power networks, significantly improving the efficiency of anti-theft efforts. Compared to traditional anti-theft methods, the present invention utilizes power network topology and electricity usage data for comprehensive analysis, enabling more accurate identification of electricity theft. This approach is applicable not only to large-scale power systems but also to small or medium-sized power networks. Furthermore, the algorithm is capable of processing complex power network topologies and variable electricity usage data. By collecting and analyzing electricity usage data in real time, the present invention can promptly detect and address electricity theft, avoiding the misjudgments or omissions that occur with traditional methods due to data lags. BRIEF DESCRIPTION OF THE DRAWINGS
[0071] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for describing the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. Those skilled in the art can also derive other drawings based on these drawings without inventive effort. Among them:
[0072] Figure 1 A schematic diagram of the basic flow of an anti-electricity theft identification method based on the Floyd-Warshall algorithm provided in one embodiment of the present invention. DETAILED DESCRIPTION
[0073] To make the above-mentioned objects, features, and advantages of the present invention more clearly understood, the following detailed description of the specific embodiments of the present invention is given in conjunction with the accompanying drawings. It is obvious that the described embodiments are only part of the embodiments of the present invention, not all of them. Based on the embodiments of the present invention, all other embodiments obtained by ordinary persons in this field without creative work should fall within the scope of protection of the present invention.
[0074] Example 1
[0075] Reference Figure 1 , as one embodiment of the present invention, provides an anti-electricity theft identification method based on the Floyd-Warshall algorithm, comprising:
[0076] S1: Obtain information about all nodes and power lines in the power system and construct the power network topology;
[0077] In an embodiment of the present application, the power network is composed of numerous nodes (such as transformer substations, distribution rooms, user terminals, etc.) and the power lines connecting these nodes, forming a complex network structure. In order to quantify this structure and analyze it, according to the actual layout of the power system, an adjacency matrix reflecting the connection relationship between nodes is constructed. The adjacency matrix is a two-dimensional array whose element values represent the direct connection state or weight (such as the length, resistance, etc. of the power line) between nodes. During the construction process, it is necessary to ensure that all actual connection relationships are accurately recorded. At the same time, for non-existent connections, their corresponding values in the matrix are set to infinity or specific marks to indicate that they are unreachable.
[0078] S2: Obtain electricity consumption data of each node in the power system and perform data cleaning and standardization;
[0079] In the embodiments of this application, electricity usage data is an important basis for identifying electricity theft. By deploying modern data collection methods such as smart meters and remote meter reading systems, key electricity parameters such as current, voltage, power, and power factor at each node can be obtained in real time or regularly. This data must first undergo preprocessing, including data cleaning (removing outliers and filling missing values) and standardization (unifying dimensions) to ensure the accuracy and effectiveness of subsequent analysis.
[0080] S3: Based on the pre-processed electricity consumption data and the power network topology, the Floyd-Warshall algorithm is used to calculate the shortest paths and their lengths between all node pairs in the power network.
[0081] In an embodiment of the present application, the Floyd-Warshall algorithm is a classic algorithm for finding the shortest paths between all pairs of vertices in a weighted graph. In a power network, each node is considered a vertex in the graph, and the power lines between the nodes are considered weighted edges. The weights can be set to line length, resistance, loss, etc. according to actual conditions. By inputting pre-processed electricity consumption data and the adjacency matrix of the power network topology, the Floyd-Warshall algorithm can calculate the shortest path and its length (or cost) between all pairs of nodes.
[0082] The core of the algorithm lies in three nested loops, which iterate through all nodes as intermediate vertices, starting points, and end points. In each loop, the algorithm checks whether a shorter path can be found through the current intermediate vertex. If so, the shortest path length is updated. This process continues until all vertices have been considered, resulting in a complete shortest path matrix that records the shortest path between any two points. The following are the detailed steps and explanation of the algorithm's implementation:
[0083] 3.1 Data Preparation
[0084] Power network topology: Obtain a structure that accurately describes the nodes and the connections between them. This is typically represented by an adjacency matrix, where the rows and columns represent nodes and the elements represent the weights of the connections between nodes (such as resistance, line length, or loss). For non-existent connections, their weights are set to infinity or a specific flag to indicate unreachability.
[0085] Power consumption data: Collect power consumption data of each node, including current, voltage, power, power factor, etc. This data will be used for subsequent analysis and comparison.
[0086] 3.2 Initialization
[0087] Adjacency matrix: According to the topology of the power network, initialize an adjacency matrix dist, where dist[i][j] represents the direct connection weight from node i to node j. For non-existent connections, dist[i][j] should be set to infinity or a specific mark.
[0088] Path matrix: To record path information, a matrix next of the same size as the adjacency matrix is required, where next[i][j] represents the previous node of j on the shortest path from node i to node j. Initially, if dist[i][j] is not infinite, next[i][j] should be set to i, indicating a direct connection; otherwise, next[i][j] can be set to a special value to indicate no path.
[0089] It should be noted that in the Floyd-Warshall algorithm, the semantics of next[i][j] is to record the previous node of j (ie, the "predecessor node") on the shortest path from node i to node j.
[0090] It should be noted that when i and j are directly connected (dist[i][j] is not infinite), the path is i→j, so the previous node to reach j is i.
[0091] 3.3 Floyd-Warshall Algorithm
[0092] The core of the Floyd-Warshall algorithm is to update the shortest path and path information by traversing all nodes as intermediate vertices, starting points, and end points through three nested loops.
[0093] Outer loop: traverse all nodes k as intermediate vertices.
[0094] Middle-level loop: traverse all nodes i as the starting point.
[0095] Inner loop: traverse all nodes j as the end point.
[0096] In each loop, check whether a shorter path from the starting point i to the ending point j can be found through the intermediate vertex k. If so, update dist[i][j] and next[i][j].
[0097] The update rules are as follows:
[0098] If dist[i][k] + dist[k][j] < dist[i][j], then update dist[i][j] = dist[i][k] + dist[k][j], indicating that a shorter path has been found.
[0099] At the same time, update next[i][j] = next[k][j].
[0100] It should be noted that when the path is updated to i → k → j, the shortest path consists of the path from i to k and the path from k to j. At this time, the predecessor node of j should be the predecessor node in the path from k to j (i.e., next[k][j]).
[0101] S4: Based on the results of the Floyd-Warshall algorithm, perform path reconstruction to clarify the actual shortest path between each pair of nodes;
[0102] In the embodiments of the present application, the shortest path matrix dist and the path matrix next calculated by the Floyd-Warshall algorithm can reconstruct the shortest path between any two points. For any pair of nodes i and j, starting from j, backtrack through the next matrix until returning to the starting point i, and record all the nodes passed through, that is, obtain the shortest path from i to j.
[0103] S5: Based on the actual shortest path, combined with the trend analysis of electricity consumption data and machine learning prediction, identify and confirm electricity theft behavior, and generate an anti-electricity-theft analysis report.
[0104] In the embodiments of the present application, after obtaining the shortest path between all node pairs, start to identify electricity theft behavior. This usually involves the following steps:
[0105] 5.1 Comparison of electricity consumption data
[0106] Before identifying electricity theft behavior, it is first necessary to collect the electricity consumption data of each node in the power grid. These data may include real-time measurement data such as current, voltage, power factor, as well as historical electricity consumption records and load curves. Through the Floyd-Warshall algorithm, calculate the shortest path between each node in the power grid, so as to understand the path and distribution of power flow.
[0107] The power consumption data of each node is correlated with the shortest path information and the power consumption data along different paths is compared. If the power consumption data on a certain path is significantly different from that on other paths, and this difference cannot be explained by normal operation or equipment failure, then the node on that path may be stealing electricity.
[0108] 5.2 Anomaly Detection
[0109] Based on the comparison of electricity usage data, anomaly detection algorithms are further used to identify potential electricity theft. Anomaly detection algorithms can automatically detect outliers or unusual patterns in the data, which are often associated with electricity theft.
[0110] In the power grid, electricity theft can cause abnormal fluctuations in node power usage data, such as sudden increases or decreases in power consumption and abnormal power factors. The Floyd-Warshall algorithm calculates the shortest paths between nodes and aggregates and analyzes the power usage data along these paths. This data is then processed using an anomaly detection algorithm to identify potential electricity theft.
[0111] 5.3 Path Analysis
[0112] Once potential electricity theft is identified, further analysis of the theft path is required. Using the Floyd-Warshall algorithm, the shortest paths between nodes in the power grid are calculated to determine the paths along which the theft may have occurred.
[0113] 5.3.1 Construction of the Graph Model
[0114] The power grid can be viewed as a graph, where nodes represent electricity meters or users, and edges represent connections between users. These connections can be based on geographic proximity, similarity in electricity usage, connectivity of power lines, or other factors. To simplify the problem, one or several key connection factors are often selected to construct a graph model.
[0115] When building a graph model, each edge also needs to be assigned a weight, which can represent the strength of the association or similarity between users. The choice of weight depends on the characteristics of electricity theft behavior you want to analyze. For example, if you believe that electricity theft is more likely to spread between geographically close users, then the edge weight can be set to the inverse of the geographical distance between users. If you believe that electricity theft is more likely to spread between users with similar electricity usage behaviors, then the edge weight can be set to the negative value of the difference in electricity usage between users.
[0116] 5.3.2 Application of the Floyd-Warshall Algorithm
[0117] After building the graph model, we can apply the Floyd-Warshall algorithm to calculate the shortest paths between all users. The basic idea of the Floyd-Warshall algorithm is to gradually update the shortest path lengths between node pairs through dynamic programming until the shortest paths between all node pairs are found.
[0118] Specifically, the algorithm maintains a two-dimensional array dist, where dist[i][j] represents the length of the shortest path from node i to node j. Initially, dist[i][j] is set to the length of the direct path from node i to node j (if a direct path exists) or infinity (if no direct path exists). The algorithm then traverses all nodes as intermediate nodes and, for each pair of nodes (i, j), checks whether there is a shorter path through the intermediate node k. If such a path exists, dist[i][j] is updated to the shorter value.
[0119] In the case of electricity theft identification, the results of the Floyd-Warshall algorithm are interpreted as the "association distance" between users. The shorter the association distance, the stronger the association between users, and the greater the possibility that electricity theft will spread among these users.
[0120] 5.3.3 Path analysis method
[0121] After obtaining the shortest paths between all users, path analysis can be performed. Path analysis methods vary, depending on the characteristics and patterns of electricity theft that one wishes to identify. The results of the Floyd-Warshall algorithm are used to construct a network of connections between users, and community discovery or cluster analysis is performed on this network. Community discovery or cluster analysis can help identify groups of users with similar electricity usage behaviors or connection characteristics, allowing further analysis to determine whether electricity theft is occurring within these groups.
[0122] Furthermore, other data analysis methods or machine learning algorithms can be combined to validate and supplement the results of path analysis. For example, clustering algorithms can be used to group users, and classification algorithms can be used to predict which users are likely to engage in electricity theft. These algorithms can be trained and tested based on information such as user electricity usage data, geographic location, and historical electricity theft records.
[0123] 5.4 Confirmation of electricity theft
[0124] Based on the path analysis, it is necessary to further confirm the existence of electricity theft. This can be achieved through the following methods:
[0125] Dispatch professionals to the site for on-site investigations to check the operating status of power equipment and power usage. If the on-site investigation reveals suspicious power usage or equipment failures, further analysis of power usage data and grid topology is required to determine whether there is power theft.
[0126] Using data analysis tools to conduct in-depth mining and analysis of electricity usage data. By comparing electricity usage data on different paths, analyzing trends and patterns in electricity usage data, and using machine learning algorithms for prediction and classification, the existence of electricity theft can be further confirmed.
[0127] Experts from the power industry are invited to evaluate and assess electricity usage data and on-site survey results. Based on their experience and knowledge, experts can identify and confirm electricity theft and provide appropriate treatment recommendations.
[0128] 5.5 Result Output
[0129] The identified electricity theft behavior will be output in the form of a report, including the specific location, time, scale and other information of the theft, as well as recommended anti-theft measures.
[0130] It should be noted that the present invention can efficiently calculate the shortest path between all pairs of nodes in the power network, and can also accurately identify potential electricity theft behaviors based on electricity consumption data and path information, providing strong technical support for the anti-electricity theft work in the power industry. Based on the electricity consumption data of users in the power grid, a user-user association graph is constructed, in which nodes represent users and edges represent the electricity consumption data association between users. The power grid data is updated in real time to ensure the accuracy and timeliness of the association graph. The Floyd-Warshall algorithm is used to calculate the shortest path between all users in the association graph to obtain the electricity consumption data transmission relationship between users. A threshold for identifying electricity theft behaviors is set. When the electricity consumption data transmission relationship between a user and other users is abnormal (such as a significant shortening of the path length or an abnormal increase in the amount of data transferred), it is regarded as a potential electricity theft behavior. According to the real-time changes in the power grid data, the threshold for identifying electricity theft behaviors is adaptively adjusted to ensure the accuracy and stability of the algorithm.
[0131] This embodiment further provides an anti-electricity theft identification system based on the Floyd-Warshall algorithm, including:
[0132] The power network topology construction module is used to obtain the power line information of all nodes and nodes in the power system and build the power network topology structure;
[0133] The data preprocessing module is used to obtain the electricity consumption data of each node in the power system and perform data cleaning and standardization;
[0134] The shortest path calculation module is used to calculate the shortest path and its length between all node pairs in the power network based on the pre-processed power consumption data and the power network topology using the Floyd-Warshall algorithm;
[0135] The path reconstruction module is used to reconstruct the path based on the results of the Floyd-Warshall algorithm and determine the actual shortest path between each pair of nodes;
[0136] The electricity theft behavior analysis module is used to identify and confirm electricity theft behaviors based on the actual shortest path, combined with trend analysis of electricity usage data and machine learning prediction, and generate anti-electricity theft analysis reports.
[0137] Furthermore, it also includes:
[0138] Memory, used to store programs;
[0139] A processor is used to load the program to execute the anti-electricity theft identification method based on the Floyd-Warshall algorithm.
[0140] This embodiment further provides a computer-readable storage medium storing a program. When the program is executed by a processor, the anti-electricity theft identification method based on the Floyd-Warshall algorithm is implemented.
[0141] The storage medium proposed in this embodiment and the anti-electricity theft identification method based on the Floyd-Warshall algorithm proposed in the above embodiment belong to the same inventive concept. For technical details not fully described in this embodiment, please refer to the above embodiment, and this embodiment has the same beneficial effects as the above embodiment.
[0142] Through the above description of the implementation methods, those skilled in the art can clearly understand that the present invention can be implemented with the help of software and necessary general-purpose hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, which can be stored in a computer-readable storage medium, such as a computer's floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods of various embodiments of the present invention.
[0143] Example 2
[0144] This is an embodiment of the present invention, which provides an anti-electricity theft identification system based on the Floyd-Warshall algorithm, including a power network topology construction module, a data preprocessing module, a shortest path calculation module, a path reconstruction module, and an electricity theft behavior analysis module;
[0145] In the embodiment of the present application, the power network topology construction module includes obtaining information about all nodes and power lines of the nodes in the power system and constructing the power network topology structure;
[0146] In the embodiment of the present application, the data preprocessing module includes obtaining the power consumption data of each node in the power system and performing data cleaning and standardization processing;
[0147] In the embodiment of the present application, the shortest path calculation module includes calculating the shortest paths and their lengths between all pairs of nodes in the power network using the Floyd-Warshall algorithm based on the pre-processed power consumption data and the power network topology;
[0148] In the embodiment of the present application, the path reconstruction module includes performing path reconstruction based on the results of the Floyd-Warshall algorithm to clarify the actual shortest path between each pair of nodes;
[0149] In an embodiment of the present application, the electricity theft behavior analysis module includes identifying and confirming electricity theft behavior based on the actual shortest path, combined with trend analysis and machine learning prediction of electricity usage data, and generating an anti-electricity theft analysis report.
[0150] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit the present invention. Although the present invention has been described in detail with reference to the preferred embodiments, those skilled in the art should understand that the technical solutions of the present invention may be modified or replaced by equivalents without departing from the spirit and scope of the technical solutions of the present invention, which should all be included in the scope of the claims of the present invention.
Claims
1. An anti-electricity theft identification method based on the Floyd-Warshall algorithm, characterized in that: Including: Obtain the information of all nodes and power lines of the power system, and construct the power network topology structure; Obtain the power consumption data of each node of the power system, and perform data cleaning and standardization processing; Based on the preprocessed power consumption data and the power network topology structure, use the Floyd-Warshall algorithm to calculate the shortest paths and their lengths between all node pairs in the power network; Based on the results of the Floyd-Warshall algorithm, perform path reconstruction to clarify the actual shortest paths between each pair of nodes; Based on the actual shortest paths, combined with the trend analysis of power consumption data and machine learning prediction, identify and confirm electricity theft behavior, and generate an anti-electricity theft analysis report.
2. The anti-electricity theft identification method based on the Floyd-Warshall algorithm according to claim 1, characterized in that: The construction of the power network topology structure includes the following steps: Represent nodes and their connection relationships through an adjacency matrix, and the elements in the matrix represent the connection weights between nodes; Initialize the adjacency matrix; Initialize the path matrix; The initialization of the adjacency matrix includes: Define a two-dimensional array dist. For non-existent connections, set dist[i][j] to infinity, where dist[i][j] represents the direct connection weight from node i to node j.
3. The anti-electricity theft identification method based on the Floyd-Warshall algorithm according to claim 1 or 2, characterized in that: The initialization of the path matrix includes: Define a matrix next of the same size as the adjacency matrix; If dist[i][j] is not infinity, set next[i][j] to i, indicating a direct connection; If dist[i][j] is infinity, set next[i][j] to a special value, indicating no path; Among them, next[i][j] represents the previous node of j on the shortest path from node i to node j.
4. The anti-electricity theft identification method based on the Floyd-Warshall algorithm according to claim 3, characterized in that: The Floyd-Warshall algorithm includes: Calculate the shortest paths and their lengths between all node pairs through three nested loops; The three nested loops include an outer loop, a middle loop, and an inner loop; The outer loop includes traversing all nodes k as intermediate vertices; The middle loop includes traversing all nodes i as starting points; The inner loop includes traversing all nodes j as end points, and judging whether there is a shorter path passing through the intermediate vertex k in each loop check.
5. The anti-electricity theft identification method based on the Floyd-Warshall algorithm according to claim 4, characterized in that: The judgment of whether there is a shorter path passing through the intermediate vertex k in each loop check includes: If dist[i][k]+dist[k][j]<dist[i][j], update dist[i][j] and next[i][j].
6. The anti-electricity theft identification method based on the Floyd-Warshall algorithm according to claim 5, characterized in that: The path reconstruction includes: Reconstruct the shortest paths between any two points through the shortest path matrix dist and the path matrix next calculated by the Floyd-Warshall algorithm; For any pair of nodes i and j, starting from j, backtrack through the next matrix until returning to the starting point i, and record all the nodes passed through to obtain the shortest path from i to j.
7. The anti-electricity theft identification method based on the Floyd-Warshall algorithm according to claim 6, characterized in that: The combination of trend analysis of power consumption data and machine learning prediction to identify and confirm electricity theft behavior includes: Combine the specific shortest path information obtained from path reconstruction with the power consumption data, and analyze whether there are significant differences in the power consumption data on the path; Use anomaly detection and classification algorithms to analyze electricity usage data and verify whether anomalies in path analysis results are related to electricity theft; Combined with path information and electricity usage data characteristics, the specific location and scale of potential electricity theft can be confirmed and an anti-electricity theft analysis report can be generated.
8. A system based on the anti-electricity theft identification method based on the Floyd-Warshall algorithm according to claim 1, characterized in that: The power network topology construction module is used to obtain the power line information of all nodes and nodes in the power system and build the power network topology structure; The data preprocessing module is used to obtain the electricity consumption data of each node in the power system and perform data cleaning and standardization; The shortest path calculation module is used to calculate the shortest path and its length between all node pairs in the power network based on the pre-processed power consumption data and the power network topology using the Floyd-Warshall algorithm; The path reconstruction module is used to reconstruct the path based on the results of the Floyd-Warshall algorithm and determine the actual shortest path between each pair of nodes; The electricity theft behavior analysis module is used to identify and confirm electricity theft behaviors based on the actual shortest path, combined with trend analysis of electricity usage data and machine learning prediction, and generate anti-electricity theft analysis reports.
9. A computing device, characterized in that include: Memory, used to store programs; A processor is configured to load the program to execute the steps of the anti-electricity theft identification method based on the Floyd-Warshall algorithm according to any one of claims 1 to 7.
10. A computer-readable storage medium storing a program, characterized in that: When the program is executed by a processor, the steps of the anti-electricity theft identification method based on the Floyd-Warshall algorithm according to any one of claims 1 to 7 are implemented.