A method, device, medium, and product for detecting electricity theft based on quantum particle swarm optimization algorithm.
By optimizing the real power distribution using the quantum particle swarm optimization algorithm and combining current amplitude and power factor angle as feature quantities, the problem of real-time performance and accuracy of electricity theft detection in power distribution networks of small and medium-sized industrial areas is solved, and efficient electricity theft identification is achieved.
Patent Information
- Application Number
- CN202611410529.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-11
- Publication Date
- 2026-11-17
AI Technical Summary
The 10kV distribution network in small and medium-sized industrial areas lacks a multi-node redundancy verification mechanism. Traditional detection methods are inefficient, costly, and have high false alarm and false alarm rates. Data-driven models lack constraints from the physical laws of the power system, and conventional particle swarm optimization algorithms have slow convergence speed and insufficient accuracy, making it difficult to meet the real-time and accuracy requirements of electricity theft detection.
A method for detecting electricity theft based on quantum particle swarm optimization (QPSO) algorithm is adopted. By acquiring the power data reported by users in the distribution network and the measured electrical quantity data of monitoring nodes, power flow calculation and global total error determination are performed. The QPSO algorithm is used to iteratively optimize the real power distribution, and the current amplitude and power factor angle are combined as the characteristic quantities for electricity theft detection to achieve real-time and accurate electricity theft identification.
It improves the real-time performance and accuracy of electricity theft detection, reduces engineering deployment costs, is suitable for power distribution networks in small and medium-sized industrial areas, and can quickly identify suspected electricity theft users.
Smart Images

