Spare power automatic switching risk prediction method and system for smart power grid

By constructing a backup power supply risk prediction method based on dynamic feature extraction and multi-model collaborative analysis, the problem of insufficient accuracy and strategy adaptability in risk prediction in smart grids is solved, achieving efficient risk assessment and execution strategy generation, and improving the safety and stability of the power grid.

CN121032175APending Publication Date: 2025-11-28SUIZHOU POWER SUPPLY COMPANY STATE GRID HUBEI ELECTRIC POWER
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202510884143.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-30
Publication Date
2025-11-28

AI Technical Summary

Technical Problem

Existing methods for predicting backup power supply risks in smart grids suffer from low prediction accuracy and insufficient strategy adaptability, failing to effectively address the impact of complex grid structures and external disturbances.

Method used

A comprehensive and dynamic feature extraction system is constructed. An initial feature set is collected using a sliding window, and time-series and frequency-domain features are processed through random forest and XGBoost models to generate a dynamic feature set. A multi-objective optimized self-initiated execution strategy is generated by combining a reinforcement learning environment model, and then adjusted through a proximal policy optimization algorithm.

Benefits of technology

It significantly improves the accuracy of backup power supply risk prediction and the adaptability of the strategy, taking into account power supply continuity, equipment safety and economic cost, and achieves synergistic optimization of feature acquisition and strategy generation.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121032175A_ABST
    Figure CN121032175A_ABST
Patent Text Reader

Abstract

The invention provides a spare power automatic switching risk prediction method and system for a smart power grid, and relates to the technical field of smart power grids, and the method comprises the steps: collecting and screening an initial feature set of the smart power grid, and generating a dynamic feature set; outputting a conventional risk probability based on a time sequence feature through a random forest model, identifying a sudden abnormal mode based on a frequency domain feature through an XGBoost model, and synchronously generating a feature importance matrix; determining a power grid state by combining the time sequence characteristics and the frequency domain characteristics, dynamically fusing output results of the models according to fusion weights of the models determined by the power grid state, and generating a comprehensive risk level; inputting the comprehensive risk level and the dynamic feature set into a reinforcement learning environment model, and solving a multi-objective function generated by the model to obtain a spare power automatic switching execution strategy; and executing the spare power automatic switching execution strategy, and dynamically adjusting the sliding window for feature acquisition until the execution result meets the preset condition, so that the accuracy of spare power automatic switching risk prediction and the adaptability of the strategy are remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of smart grid technology, and in particular to a method and system for predicting backup power supply risks in smart grids. Background Technology

[0002] With the continuous advancement of energy technologies and the increasing demand for electricity, smart grids, as an important development direction of modern power systems, are gradually becoming a research hotspot in the power industry. By integrating advanced sensing, communication, and control technologies, smart grids achieve real-time monitoring, precise control, and efficient management of the power grid's operating status, greatly improving the reliability, security, and economy of power supply.

[0003] However, smart grids face numerous complex risk factors during operation. On the one hand, the increasingly complex grid structure and the large-scale integration of new power components such as distributed power sources and energy storage devices have significantly changed the dynamic characteristics and operating modes of the grid, increasing the likelihood and uncertainty of grid failures. On the other hand, external environmental disturbances, such as natural disasters and human-caused damage, can also severely impact the grid, leading to abnormal grid operation or even power outages.

[0004] Automatic transfer switch (ATS) systems are crucial for ensuring power continuity in smart grids. When the main power source fails due to a fault or other reasons, the ATS system can quickly and automatically activate the backup power source, thereby reducing outage time and improving power supply reliability. Therefore, accurately predicting the risks associated with ATS systems and developing reasonable implementation strategies are of great significance for ensuring the safe and stable operation of smart grids.

[0005] Currently, most existing methods for predicting self-reinforced reserve risk are based on traditional statistical analysis or simple machine learning algorithms.

[0006] Therefore, it is necessary to provide a method and system for predicting backup automatic transfer risks in smart grids to solve the above-mentioned technical problems. Summary of the Invention

[0007] To address the aforementioned technical problems, this invention provides a method and system for predicting backup power generation risk in smart grids. By constructing a comprehensive and dynamic feature extraction system, a multi-model collaborative analysis mechanism, a multi-objective optimization strategy generation framework, and a closed-loop feedback system for feature acquisition and strategy execution, the accuracy of backup power generation risk prediction and the adaptability of the strategy are significantly improved.

[0008] On the one hand, the present invention provides a method for predicting the risk of automatic backup power transfer in smart grids, the method comprising the following steps:

[0009] The initial feature set of the smart grid is collected based on a sliding window, and the initial feature set is filtered according to feature processing rules to generate a dynamic feature set, wherein the dynamic feature set includes time-series features and frequency domain features.

[0010] The pre-trained random forest model outputs the regular risk probability based on the time-series features, and the pre-trained XGBoost model identifies sudden anomaly patterns based on the frequency domain features, and simultaneously generates a feature importance matrix for adjusting the feature processing rules.

[0011] The power grid state is determined by combining the time-series and frequency-domain features, and the output results of each model are dynamically fused according to the fusion weights of each model determined by the power grid state to generate a comprehensive risk level.

[0012] The comprehensive risk level and the dynamic feature set are input into the reinforcement learning environment model, and the multi-objective function generated by the reinforcement learning environment model is solved based on the near-end policy optimization algorithm to obtain the backup self-initiation execution strategy.

[0013] The backup self-supply strategy is executed, and the sliding window for feature acquisition is dynamically adjusted according to the execution result until the execution result meets the preset conditions.

[0014] Preferably, the step of acquiring an initial feature set of the smart grid based on a sliding window, and filtering the initial feature set according to feature processing rules to generate a dynamic feature set includes:

