A low-voltage power distribution system leakage detection method and device
By using a genetic algorithm to select feature combinations and a random forest algorithm to optimize model hyperparameters, a leakage current detection method for low-voltage power distribution systems is constructed. This method solves the problems of low efficiency and low accuracy in existing leakage current detection technologies, and achieves efficient and accurate leakage current fault detection in complex environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- STATE GRID HUNAN ELECTRIC POWER COMPANY LIMITED
- Filing Date
- 2023-11-14
- Publication Date
- 2026-05-29
AI Technical Summary
Existing methods for detecting leakage current in low-voltage power distribution systems suffer from frequent false alarms and failures to operate, making it difficult to accurately detect leakage faults in complex environments. Furthermore, traditional methods are characterized by low detection efficiency, low accuracy, and poor robustness.
A genetic algorithm is used to select feature combinations, and random forest algorithm and particle swarm algorithm are combined to optimize model hyperparameters to construct a leakage current detection method for low-voltage power distribution system. By collecting residual current data under different interference factors, a fault discrimination feature sample set is constructed, and data processing and feature extraction are performed to select the optimal feature combination and train the detection model.
It improves the accuracy and efficiency of leakage fault detection, can adapt to leakage fault detection under various interference factors, reduces the probability of false operation and failure to operate, and enhances the robustness of detection.
Smart Images