Figure CN123116753A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of power system security operation and maintenance technology, and in particular to a method, device, medium and product for detecting electricity theft based on quantum particle swarm optimization algorithm. Background Technology
[0002] Small and medium-sized industrial zones are an important part of China's manufacturing system, and the stability and economy of their power supply are directly related to the high-quality development of the regional economy. 10kV distribution networks, with their advantages of low construction costs, clear topology, and simple operation and maintenance, have become the mainstream form of power supply for dedicated transformer users in small and medium-sized industrial zones. However, the inherent characteristic of this type of system—single-source, unidirectional power supply—leads to a lack of multi-node redundancy verification mechanisms, providing opportunities for various forms of electricity theft.
[0003] Currently, detection technologies for dedicated transformer users in small and medium-sized industrial zones still have significant shortcomings. Traditional manual inspection methods rely on the on-site experience of maintenance personnel and door-to-door checks, which have inherent drawbacks such as low efficiency, high cost, and detection lag, making them unsuitable for the large-scale, decentralized power management needs of industrial zones. Detection methods based on fixed thresholds identify electricity theft by setting abnormal thresholds for electrical indicators such as line loss rate and power factor. However, the production power consumption of dedicated transformer users is significantly volatile and random due to factors such as order volume and production shifts, making electricity theft characteristics easily masked by normal load fluctuations, resulting in high false alarm and false negative rates for this method.
[0004] In recent years, data-driven methods, represented by machine learning, have provided new technical approaches for electricity theft detection. However, purely data-driven models lack the constraints of the physical laws governing power systems, resulting in poor interpretability of their predictions and making them unsuitable as effective evidence for power law enforcement. Meanwhile, electricity theft detection methods based on state estimation and final algorithms identify anomalous nodes by solving the residuals of power flow equations. However, conventional particle swarm optimization algorithms suffer from problems such as being prone to getting trapped in local optima, slow convergence speed, and insufficient solution accuracy. When dealing with the problem of electricity theft detection in distribution networks with multiple nodes and multiple operating conditions, they struggle to meet the dual requirements of real-time performance and accuracy.
[0005] Therefore, in the power distribution network of small and medium-sized industrial areas, how to achieve both real-time and accurate electricity theft detection has become a technical problem that urgently needs to be solved in the field of power system safety operation and maintenance. Summary of the Invention
[0006] The purpose of this application is to provide a method, device, medium, and product for detecting electricity theft based on quantum particle swarm optimization, so as to simultaneously improve the real-time performance and accuracy of electricity theft detection in power distribution networks.
[0007] To achieve the above objectives, this application provides the following solution.
[0008] In a first aspect, this application provides a method for detecting electricity theft based on the quantum particle swarm optimization algorithm, comprising: The system acquires the reported power data from each user in the distribution network and the measured electrical quantity data from each monitoring node; the reported power data includes reported active power and reported reactive power, and the measured electrical quantity data includes measured current amplitude and measured power factor angle. Power flow calculations are performed based on the power data reported by each user to obtain the theoretical electrical quantity data of each monitoring node under the reported power data; the theoretical electrical quantity data includes the theoretical current amplitude and the theoretical power factor angle; Based on the measured electrical quantity data of all monitoring nodes and the theoretical electrical quantity data under the reported power data, the global total error is determined; When the global total error exceeds a preset threshold, the actual power data of each user is used as the optimization variable, and the goal is to minimize the residual between the theoretical electrical quantity data and the measured electrical quantity data of each monitoring node. The quantum particle swarm optimization algorithm is used for iterative optimization to obtain the final actual power distribution. The actual power distribution includes the actual power data of each user, which includes actual active power and actual reactive power. In the quantum particle swarm optimization algorithm: multiple sets of initial actual power distributions satisfying the physical feasible region constraints are randomly generated, and the actual active power or actual reactive power of each user in each set of initial actual power distributions is mapped to two initial probability amplitudes and an initial self-phase angle of the corresponding qubit, thereby obtaining the initial population. The population includes... It includes multiple particles, each particle corresponds to a set of real power distributions, and each particle includes multiple qubits. The quantum position of a qubit corresponds to the real active power or real reactive power of a user. There are two probability amplitudes, including cosine probability amplitude and sine probability amplitude. There are two search positions, including cosine power search position and sine power search position. During the iteration process, each qubit of each particle updates its own phase angle through a quantum rotation gate. The updated phase angle recalculates the two probability amplitudes and maps them to two search positions. The real power data corresponding to the two search positions are substituted into the power flow calculation to obtain the corresponding theoretical electrical quantity data. The weighted fitness function value corresponding to the two search positions is calculated respectively. The search position with the smaller weighted fitness function value is taken as the quantum position of the qubit. Based on the final actual power distribution and the power data reported by each user, users suspected of electricity theft in the distribution network were identified.
[0009] In one embodiment, the power flow calculation methods include the forward-backward substitution method and the Newton-Raphson method.
[0010] In one implementation, the global total error is determined based on the measured electrical quantity data of all monitoring nodes and the theoretical electrical quantity data under the reported power data, including: Based on the measured current amplitude and the theoretical current amplitude under the reported power data, the residual current amplitude of each monitoring node under the reported power data is determined. Based on the measured power factor angle and the theoretical power factor angle of each monitoring node, the power factor angle residual of each monitoring node under the reported power data is determined. The global total error is determined based on the residual current amplitude and power factor angle of all monitoring nodes under the reported power data.
[0011] In one implementation, using the actual power data of each user as the optimization variable, and aiming to minimize the residual between the theoretical electrical quantity data and the measured electrical quantity data of each monitoring node, an iterative optimization using the quantum particle swarm optimization algorithm is employed to obtain the final actual power distribution, including: Under the constraint of the physical feasible region, multiple initial real power distributions are randomly generated, and the real active power or real reactive power of each user in each initial real power distribution is mapped to the two initial probability amplitudes and the initial self-phase angle of the corresponding qubit, thereby obtaining the initial population. Based on the initial self-phase angle of each qubit in each particle in the initial population, the quantum rotation gate is used to iterate and update the self-phase angle, two probability amplitudes and two search positions of each qubit in each particle in the initial population in multiple rounds to obtain the final self-phase angle, two final probability amplitudes and two final search positions of the corresponding qubit, thus forming the final population. Determine any particle in the final population as the target particle, and any search position as the target position; Determine the final true power data of the user corresponding to each qubit in the target particle at the final target position; Power flow calculations are performed based on the final actual power data of the users corresponding to all qubits in the target particle at the final target position, to obtain the final theoretical electrical quantity data of each monitoring node at the final target position under the target particle. Based on the measured electrical quantity data of all monitoring nodes and the final theoretical electrical quantity data of all monitoring nodes at the final target position under the target particle, the weighted fitness function value of the target particle at the final target position is determined. The minimum value of the weighted fitness function of the target particle at the two final search positions is determined as the weighted fitness function value of the target particle. The true power distribution corresponding to the particle with the smallest weighted fitness function value in the final population is determined as the final true power distribution.
[0012] In one embodiment, the physical feasible domain constraints include the actual active power constraints and the actual reactive power constraints for each user; The upper and lower limits of the actual active power constraint and the actual reactive power constraint for each user are determined based on the active power reported by the corresponding user.
[0013] In one embodiment, during the process of iteratively updating the phase angle, two probability amplitudes, and two search positions of each qubit in each particle of the initial population using a quantum rotation gate across multiple rounds based on the initial self-phase angle of each qubit in the initial population, the update process in any current round includes: Determine any particle in the population as the current particle, and determine any qubit in the current particle as the current qubit; Obtain the current qubit's own phase angle, individual optimal phase angle, global optimal phase angle, and phase angle increment in the previous round; when the current round is the initial round, the current qubit's own phase angle and individual optimal phase angle in the previous round are both the initial phase angle of the current qubit, the global optimal phase angle of the current qubit in the previous round is the initial phase angle of the qubit corresponding to the particle with the smallest weighted fitness function value in the initial population, and the phase angle increment of the current qubit in the previous round is 0; Based on the current qubit's own phase angle, individual optimal phase angle, and global optimal phase angle in the previous round, determine the minimum individual phase difference and minimum global phase difference of the current qubit in the previous round; Based on the current qubit's own phase angle increment, minimum individual phase difference, and minimum global phase difference in the previous round, determine the current qubit's own phase angle increment in the current round; Based on the phase angle of the current qubit in the previous round and the increment of the phase angle of the current qubit in the current round, determine the phase angle of the current qubit in the current round; Based on the physical feasible region constraint and the phase angle of the current qubit in the current round, the two probability amplitudes and two search positions of the current qubit in the current round are determined, and the population in the current round is obtained. Set any search location as the current location; Determine the actual power data of each qubit in the current particle at the current position in the current round, corresponding to the user in the current round; Power flow calculations are performed based on the actual power data of all users corresponding to all qubits in the current particle at the current position in the current round, to obtain the theoretical electrical quantity data of each monitoring node at the current position in the current round of the current particle; Based on the measured electrical quantity data of all monitoring nodes and the theoretical electrical quantity data of all monitoring nodes at the current position of the current particle in the current round, the weighted fitness function value of the current particle at the current position of the current round is determined. The search position corresponding to the minimum value of the weighted fitness function is determined as the particle level position of each quantum bit in the current particle in the current round. The particle-level position of each qubit in the current particle in the current round is determined as the quantum position of the corresponding qubit in the current round; Determine whether the stopping condition has been met; the stopping condition is that the maximum number of iterations has been reached or the minimum value of the weighted fitness function of all particles at the two search positions in the current round is less than the preset fitness. If so, the phase angle, two probability amplitudes, and two search positions of each qubit in each individual in the current round are determined as the final phase angle, two final probability amplitudes, and two final search positions of the corresponding qubit, thus forming the final population. If not, then based on the weighted fitness function value of each particle in all rounds, the phase angle of each qubit in each particle in the current round, and the individual optimal phase angle of each qubit in each particle in the previous round, determine the individual optimal phase angle of each qubit in each particle in the current round. Based on the weighted fitness function value of all particles in all rounds, the individual optimal phase angle of each qubit in each particle in the current round, and the global optimal phase angle of each qubit in each particle in the previous round, determine the global optimal phase angle of each qubit in each particle in the current round. Then update the phase angle, individual optimal phase angle, and global optimal phase angle of each qubit in the previous round to the phase angle, individual optimal phase angle, and global optimal phase angle of each qubit in the current round, respectively. Return "Based on the phase angle, individual optimal phase angle, and global optimal phase angle of the current qubit in the previous round, determine the minimum individual phase difference and minimum global phase difference of the current qubit in the previous round."
[0014] In one implementation, based on the physical feasible region constraint and the phase angle of the current qubit in the current round, two probability amplitudes and two search positions of the current qubit in the current round are determined, including: Calculate the two probability amplitudes of the current qubit in the current round based on its own phase angle in the current round; Based on the physical feasible region constraint and the phase angle and two probability amplitudes of the current qubit in the current round, calculate the two search positions of the current qubit in the current round.
[0015] Secondly, this application provides a computer device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the above-described method for detecting electricity theft based on the quantum particle swarm optimization algorithm.
[0016] Thirdly, this application provides a computer-readable storage medium storing a computer program thereon, which, when executed by a processor, implements the above-described method for detecting electricity theft based on the quantum particle swarm algorithm.
[0017] Fourthly, this application provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method for detecting electricity theft based on the quantum particle swarm algorithm.
[0018] According to the specific embodiments provided in this application, the following technical effects are disclosed: This application discloses a method, device, medium, and product for electricity theft detection based on quantum particle swarm optimization (QPSO). It acquires reported power data from each user in the distribution network and measured current amplitude and measured power factor angle from each monitoring node. Based on the reported power data, it performs power flow calculations to obtain theoretical current amplitude and theoretical power factor angle. The global total error is determined based on the residual between measured and theoretical values. When the global total error exceeds a preset threshold, the QPSO algorithm is initiated iteratively using the actual power data as the optimization variable. This provides a clear physical initiation condition for electricity theft detection, rather than unconditional execution. In the QPSO algorithm, the initial actual power distribution satisfying the physical feasible region constraint is mapped to... The probability amplitude and phase angle of the qubit ensure that the entire initial population is within the feasible region, avoiding invalid searches and improving convergence speed. During iteration, each qubit updates its phase angle through a quantum rotation gate and maps it to two search positions. The actual power data corresponding to the two positions are substituted into the power flow calculation and the weighted fitness function value is calculated separately. The search position corresponding to the smaller fitness value is taken as the quantum position of the qubit. The weighted fitness function assigns different weights to the current amplitude residual and the power factor angle residual, amplifying the error gradient and enabling the particles to sensitively perceive the optimization direction, thereby accelerating convergence and improving solution accuracy. Finally, the suspected electricity theft user is determined based on the difference between the actual power distribution and the reported power data. This application achieves a technical effect that balances real-time performance and accuracy in power theft detection in distribution networks through the above methods. Attached Figure Description
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or related technologies, the drawings used in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 A schematic flowchart of an electricity theft detection method based on quantum particle swarm optimization algorithm provided in an embodiment of this application; Figure 2 This is a schematic diagram of the structure of a computer device provided in an embodiment of this application. Detailed Implementation
[0021] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0022] The purpose of this application is to provide a method, device, medium, and product for detecting electricity theft based on the quantum particle swarm optimization algorithm, aiming to improve the real-time performance and accuracy of electricity theft detection in power distribution networks.
[0023] To make the above-mentioned objectives, features and advantages of this application more apparent and understandable, the application will be further described in detail below with reference to the accompanying drawings and specific embodiments.
[0024] In one exemplary embodiment, such as Figure 1 As shown, a method for detecting electricity theft based on the quantum particle swarm optimization algorithm is provided, including the following steps.
[0025] Step 1: Obtain the power data reported by each user in the distribution network and the measured electrical quantity data of each monitoring node.
[0026] The reported power data includes reported active power and reported reactive power, while the measured electrical quantity data includes measured current amplitude and measured power factor angle.
[0027] Specifically, the electricity theft detection method of this application is universal and applicable to various power distribution networks capable of power flow calculation, without relying on a specific topology. Taking a 10kV open-radial distribution network topology model that conforms to the power supply characteristics of small and medium-sized industrial areas as an example, this method constructs a 10kV open-radial distribution network topology model that conforms to the power supply characteristics of small and medium-sized industrial areas, and builds a standardized simulation line as the basis for algorithm verification and training, thus addressing the problem of existing research lacking a simulation platform for industrial scenarios.
[0028] Based on the typical power supply mode of a 10kV distribution network in small and medium-sized industrial areas, characterized by a single power source, tree-like radial distribution, and no closed loops, and considering the typical distribution scale and electrical parameters of dedicated transformer users in small and medium-sized industrial areas in China, a simulation line was constructed, comprising one power source node and 12 dedicated transformer user load nodes (i.e., users). Specific parameters and structure are as follows: the rated voltage of the line is 10kV, the line impedance is set to 0.33 + j0.34Ω / km, and the distance between users is set to 0.15km.
[0029] By simulating the electricity theft conditions of 12 users at different locations and with varying theft rates, power flow calculations and electrical quantity sensitivity comparisons were conducted to analyze the impact of electricity theft on current amplitude, voltage amplitude, voltage phase angle, and power factor angle. The results show that power deviations caused by user electricity theft, after being transmitted through open network power flow, have the most significant and sensitive disturbances on node current amplitude and power factor angle; while voltage amplitude and voltage phase angle are less affected by electricity theft and are easily masked by normal load fluctuations, making them unsuitable as characteristic quantities for electricity theft detection. Therefore, this application selects current amplitude and power factor angle as electrical quantities for electricity theft detection.
[0030] The six monitoring nodes are the core nodes for power transmission in the open system, which can fully cover the entire power supply path of 12 users. Any user's electricity theft will be transmitted to the corresponding upstream monitoring node through power flow, realizing the detection of anomalies on the entire line. At the same time, deploying only six monitoring nodes significantly reduces engineering costs and balances detection accuracy and practicality.
[0031] Step 2: Perform power flow calculations based on the power data reported by each user to obtain the theoretical electrical quantity data of each monitoring node under the reported power data.
[0032] The theoretical electrical quantity data includes the theoretical current amplitude and the theoretical power factor angle.
[0033] As an optional implementation, in step 2, the power flow calculation methods include the forward-backward substitution method and the Newton-Raphson method.
[0034] Step 3: Determine the total global error based on the measured electrical quantity data of all monitoring nodes and the theoretical electrical quantity data under the reported power data.
[0035] As an optional implementation, step 3 includes the following steps.
[0036] Step 31: Determine the residual current amplitude of each monitoring node under the reported power data based on the measured current amplitude of each monitoring node and the theoretical current amplitude under the reported power data.
[0037] Specifically, the formula for calculating the residual current amplitude is: ; in, Let be the residual current amplitude at the m-th monitoring node; Let be the theoretical current amplitude of the m-th monitoring node; Let be the measured current amplitude of the m-th monitoring node.
[0038] Step 32: Determine the power factor angle residual of each monitoring node under the reported power data based on the measured power factor angle and the theoretical power factor angle of each monitoring node.
[0039] Specifically, the formula for calculating the power factor angle residual is: ; in, Let be the power factor angle residual of the m-th monitoring node; Let be the theoretical power factor angle of the m-th monitoring node; Let be the measured power factor angle of the m-th monitoring node.
[0040] Step 33: Determine the total global error based on the residual current amplitude and power factor angle of all monitoring nodes under the reported power data.
[0041] Specifically, the formula for calculating the total global error is: ; in, This represents the total global error. To take the absolute value.
[0042] Step 4: When the total global error exceeds the preset threshold, the actual power data of each user is used as the optimization variable, and the goal is to minimize the residual between the theoretical electrical quantity data and the measured electrical quantity data of each monitoring node. The quantum particle swarm optimization algorithm is used for iterative optimization to obtain the final actual power distribution.
[0043] The actual power distribution includes the actual power data of each user, which includes actual active power and actual reactive power.
[0044] In the quantum particle swarm optimization algorithm: multiple initial real power distributions satisfying the physical feasible region constraints are randomly generated, and the real active power or real reactive power of each user in each initial real power distribution is mapped to two initial probability amplitudes and an initial self-phase angle of the corresponding qubit, thus obtaining the initial population; the population includes multiple particles, one particle corresponds to one set of real power distributions, one particle includes multiple qubits, and the quantum position of one qubit corresponds to the real active power or real reactive power of one user; the two probability amplitudes include cosine probability amplitude and sine probability amplitude; the two search positions include cosine power search position and sine power search position; during the iteration process, each qubit of each particle updates its own phase angle through a quantum rotation gate, and the updated self-phase angle recalculates the two probability amplitudes, which are mapped to two search positions. The real power data corresponding to the two search positions are substituted into the power flow calculation to obtain the corresponding theoretical electrical quantity data, and the weighted fitness function value corresponding to the two search positions is calculated respectively. The search position with the smaller weighted fitness function value is taken as the quantum position of the qubit.
[0045] As an optional implementation, step 4 includes the following steps.
[0046] Step 41: Under the constraint of the physical feasible region, randomly generate multiple sets of initial real power distributions, and map the real active power or real reactive power of each user in each set of initial real power distributions to the two initial probability amplitudes and the initial self-phase angle of the corresponding qubit, thereby obtaining the initial population.
[0047] As an optional implementation, in step 41, the physical feasible domain constraints include the actual active power constraints and the actual reactive power constraints for each user. The upper and lower limits of the actual active power constraint and the actual reactive power constraint for each user are determined based on the active power reported by the corresponding user.
[0048] Specifically, the actual active power constraint is expressed as: ; When the user's load is an inductive load, the actual reactive power constraint is expressed as follows: ; When the user's load is capacitive, the actual reactive power constraint is expressed as follows: ; in, The active power reported by the nth user; This represents the actual active power of the nth user. This represents the actual reactive power of the nth user. In reality, the constraints 0.5, 1.5, ... and All settings can be adjusted according to actual conditions. Small and medium-sized industrial users are affected by factors such as production shift changes, order volume changes, and equipment start-up and shutdown, and their active power usually fluctuates by ±50%. This feasible region can fully cover such normal operating conditions. Moreover, the power deviation ratio of common electricity theft behaviors is mostly between 10% and 50%. This feasible region can ensure that the actual active power caused by electricity theft is always within the search range. By setting reasonable upper and lower limits, impossible values that exceed the user's rated capacity and equipment operating limits are eliminated, which greatly improves the algorithm's solution efficiency and avoids invalid searches.
[0049] Specifically, in step 41, the actual active power or actual reactive power of each user in each initial actual power distribution is mapped to two initial probability amplitudes and an initial self-phase angle of the corresponding qubit, including the following steps.
[0050] Step 411: Using the cosine probability amplitude-true power data mapping formula, map the true active power or true reactive power of each user in the initial true power distribution of the group to the initial cosine probability amplitude of the corresponding qubit; the cosine probability amplitude-true power data mapping formula is: ; in, Let be the cosine probability amplitude of the j-th qubit in the i-th particle; This represents the actual active power or actual reactive power of the user corresponding to the j-th qubit in the i-th particle. This is the upper bound of the actual active or reactive power of the user corresponding to the j-th qubit within the physical feasible region constraint. This is the lower bound of the actual active or reactive power of the user corresponding to the j-th qubit within the physical feasible region constraint.
[0051] Step 412: Using the sinusoidal probability amplitude calculation formula, calculate the initial sinusoidal probability amplitude of the corresponding qubit based on the initial cosine probability amplitude of each qubit; the sinusoidal probability amplitude calculation formula is: ; in, Let be the sinusoidal probability amplitude of the j-th qubit in the i-th particle; Let be the sign factor of the sinusoidal probability amplitude of the j-th qubit in the randomly generated i-th particle. .
[0052] Step 413: Using the temporary phase angle calculation formula, calculate the temporary phase angle of the corresponding qubit based on the initial cosine probability amplitude and sine probability amplitude of each qubit; the temporary phase angle calculation formula is: ; in, Let be the temporary phase angle of the j-th qubit in the i-th particle. The formula for calculating the temporary phase angle is the arctan² quadrant discrimination algorithm, relying on... and Determine the quadrant of the coordinates for positive and negative determination, and output them in segments. Temporary phase angle of the interval.
[0053] Step 414: Using the interval conversion formula, calculate the initial self-phase angle of the corresponding qubit based on the temporary phase angle of each qubit; the interval conversion formula is: ; in, Let be the phase angle of the j-th qubit in the i-th particle.
[0054] Step 42: Based on the initial self-phase angle of each qubit in each particle in the initial population, the self-phase angle, two probability amplitudes and two search positions of each qubit in each particle in the initial population are updated in multiple rounds using a quantum rotation gate to obtain the final self-phase angle, two final probability amplitudes and two final search positions of the corresponding qubit, thus forming the final population.
[0055] As an optional implementation, in step 42, during the process of iteratively updating the phase angle of each qubit in each particle in the initial population, the two probability amplitudes and the two search positions of each qubit in the initial population using a quantum rotation gate in multiple rounds, the update process in any current round includes the following steps.
[0056] Step S01: Determine any particle in the population as the current particle, and determine any qubit in the current particle as the current qubit.
[0057] Step S02: Obtain the current qubit's own phase angle, individual optimal phase angle, global optimal phase angle, and phase angle increment in the previous round; when the current round is the initial round, the current qubit's own phase angle and individual optimal phase angle in the previous round are both the initial phase angle of the current qubit, the global optimal phase angle of the current qubit in the previous round is the initial phase angle of the qubit corresponding to the particle with the smallest weighted fitness function value in the initial population, and the phase angle increment of the current qubit in the previous round is 0.
[0058] Step S03: Based on the current qubit's own phase angle, individual optimal phase angle, and global optimal phase angle in the previous round, determine the minimum individual phase difference and minimum global phase difference of the current qubit in the previous round.
[0059] Specifically, the formulas for calculating the minimum individual phase difference and the minimum global phase difference are as follows: ; ; in, Let be the minimum individual phase difference of the j-th qubit in the i-th particle at round t-1; Let be the individual optimal phase angle of the j-th qubit in the i-th particle in round t-1; Let be the phase angle of the j-th qubit in the i-th particle in the (t-1)-th round; Let $\frac{i}{j}$ be the minimum global phase difference of the $j$-th qubit in the $i$-th particle at round $t-1$. Let be the globally optimal phase angle of the j-th qubit in round t-1.
[0060] Step S04: Based on the current qubit's own phase angle increment, minimum individual phase difference, and minimum global phase difference in the previous round, determine the current qubit's own phase angle increment in the current round.
[0061] Specifically, the formula for calculating the self-phase angle increment is: ; in, Let be the phase angle increment of the j-th qubit in the i-th particle in the t-th round; This is the inertia factor, used to balance the global search and local exploitation capabilities of the algorithm; Let be the phase angle increment of the j-th qubit in the i-th particle in the (t-1)-th round; It serves as an individual learning factor, used to guide particles toward their historical best position. It serves as a global learning factor, used to guide particles toward the global optimal position of the population; and All are uniform random numbers in the interval [0, 1], used to increase the randomness of the population search.
[0062] Step S05: Based on the phase angle of the current qubit in the previous round and the phase angle increment of the current qubit in the current round, determine the phase angle of the current qubit in the current round.
[0063] Specifically, the formula for calculating the phase angle is: ; in, Let be the phase angle of the j-th qubit in the i-th particle in the t-th round; Modulo operation normalization is performed to ensure that the phase angle always remains within the defined standard range. Inside.
[0064] Step S06: Based on the physical feasible region constraint and the phase angle of the current qubit in the current round, determine the two probability amplitudes and two search positions of the current qubit in the current round, and obtain the population in the current round.
[0065] As an optional implementation, step S06 includes the following steps.
[0066] Step S061: Calculate the two probability amplitudes of the current qubit in the current round based on the phase angle of the current qubit in the current round.
[0067] Specifically, the formulas for calculating the two probability amplitudes are as follows: ; ; in, Let be the cosine probability amplitude of the j-th qubit in the i-th particle in the t-th round; It is a cosine function; Let be the sinusoidal probability amplitude of the j-th qubit in the i-th particle in the t-th round; It is a sine function.
[0068] Step S062: Based on the physical feasible region constraint and the phase angle and two probability amplitudes of the current qubit in the current round, calculate the two search positions of the current qubit in the current round.
[0069] Specifically, the formulas for calculating the two search positions are as follows: ; ; in, Let be the cosine power search position of the j-th qubit in the i-th particle in the t-th round; Let be the sinusoidal power search position of the j-th qubit in the i-th particle during the t-th round.
[0070] Step S07: Determine any search location as the current location.
[0071] Step S08: Determine the actual power data of each qubit in the current particle at the current position in the current round for the corresponding user in the current round.
[0072] Step S09: Perform power flow calculation based on the actual power data of all users corresponding to all qubits in the current particle at the current position in the current round, and obtain the theoretical electrical quantity data of each monitoring node at the current position in the current round under the current particle.
[0073] Step S10: Based on the measured electrical quantity data of all monitoring nodes and the theoretical electrical quantity data of all monitoring nodes at the current position of the current particle in the current round, determine the weighted fitness function value of the current particle at the current position of the current round.
[0074] Specifically, the weighted fitness function is expressed as: ; in, The weighted fitness function value; This is the weighting coefficient for the current amplitude residual; The weighting coefficients are the power factor angle residuals. A smaller weighted fitness function value indicates that the user power distribution corresponding to the particle is closer to the real situation. The optimization objective of the algorithm is to minimize the weighted fitness function value. Step S11: Determine the search position corresponding to the minimum value of the weighted fitness function as the particle level position of each qubit in the current particle in the current round.
[0075] Step S12: Determine the particle level position of each qubit in the current particle in the current round as the quantum position of the corresponding qubit in the current round.
[0076] Specifically, the formula for calculating quantum position is: ; in, Let be the quantum position of the j-th qubit in the i-th particle in the t-th round; The weighted fitness function value of the i-th particle at the cosine power search position in round t; is the weighted fitness function value of the i-th particle at the sinusoidal power search position in round t.
[0077] Step S13: Determine whether the stopping condition has been met; the stopping condition is that the maximum number of iterations has been reached or the minimum value of the weighted fitness function of all particles at the two search positions in the current round is less than the preset fitness.
[0078] Step S14: If yes, then determine the phase angle, two probability amplitudes and two search positions of each qubit in each individual in the current round as the final phase angle, two final probability amplitudes and two final search positions of the corresponding qubit, thereby forming the final population.
[0079] Step S15: If not, determine the individual optimal phase angle of each qubit in the current round based on the weighted fitness function value of each particle in all rounds, the phase angle of each qubit in the current round, and the individual optimal phase angle of each qubit in the previous round. Determine the global optimal phase angle of each qubit in the current round based on the weighted fitness function value of all particles in all rounds, the individual optimal phase angle of each qubit in the current round, and the global optimal phase angle of each qubit in the previous round. Update the phase angle, individual optimal phase angle, and global optimal phase angle of each qubit in the previous round to the phase angle, individual optimal phase angle, and global optimal phase angle of each qubit in the current round, respectively, and return to step S03.
[0080] Specifically, if the minimum value of the weighted fitness function of a particle at two search positions in the current round is less than the minimum value of the weighted fitness function of the particle at two search positions in all rounds, then the particle's own phase angle in the current round is taken as the particle's individual optimal phase angle in the current round; otherwise, the particle's individual optimal phase angle in the previous round is taken as the particle's individual optimal phase angle in the current round.
[0081] If the minimum value of the weighted fitness function of a particle at two search positions in all rounds is less than the minimum value of the weighted fitness function of all particles in the population at two search positions in all rounds, then the individual optimal phase angle of the particle in the current round is taken as the global optimal phase angle of the particle in the current round; otherwise, the global optimal phase angle of the particle in the previous round is taken as the global optimal phase angle of the particle in the current round.
[0082] Step 43: Determine any particle in the final population as the target particle, and determine any search position as the target position.
[0083] Step 44: Determine the final true power data of the user corresponding to each qubit in the target particle at the final target position.
[0084] Step 45: Perform power flow calculations based on the final actual power data of all users corresponding to all qubits in the target particle at the final target position, and obtain the final theoretical electrical quantity data of each monitoring node at the final target position under the target particle.
[0085] Step 46: Based on the measured electrical quantity data of all monitoring nodes and the final theoretical electrical quantity data of all monitoring nodes at the final target position of the target particle, determine the weighted fitness function value of the target particle at the final target position.
[0086] Step 47: Determine the minimum value of the weighted fitness function of the target particle at the two final search positions as the weighted fitness function value of the target particle.
[0087] Step 48: Determine the true power distribution corresponding to the particle with the smallest weighted fitness function value in the final population as the final true power distribution.
[0088] Step 5: Based on the final actual power distribution and the power data reported by each user, identify users in the distribution network suspected of electricity theft.
[0089] Specifically, if the difference between a user's final actual power data and the reported power data is greater than a preset difference, then the user is determined to be a user suspected of electricity theft.
[0090] Using the method described in this application, key monitoring nodes only need to be deployed at the beginning of the main line and the beginning of major branch lines to cover all dedicated transformer users along the entire line. The engineering deployment cost is only 50% of that of the full node deployment scheme. No modification to user-side metering devices is required, and normal power consumption by users is not affected. It can be quickly promoted and applied to distribution networks in various small and medium-sized industrial areas. Through electricity theft simulation and power flow calculation analysis, current amplitude and power factor angle are scientifically selected as the core feature quantities for electricity theft detection. Quantitative analysis shows that these two electrical quantities have the most significant impact on electricity theft behavior and the highest sensitivity, effectively distinguishing normal load fluctuations from abnormal electricity theft. This eliminates false detection problems caused by feature quantities such as voltage amplitude and voltage phase angle, which are easily affected by grid operating conditions, significantly improving the anti-interference capability and robustness of the detection system. Multi-dimensional engineering optimizations were performed on the quantum particle swarm optimization algorithm, setting a strict feasible region based on the physical constraints of the power system to compress the search space. An initialization method of first initializing with physical constraints and then reverse mapping quantum encoding is proposed to ensure that the initial population is within the feasible region and avoid invalid searches. Employing a quantum dual-probability amplitude encoding mechanism, a single particle simultaneously occupies two search positions, effectively doubling the number of search particles. A weighted fitness function is introduced to amplify the error gradient, resolving the gradient vanishing and iteration stagnation issues encountered in traditional algorithms.
[0091] In one exemplary embodiment, a computer device is provided, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement a method for detecting electricity theft based on a quantum particle swarm optimization algorithm.
[0092] In one exemplary embodiment, a computer-readable storage medium is provided having a computer program stored thereon that, when executed by a processor, implements a method for detecting electricity theft based on a quantum particle swarm optimization algorithm.
[0093] In one exemplary embodiment, a computer program product is provided, including a computer program that, when executed by a processor, implements a method for detecting electricity theft based on a quantum particle swarm optimization algorithm.
[0094] In one exemplary embodiment, a computer device is provided, which may be a server or a terminal, and its internal structure diagram may be as follows. Figure 2 As shown, this computer device includes a processor, memory, input / output (I / O) interfaces, and a communication interface. The processor, memory, and I / O interfaces are connected via a system bus, and the communication interface is also connected to the system bus via the I / O interfaces. The processor provides computational and control capabilities. The memory includes non-volatile storage media and internal memory. The non-volatile storage media stores the operating system, computer programs, and databases. The internal memory provides the environment for the operating system and computer programs stored in the non-volatile storage media to run. The I / O interfaces are used for exchanging information between the processor and external devices. The communication interface is used for communicating with external terminals via a network connection. When the computer program is executed by the processor, it implements a method for detecting electricity theft based on a quantum particle swarm optimization algorithm.
[0095] Those skilled in the art will understand that Figure 2 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0096] Those skilled in the art will understand that all or part of the processes in the above embodiments can be implemented by a computer program instructing related hardware. The computer program can be stored in a non-volatile computer-readable storage medium. When executed, the computer program can include the processes of the embodiments described above. Any references to memory, databases, or other media used in the embodiments provided in this application can include at least one of non-volatile and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM).
[0097] The databases involved in the embodiments provided in this application may include at least one type of relational database and non-relational database. Non-relational databases may include, but are not limited to, blockchain-based distributed databases. The processors involved in the embodiments provided in this application may be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, quantum computing-based data processing logic devices, etc., and are not limited to these.
[0098] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of the relevant data must comply with relevant regulations.
[0099] The technical features of the above embodiments can be combined in any way. For the sake of brevity, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.
[0100] This document uses specific examples to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. Furthermore, those skilled in the art will recognize that, based on the ideas of this application, there will be changes in the specific implementation methods and application scope. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for detecting electricity theft based on quantum particle swarm optimization, characterized in that, The electricity theft detection method includes: The system acquires the reported power data from each user in the distribution network and the measured electrical quantity data from each monitoring node; the reported power data includes reported active power and reported reactive power, and the measured electrical quantity data includes measured current amplitude and measured power factor angle. Power flow calculations are performed based on the power data reported by each user to obtain the theoretical electrical quantity data of each monitoring node under the reported power data; the theoretical electrical quantity data includes the theoretical current amplitude and the theoretical power factor angle; Based on the measured electrical quantity data of all monitoring nodes and the theoretical electrical quantity data under the reported power data, the global total error is determined; When the global total error exceeds a preset threshold, the actual power data of each user is used as the optimization variable, and the goal is to minimize the residual between the theoretical electrical quantity data and the measured electrical quantity data of each monitoring node. The quantum particle swarm optimization algorithm is used for iterative optimization to obtain the final actual power distribution. The actual power distribution includes the actual power data of each user, which includes actual active power and actual reactive power. In the quantum particle swarm optimization algorithm: multiple sets of initial actual power distributions satisfying the physical feasible region constraints are randomly generated, and the actual active power or actual reactive power of each user in each set of initial actual power distributions is mapped to two initial probability amplitudes and an initial self-phase angle of the corresponding qubit, thereby obtaining the initial population. The population includes... It includes multiple particles, each particle corresponds to a set of real power distributions, and each particle includes multiple qubits. The quantum position of a qubit corresponds to the real active power or real reactive power of a user. There are two probability amplitudes, including cosine probability amplitude and sine probability amplitude. There are two search positions, including cosine power search position and sine power search position. During the iteration process, each qubit of each particle updates its own phase angle through a quantum rotation gate. The updated phase angle recalculates the two probability amplitudes and maps them to two search positions. The real power data corresponding to the two search positions are substituted into the power flow calculation to obtain the corresponding theoretical electrical quantity data. The weighted fitness function value corresponding to the two search positions is calculated respectively. The search position with the smaller weighted fitness function value is taken as the quantum position of the qubit. Based on the final actual power distribution and the power data reported by each user, users suspected of electricity theft in the distribution network were identified.
2. The electricity theft detection method based on quantum particle swarm optimization algorithm according to claim 1, characterized in that, The methods used for power flow calculation include the forward substitution method and the Newton-Raphson method.
3. The electricity theft detection method based on quantum particle swarm optimization algorithm according to claim 1, characterized in that, Based on the measured electrical quantity data of all monitoring nodes and the theoretical electrical quantity data under the reported power data, the global total error is determined, including: Based on the measured current amplitude and the theoretical current amplitude under the reported power data, the residual current amplitude of each monitoring node under the reported power data is determined. Based on the measured power factor angle and the theoretical power factor angle of each monitoring node, the power factor angle residual of each monitoring node under the reported power data is determined. The global total error is determined based on the residual current amplitude and power factor angle of all monitoring nodes under the reported power data.
4. The electricity theft detection method based on quantum particle swarm optimization algorithm according to claim 1, characterized in that, Using the actual power data of each user as the optimization variable, and aiming to minimize the residual between the theoretical and measured electrical quantities at each monitoring node, the quantum particle swarm optimization algorithm is used for iterative optimization to obtain the final actual power distribution, including: Under the constraint of the physical feasible region, multiple initial real power distributions are randomly generated, and the real active power or real reactive power of each user in each initial real power distribution is mapped to the two initial probability amplitudes and the initial self-phase angle of the corresponding qubit, thereby obtaining the initial population. Based on the initial self-phase angle of each qubit in each particle in the initial population, the quantum rotation gate is used to iterate and update the self-phase angle, two probability amplitudes and two search positions of each qubit in each particle in the initial population in multiple rounds to obtain the final self-phase angle, two final probability amplitudes and two final search positions of the corresponding qubit, thus forming the final population. Determine any particle in the final population as the target particle, and any search position as the target position; Determine the final true power data of the user corresponding to each qubit in the target particle at the final target position; Power flow calculations are performed based on the final actual power data of the users corresponding to all qubits in the target particle at the final target position, to obtain the final theoretical electrical quantity data of each monitoring node at the final target position under the target particle. Based on the measured electrical quantity data of all monitoring nodes and the final theoretical electrical quantity data of all monitoring nodes at the final target position under the target particle, the weighted fitness function value of the target particle at the final target position is determined. The minimum value of the weighted fitness function of the target particle at the two final search positions is determined as the weighted fitness function value of the target particle. The true power distribution corresponding to the particle with the smallest weighted fitness function value in the final population is determined as the final true power distribution.
5. The electricity theft detection method based on quantum particle swarm optimization algorithm according to claim 4, characterized in that, The physical feasible region constraints include the actual active power constraints and actual reactive power constraints for each user. The upper and lower limits of the actual active power constraint and the actual reactive power constraint for each user are determined based on the active power reported by the corresponding user.
6. The electricity theft detection method based on quantum particle swarm optimization algorithm according to claim 5, characterized in that, In the process of iteratively updating the phase angle, two probability amplitudes, and two search positions of each qubit in each particle of the initial population using a quantum rotation gate across multiple rounds, the update process in any current round includes: Determine any particle in the population as the current particle, and determine any qubit in the current particle as the current qubit; Obtain the current qubit's own phase angle, individual optimal phase angle, global optimal phase angle, and phase angle increment in the previous round; when the current round is the initial round, the current qubit's own phase angle and individual optimal phase angle in the previous round are both the initial phase angle of the current qubit, the global optimal phase angle of the current qubit in the previous round is the initial phase angle of the qubit corresponding to the particle with the smallest weighted fitness function value in the initial population, and the phase angle increment of the current qubit in the previous round is 0; Based on the current qubit's own phase angle, individual optimal phase angle, and global optimal phase angle in the previous round, determine the minimum individual phase difference and minimum global phase difference of the current qubit in the previous round; Based on the current qubit's own phase angle increment, minimum individual phase difference, and minimum global phase difference in the previous round, determine the current qubit's own phase angle increment in the current round; Based on the phase angle of the current qubit in the previous round and the increment of the phase angle of the current qubit in the current round, determine the phase angle of the current qubit in the current round; Based on the physical feasible region constraint and the phase angle of the current qubit in the current round, the two probability amplitudes and two search positions of the current qubit in the current round are determined, and the population in the current round is obtained. Set any search location as the current location; Determine the actual power data of each qubit in the current particle at the current position in the current round, corresponding to the user in the current round; Power flow calculations are performed based on the actual power data of all users corresponding to all qubits in the current particle at the current position in the current round, to obtain the theoretical electrical quantity data of each monitoring node at the current position in the current round of the current particle; Based on the measured electrical quantity data of all monitoring nodes and the theoretical electrical quantity data of all monitoring nodes at the current position of the current particle in the current round, the weighted fitness function value of the current particle at the current position of the current round is determined. The search position corresponding to the minimum value of the weighted fitness function is determined as the particle level position of each quantum bit in the current particle in the current round. The particle-level position of each qubit in the current particle in the current round is determined as the quantum position of the corresponding qubit in the current round; Determine whether the stopping condition has been met; the stopping condition is that the maximum number of iterations has been reached or the minimum value of the weighted fitness function of all particles at the two search positions in the current round is less than the preset fitness. If so, the phase angle, two probability amplitudes, and two search positions of each qubit in each individual in the current round are determined as the final phase angle, two final probability amplitudes, and two final search positions of the corresponding qubit, thus forming the final population. If not, then based on the weighted fitness function value of each particle in all rounds, the phase angle of each qubit in each particle in the current round, and the individual optimal phase angle of each qubit in each particle in the previous round, determine the individual optimal phase angle of each qubit in each particle in the current round. Based on the weighted fitness function value of all particles in all rounds, the individual optimal phase angle of each qubit in each particle in the current round, and the global optimal phase angle of each qubit in each particle in the previous round, determine the global optimal phase angle of each qubit in each particle in the current round. Then update the phase angle, individual optimal phase angle, and global optimal phase angle of each qubit in the previous round to the phase angle, individual optimal phase angle, and global optimal phase angle of each qubit in the current round, respectively. Return "Based on the phase angle, individual optimal phase angle, and global optimal phase angle of the current qubit in the previous round, determine the minimum individual phase difference and minimum global phase difference of the current qubit in the previous round." 7. The electricity theft detection method based on quantum particle swarm optimization algorithm according to claim 6, characterized in that, Based on the physical feasible region constraint and the phase angle of the current qubit in the current round, determine the two probability amplitudes and two search positions of the current qubit in the current round, including: Calculate the two probability amplitudes of the current qubit in the current round based on its own phase angle in the current round; Based on the physical feasible region constraint and the phase angle and two probability amplitudes of the current qubit in the current round, calculate the two search positions of the current qubit in the current round.
8. A computer device, comprising: A memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that the processor executes the computer program to implement the electricity theft detection method based on the quantum particle swarm optimization algorithm according to any one of claims 1-7.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When executed by a processor, the computer program implements the electricity theft detection method based on the quantum particle swarm algorithm as described in any one of claims 1-7.
10. A computer program product, comprising a computer program, characterized in that, When executed by a processor, the computer program implements the electricity theft detection method based on the quantum particle swarm algorithm as described in any one of claims 1-7.