[0015] Based on the preset sliding window length and sliding step size, the raw data of main power supply voltage, backup power supply capacity and load distribution are collected in real time to generate an initial feature set.

[0016] The initial feature set is subjected to variance threshold screening and Pearson correlation analysis, and the feature set that meets the preset threshold conditions is retained to form a candidate feature set;

[0017] The candidate feature set is subjected to time-frequency decomposition to extract time-series features and frequency-domain features. The time-series features include the mean voltage fluctuation rate and the discrete first-order difference of the load change rate within the sliding window. The frequency-domain features include the harmonic distortion rate and the spectral energy proportion of the transient oscillation frequency.

[0018] The time-series features and frequency-domain features are fused according to preset weights to generate a dynamic feature set.

[0019] Preferably, the pre-trained random forest model outputs a regular risk probability based on the time-series features, and the pre-trained XGBoost model identifies sudden anomaly patterns based on the frequency domain features, while simultaneously generating a feature importance matrix for adjusting the feature processing rules, including:

[0020] The time-series features in the dynamic feature set are input into a pre-trained random forest model, which outputs the regular risk probability and calculates the contribution score of each time-series feature to risk prediction.

[0021] The frequency domain features in the dynamic feature set are input into the pre-trained XGBoost model to identify sudden anomaly patterns and calculate the discrimination score of each frequency domain feature for anomaly detection.

[0022] The contribution score and the discrimination score are normalized to generate a feature importance matrix.

[0023] Preferably, the adjustment of the feature processing rules by the feature importance matrix includes:

[0024] Based on the normalized feature importance matrix, the contribution score of time-series features and the discriminative score of frequency-domain features are extracted respectively.

[0025] The contribution score and the discrimination score are independently ranked, and key features that meet the following conditions are selected:

[0026] The contribution score of the time series feature is higher than the preset time series score threshold;

[0027] The discrimination score of the frequency domain feature is higher than the preset frequency domain score threshold;

[0028] The variance threshold, minimum correlation coefficient of Pearson correlation analysis, and / or preset weights for fusion are dynamically adjusted based on the scoring type of key features.

[0029] Preferably, the step of determining the power grid state by combining the time-series features and frequency-domain features, and dynamically fusing the output results of each model according to the fusion weights of each model determined by the power grid state to generate a comprehensive risk level, includes:

[0030] Based on the mean voltage fluctuation rate and harmonic distortion rate, the power grid status is classified according to a preset classification rule;

[0031] Based on the power grid status, the fusion weights are dynamically allocated according to a preset weight allocation function;

[0032] The probability of conventional risks and the pattern of sudden anomalies are weighted and fused according to dynamically allocated fusion weights to generate a comprehensive risk level.

[0033] Preferably, the step of inputting the comprehensive risk level and the dynamic feature set into the reinforcement learning environment model, and solving the multi-objective function generated by the reinforcement learning environment model based on the proximal policy optimization algorithm to obtain the alternative self-initiation execution strategy includes:

[0034] A reinforcement learning environment model is constructed with multiple optimization objectives, including power supply continuity, equipment safety, and economic cost.

[0035] The state space is generated by jointly encoding the comprehensive risk level and the temporal and frequency domain features in the dynamic feature set;

[0036] The action space includes the standby automatic transfer delay time and the discrete action set of reactive power compensation equipment switching commands;

[0037] The reward function is based on the multi-objective optimization objective and defines a weighted sum of the power supply continuity score, equipment safety score, and economic benefit score.

[0038] Based on the proximal policy optimization algorithm, the following operations are performed in the reinforcement learning environment model:

[0039] The exploration starting point for the strategy network is initialized using the aforementioned comprehensive risk level;

[0040] Pareto optimal policy set is generated through policy gradient update iteration, where each policy update is constrained by the feature importance matrix;

[0041] Select backup self-starting execution strategies that meet the preset optimization constraints from the Pareto optimal strategy set.

[0042] Preferably, the step of executing the backup self-deployment strategy and dynamically adjusting the sliding window of feature acquisition based on the execution result until the execution result meets the preset conditions includes:

[0043] The automatic transfer switch strategy is executed, and the voltage sag and harmonic distortion rate are monitored in real time and used as the execution result.

[0044] Based on the execution results, the length and step size of the sliding window are dynamically adjusted according to a preset adjustment logic;

[0045] Based on the adjusted sliding window, an updated backup self-reinforcement execution strategy is generated until the preset conditions are met.

[0046] On the other hand, the present invention also provides a backup power supply (SPFS) risk prediction system for smart grids, used to execute a backup power supply (SPFS) risk prediction method for smart grids, the system comprising:

[0047] The feature dynamic filtering module is used to collect the initial feature set of the smart grid based on a sliding window, and filter the initial feature set according to feature processing rules to generate a dynamic feature set, wherein the dynamic feature set includes time-series features and frequency domain features.

[0048] The model prediction module is used to output the regular risk probability based on the time-series features using a pre-trained random forest model, and to identify sudden abnormal patterns based on the frequency domain features using a pre-trained XGBoost model, and simultaneously generate a feature importance matrix for adjusting the feature processing rules.

[0049] The risk assessment module is used to determine the power grid status by combining the time-series features and frequency-domain features, and to dynamically fuse the output results of each model according to the fusion weights of each model determined by the power grid status to generate a comprehensive risk level.

[0050] The reinforcement strategy generation module is used to input the comprehensive risk level and the dynamic feature set into the reinforcement learning environment model, and solve the multi-objective function generated by the reinforcement learning environment model based on the near-end policy optimization algorithm to obtain the backup self-injection execution strategy.