Figure CN117554854B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of low-voltage power distribution system technology, and in particular to a method and device for detecting leakage current in low-voltage power distribution systems. Background Technology
[0002] In low-voltage power distribution systems, if a circuit or electrical equipment leaks current, the current will form a closed loop with the equipment casing, neutral wire, and protective grounding wire. This leads to a continuous increase in leakage current, power loss, and may also cause electric shock and electrical fires. Traditional methods of leakage detection rely on regular manual inspections. This approach is time-consuming and labor-intensive, and cannot provide comprehensive and accurate leakage current detection, leaving significant potential hazards. Residual current protection devices (RCDs) are widely used in low-voltage power grids and play a crucial role in preventing electrical fires not caused by leakage. However, RCDs frequently malfunction or fail to operate due to normal leakage current. Furthermore, the operating current setting of currently operating RCDs often uses the detected effective value of the residual current as the sole criterion for operation. This criterion is insufficient to accurately detect fault leakage current signals, frequently resulting in maloperation or failure to operate, significantly reducing the reliability and correct commissioning rate of RCDs.
[0003] To address the aforementioned issues, some practitioners have proposed a leakage current protection method that considers both the amplitude and phase of the residual current. This method determines whether leakage occurs by setting a fixed operating current setting. However, the leakage current in the power grid varies significantly with the external environment, making fixed operating threshold leakage protection unsuitable for practical needs. Alternatively, the method uses the change in residual current over 2 to 5 cycles to represent the fault leakage, employing both residual current and its change as dual criteria for accurate fault leakage protection. However, this method requires the leakage current to remain constant over the time intervals, while in real-world scenarios, the leakage current changes constantly with the external environment, making it difficult to accurately capture the changing patterns. Therefore, this method has certain limitations. Other practitioners have proposed an adaptive leakage current protection method based on a floating threshold, replacing the traditional fixed threshold. However, the threshold setting process for this method is complex and time-consuming.
[0004] Automatic fault classification can be achieved by establishing intelligent algorithm classification models such as SVM (Support Vector Machine). For this type of approach, existing technologies usually extract the time-frequency domain features of historical fault signals and use them directly as the input vector of the model for fault type identification. However, this type of method does not consider the impact of interference factors existing in real leakage fault scenarios on leakage detection. For example, excessive normal leakage current of lines or equipment can affect the accuracy of leakage detection, resulting in poor generalization ability and robustness of the actual model. Summary of the Invention
[0005] The technical problem to be solved by the present invention is to provide a method and device for detecting leakage current in low-voltage power distribution systems that is simple to operate, low in cost, efficient in detection, highly accurate and robust.
[0006] To solve the above-mentioned technical problems, the technical solution proposed by this invention is as follows:
[0007] A method for detecting leakage current in a low-voltage power distribution system, comprising the following steps:
[0008] Step S01. Collect data on the normal operation status of the line and the residual current when leakage fault occurs under different interference factors in the low-voltage power distribution system under test. Perform data processing and feature extraction to construct an initial fault discrimination feature sample set. The interference factors include controlling the load switching of the branch near the fault, increasing the line length of the ground capacitance simulation panel, and increasing the leakage fault sensing distance.
[0009] Step S02. Use a genetic algorithm to screen each feature in the initial fault discrimination feature sample set, select the optimal feature combination, and obtain the final fault discrimination feature sample set. The genetic algorithm uses a directed mutation operation in the feature screening process, and controls the mutation direction so that it does not mutate in the direction of eliminating chromosome features.
[0010] Step S03. Use the final fault discrimination feature sample set to train the detection model built based on the random forest algorithm. After training, the detection model is obtained for detecting and identifying leakage faults in low-voltage power distribution systems.
[0011] Furthermore, in step S02, an improved genetic algorithm is used to screen each feature in the initial fault discrimination feature sample set. The steps include:
[0012] Step S201. The features to be screened are normalized into a vector to form a chromosome Chrom_q; M chromosome vectors Chrom_q[p] are generated using random numbers, where M variables are used to store the total number of the current population, q is used to identify the unique chromosome, and p is used to identify the feature quantity in the chromosome.
[0013] Step S202. Obtain a set of training data and input it into the detection model corresponding to the q-th chromosome Chrom_q to obtain the actual detection value corresponding to chromosome Chrom_q. Calculate the fit Fit_q between the actual detection value and the expected value. Find a q that makes Fit_q < δ by traversing the entire population, where δ is a preset fit value. If found, training is complete, and the feature combination that has been trained is output. If no q that meets the requirements is found, proceed to step S203 after traversing the entire population.
[0014] Step S203. Sort all chromosomes in descending order of their fit Fit_q value, select the first specified number of chromosomes Chrom_q[p] and form a winning matrix A by row. Eliminate the remaining unselected chromosomes Chrom_q[p] and form a losing matrix B by row.
[0015] Step S204. Perform genetic operations and directed mutation operations on the offspring. During the directed mutation operation, determine whether the mutation parameter is a key feature parameter. If so, control the direction of change during the update so that it does not mutate towards the feature value of the eliminated chromosome. The key feature parameter is the feature parameter to be eliminated, which is selected based on the difference between the winning matrix and the elimination matrix. Return to step S202.
[0016] Furthermore, step S204 includes:
[0017] Step S241. Let rowA, rowB, and col be the index variables of the matrix and initialize them to 1. Here, rowA, rowB, and col represent the rows of the winning matrix A, the rows of the losing matrix B, and the columns of the two matrices, respectively. Calculate the average between rowA and col, the average between rowB and col, and the difference between the two averages. After each calculation, the value of col is incremented by one until the value of col reaches the preset threshold.
[0018] Step S242. Differ for each column col Sort by size from largest to smallest, and select the feature values corresponding to the first specified number of columns as the key feature indicators for controlling elimination;
[0019] Step S243. Genetic operation: The chromosomes in the winning matrix A are copied and the copied chromosomes are randomly cross-crossed to generate new offspring chromosomes, update variable M, and form a new population;
[0020] Step S244. Mutation operation; Fine-tune the parameters of the chromosomes in the winning matrix A. First, randomly select mutation parameters. If the selected mutation parameters are not the key feature indicators, use a random function to generate random values to update the mutation parameters. If the selected mutation parameters are the key feature indicators, control the direction of change to update the mutation parameters so that they do not mutate in the direction of the eliminated chromosome feature quantity.
[0021] Furthermore, in step S244, if the index value of the randomly selected mutation parameter is not a key feature indicator, the mutation parameter Chrom is updated according to the following formula. q [p]:
[0022] Chrom q [p]=Chrom q [p]+r(0.5-random())
[0023] Among them, random() is a function that generates random numbers between (0,1);
[0024] If the index value points to a key feature indicator, then the mutation parameter Chrom is updated according to the following formula. q [p], to control the direction of change during updates:
[0025]
[0026] Where r is the step size during the update. The average of rowA and col. This is the average between rowB and col.
[0027] Furthermore, step S03, which involves training the detection model, includes:
[0028] Step S301. Divide the fault discrimination feature sample set into a training set and a test set according to the proportion, select the feature vector as the model input, and the state code as the model output;
[0029] Step S302. Initially set hyperparameters for pre-training, and simultaneously optimize multiple hyperparameters of the model using the particle swarm optimization algorithm;
[0030] Step S303. Perform model training until the model training loss value reaches the minimum, terminate the iteration, and output the optimal hyperparameter values;
[0031] Step S304. Set the detection model to the obtained optimal hyperparameters and use the test set to test the effect of the detection model. If the preset performance requirements are met, the model training is completed.
[0032] Furthermore, the residual current data is the total residual current data, which is collected according to the following steps:
[0033] A leakage current detection platform was constructed, which uses a ground capacitance simulation panel to simulate the line-to-ground capacitance and incorporates the interference factor of line-to-ground leakage current on the detection of leakage current faults in low-voltage users.
[0034] When collecting data on normal and faulty residual current of the line, the load switching of the load on the faulty branch is turned on and off to introduce interference factors for leakage fault detection.
[0035] Increase the sensing distance between the residual current sensor and the location of the leakage fault;
[0036] Record the total residual current data of the line under normal operating conditions and when leakage faults occur, taking into account various interference factors.
[0037] Furthermore, in step S01, data processing includes any one or more of the following: baseline removal, data denoising, sliding time window sequence extraction, and normalization.
[0038] Furthermore, the step of eliminating the baseline value includes: taking the average value of all unloaded data, subtracting the average value of the unloaded data from all current data to eliminate the baseline value of the conditioning circuit, and obtaining accurate total residual current data, i.e.:
[0039]
[0040] Where, x i Let x1+x2+...+x be the data sample at time i, and n be the number of empty samples. n For n empty sample data.
[0041] Furthermore, the features extracted in step S01 include any one or more of the following: peak-to-peak value, current amplitude, integral, Shannon entropy, kurtosis, variance, impulse factor, and waveform factor.
[0042] A leakage current detection device for a low-voltage power distribution system includes a processor and a memory, wherein the memory is used to store a computer program and the processor is used to execute the computer program to perform the method described above.
[0043] Compared with the prior art, the advantages of the present invention are as follows:
[0044] 1. This invention fully considers multiple interference factors in actual fault scenarios, such as excessive normal leakage current, frequent load switching of nearby branches, and changes in sensing distance, to construct an initial fault discrimination feature sample set. This enables the acquisition of original residual current data that closely resembles the real fault scenario, ensuring detection accuracy. It is applicable to real leakage fault scenarios with multiple interference factors, effectively improving the detection accuracy of leakage faults.
[0045] 2. This invention processes the original residual current data and uses an improved genetic algorithm to perform deep screening and recombination of the original features. During the feature screening process, the mutation direction is controlled to prevent mutations from moving towards the elimination of chromosome features. This not only effectively reduces the amount of irrelevant and redundant information in the feature set, but also quickly and effectively selects the optimal and most effective feature combination. This solves the instability of traditional genetic algorithms and improves the efficiency and accuracy of leakage fault detection.
[0046] 3. This invention further employs the particle swarm optimization algorithm to optimize the main hyperparameters of the random forest model, giving full play to the advantages of the particle swarm optimization algorithm. It does not require the calculation of gradient information and has good global convergence, which can effectively shorten the model calculation time and further improve the detection accuracy of the leakage fault detection model. Attached Figure Description
[0047] Figure 1 This is a schematic diagram illustrating the implementation process of the leakage current detection method for low-voltage power distribution systems according to an embodiment of the present invention.
[0048] Figure 2 This is a detailed flowchart illustrating the principle of the low-voltage power distribution system leakage detection method according to an embodiment of the present invention.
[0049] Figure 3 This is a schematic diagram of a leakage current detection experimental circuit constructed in a specific application embodiment of the present invention.
[0050] Figure 4 This is a schematic diagram illustrating the implementation process of fault feature depth screening based on an improved genetic algorithm in an embodiment of the present invention.
[0051] Figure 5 This is a schematic diagram illustrating the principle of training the leakage current detection model in an embodiment of the present invention.
[0052] Figure 6 This is a schematic diagram illustrating the principle of Bootstrap sampling with replacement in an embodiment of the present invention. Detailed Implementation
[0053] The present invention will be further described below with reference to the accompanying drawings and specific preferred embodiments, but this does not limit the scope of protection of the present invention.
[0054] Considering the impact of interference factors in real leakage fault scenarios on leakage detection, and to approximate the real leakage fault scenario as closely as possible, this invention fully considers multiple interference factors in actual fault scenarios, such as excessive normal leakage current, frequent load switching of nearby branches, and changes in sensing distance, to construct an initial fault discrimination feature sample set. This enables the acquisition of raw residual current data that closely approximates the real fault scenario, ensuring detection accuracy.
[0055] Meanwhile, when detecting leakage current faults, appropriate feature combinations can effectively improve the detection accuracy. However, in actual detection, it is difficult to determine which features are useful for leakage current fault detection, and too many features can significantly increase the time required for the detection process. This invention processes the original residual current data and uses a genetic algorithm to deeply screen and recombine the original features. During the feature screening process, the mutation direction is controlled to prevent mutations from moving towards the elimination of chromosome features, forming an improved genetic algorithm. This improved genetic algorithm can not only effectively reduce the amount of irrelevant and redundant information in the feature set, but also quickly and effectively screen out the optimal and most effective feature combinations that have the greatest impact on leakage current detection results. It solves the instability defects of traditional genetic algorithms, improves the efficiency and accuracy of leakage current fault detection, and thus enables accurate detection of leakage current faults under the influence of multiple interference factors.
[0056] like Figure 1 , 2 As shown, the steps of the low-voltage power distribution system leakage current detection method in this embodiment include:
[0057] Step S01. Collect data on the normal operation status of the line and the residual current when leakage fault occurs under different interference factors in the low-voltage power distribution system under test. Perform data processing and feature extraction to construct an initial fault discrimination feature sample set. Interference factors include controlling the load switching of the branch near the fault, increasing the line length of the ground capacitance simulation panel, and increasing the leakage fault sensing distance.
[0058] Step S02. Use a genetic algorithm to screen each feature in the initial fault discrimination feature sample set, select the optimal feature combination, and obtain the final fault discrimination feature sample set. The genetic algorithm uses a directed mutation operation in the feature screening process, and controls the mutation direction so that it does not mutate in the direction of eliminating chromosome features.
[0059] Step S03. Use the final fault discrimination feature sample set to train the detection model built based on the random forest algorithm. After training, the detection model is obtained for detecting and identifying leakage faults in low-voltage power distribution systems.
[0060] In step S01 of this embodiment, the residual current data specifically refers to the total residual current data, which is collected according to the following steps:
[0061] A leakage current detection platform was constructed, which uses a ground capacitance simulation panel to simulate the line-to-ground capacitance and incorporates the interference factor of line-to-ground leakage current on the detection of leakage current faults in low-voltage users.
[0062] When collecting data on normal and faulty residual current of the line, the load switching of the load on the faulty branch is turned on and off to introduce interference factors for leakage fault detection.
[0063] Configure the sensing distance between the residual current sensor and the location of the leakage fault;
[0064] Record the total residual current data of the line under normal operating conditions and when leakage faults occur, taking into account various interference factors.
[0065] In a specific application embodiment, the detailed steps for raw data acquisition are as follows:
[0066] A realistic leakage current physical experiment platform was built. The schematic diagram of the low-voltage system leakage current experiment circuit is shown below. Figure 3 As shown. The experimental equipment for leakage current detection includes: a programmable power supply, a LabVIEW data acquisition device, a ground capacitance simulation panel, a small current transformer, a conditioning circuit, and household electrical loads (resistive loads and nonlinear power electronic loads). The residual current signal is measured by the residual current transformer. The measured residual current is then converted into a digital signal by the conditioning circuit, which can be used for data acquisition, process control, calculation execution, and display. The programmable power supply provides the line with a phase voltage of 220V AC. The live wire and neutral wire pass through the residual current transformer together and are connected to the LabVIEW data acquisition device via signal lines, which can record the total residual current data under normal operating conditions and when a leakage fault occurs.
[0067] Since the normal leakage current in a line under normal operating conditions is mainly generated by the line-to-ground capacitance, and this normal leakage current has a significant impact on the magnitude of the residual current, in this embodiment's real-scale low-voltage system leakage fault experiment, a ground capacitance simulation panel is used to simulate the 2km line-to-ground capacitance, incorporating the interference factor of the line-to-ground leakage current on low-voltage user leakage fault detection. Based on the actual sensing distance requirements for leakage fault detection, the sensing distance between the residual current sensor and the location of the leakage fault is set to 25 meters to account for the interference effect of increasing the fault sensing distance on leakage fault detection. After increasing the fault sensing distance and the line-to-ground capacitance, the original residual current data can be detected by controlling the leakage control switch and the load switching switch.
[0068] Taking a fault resistance of 5000 as an example, the process for acquiring the original residual current data is as follows:
[0069] ① Control the programmable power supply to output 220V AC, run the NI data acquisition system, turn on the dimmer load to work normally, add interference (the load switching switch of the resistor branch creates interference), activate the leakage control switch of the leakage branch (a leakage fault occurs), add interference (the load switching switch of the resistor branch creates interference).
[0070] ② Control the programmable power supply to output 220V AC, run the NI data acquisition system, turn on the computer load to work normally, introduce interference (the load switching switch of the resistor branch creates interference), activate the leakage control switch of the leakage fault branch (create leakage fault), introduce interference (the load switching switch of the resistor branch creates interference).
[0071] By simulating the leakage fault state and normal operation state of the low-voltage power supply system, the data acquisition system collects the total residual current data IDi from the simulation experiment according to the above steps, forming the original dataset matrix OD. The matrix structure is M rows and 3 columns, where the i-th row represents the data at the i-th sampling point, the first column represents the sampling point number, the second column represents the total residual current data, and the third column represents the label value (normal operation state label: "0", leakage state label: "1").
[0072] After collecting the above raw data, data processing is performed, including baseline value elimination, data denoising, sequence extraction via sliding time window, and normalization, in order to analyze the frequency and time domain characteristics of the residual current and extract time and frequency domain features using the Fourier transform algorithm.
[0073] Adding a DC component to the experimental circuit during the leakage current test can prevent diode burnout and ensure the conditioning circuit does not reverse, but it also causes the baseline value of the current transformer's measurement to rise. To ensure the accuracy of the total residual current detection, the load must be disconnected first, DC data from the line is collected without load, and the current transformer is calibrated. In this embodiment, the steps to eliminate the baseline value include: taking the average of all unloaded data, subtracting the average of the unloaded data from all current data to eliminate the baseline value of the conditioning circuit, and obtaining accurate total residual current data, i.e.:
[0074]
[0075] Where, x i Let x1 be the data sample at time i, n be the number of empty samples, and x1 be the data sample at time i. + x² + ... + x n For n empty sample data.
[0076] In a specific application embodiment, the specific steps for data denoising are as follows: The original residual current is denoised using wavelet signal denoising software. First, a wavelet with N layers is selected to perform wavelet decomposition on the signal. After decomposition, a threshold is selected, and the coefficients of each layer are quantized using a threshold function. Finally, the signal is reconstructed using the processed coefficients, thus completing the signal denoising. In practical applications, the system only has a strong correlation with data near the working point, while the correlation with data far from the working point is not strong. The steps for extracting the sequence using a sliding time window are as follows:
[0077] Establish a sliding time window model, keeping the data interval length at 200 sampling points. When a new data point is added, the oldest data point slides out of the upper interval accordingly. As the data interval is continuously updated, the model is also continuously updated with the data from the new interval.
[0078] The specific formula for normalizing data using the max-min standardization method is as follows:
[0079]
[0080] Where x and x * These are the corresponding sample values before and after normalization, respectively; x max x represents the maximum value of the sample data. min This is the minimum value of the sample data.
[0081] To increase the efficiency of model detection and reduce computer memory usage, the original data is further processed by dimensionality reduction, i.e., feature extraction. This allows for the use of a few more representative features to reflect the overall original data. The features extracted in step S01 specifically include peak-to-peak value, current amplitude, integral, Shannon entropy, kurtosis, variance, impulse factor, and waveform factor, etc., to extract different features from the original time window data table. Single-dimensional feature vectors cannot clearly and accurately distinguish between normal and fault states. This embodiment constructs multi-dimensional feature vectors by visualizing the feature distribution of individual features, achieving better leakage fault detection results and avoiding the problem of low accuracy in leakage fault detection due to using a single feature as a criterion.
[0082] In a specific application embodiment, each feature parameter is obtained in the following manner:
[0083] 1) Kurtosis
[0084] Kurtosis is a characteristic quantity used to characterize the degree of concentration in a data distribution; specifically, it characterizes the peak or spurious shape of a probability density curve. The kurtosis of the current sampling point i is calculated by taking the kurtosis of the sampled values within a recent period T at the time of sampling point i. The residual current data Id... i and total current data Ia iThe kurtosis is represented by Kd. i Ka i The calculation formula is as follows:
[0085]
[0086]
[0087] The kurtosis of a normal distribution is 3. If the calculated kurtosis is greater than 3, it means that the data sequence is more dispersed than the normal distribution. If it is less than 3, it means that the data sequence is more concentrated than the normal distribution.
[0088] 2) Integral and Variance
[0089] The integral and variance of the current sampling point i are calculated by integrating and calculating the variance of the sampled values within a recent power frequency cycle T at the current sampling point i. The residual current data Id i and total current data Ia i The integral and variance are denoted as INTGd, respectively. i 、Dd i INTGa i Da i The specific calculation formula is as follows:
[0090]
[0091]
[0092]
[0093]
[0094] Where Id mean Ia mean It is the average value of the residual current over a recent power frequency cycle T.
[0095] 3) Peak-to-peak value
[0096] The peak-to-peak value of the current sampling point i is the difference between the previous peak value and the previous reverse peak value. The peak-to-peak value of the total residual current and the total current is denoted as Pvd. i Pva i .
[0097] 4) Current amplitude
[0098] The amplitude of the current at the current sampling point i, and the amplitude of the residual current at time i, are denoted as Ad. i The magnitude of the total current at time i is denoted as Aa. i .
[0099] 5) Shannon entropy
[0100] Shannon entropy is used to characterize the degree of uncertainty of a random variable. A higher information entropy indicates a more discrete information sequence and stronger uncertainty, while a lower entropy indicates less uncertainty. The power spectrum information entropy Pse is calculated from the sampled values within a recent period T at the current sampling point i. i The calculated total current power spectral entropy Pse i Represented as:
[0101]
[0102] Among them, P i This indicates the total power of the low-voltage user.
[0103] 6) Pulse Indicators
[0104] The impulse index, also known as the impulse factor, is defined as the ratio of the signal peak value to its absolute mean (rectified average value), and it indicates the impulse nature of the signal. The formula for calculating the impulse index is shown in Formula 28:
[0105]
[0106] 7) Waveform factor
[0107] The waveform index, also known as the waveform factor, is defined as the ratio of the root mean square value of the signal (at the i-th sampling point) to its absolute mean. It represents the difference and degree of distortion between the actual waveform and a standard sine wave. The formula for calculating the waveform index is as follows:
[0108]
[0109] x rms x represents the root mean square value of the i-th sampling point over one power frequency cycle; i This represents the i-th sampling point; The absolute mean of the most recent power frequency cycle; The mean is denoted as N; N represents the number of samples in one power frequency cycle.
[0110] By integrating the above eight features to form a multi-dimensional feature vector, an initial low-voltage fault discrimination feature sample set is constructed.
[0111] In step S02 of this embodiment, an improved genetic algorithm is used to screen each feature in the initial fault discrimination feature sample set, such as... Figure 4 As shown, the specific steps include:
[0112] Step S201. The features to be screened are regularized into a vector to form a chromosome Chrom_q. The chromosome includes all recombinable features, and each chromosome uniquely corresponds to a feature value. M chromosome vectors Chrom_q[p] are generated using random numbers, where the M variable is used to store the total number of the current population, q is used to identify the uniquely determined chromosome, and p is used to identify the feature value in the chromosome.
[0113] Step S202. Each chromosome corresponds to a detection model built based on the random forest algorithm. A set of training data is obtained and input into the detection model corresponding to the q-th chromosome Chrom_q to obtain the actual detection value L_q^a of the detection model corresponding to the chromosome Chrom_q. The fit degree Fit_q between the actual detection value L_q^a and the expected value L_q^d is calculated. After completing one calculation, q is incremented by q++ until the entire population is traversed. By traversing the entire population, a q is found that makes the fit degree Fit_q < δ, where δ is a preset fit degree value. If found, the training is completed and the feature combination of the training is output. If no q that meets the requirements is found, then step S203 is performed after the traversal is completed.
[0114] Step S203. Sort all chromosomes from largest to smallest according to their Fit_q value, select the specified number of chromosomes Chrom_q[p] and form a winning matrix A by row, that is, form a winning matrix A with each chromosome in a row. Eliminate the remaining unselected chromosomes Chrom_q[p] and form a substandard matrix B by row, that is, classify them into substandard matrix B with each chromosome in a row.
[0115] Step S204. Perform genetic operations and directed mutation operations on the offspring. During the directed mutation operation, determine whether the mutation parameter is a key feature parameter. If it is, control the direction of change during the update so that it does not mutate towards the feature value of the eliminated chromosome. The key feature parameter is the feature parameter that needs to be eliminated, which is selected based on the difference between the winning matrix and the elimination matrix. Return to step S202.
[0116] This embodiment utilizes an improved genetic algorithm for feature selection. By mining the "reasons" of eliminated individuals based on their fit, it controls the direction of mutation, preventing mutations from leading to elimination. This allows for the stable and effective selection of the optimal combination of leakage fault features, effectively improving the model's training efficiency and accuracy, thereby enhancing the efficiency and accuracy of leakage fault detection.
[0117] The specific expression for calculating the fit Fit_q mentioned above is as follows:
[0118]
[0119] In this embodiment, step S204 includes the following specific steps:
[0120] Step S241. Let rowA, rowB, and col be the index variables of the matrix and initialize them to 1. Here, rowA, rowB, and col represent the rows of the winning matrix A, the rows of the losing matrix B, and the columns of the two matrices, respectively. Calculate the average between rowA and col, the average between rowB and col, and the difference between the two averages. After each calculation, the value of col is incremented by one until the value of col reaches the preset threshold.
[0121] Step S242. Differ for each column col Sort by size from largest to smallest, select the feature values corresponding to the first specified number of columns as the key feature indicators for controlling elimination. These key feature indicators are used to control the direction in subsequent mutation operations, and the key feature values will not mutate in the direction of the eliminated chromosome feature values.
[0122] Step S243. Genetic operation: The chromosomes in the winning matrix A are copied and the copied chromosomes are randomly cross-crossed to generate new offspring chromosomes. The variable M is updated, that is, the total number of chromosomes in set A increases, and the new value is assigned to variable M to form a new population.
[0123] Step S244. Mutation operation: Fine-tune the parameters of the chromosomes in the winning matrix A, that is, randomly change them within a small range. First, randomly select mutation parameters. If the selected mutation parameters are not the key feature indicators, use a random function to generate random values to update the mutation parameters. If the selected mutation parameters are the key feature indicators, control the direction of change to update the mutation parameters, and do not mutate in the direction of the eliminated chromosome feature quantity.
[0124] In step S41 above, the corresponding average Mean can be calculated using the following formula:
[0125]
[0126]
[0127] Calculate the percentage difference between two means. col :
[0128]
[0129] In step S244 above, the mutation parameter is randomly selected, specifically by selecting index p according to the following formula:
[0130]
[0131] The random() function generates random numbers between (0,1).
[0132] If the index value of the randomly selected mutation parameter is not a key feature indicator, then the mutation parameter Chrom is updated according to the following formula. q [p]:
[0133] Chrom q [p]=Chrom q [p]+r(0.5-random()) (17)
[0134] If the index value points to a key feature indicator, then the mutation parameter Chrom is updated according to the following formula. q [p], to control the direction of change during updates:
[0135]
[0136] Where r is the step size during the update. The average of rowA and col. This is the average between rowB and col.
[0137] The step of training the detection model in step S03 of this embodiment includes:
[0138] Step S301. Divide the fault discrimination feature sample set into a training set and a test set according to the proportion, select the feature vector as the model input, and the state code as the model output;
[0139] Step S302. Initially set hyperparameters for pre-training, and simultaneously optimize multiple hyperparameters of the model using the particle swarm optimization algorithm;
[0140] Step S303. Perform model training until the model training loss value reaches the minimum, terminate the iteration, and output the optimal hyperparameter values;
[0141] Step S304. Set the detection model to the obtained optimal hyperparameters and use the test set to test the effect of the detection model. If the preset performance requirements are met, the model training is completed.
[0142] This embodiment builds a leakage current detection model based on the random forest algorithm, optimizes the model hyperparameters using the particle swarm optimization algorithm, and trains the model using a leakage current fault discrimination feature sample set, thereby enabling accurate detection of leakage current faults in low-voltage power distribution systems.
[0143] After optimizing the hyperparameters of the random forest algorithm model using the particle swarm optimization algorithm, the specific hyperparameters selected in this embodiment are the number of decision trees (n_estimators), the maximum depth of the constructed tree (max_depth), and the number of features considered when limiting branching (max_features).
[0144] This embodiment further adopts the principle of majority rule for the output of all decision trees as the final low-voltage customer perception result, instead of the output of a single model. That is, each decision tree in the random forest model outputs a fault category, and the principle of majority rule is adopted to obtain the overall leakage fault detection result. This can avoid the drawback of traditional neural networks being prone to getting stuck in local extrema during training, and allows the ensemble classifier to consider multiple cases at the same time, so that it will not be affected by the problem of local extrema. This greatly reduces the probability of overfitting problems that are prone to occur in traditional neural networks and enhances the generalization ability.
[0145] like Figure 5 As shown, in a specific application embodiment, the feature dataset is first divided into a training set and a test set, and then Bootstrap resampling (Bootstrap has sampling with replacement, such as...) is used. Figure 6 The method (shown) randomly selects multiple training sample subsets from the training sample set, performs decision tree modeling on each subset, combines the decision results of multiple trees, and finally determines the detection result through voting, thus completing the establishment of the low-voltage system leakage detection model. The specific steps are as follows:
[0146] ① Model pre-training
[0147] By using the training set as input to the RF model, a low-voltage system leakage current detection model can be trained. Finally, the leakage current detection performance of the low-voltage system leakage current detection model can be tested using the test set.
[0148] This invention uses RandomForestRegressor to build the model, where n_estimators is the number of decision trees; random_state is the random number seed for each tree when resampling (i.e., out-of-bag random sampling with replacement) using Bootstrap in the Bagging strategy; fit is used to train the model, and predict is used to make predictions.
[0149] 1) Import the relevant packages
[0150] Import the RandomForestClassifier from sklearn_ensemble; import the dataset from sklearn.datasets using the load() function; import the read_excel method from the pandas package to read the data; import the matplotlib.pyplot module for visualizing the transformation process of the base classifier and its corresponding classification accuracy.
[0151] 2) Import and read the dataset, and set the relevant parameters.
[0152] Import the dataset containing data of the circuit under normal operating conditions and under leakage fault conditions, i.e., data = load_OD(); use the read_excel method from the imported Pandas package to read the OD dataset.
[0153] After setting the parameters, use the `fit` function to train the model, using the training data as parameters to enter the training phase, and then output the trained random forest model.
[0154] ② Model hyperparameter optimization
[0155] The random forest model was pre-trained, and then multiple hyperparameters of the random forest model were optimized using the particle swarm optimization algorithm. The resulting hyperparameter combinations of the random forest model are shown in Table 1.
[0156] Table 1 Random Forest Model Parameter Settings
[0157]
[0158] ③ Model Evaluation and Use
[0159] The `score` function is used to evaluate the classification ability of the forest model on the test set using random forest algorithm, and the corresponding evaluation value is output as the evaluation index of the model's classification ability. This evaluation value indicates that the low-voltage system leakage current detection model based on random forest algorithm is qualified.
[0160] The test feature dataset is used as input to the random forest model. Each decision tree in the model outputs a working state judgment result. Following the principle of "majority rule," the recognition results of all decision trees are statistically analyzed, and the perception state with the largest percentage of results is taken as the final result of the low-voltage system leakage detection model. The predict function is used with the test set as input to the model to view the output and obtain the corresponding category (normal operation label: "0", leakage state label: "1").
[0161] ④ Model Testing
[0162] To demonstrate the effectiveness of this invention, multiple real-world leakage current experiments were conducted in specific application embodiments to select effective data samples for in-depth testing of the established leakage current detection model. Specifically, tens of thousands of experimental data points that did not overlap with the training data samples were selected and their order was shuffled. Interference samples were added (including frequent load switching interference caused by operating the load switching switch of the nearby branch under normal and leakage fault conditions; interference caused by increasing the line length of the ground capacitance simulation panel to increase the line leakage current to ground; and interference caused by increasing the leakage fault sensing distance).
[0163] Furthermore, a two-dimensional matrix composed of test set labels and model test set output labels is used as input to the confusion matrix algorithm model, outputting confusion matrices for three models. The number of false recognitions by the model can be determined from the confusion matrix, and the detection accuracy of the leakage current detection model considering multiple interference factors can be calculated. Experimental results show that this invention can accurately detect leakage current under various operating conditions.
[0164] This embodiment fully considers interference factors in actual power consumption scenarios, such as excessive normal leakage current and frequent load switching of branches near the fault. It collects raw residual current data that closely resembles real fault scenarios to the greatest extent possible. By preprocessing the total raw residual current data, the Fourier transform algorithm is used to extract time-frequency domain features from the dataset. At the same time, an improved genetic algorithm is used to control the direction of mutation and perform deep feature screening on the time-frequency domain features to obtain the most effective fault feature combination for leakage fault detection. This completes the establishment and training of the low-voltage system leakage detection model. Finally, the leakage detection model is deeply tested using real-time data containing interference samples. It can be applied to real leakage fault scenarios with multiple interference factors, reducing the complexity of fault detection and improving the efficiency and accuracy of leakage fault detection under the condition of considering multiple interference factors.
[0165] This embodiment also provides a low-voltage power distribution system leakage current detection device, including a processor and a memory. The memory is used to store a computer program, and the processor is used to execute the computer program to perform the method described above.
[0166] It is understood that the method described in this embodiment can be executed by a single device, such as a computer or server, or it can be applied to a distributed scenario where multiple devices cooperate to complete the task. In a distributed scenario, one of the multiple devices may execute only one or more steps of the method described in this embodiment, and the multiple devices interact to complete the method. The processor can be implemented using a general-purpose CPU, microprocessor, application-specific integrated circuit, or one or more integrated circuits, and is used to execute relevant programs to implement the method described in this embodiment. The memory can be implemented using read-only memory (ROM), random access memory (RAM), static storage devices, and dynamic storage devices. The memory can store the operating system and other applications. When the method described in this embodiment is implemented through software or firmware, the relevant program code is stored in the memory and called and executed by the processor.
[0167] The above description is merely a preferred embodiment of the present invention and is not intended to limit the invention in any way. Although the present invention has been disclosed above with reference to preferred embodiments, it is not intended to limit the invention. Therefore, any simple modifications, equivalent changes, and alterations made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention should fall within the protection scope of the present invention.
Claims
1. A method for detecting leakage current in a low-voltage power distribution system, characterized in that the steps include: include: Step S01. Collect data on the normal operation of the low-voltage power distribution system under different interference factors and the residual current data when a leakage fault occurs. Process the data and extract features to construct an initial fault discrimination feature sample set. The interference factors include controlling the load switching of branches near the fault, increasing the line length of the ground capacitance simulation panel, and increasing the leakage fault sensing distance. The extracted features include peak-to-peak value. Current amplitude, integral Shannon entropy Kudo Any one or more of variance, impulse factor, and waveform factor; Step S02. Use a genetic algorithm to screen each feature in the initial fault discrimination feature sample set, select the optimal feature combination, and obtain the final fault discrimination feature sample set. The genetic algorithm uses a directed mutation operation in the feature screening process, and controls the mutation direction so that it does not mutate in the direction of eliminating chromosome features. Step S03. Use the final fault discrimination feature sample set to train the detection model built based on the random forest algorithm. After training, the detection model is obtained for detecting and identifying leakage faults in low-voltage power distribution systems.
2. The method for detecting leakage current in a low-voltage power distribution system according to claim 1, characterized in that, In step S02, an improved genetic algorithm is used to screen the features in the initial fault discrimination feature sample set. The steps include: Step S201. The features to be screened are normalized into a vector to form a chromosome Chrom_q; M chromosome vectors Chrom_q[p] are generated using random numbers, where M variables are used to store the total number of the current population, q is used to identify the unique chromosome, and p is used to identify the feature quantity in the chromosome. Step S202. Obtain a set of training data and input it into the detection model corresponding to the q-th chromosome Chrom_q to obtain the actual detection value corresponding to chromosome Chrom_q. Calculate the fit Fit_q between the actual detection value and the expected value. Find a q that makes Fit_q < δ by traversing the entire population, where δ is a preset fit value. If found, training is complete, and the feature combination that has been trained is output. If no q that meets the requirements is found, proceed to step S203 after traversing the entire population. Step S203. Sort all chromosomes from largest to smallest according to their Fit_q value, select the first specified number of chromosomes Chrom_q[p] and form a winning matrix A by row, and eliminate the remaining unselected chromosomes Chrom_q[p] and form a losing matrix B by row. Step S204. Perform genetic operations and directed mutation operations on the offspring. During the directed mutation operation, determine whether the mutation parameter is a key feature parameter. If it is, control the direction of change during the update so that it does not mutate towards the feature value of the eliminated chromosome. The key feature parameter is the feature parameter that needs to be eliminated, which is selected based on the difference between the winning matrix and the elimination matrix. Return to step S202.
3. The method for detecting leakage current in a low-voltage power distribution system according to claim 2, characterized in that, The steps in step S204 include: Step S241. Let rowA, rowB, and col be the index variables of the matrix and initialize them to 1. Here, rowA, rowB, and col represent the rows of the winning matrix A, the rows of the losing matrix B, and the columns of the two matrices, respectively. Calculate the average between rowA and col, the average between rowB and col, and the difference between the two averages. After each calculation, the value of col is incremented by one until the value of col reaches the preset threshold. Step S242. Transfer each column's... Sort by size from largest to smallest, and select the feature values corresponding to the first specified number of columns as the key feature indicators for controlling elimination; Step S243. Genetic operation: The chromosomes in the winning matrix A are copied and the copied chromosomes are randomly cross-crossed to generate new offspring chromosomes, update variable M, and form a new population; Step S244. Mutation operation; Fine-tune the parameters of the chromosomes in the winning matrix A. First, randomly select mutation parameters. If the selected mutation parameters are not the key feature indicators, use a random function to generate random values to update the mutation parameters. If the selected mutation parameters are the key feature indicators, control the direction of change to update the mutation parameters so that they do not mutate in the direction of the eliminated chromosome feature quantity.
4. The method for detecting leakage current in a low-voltage power distribution system according to claim 3, characterized in that, In step S244, if the index value of the randomly selected variation parameter is not a key feature indicator, the variation parameter is updated according to the following formula. Chrom q [p]: Among them, random() is a function that generates random numbers between (0,1); If the index value points to a key feature indicator, then the variation parameter is updated according to the following formula. Chrom q [p], to control the direction of change during updates: Where r is the step size during the update. The average of rowA and col. This is the average between rowB and col.
5. The method for detecting leakage current in a low-voltage power distribution system according to claim 1, characterized in that, Step S03, which involves training the detection model, includes: Step S301. Divide the fault discrimination feature sample set into a training set and a test set according to the proportion, select the feature vector as the model input, and the state code as the model output; Step S302. Initially set hyperparameters for pre-training, and simultaneously optimize multiple hyperparameters of the model using the particle swarm optimization algorithm; Step S303. Perform model training until the model training loss value reaches the minimum, terminate the iteration, and output the optimal hyperparameter values; Step S304. Set the detection model to the obtained optimal hyperparameters and use the test set to test the effect of the detection model. If the preset performance requirements are met, the model training is completed.
6. The method for detecting leakage current in a low-voltage power distribution system according to claim 1, characterized in that, The residual current data is the total residual current data, which is collected according to the following steps: A leakage current detection platform was constructed, which uses a ground capacitance simulation panel to simulate the line-to-ground capacitance and incorporates the interference factor of line-to-ground leakage current on the detection of leakage current faults in low-voltage users. When collecting data on normal and faulty residual current of the line, the load switching of the load on the faulty branch is turned on and off to introduce interference factors for leakage fault detection. Increase the sensing distance between the residual current sensor and the location of the leakage fault; Record the total residual current data of the line under normal operating conditions and when leakage faults occur, taking into account various interference factors.
7. The method for detecting leakage current in a low-voltage power distribution system according to any one of claims 1 to 6, characterized in that, In step S01, data processing includes any one or more of the following: baseline removal, data denoising, sliding time window sequence extraction, and normalization.
8. The method for detecting leakage current in a low-voltage power distribution system according to claim 7, characterized in that, The step of eliminating the baseline value includes: taking the average value of all unloaded data, subtracting the average value of the unloaded data from all current data to eliminate the baseline value of the conditioning circuit, and obtaining accurate total residual current data, i.e.: in, Let i be the data sample at time i. The number of empty samples. for Empty sample data.
9. A leakage current detection device for a low-voltage power distribution system, comprising a processor and a memory, wherein the memory is used to store a computer program, characterized in that, The processor is used to execute the computer program to perform the method as described in any one of claims 1 to 8.