[0051] The dynamic adjustment module is used to execute the backup self-supply strategy and dynamically adjust the sliding window of feature acquisition according to the execution result until the execution result meets the preset conditions.

[0052] Compared with related technologies, the backup power switching risk prediction method and system for smart grids provided by this invention have the following beneficial effects:

[0053] In feature extraction, this invention comprehensively collects and filters initial features using a sliding window, generating a dynamic feature set containing both temporal and frequency domain features, laying the foundation for accurate prediction. Regarding model application, random forest and XGBoost models are used to process temporal and frequency domain features respectively, simultaneously generating a feature importance matrix to dynamically adjust feature processing rules and improve prediction accuracy. In the policy generation stage, a multi-objective reinforcement learning environment model is constructed, and a Pareto optimal policy set is generated based on a proximal policy optimization algorithm. Execution policies that meet optimization constraints are selected, balancing power supply continuity, equipment safety, and economic cost. Furthermore, after policy execution, the feature acquisition sliding window is dynamically adjusted based on the results, achieving coordinated optimization of feature acquisition and policy generation. Attached Figure Description

[0054] Figure 1 A flowchart of a method for predicting the risk of automatic backup power transfer in smart grids provided by the present invention;

[0055] Figure 2 This invention provides a schematic diagram of the module structure of a backup power supply risk prediction system for smart grids. Detailed Implementation

[0056] The present invention will now be described in further detail with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and not intended to limit it. Furthermore, it should be noted that, for ease of description, only the parts relevant to the invention are shown in the drawings, not all structures. Moreover, unless otherwise specified, the embodiments and features described herein can be combined with each other.

[0057] It should also be noted that, for ease of description, the accompanying drawings show only the parts relevant to the invention and not all of them. Before discussing exemplary embodiments in more detail, it should be mentioned that some exemplary embodiments are described as processes or methods depicted as flowcharts. Although the flowcharts describe the operations (or steps) as sequential processes, many of the operations can be performed in parallel, concurrently, or simultaneously. Furthermore, the order of the operations can be rearranged. The process can be terminated when its operation is completed, but it may also have additional steps not included in the drawings. The process may correspond to a method, function, procedure, subroutine, subprogram, etc.

[0058] Example 1

[0059] On the one hand, this invention provides a method for predicting backup power generation risk in smart grids, referring to... Figure 1 As shown, the method includes the following steps:

[0060] S1: The initial feature set of the smart grid is collected based on a sliding window, and the initial feature set is filtered according to the feature processing rules to generate a dynamic feature set, wherein the dynamic feature set includes time-series features and frequency domain features.

[0061] Specifically, step S1 includes the following steps:

[0062] S11: Based on the preset sliding window length and sliding step size, collect raw data of main power supply voltage, backup power supply capacity and load distribution in real time to generate an initial feature set.

[0063] In step S11, based on a preset sliding window length (e.g., 1 second) and sliding step size (e.g., 200 ms), raw data on the main power supply voltage, backup power supply capacity, and load distribution are collected in real time using, but not limited to, smart meters or sensors, to form an initial feature set. Specifically, the main power supply voltage is obtained as an instantaneous value through a voltage transformer at a sampling rate of 10 kHz; the backup power supply capacity is read from the SOC (State of Charge) status by the battery management system; and the load distribution is collected as real-time power data for each branch by current sensors in the smart distribution cabinet. This step ensures the temporal continuity of the data through a sliding window mechanism. The setting of the window length and step size needs to balance real-time performance and computational efficiency. For example, in transient scenarios, the window can be shortened to 500 ms to improve response speed.

[0064] S12: Perform variance threshold screening and Pearson correlation analysis on the initial feature set, retaining those that meet the preset threshold conditions to form a candidate feature set.

[0065] In this embodiment, the initial feature set undergoes variance threshold screening (retaining features with variance greater than 1%) and Pearson correlation analysis (retaining features with a correlation coefficient |r| greater than 0.5 with the load peak) to eliminate low-variance noise features and redundant features, forming a candidate feature set. Specifically, variance threshold screening calculates the standard deviation of each feature value within a sliding window; specifically, the variance of voltage fluctuation rate is calculated as the square of the standard deviation of the voltage values ​​within the window, retaining features with a variance exceeding 1% to filter steady-state noise. Pearson correlation analysis calculates the correlation coefficient between each feature and the load peak, eliminating low-correlation features (such as backup power capacity fluctuations with a correlation coefficient |r| less than or equal to 0.5), thereby reducing feature dimensionality and improving subsequent processing efficiency.

[0066] S13: Perform time-frequency decomposition processing on the candidate feature set to extract time-series features and frequency domain features, wherein the time-series features include the mean voltage fluctuation rate and the discrete first-order difference of the load change rate within the sliding window, and the frequency domain features include the harmonic distortion rate and the spectral energy ratio of the transient oscillation frequency.

[0067] In this embodiment, step S13 performs time-frequency decomposition processing on the candidate feature set: time-series features are calculated using the sliding window mean (e.g., the voltage fluctuation rate mean is the average magnitude of the voltage deviation from the nominal value within the window), and combined with discrete first-order difference (load change rate = Δload / Δt) to capture short-term trends; frequency-domain features are extracted using FFT (Fast Fourier Transform), for example, the harmonic distortion rate is calculated as the ratio of the sum of squares of the amplitudes of each harmonic to the fundamental amplitude, and the spectral energy proportion of transient oscillation frequencies is obtained by calculating the percentage of energy in a specific frequency band (e.g., 50-500Hz) to the total energy of the entire frequency band. This step converts the original signal into a joint time-frequency domain representation, providing multi-dimensional input for the model.

[0068] S14: The time-series features and frequency-domain features are fused according to preset weights to generate a dynamic feature set.

[0069] In this embodiment, after eliminating dimensional differences using Z-score standardization, the data is weighted and summed. For example, the mean voltage fluctuation rate (time series) and harmonic distortion rate (frequency domain) are multiplied by 0.6 and 0.4 respectively and then summed to form a comprehensive feature vector. The weights are set based on historical data verification, and the optimal weight combination is determined through grid search to ensure the complementarity of time-frequency features. The fused dynamic feature set serves as a unified input for subsequent model processing, supporting the collaborative optimization of risk assessment and strategy generation.

[0070] S2: The pre-trained random forest model outputs the regular risk probability based on the time-series features, and the pre-trained XGBoost model identifies sudden abnormal patterns based on the frequency domain features, and simultaneously generates a feature importance matrix for adjusting the feature processing rules.

[0071] Specifically, step S2 includes the following steps:

[0072] S21: Input the time-series features in the dynamic feature set into the pre-trained random forest model, output the regular risk probability, and calculate the contribution score of each time-series feature to risk prediction.

[0073] In this embodiment, time-series features from the dynamic feature set (including the mean voltage fluctuation rate within the sliding window and the discrete first-order difference of the load change rate) are input into a pre-trained random forest model, which outputs a conventional risk probability. The contribution score of each time-series feature is calculated based on the Gini importance algorithm. The random forest model consists of 100 decision trees, each with a maximum depth of 10 layers. The node splitting criterion is minimizing Gini impurity. The specific process of calculating Gini importance is as follows: For each decision tree, all its internal nodes are traversed. When a certain time-series feature (such as the mean voltage fluctuation rate) is used for splitting in a node, the reduction in Gini impurity before and after the split is recorded. The calculation formula is:

[0074]

[0075] in, p i Let N be the proportion of the i-th type of sample in the node. 父 N 左 and N 右The contribution score is calculated by summing the reductions in Gini impurity for the feature across all decision trees, given the sample counts for the parent node, left child node, and right child node, and then dividing by the total number of trees. For example, if the cumulative reduction in the mean voltage volatility across 100 trees is 25, the contribution score is 0.25. During model training, a historical dataset (containing time-series features such as mean voltage volatility and load change rate, along with corresponding risk labels 0 / 1) is used. Hyperparameters are optimized through five-fold cross-validation. The final model is exported in ONNX format for real-time use.

[0076] S22: Input the frequency domain features from the dynamic feature set into the pre-trained XGBoost model to identify sudden anomaly patterns and calculate the discrimination score of each frequency domain feature for anomaly detection.

[0077] In this embodiment, frequency domain features (including harmonic distortion rate and the spectral energy proportion of transient oscillation frequencies) from the dynamic feature set are input into a pre-trained XGBoost model, which outputs the probability of sudden anomalies and calculates the discriminative score of each frequency domain feature based on the information gain algorithm. The XGBoost model consists of gradient boosting trees with the following parameters: learning rate 0.1, maximum tree depth 6 layers, L2 regularization coefficient λ = 1, and minimum number of leaf node samples 10. The information gain calculation process is as follows: During the node splitting process of each tree, the information gain brought by the splitting of candidate features (such as harmonic distortion rate) is calculated using the following formula:

[0078]

[0079] Among them, g i h is the first gradient of sample i (the derivative of the loss function with respect to the predicted value). i For the second-order gradient, I, I L and I R The sample index sets are the parent node, left child node, and right child node, respectively. γ is a complexity control parameter (default is 0.1). The sum of the information gains of all effective splits for each feature across all trees is the discriminant score. For example, if the cumulative information gain of harmonic distortion rate across 100 trees is 18.5, then the discriminant score is 18.5. Model training uses a labeled anomalous dataset (0 indicates normal, 1 indicates anomalous). Overfitting is prevented by early stopping (terminating after 10 consecutive rounds of validation set loss without improvement). The model exports its tree structure and weights in JSON format for real-time loading.

[0080] S23: Normalize the contribution score and the discrimination score to generate a feature importance matrix.

[0081] In this embodiment, the specific implementation process of step S23 is as follows:

[0082] Contribution score normalization: First, calculate the minimum and maximum contribution scores of all time series features. Subtract the minimum score from the score of each feature and then divide by the difference between the maximum and minimum scores. Map the result to the interval between 0 and 1.

[0083] Discrimination score normalization: Since the information gain of the XGBoost model may be negative (indicating that the split is invalid), all discrimination scores need to be shifted first, that is, the absolute value of the minimum score is added to make it non-negative, and then the results are mapped to the interval of 0 to 1 through linear normalization.

[0084] Matrix generation and storage: The normalized scores are organized into a two-dimensional array according to feature name (e.g., mean voltage fluctuation rate, harmonic distortion rate) and score type (contribution score, discrimination score), forming a feature importance matrix. The matrix data is stored in CSV format, updated every 5 minutes, and transmitted to downstream modules via a RESTful API.

[0085] Specifically, in step S2, the feature processing rules are adjusted using the feature importance matrix, including the following steps:

[0086] Based on the normalized feature importance matrix, the contribution score of time-series features and the discriminative score of frequency-domain features are extracted respectively.

[0087] In this embodiment, the contribution scores of time-series features and the discrimination scores of frequency-domain features are parsed from the normalized feature importance matrix. Specific features are located using row and column indexes in a CSV file (e.g., "mean voltage fluctuation rate" corresponds to the contribution score column, and "harmonic distortion rate" corresponds to the discrimination score column). Data is stored in key-value pairs. After parsing, the scores are stored in an in-memory database (e.g., Redis) for real-time querying. For example, if a feature has a contribution score of 0.85 (time-series feature) and a discrimination score of 0.62 (frequency-domain feature), it is marked as a high-priority feature.

[0088] The contribution score and the discrimination score are independently ranked, and key features that meet the following conditions are selected:

[0089] The contribution score of the time series feature is higher than the preset time series score threshold;

[0090] The discrimination score of the frequency domain feature is higher than the preset frequency domain score threshold.

[0091] In this embodiment, contribution scores and discrimination scores are independently sorted to filter key features that meet preset threshold conditions. The contribution score threshold for time-series features is set to 0.7 (determined through historical data verification), and the discrimination score threshold for frequency-domain features is set to 0.6. The sorting is done in descending order. For example, if the contribution score list is [0.85, 0.72, 0.68…], features with scores ≥ 0.7 (such as average voltage fluctuation rate 0.85, load change rate 0.72) are filtered out; if the discrimination score list is [0.92, 0.58, 0.45…], features with scores ≥ 0.6 (such as harmonic distortion rate 0.92) are filtered out. The filtering results are stored in a temporary queue, and a rule adjustment event is triggered.

[0092] The variance threshold, minimum correlation coefficient of Pearson correlation analysis, and / or preset weights for fusion are dynamically adjusted based on the scoring type of key features.

[0093] In this embodiment, the feature processing rule parameters are dynamically adjusted according to the scoring type of key features: for time-series features with a contribution score ≥ 0.7 (such as the mean voltage fluctuation rate), the variance threshold is reduced from 1% to 0.5%, and its fusion weight is increased (e.g., from 0.6 to 0.7); for frequency domain features with a discrimination score ≥ 0.6 (such as harmonic distortion rate), the minimum correlation coefficient of Pearson correlation analysis is increased from 0.5 to 0.6, and the fusion weight is increased from 0.4 to 0.5. The adjusted parameters are updated in real time to the feature processing module in step S1 via an API interface, for example, by calling the / update_rules interface of the feature processing service and passing in JSON parameters. The adjusted rules take effect immediately, regenerating the dynamic feature set and triggering subsequent model iterations.

[0094] S3: Combine the time-series features and frequency-domain features to determine the power grid state, and dynamically fuse the output results of each model according to the fusion weights of each model determined by the power grid state to generate a comprehensive risk level.

[0095] Specifically, step S3 includes the following steps:

[0096] S31: Based on the average voltage fluctuation rate and harmonic distortion rate, classify the power grid status according to the preset classification rules.

[0097] In this embodiment, based on the average voltage fluctuation rate and harmonic distortion rate, the power grid state is classified into steady state, transient state, and fault state according to a preset classification rule. Specifically, the preset classification rule is as follows: when the average voltage fluctuation rate is ≤5% and the harmonic distortion rate is ≤3%, it is determined to be a steady state; when the average voltage fluctuation rate is >5% and ≤15% or the harmonic distortion rate is >3% and ≤10%, it is determined to be a transient state; when the average voltage fluctuation rate is >15% or the harmonic distortion rate is >10%, it is forcibly determined to be a fault state.

[0098] The mean voltage fluctuation rate is the time-series feature generated in step S1, calculated by the average deviation of the instantaneous voltage value from the nominal value within a sliding window; the harmonic distortion rate is the frequency-domain feature generated in step S1, calculated by extracting the ratio of the sum of squares of each harmonic amplitude to the fundamental amplitude using FFT. Threshold settings are based on historical power grid fault data analysis, for example, statistically, in 95% of steady-state scenarios, the voltage fluctuation rate is ≤5% and the harmonic distortion rate is ≤3%. The state classification results are converted into discrete labels (e.g., 0-steady-state, 1-transient, 2-fault state) by a state encoder and stored in the real-time state database.

[0099] S32: Based on the power grid status, dynamically allocate fusion weights according to a preset weight allocation function.

[0100] In this embodiment, the fusion weights of the random forest model and the XGBoost model are dynamically allocated according to the power grid state and a preset weight allocation function.

[0101] The weight allocation rules are as follows: in steady state, the random forest model accounts for 70%-90% of the weight, and the XGBoost model accounts for 10%-30% of the weight; in transient state, the XGBoost model accounts for 80%-95% of the weight, and the random forest model accounts for 5%-20% of the weight; in fault state, the XGBoost model weight is forced to be 100%.

[0102] In practice, weights are dynamically calculated using linear interpolation. For example, in transient scenarios, if the average voltage fluctuation is 10% (in the middle of the 5%-15% range), then the XGBoost weight is 87.5% (80% + (10-5) / (15-5) × 15%). The weight allocation function is implemented by querying a predefined weight mapping table, which is generated based on grid search and cross-validation optimization, stored in JSON format, and loaded into memory in real time. Weight adjustment signals are published to the model fusion module via a message queue (such as Kafka), triggering real-time weight updates.

[0103] S33: The probability of conventional risks and the sudden abnormality pattern are weighted and fused according to the dynamically allocated fusion weights to generate a comprehensive risk level.

[0104] In this embodiment, the probability of normal risks and the sudden abnormal patterns are weighted and fused according to dynamically allocated fusion weights to generate a comprehensive risk level.

[0105] The specific implementation includes: obtaining the normal risk probability (0-1 scale value) output by the Random Forest and the sudden anomaly probability (0-1 scale value) output by XGBoost from step S2, and then linearly weighting them according to the current weight allocation ratio. For example, if the Random Forest weight is 80% and the XGBoost weight is 20% in steady state, then the comprehensive risk level = 0.8 × normal risk probability + 0.2 × sudden anomaly probability. The weighted result is mapped to a risk level score of 0-100 using the Sigmoid function, and risk intervals are divided: 0-30 is low risk (green), 31-70 is medium risk (yellow), and 71-100 is high risk (red).

[0106] S4: Input the comprehensive risk level and the dynamic feature set into the reinforcement learning environment model, and solve the multi-objective function generated by the reinforcement learning environment model based on the near-end policy optimization algorithm to obtain the backup self-initiation execution strategy.

[0107] Specifically, step S4 includes the following steps:

[0108] S41: Construct a reinforcement learning environment model with multiple optimization objectives, including power supply continuity, equipment safety, and economic cost, where:

[0109] The state space is generated by jointly encoding the comprehensive risk level and the temporal and frequency domain features in the dynamic feature set;

[0110] The action space includes the standby automatic transfer delay time and the discrete action set of reactive power compensation equipment switching commands;

[0111] The reward function is based on the multi-objective optimization objective and defines a weighted sum of power supply continuity score, equipment safety score, and economic benefit score.

[0112] In this embodiment, a reinforcement learning environment model is constructed with multiple optimization objectives, including power supply continuity, equipment safety, and economic cost. The state space is jointly encoded by the comprehensive risk level (0-100 scale value) and time-series features (such as the mean voltage fluctuation rate) and frequency-domain features (such as harmonic distortion rate) from the dynamic feature set. Specifically, this is achieved through concatenation encoding: the comprehensive risk level is converted into a three-bit binary code (e.g., 85→1010101), and the time-series and frequency-domain features are Z-score standardized and the first four decimal places are taken (e.g., 0.75→0750), ultimately generating an 18-dimensional state vector. The action space includes the standby automatic transfer switching delay time (0ms / 200ms / 500ms) and reactive power compensation equipment switching commands (0-off / 1-STATCOM on / 2-SVC on), forming six discrete action combinations. The reward function is defined as the weighted sum of the power supply continuity score (weight 0.6), equipment safety score (weight 0.3), and economic benefit score (weight 0.1), where power supply continuity score = 1 - load shedding ratio, equipment safety score = 1 - (harmonic distortion rate / 10%), and economic benefit score = electricity price revenue base × (1 - switching delay time / 1000ms). Model parameters are optimized through distributed training using the Ray framework, and the environment interface is implemented based on the OpenAI Gym specification.

[0113] S42: Based on the proximal policy optimization algorithm, perform the following operations in the reinforcement learning environment model:

[0114] The exploration starting point for the strategy network is initialized using the aforementioned comprehensive risk level;

[0115] The Pareto optimal policy set is generated through policy gradient updates, where each policy update is constrained by the feature importance matrix.

[0116] In this embodiment, policy optimization is performed in a reinforcement learning environment model based on the Proximal Policy Optimization (PPO) algorithm. First, the policy network is initialized using the comprehensive risk level generated in step S3: high risk level (≥70) corresponds to an exploration rate ε = 0.3, and low risk level (<30) corresponds to ε = 0.1. The initialization parameters are sampled using a normal distribution (μ = 0, σ = 0.01). During policy updates, 500 trajectory data points are collected per round. When calculating the advantage function, the feature importance matrix generated in step S2 is used as a constraint: the action advantage value associated with high-importance features (score > 0.8) is multiplied by a weight of 1.5, and the action advantage value associated with low-importance features (score < 0.3) is multiplied by 0.5. The policy network adopts a two-layer fully connected structure (256-128 nodes), with a learning rate set to 3e-4. Each iteration performs 10 minibatch updates (batch_size = 64). After 200 iterations, a Pareto optimal policy set is generated and stored as an HDF5 format file. Each policy includes an action probability distribution and an expected reward value.

[0117] S43: Select backup self-starting execution strategies that satisfy preset optimization constraints from the Pareto optimal strategy set.

[0118] In this embodiment, backup automatic transfer execution strategies that meet preset optimization constraints are selected from the Pareto optimal strategy set. These constraints include: power supply continuity score ≥ 0.8 (corresponding to a load shedding ratio ≤ 20%), equipment safety score ≥ 0.7 (harmonic distortion rate ≤ 3%), and economic benefit score ≥ 0.6. The selection process uses the Non-Dominated Ranking Algorithm (NSGA-II). First, strategies that violate hard constraints (such as a safety score < 0.7) are excluded; the remaining strategies are then ranked according to the objective function weights.

[0119] For example, if the weighted score of strategy A is 0.6×0.85+0.3×0.75+0.1×0.9=0.825, and the weighted score of strategy B is 0.6×0.8+0.3×0.8+0.1×0.8=0.8, then strategy A is preferred. The finally selected strategy is encoded using the Protobuf protocol and transmitted to the execution module via a Kafka message queue. Simultaneously, the strategy feature vector is stored in the Neo4j graph database for subsequent traceability analysis. When no strategy satisfies all constraints, a degradation mode is initiated: the economic benefit score is relaxed to 0.5, and the sliding window adjustment mechanism in step S1 is triggered to regenerate the feature set.

[0120] S5: Execute the backup self-supply execution strategy, and dynamically adjust the sliding window of feature acquisition according to the execution result until the execution result meets the preset conditions.

[0121] Specifically, step S5 includes the following steps:

[0122] S51: Execute the backup automatic transfer strategy, monitor the voltage sag and harmonic distortion rate in real time, and use them as the execution result.

[0123] In this embodiment, the automatic transfer switch execution strategy generated in step S4 is executed, and the specific operation is realized through the intelligent circuit breaker and reactive power compensation device controller. Voltage sag amplitude (capturing instantaneous voltage values ​​at a 1kHz sampling rate using a voltage transformer and calculating the percentage drop in effective voltage values ​​between adjacent cycles) and harmonic distortion rate (calculating the total harmonic distortion (THD) through real-time FFT analysis of the 0-2kHz frequency band) are monitored in real time. Monitoring data is transmitted to the monitoring system via Modbus / TCP protocol, updated every 200ms, and stored as execution results in the time-series database InfluxDB. If a voltage sag amplitude exceeding 15% or a harmonic distortion rate exceeding 8% is detected, an alarm event is immediately triggered and recorded in the anomaly log.

[0124] S52: Based on the execution result, dynamically adjust the length and step size of the sliding window according to the preset adjustment logic.

[0125] In this embodiment, the sliding window parameters are dynamically adjusted based on the execution results: when the voltage sag is ≥10% or the harmonic distortion rate is ≥6% within three consecutive window periods, the sliding window length is shortened from 1 second to 500ms and the step size is adjusted from 200ms to 100ms to increase the feature acquisition frequency; if the voltage sag is ≤5% and the harmonic distortion rate is ≤3% within five consecutive window periods, the window length is restored to 1 second and the step size is restored to 200ms to reduce the computational load. The adjustment logic is implemented through a finite state machine, and the state transition conditions are based on preset thresholds (such as voltage sag thresholds of 5% and 10%). The adjustment command is sent to step S1 in real time through the gRPC interface to ensure that the parameter changes take effect in the next sliding window period.

[0126] S53: Based on the adjusted sliding window, generate an updated backup self-starting execution strategy until the preset conditions are met.

[0127] In this embodiment, a dynamic feature set is regenerated based on the adjusted sliding window, triggering a complete process iteration from steps S1 to S4 to generate an updated backup automatic transfer execution strategy. When the voltage sag stabilizes at ≤5% and the harmonic distortion rate at ≤3% after three consecutive iterations of the generated strategy, the system is determined to have entered a steady state, the sliding window adjustment is terminated, and the current parameters are locked. If the conditions are not met even after the number of adjustments reaches a preset upper limit (e.g., 10 times), a degradation mode is initiated: a fixed window parameter (1 second / 200ms) is adopted, and a conservative strategy library is switched (e.g., prioritizing extending the switching delay to 500ms), while a critical alarm is sent to the network management system via the SNMP protocol. All parameter adjustment records and strategy versions during the iteration process are stored on a blockchain (using the Hyperledger Fabric framework) to ensure operational traceability.

[0128] Example 2

[0129] On the other hand, the present invention also provides a backup power supply (SPFS) risk prediction system for smart grids, used to execute a backup power supply (SPFS) risk prediction method for smart grids, with reference to... Figure 2 As shown, the system includes:

[0130] The feature dynamic filtering module 100 is used to collect the initial feature set of the smart grid based on a sliding window, and filter the initial feature set according to feature processing rules to generate a dynamic feature set, wherein the dynamic feature set includes time-series features and frequency domain features.

[0131] The model prediction module 200 is used to output the regular risk probability based on the time-series features using a pre-trained random forest model, and to identify sudden abnormal patterns based on the frequency domain features using a pre-trained XGBoost model, and simultaneously generate a feature importance matrix for adjusting the feature processing rules.

[0132] The risk assessment module 300 is used to determine the power grid state by combining the time-series features and frequency-domain features, and dynamically fuse the output results of each model according to the fusion weights of each model determined by the power grid state to generate a comprehensive risk level.

[0133] The reinforcement strategy generation module 400 is used to input the comprehensive risk level and the dynamic feature set into the reinforcement learning environment model, and solve the multi-objective function generated by the reinforcement learning environment model based on the near-end policy optimization algorithm to obtain the backup self-initiation execution strategy.

[0134] The dynamic adjustment module 500 is used to execute the backup self-starting execution strategy and dynamically adjust the sliding window of feature acquisition according to the execution result until the execution result meets the preset conditions.

[0135] This application is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of this application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart... Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0136] Those skilled in the art will understand that all or part of the steps in the various methods of the above embodiments can be implemented by a program instructing related hardware. The program can be stored in a computer-readable storage medium, including read-only memory (ROM), random access memory (RAM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), one-time programmable read-only memory (OTPROM), electrically-Erasable Programmable Read-Only Memory (EEPROM), compact disc read-only memory (CD-ROM) or other optical disc storage, disk storage, magnetic tape storage, or any other computer-readable medium capable of carrying or storing data.

[0137] It should also be noted that the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

Claims

1. A method for predicting backup power supply (SPFS) risk in smart grids, characterized in that, The method includes the following steps: The initial feature set of the smart grid is collected based on a sliding window, and the initial feature set is filtered according to feature processing rules to generate a dynamic feature set, wherein the dynamic feature set includes time-series features and frequency domain features. The pre-trained random forest model outputs the regular risk probability based on the time-series features, and the pre-trained XGBoost model identifies sudden anomaly patterns based on the frequency domain features, and simultaneously generates a feature importance matrix for adjusting the feature processing rules. The power grid state is determined by combining the time-series and frequency-domain features, and the output results of each model are dynamically fused according to the fusion weights of each model determined by the power grid state to generate a comprehensive risk level. The comprehensive risk level and the dynamic feature set are input into the reinforcement learning environment model, and the multi-objective function generated by the reinforcement learning environment model is solved based on the near-end policy optimization algorithm to obtain the backup self-initiation execution strategy. The backup self-supply strategy is executed, and the sliding window for feature acquisition is dynamically adjusted according to the execution result until the execution result meets the preset conditions.

2. The method for predicting backup power supply risk for smart grids according to claim 1, characterized in that, The process of acquiring an initial feature set of the smart grid based on a sliding window, and then filtering the initial feature set according to feature processing rules to generate a dynamic feature set includes: Based on the preset sliding window length and sliding step size, the raw data of main power supply voltage, backup power supply capacity and load distribution are collected in real time to generate an initial feature set. The initial feature set is subjected to variance threshold screening and Pearson correlation analysis, and the feature set that meets the preset threshold conditions is retained to form a candidate feature set; The candidate feature set is subjected to time-frequency decomposition to extract time-series features and frequency-domain features. The time-series features include the mean voltage fluctuation rate and the discrete first-order difference of the load change rate within the sliding window. The frequency-domain features include the harmonic distortion rate and the spectral energy proportion of the transient oscillation frequency. The time-series features and frequency-domain features are fused according to preset weights to generate a dynamic feature set.

3. The method for predicting backup power supply risk for smart grids according to claim 2, characterized in that, The pre-trained random forest model outputs a regular risk probability based on the time-series features, and the pre-trained XGBoost model identifies sudden anomaly patterns based on the frequency domain features, simultaneously generating a feature importance matrix for adjusting the feature processing rules, including: The time-series features in the dynamic feature set are input into a pre-trained random forest model, which outputs the regular risk probability and calculates the contribution score of each time-series feature to risk prediction. The frequency domain features in the dynamic feature set are input into the pre-trained XGBoost model to identify sudden anomaly patterns and calculate the discrimination score of each frequency domain feature for anomaly detection. The contribution score and the discrimination score are normalized to generate a feature importance matrix.

4. The method for predicting backup power supply risk for smart grids according to claim 3, characterized in that, The adjustment of the feature processing rules by the feature importance matrix includes: Based on the normalized feature importance matrix, the contribution score of time-series features and the discriminative score of frequency-domain features are extracted respectively. The contribution score and the discrimination score are independently ranked, and key features that meet the following conditions are selected: The contribution score of the time series feature is higher than the preset time series score threshold; The discrimination score of the frequency domain feature is higher than the preset frequency domain score threshold; The variance threshold, minimum correlation coefficient of Pearson correlation analysis, and / or preset weights for fusion are dynamically adjusted based on the scoring type of key features.

5. The method for predicting backup power supply risk for smart grids according to claim 4, characterized in that, The process involves combining the time-series and frequency-domain features to determine the power grid state, and dynamically fusing the outputs of each model based on the fusion weights determined by the power grid state to generate a comprehensive risk level, including: Based on the mean voltage fluctuation rate and harmonic distortion rate, the power grid status is classified according to a preset classification rule; Based on the power grid status, the fusion weights are dynamically allocated according to a preset weight allocation function; The probability of conventional risks and the pattern of sudden anomalies are weighted and fused according to dynamically allocated fusion weights to generate a comprehensive risk level.

6. The method for predicting backup power supply risk for smart grids according to claim 5, characterized in that, The step of inputting the comprehensive risk level and the dynamic feature set into the reinforcement learning environment model, and solving the multi-objective function generated by the reinforcement learning environment model based on the near-end policy optimization algorithm to obtain the alternative self-initiation execution strategy includes: A reinforcement learning environment model is constructed with multiple optimization objectives, including power supply continuity, equipment safety, and economic cost. The state space is generated by jointly encoding the comprehensive risk level and the temporal and frequency domain features in the dynamic feature set; The action space includes the standby automatic transfer delay time and the discrete action set of reactive power compensation equipment switching commands; The reward function is based on the multi-objective optimization objective and defines a weighted sum of the power supply continuity score, equipment safety score, and economic benefit score. Based on the proximal policy optimization algorithm, the following operations are performed in the reinforcement learning environment model: The exploration starting point for the strategy network is initialized using the aforementioned comprehensive risk level; Pareto optimal policy set is generated through policy gradient update iteration, where each policy update is constrained by the feature importance matrix; Select backup self-starting execution strategies that meet the preset optimization constraints from the Pareto optimal strategy set.

7. The method for predicting backup power supply risk for smart grids according to claim 6, characterized in that, The execution of the backup self-supply strategy, and the dynamic adjustment of the feature acquisition sliding window based on the execution result until the execution result meets the preset conditions, includes: The automatic transfer switch strategy is executed, and the voltage sag and harmonic distortion rate are monitored in real time and used as the execution result. Based on the execution results, the length and step size of the sliding window are dynamically adjusted according to a preset adjustment logic; Based on the adjusted sliding window, an updated backup self-reinforcement execution strategy is generated until the preset conditions are met.

8. A backup power automatic transfer risk prediction system for smart grids, used to execute a backup power automatic transfer risk prediction method for smart grids as described in any one of claims 1 to 7, characterized in that, The system includes: The feature dynamic filtering module is used to collect the initial feature set of the smart grid based on a sliding window, and filter the initial feature set according to feature processing rules to generate a dynamic feature set, wherein the dynamic feature set includes time-series features and frequency domain features. The model prediction module is used to output the regular risk probability based on the time-series features using a pre-trained random forest model, and to identify sudden abnormal patterns based on the frequency domain features using a pre-trained XGBoost model, and simultaneously generate a feature importance matrix for adjusting the feature processing rules. The risk assessment module is used to determine the power grid status by combining the time-series features and frequency-domain features, and to dynamically fuse the output results of each model according to the fusion weights of each model determined by the power grid status to generate a comprehensive risk level. The reinforcement strategy generation module is used to input the comprehensive risk level and the dynamic feature set into the reinforcement learning environment model, and solve the multi-objective function generated by the reinforcement learning environment model based on the near-end policy optimization algorithm to obtain the backup self-injection execution strategy. The dynamic adjustment module is used to execute the backup self-supply strategy and dynamically adjust the sliding window of feature acquisition according to the execution result until the execution result meets the preset conditions.

Citation Information

Cited By

  • Test method and device for spare power automatic switching device free of disconnection

    CN122238760A

  • A method for identifying harmonic risk and inhibiting mis-switching of an intelligent metal comprehensive distribution box

    CN122456492A